mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
separate visit methods for all types of classes, enums, interfaces, annotation types, and anonymous classes
This commit is contained in:
+2
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,6 +57,7 @@ public class ClashingGettersInspection extends BaseInspection {
|
||||
return GroovyInspectionBundle.message("getter.0.clashes.with.getter.1", args);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected BaseInspectionVisitor buildVisitor() {
|
||||
return new BaseInspectionVisitor() {
|
||||
|
||||
+5
-9
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnnotationTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
|
||||
public class GroovyAnnotationNamingConventionInspection extends ConventionInspection {
|
||||
|
||||
@@ -32,7 +31,7 @@ public class GroovyAnnotationNamingConventionInspection extends ConventionInspec
|
||||
return "Annotation naming convention";
|
||||
}
|
||||
|
||||
protected GroovyFix buildFix(PsiElement location) {
|
||||
protected GroovyFix buildFix(@NotNull PsiElement location) {
|
||||
return new RenameFix();
|
||||
}
|
||||
|
||||
@@ -63,18 +62,15 @@ public class GroovyAnnotationNamingConventionInspection extends ConventionInspec
|
||||
return DEFAULT_MAX_LENGTH;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new NamingConventionsVisitor();
|
||||
}
|
||||
|
||||
private class NamingConventionsVisitor extends BaseInspectionVisitor {
|
||||
|
||||
public void visitTypeDefinition(GrTypeDefinition grTypeDefinition) {
|
||||
super.visitTypeDefinition(grTypeDefinition);
|
||||
if (!(grTypeDefinition instanceof GrAnnotationTypeDefinition)) {
|
||||
return;
|
||||
}
|
||||
final GrAnnotationTypeDefinition aClass = (GrAnnotationTypeDefinition) grTypeDefinition;
|
||||
@Override
|
||||
public void visitAnnotationTypeDefinition(GrAnnotationTypeDefinition aClass) {
|
||||
super.visitAnnotationTypeDefinition(aClass);
|
||||
|
||||
final String name = aClass.getName();
|
||||
if (name == null) {
|
||||
|
||||
+7
-11
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrClassDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
|
||||
public class GroovyClassNamingConventionInspection extends ConventionInspection {
|
||||
|
||||
@@ -32,7 +31,7 @@ public class GroovyClassNamingConventionInspection extends ConventionInspection
|
||||
return "Class naming convention";
|
||||
}
|
||||
|
||||
protected GroovyFix buildFix(PsiElement location) {
|
||||
protected GroovyFix buildFix(@NotNull PsiElement location) {
|
||||
return new RenameFix();
|
||||
}
|
||||
|
||||
@@ -63,26 +62,23 @@ public class GroovyClassNamingConventionInspection extends ConventionInspection
|
||||
return DEFAULT_MAX_LENGTH;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new NamingConventionsVisitor();
|
||||
}
|
||||
|
||||
private class NamingConventionsVisitor extends BaseInspectionVisitor {
|
||||
|
||||
public void visitTypeDefinition(GrTypeDefinition grTypeDefinition) {
|
||||
super.visitTypeDefinition(grTypeDefinition);
|
||||
if (!(grTypeDefinition instanceof GrClassDefinition)) {
|
||||
return;
|
||||
}
|
||||
GrClassDefinition aClass = (GrClassDefinition) grTypeDefinition;
|
||||
final String name = aClass.getName();
|
||||
@Override
|
||||
public void visitClassDefinition(GrClassDefinition classDefinition) {
|
||||
super.visitClassDefinition(classDefinition);
|
||||
final String name = classDefinition.getName();
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
if (isValid(name)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass, name);
|
||||
registerClassError(classDefinition, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-17
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
|
||||
public class GroovyEnumerationNamingConventionInspection extends ConventionInspection {
|
||||
|
||||
@@ -32,7 +31,7 @@ public class GroovyEnumerationNamingConventionInspection extends ConventionInspe
|
||||
return "Enumeration naming convention";
|
||||
}
|
||||
|
||||
protected GroovyFix buildFix(PsiElement location) {
|
||||
protected GroovyFix buildFix(@NotNull PsiElement location) {
|
||||
return new RenameFix();
|
||||
}
|
||||
|
||||
@@ -63,27 +62,24 @@ public class GroovyEnumerationNamingConventionInspection extends ConventionInspe
|
||||
return DEFAULT_MAX_LENGTH;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new NamingConventionsVisitor();
|
||||
}
|
||||
|
||||
private class NamingConventionsVisitor extends BaseInspectionVisitor {
|
||||
@Override
|
||||
public void visitEnumDefinition(GrEnumTypeDefinition aClass) {
|
||||
super.visitEnumDefinition(aClass);
|
||||
|
||||
public void visitTypeDefinition(GrTypeDefinition grTypeDefinition) {
|
||||
super.visitTypeDefinition(grTypeDefinition);
|
||||
if (!(grTypeDefinition instanceof GrEnumTypeDefinition)) {
|
||||
return;
|
||||
}
|
||||
final GrEnumTypeDefinition aClass = (GrEnumTypeDefinition) grTypeDefinition;
|
||||
|
||||
final String name = aClass.getName();
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
if (isValid(name)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass, name);
|
||||
final String name = aClass.getName();
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
if (isValid(name)) {
|
||||
return;
|
||||
}
|
||||
registerClassError(aClass, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-9
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrInterfaceDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
|
||||
public class GroovyInterfaceNamingConventionInspection extends ConventionInspection {
|
||||
|
||||
@@ -32,7 +31,7 @@ public class GroovyInterfaceNamingConventionInspection extends ConventionInspect
|
||||
return "Interface naming convention";
|
||||
}
|
||||
|
||||
protected GroovyFix buildFix(PsiElement location) {
|
||||
protected GroovyFix buildFix(@NotNull PsiElement location) {
|
||||
return new RenameFix();
|
||||
}
|
||||
|
||||
@@ -63,18 +62,15 @@ public class GroovyInterfaceNamingConventionInspection extends ConventionInspect
|
||||
return DEFAULT_MAX_LENGTH;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public BaseInspectionVisitor buildVisitor() {
|
||||
return new NamingConventionsVisitor();
|
||||
}
|
||||
|
||||
private class NamingConventionsVisitor extends BaseInspectionVisitor {
|
||||
|
||||
public void visitTypeDefinition(GrTypeDefinition grTypeDefinition) {
|
||||
super.visitTypeDefinition(grTypeDefinition);
|
||||
if (!(grTypeDefinition instanceof GrInterfaceDefinition)) {
|
||||
return;
|
||||
}
|
||||
final GrInterfaceDefinition aClass = (GrInterfaceDefinition) grTypeDefinition;
|
||||
@Override
|
||||
public void visitInterfaceDefinition(GrInterfaceDefinition aClass) {
|
||||
super.visitInterfaceDefinition(aClass);
|
||||
|
||||
final String name = aClass.getName();
|
||||
if (name == null) {
|
||||
@@ -85,5 +81,6 @@ public class GroovyInterfaceNamingConventionInspection extends ConventionInspect
|
||||
}
|
||||
registerClassError(aClass, name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -255,6 +255,26 @@ public abstract class GroovyElementVisitor {
|
||||
visitElement(typeDefinition);
|
||||
}
|
||||
|
||||
public void visitClassDefinition(GrClassDefinition classDefinition) {
|
||||
visitTypeDefinition(classDefinition);
|
||||
}
|
||||
|
||||
public void visitEnumDefinition(GrEnumTypeDefinition enumDefinition) {
|
||||
visitTypeDefinition(enumDefinition);
|
||||
}
|
||||
|
||||
public void visitInterfaceDefinition(GrInterfaceDefinition interfaceDefinition) {
|
||||
visitTypeDefinition(interfaceDefinition);
|
||||
}
|
||||
|
||||
public void visitAnonymousClassDefinition(GrAnonymousClassDefinition anonymousClassDefinition) {
|
||||
visitTypeDefinition(anonymousClassDefinition);
|
||||
}
|
||||
|
||||
public void visitAnnotationTypeDefinition(GrAnnotationTypeDefinition annotationTypeDefinition) {
|
||||
visitTypeDefinition(annotationTypeDefinition);
|
||||
}
|
||||
|
||||
public void visitExtendsClause(GrExtendsClause extendsClause) {
|
||||
visitElement(extendsClause);
|
||||
}
|
||||
|
||||
+8
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,10 +19,11 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiClassType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnnotationTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
|
||||
/**
|
||||
* @author Dmitry.Krasilschikov
|
||||
@@ -61,4 +62,9 @@ public class GrAnnotationTypeDefinitionImpl extends GrTypeDefinitionImpl impleme
|
||||
private PsiClassType createAnnotationType() {
|
||||
return TypesUtil.createTypeByFQClassName("java.lang.annotation.Annotation", this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitAnnotationTypeDefinition(this);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
|
||||
@@ -250,4 +251,10 @@ public class GrAnonymousClassDefinitionImpl extends GrTypeDefinitionImpl impleme
|
||||
public PsiIdentifier getNameIdentifier() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitAnonymousClassDefinition(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrClassDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub;
|
||||
|
||||
@@ -39,4 +40,9 @@ public class GrClassDefinitionImpl extends GrTypeDefinitionImpl implements GrCla
|
||||
public String toString() {
|
||||
return "Class definition";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitClassDefinition(this);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumDefinitionBody;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumTypeDefinition;
|
||||
@@ -175,4 +176,9 @@ public class GrEnumTypeDefinitionImpl extends GrTypeDefinitionImpl implements Gr
|
||||
if (enumDefinitionBody != null) return enumDefinitionBody.getEnumConstantList();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitEnumDefinition(this);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,11 +17,11 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrInterfaceDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
|
||||
/**
|
||||
* @author Dmitry.Krasilschikov
|
||||
@@ -44,4 +44,9 @@ public class GrInterfaceDefinitionImpl extends GrTypeDefinitionImpl implements G
|
||||
public boolean isInterface() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(GroovyElementVisitor visitor) {
|
||||
visitor.visitInterfaceDefinition(this);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user