mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Groovy imports and package definitions always have annotation lists
This commit is contained in:
@@ -20,7 +20,7 @@ import com.intellij.codeInsight.daemon.JavaErrorMessages;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodBodyFix;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.CreateConstructorMatchingSuperFix;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.DeleteMethodBodyFix;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementUtil;
|
||||
import com.intellij.codeInsight.generation.OverrideImplementExploreUtil;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.codeInsight.intention.QuickFixFactory;
|
||||
import com.intellij.lang.ASTNode;
|
||||
@@ -51,7 +51,6 @@ import org.jetbrains.plugins.groovy.annotator.intentions.*;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilityCheckInspection;
|
||||
import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection;
|
||||
import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
|
||||
import org.jetbrains.plugins.groovy.highlighter.DefaultHighlighter;
|
||||
import org.jetbrains.plugins.groovy.lang.documentation.GroovyPresentationUtil;
|
||||
import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
|
||||
@@ -651,11 +650,11 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
if (constructorReference != null) {
|
||||
final PsiElement startToken = listOrMap.getFirstChild();
|
||||
if (startToken != null && startToken.getNode().getElementType() == GroovyTokenTypes.mLBRACK) {
|
||||
myHolder.createInfoAnnotation(startToken, null).setTextAttributes(DefaultHighlighter.LITERAL_CONVERSION);
|
||||
myHolder.createInfoAnnotation(startToken, null).setTextAttributes(LITERAL_CONVERSION);
|
||||
}
|
||||
final PsiElement endToken = listOrMap.getLastChild();
|
||||
if (endToken != null && endToken.getNode().getElementType() == GroovyTokenTypes.mRBRACK) {
|
||||
myHolder.createInfoAnnotation(endToken, null).setTextAttributes(DefaultHighlighter.LITERAL_CONVERSION);
|
||||
myHolder.createInfoAnnotation(endToken, null).setTextAttributes(LITERAL_CONVERSION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -860,7 +859,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
for (GrNamedArgument namedArgument : namedArguments) {
|
||||
final GrArgumentLabel label = namedArgument.getLabel();
|
||||
if (label != null && label.getExpression() == null && label.getNameElement().getNode().getElementType() != GroovyTokenTypes.mSTAR) {
|
||||
myHolder.createInfoAnnotation(label, null).setTextAttributes(DefaultHighlighter.MAP_KEY);
|
||||
myHolder.createInfoAnnotation(label, null).setTextAttributes(MAP_KEY);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -940,7 +939,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
String qname = clazz.getQualifiedName();
|
||||
LOG.assertTrue(qname != null, clazz.getText());
|
||||
Annotation annotation = myHolder.createErrorAnnotation(refElement, GroovyBundle.message("cannot.reference.nonstatic", qname));
|
||||
annotation.setTextAttributes(DefaultHighlighter.UNRESOLVED_ACCESS);
|
||||
annotation.setTextAttributes(UNRESOLVED_ACCESS);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1442,7 +1441,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
|
||||
if (PsiTreeUtil.isAncestor(resolved, ref, true)) {
|
||||
if (PsiUtil.hasEnclosingInstanceInScope((PsiClass)resolved, ref, true)) {
|
||||
holder.createInfoAnnotation(nameElement, null).setTextAttributes(DefaultHighlighter.KEYWORD);
|
||||
holder.createInfoAnnotation(nameElement, null).setTextAttributes(KEYWORD);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1466,12 +1465,11 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
ASTNode node = element.getNode();
|
||||
if (node != null && TokenSets.BUILT_IN_TYPE.contains(node.getElementType())) {
|
||||
Annotation annotation = holder.createInfoAnnotation(element, null);
|
||||
annotation.setTextAttributes(DefaultHighlighter.KEYWORD);
|
||||
annotation.setTextAttributes(KEYWORD);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkAnnotationList(AnnotationHolder holder, @Nullable GrModifierList modifierList, String message) {
|
||||
if (modifierList == null) return;
|
||||
private static void checkAnnotationList(AnnotationHolder holder, @NotNull GrModifierList modifierList, String message) {
|
||||
final PsiElement[] modifiers = modifierList.getModifiers();
|
||||
for (PsiElement modifier : modifiers) {
|
||||
if (!(modifier instanceof PsiAnnotation)) {
|
||||
@@ -1485,7 +1483,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
if (typeDefinition.isAnnotationType()) return;
|
||||
if (typeDefinition instanceof GrTypeParameter) return;
|
||||
|
||||
Collection<CandidateInfo> collection = OverrideImplementUtil.getMethodsToOverrideImplement(typeDefinition, true);
|
||||
Collection<CandidateInfo> collection = OverrideImplementExploreUtil.getMethodsToOverrideImplement(typeDefinition, true);
|
||||
if (collection.isEmpty()) return;
|
||||
|
||||
final PsiElement element = collection.iterator().next().getElement();
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.GrTopStatement;
|
||||
@@ -40,7 +41,7 @@ public interface GrImportStatement extends GrTopStatement {
|
||||
|
||||
boolean isAliasedImport();
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
GrModifierList getAnnotationList();
|
||||
|
||||
@Nullable
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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,6 +17,7 @@
|
||||
package org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging;
|
||||
|
||||
import com.intellij.psi.PsiModifierListOwner;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.GrTopStatement;
|
||||
@@ -32,6 +33,6 @@ public interface GrPackageDefinition extends GrTopStatement, PsiModifierListOwne
|
||||
@Nullable
|
||||
GrCodeReferenceElement getPackageReference();
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
GrModifierList getAnnotationList();
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -268,8 +268,9 @@ public class GrImportStatementImpl extends GroovyPsiElementImpl implements GrImp
|
||||
return findChildByType(GroovyTokenTypes.mSTAR) != null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GrModifierList getAnnotationList() {
|
||||
return findChildByClass(GrModifierList.class);
|
||||
return findNotNullChildByClass(GrModifierList.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
@@ -72,6 +72,7 @@ public class GrPackageDefinitionImpl extends GrStubElementBase<GrPackageDefiniti
|
||||
return (GrCodeReferenceElement) findChildByType(GroovyElementTypes.REFERENCE_ELEMENT);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GrModifierList getAnnotationList() {
|
||||
return getStubOrPsiChild(GroovyElementTypes.MODIFIERS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user