當前位置: 首頁>>代碼示例>>Java>>正文


Java Annotation類代碼示例

本文整理匯總了Java中com.intellij.lang.annotation.Annotation的典型用法代碼示例。如果您正苦於以下問題:Java Annotation類的具體用法?Java Annotation怎麽用?Java Annotation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Annotation類屬於com.intellij.lang.annotation包,在下文中一共展示了Annotation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visitDocTag

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
@Override
public void visitDocTag(LuaDocTag e) {
    super.visitDocTag(e);

    LuaDocSyntaxHighlighter highlighter = new LuaDocSyntaxHighlighter();

    PsiElement element = e.getFirstChild();
    while (element != null) {
        if (element instanceof ASTNode) {
            ASTNode astNode = (ASTNode) element;
            TextAttributesKey[] keys = highlighter.getTokenHighlights(astNode.getElementType());
            for (TextAttributesKey key : keys) {
                final Annotation a = myHolder.createInfoAnnotation(element, null);
                a.setTextAttributes(key);
            }
        }
        element = element.getNextSibling();
    }
}
 
開發者ID:internetisalie,項目名稱:lua-for-idea,代碼行數:20,代碼來源:LuaAnnotator.java

示例2: visitIdentifier

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
public void visitIdentifier(LuaIdentifier id) {
    if ((id != null) && id instanceof LuaGlobal) {
        addSemanticHighlight(id, LuaHighlightingData.GLOBAL_VAR);
        return;
    }
    if (id instanceof LuaFieldIdentifier) {
        addSemanticHighlight(id, LuaHighlightingData.FIELD);
        return;
    }
    if (id instanceof LuaUpvalueIdentifier) {
        addSemanticHighlight(id, LuaHighlightingData.UPVAL);
    } else if (id instanceof LuaLocalIdentifier) {
        PsiReference reference = id.getReference();
        if (reference != null) {
            PsiElement resolved = reference.resolve();
            if (resolved instanceof LuaParameter)
                return;
        }
        final Annotation annotation = myHolder.createInfoAnnotation(id, null);
        annotation.setTextAttributes(LuaHighlightingData.LOCAL_VAR);
    }

}
 
開發者ID:internetisalie,項目名稱:lua-for-idea,代碼行數:24,代碼來源:LuaAnnotator.java

示例3: annotate

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
    if (SmcTypes.ACTION_NAME.equals(element.getNode().getElementType())) {
        PsiElement parent = element.getParent();
        if (parent == null || !(parent instanceof SmcAction)) {
            return;
        }
        SmcAction action = (SmcAction) parent;
        SmcFile containingFile = (SmcFile)action.getContainingFile();
        String contextClassName = containingFile.getContextClassQName();
        if (!SmcPsiUtil.isMethodInClass(contextClassName, action.getName(), action.getArgumentCount(), element.getProject())) {
            Annotation errorAnnotation = holder.createErrorAnnotation(element, getNotResolvedMessage(action.getFullName(), contextClassName));
            errorAnnotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
            errorAnnotation.registerFix(new CreateMethodInContextClassFix(action.getName(), action.getArgumentCount()));
        } else if (SmcPsiUtil.isMethodInClassNotUnique(contextClassName, action.getName(), action.getArgumentCount(), element.getProject())) {
            holder.createWarningAnnotation(element, getAmbiguityMessage(action.getFullName(),contextClassName));
        }
    }
}
 
開發者ID:menshele,項目名稱:smcplugin,代碼行數:20,代碼來源:SmcActionAnnotator.java

示例4: registerMakeAbstractMethodNotAbstractFix

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private static void registerMakeAbstractMethodNotAbstractFix(Annotation annotation, GrMethod method, boolean makeClassAbstract) {
  if (method.getBlock() == null) {
    annotation.registerFix(QuickFixFactory.getInstance().createAddMethodBodyFix(method));
  }
  else {
    annotation.registerFix(QuickFixFactory.getInstance().createDeleteMethodBodyFix(method));
  }
  registerFix(annotation, new GrModifierFix(method, PsiModifier.ABSTRACT, false, false, GrModifierFix.MODIFIER_LIST_OWNER), method);
  if (makeClassAbstract) {
    final PsiClass containingClass = method.getContainingClass();
    if (containingClass != null) {
      final PsiModifierList list = containingClass.getModifierList();
      if (list != null && !list.hasModifierProperty(PsiModifier.ABSTRACT)) {
        registerFix(annotation, new GrModifierFix(containingClass, PsiModifier.ABSTRACT, false, true, GrModifierFix.MODIFIER_LIST_OWNER), containingClass);
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:GroovyAnnotator.java

示例5: checkFieldModifiers

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private static void checkFieldModifiers(AnnotationHolder holder, GrVariableDeclaration fieldDeclaration) {
  final GrModifierList modifierList = fieldDeclaration.getModifierList();
  final GrField member = (GrField)fieldDeclaration.getVariables()[0];

  checkAccessModifiers(holder, modifierList, member);
  checkDuplicateModifiers(holder, modifierList, member);

  if (modifierList.hasExplicitModifier(PsiModifier.VOLATILE) && modifierList.hasExplicitModifier(PsiModifier.FINAL)) {
    final Annotation annotation =
      holder.createErrorAnnotation(modifierList, GroovyBundle.message("illegal.combination.of.modifiers.volatile.and.final"));
    registerFix(annotation, new GrModifierFix(member, PsiModifier.VOLATILE, true, false, GrModifierFix.MODIFIER_LIST), modifierList);
    registerFix(annotation, new GrModifierFix(member, PsiModifier.FINAL, true, false, GrModifierFix.MODIFIER_LIST), modifierList);
  }

  checkModifierIsNotAllowed(modifierList, PsiModifier.NATIVE, GroovyBundle.message("variable.cannot.be.native"), holder);
  checkModifierIsNotAllowed(modifierList, PsiModifier.ABSTRACT, GroovyBundle.message("variable.cannot.be.abstract"), holder);

  if (member.getContainingClass() instanceof GrInterfaceDefinition) {
    checkModifierIsNotAllowed(modifierList,
                              PsiModifier.PRIVATE, GroovyBundle.message("interface.members.are.not.allowed.to.be", PsiModifier.PRIVATE), holder);
    checkModifierIsNotAllowed(modifierList, PsiModifier.PROTECTED, GroovyBundle.message("interface.members.are.not.allowed.to.be",
                                                                                        PsiModifier.PROTECTED),
                              holder);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:GroovyAnnotator.java

示例6: registerImplementsMethodsFix

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private static void registerImplementsMethodsFix(@NotNull GrTypeDefinition typeDefinition,
                                                 @NotNull PsiMethod abstractMethod,
                                                 @NotNull Annotation annotation) {
  if (!OverrideImplementExploreUtil.getMethodsToOverrideImplement(typeDefinition, true).isEmpty()) {
    annotation.registerFix(QuickFixFactory.getInstance().createImplementMethodsFix(typeDefinition));
  }

  if (!JavaPsiFacade.getInstance(typeDefinition.getProject()).getResolveHelper().isAccessible(abstractMethod, typeDefinition, null)) {
    registerFix(annotation, new GrModifierFix(abstractMethod, PsiModifier.PUBLIC, true, true, GrModifierFix.MODIFIER_LIST_OWNER), abstractMethod);
    registerFix(annotation, new GrModifierFix(abstractMethod, PsiModifier.PROTECTED, true, true, GrModifierFix.MODIFIER_LIST_OWNER), abstractMethod);
  }

  if (!(typeDefinition instanceof GrAnnotationTypeDefinition) && typeDefinition.getModifierList() != null) {
    registerFix(annotation, new GrModifierFix(typeDefinition, PsiModifier.ABSTRACT, false, true, GrModifierFix.MODIFIER_LIST_OWNER), typeDefinition);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:GroovyAnnotator.java

示例7: attachColorIcon

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private static void attachColorIcon(final PsiElement element, AnnotationHolder holder, String attributeValueText) {
  try {
    Color color = null;
    if (attributeValueText.startsWith("#")) {
      color = ColorUtil.fromHex(attributeValueText.substring(1));
    } else {
      final String hexCode = ColorMap.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText));
      if (hexCode != null) {
        color = ColorUtil.fromHex(hexCode);
      }
    }
    if (color != null) {
      final ColorIcon icon = new ColorIcon(8, color);
      final Annotation annotation = holder.createInfoAnnotation(element, null);
      annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element));
    }
  }
  catch (Exception ignored) {
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:JavaFxAnnotator.java

示例8: checkPrefixReferences

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private static void checkPrefixReferences(AnnotationHolder holder, QNameElement element, ContextProvider myProvider) {
  final PsiReference[] references = element.getReferences();
  for (PsiReference reference : references) {
    if (reference instanceof PrefixReference) {
      final PrefixReference pr = ((PrefixReference)reference);
      if (!pr.isSoft() && pr.isUnresolved()) {
        final TextRange range = pr.getRangeInElement().shiftRight(pr.getElement().getTextRange().getStartOffset());
        final Annotation a = holder.createErrorAnnotation(range, "Unresolved namespace prefix '" + pr.getCanonicalText() + "'");
        a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);

        final NamespaceContext namespaceContext = myProvider.getNamespaceContext();
        final PrefixedName qName = element.getQName();
        if (namespaceContext != null && qName != null) {
          final IntentionAction[] fixes = namespaceContext.getUnresolvedNamespaceFixes(reference, qName.getLocalName());
          for (IntentionAction fix : fixes) {
            a.registerFix(fix);
          }
        }
      }
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:XPathAnnotator.java

示例9: checkImplementedMethodsOfClass

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private static void checkImplementedMethodsOfClass(AnnotationHolder holder, GrTypeDefinition typeDefinition) {
  if (typeDefinition.hasModifierProperty(PsiModifier.ABSTRACT)) return;
  if (typeDefinition.isAnnotationType()) return;
  if (typeDefinition instanceof GrTypeParameter) return;


  PsiMethod abstractMethod = ClassUtil.getAnyAbstractMethod(typeDefinition);
  if (abstractMethod == null) return;

  String notImplementedMethodName = abstractMethod.getName();

  final TextRange range = GrHighlightUtil.getClassHeaderTextRange(typeDefinition);
  final Annotation annotation = holder.createErrorAnnotation(range,
                                                             GroovyBundle.message("method.is.not.implemented", notImplementedMethodName));
  registerImplementsMethodsFix(typeDefinition, abstractMethod, annotation);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:GroovyAnnotator.java

示例10: visitPyReferenceExpression

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
@Override
public void visitPyReferenceExpression(PyReferenceExpression node) {
  final String name = node.getName();
  if (name == null) return;
  final boolean highlightedAsAttribute = highlightAsAttribute(node, name);
  if (!highlightedAsAttribute && PyBuiltinCache.isInBuiltins(node)) {
    final Annotation ann;
    final PsiElement parent = node.getParent();
    if (parent instanceof PyDecorator) {
      // don't mark the entire decorator, only mark the "@", else we'll conflict with deco annotator
      ann = getHolder().createInfoAnnotation(parent.getFirstChild(), null); // first child is there, or we'd not parse as deco
    }
    else {
      ann = getHolder().createInfoAnnotation(node, null);
    }
    ann.setTextAttributes(PyHighlighter.PY_BUILTIN_NAME);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:PyBuiltinAnnotator.java

示例11: visitXPath2TypeElement

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
@Override
public void visitXPath2TypeElement(XPath2TypeElement o) {
  final ContextProvider contextProvider = o.getXPathContext();
  checkPrefixReferences(myHolder, o, contextProvider);

  if (o.getDeclaredType() == XPathType.UNKNOWN) {
    final PsiReference[] references = o.getReferences();
    for (PsiReference reference : references) {
      if (reference instanceof XsltReferenceContributor.SchemaTypeReference ) {
        if (!reference.isSoft() && reference.resolve() == null) {
          final String message = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern();
          final Annotation annotation =
            myHolder.createErrorAnnotation(reference.getRangeInElement().shiftRight(o.getTextOffset()), message);
          annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
        }
      }
    }
  }
  super.visitXPath2TypeElement(o);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:XPathAnnotator.java

示例12: annotateDocStringStmt

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private void annotateDocStringStmt(final PyStringLiteralExpression stmt) {
  if (stmt != null) {
    final DocStringFormat format = DocStringUtil.getConfiguredDocStringFormat(stmt);
    final String[] tags;
    if (format == DocStringFormat.EPYTEXT) {
      tags = EpydocString.ALL_TAGS;
    }
    else if (format == DocStringFormat.REST) {
      tags = SphinxDocString.ALL_TAGS;
    }
    else {
      return;
    }
    int pos = 0;
    while (true) {
      TextRange textRange = DocStringReferenceProvider.findNextTag(stmt.getText(), pos, tags);
      if (textRange == null) break;
      Annotation annotation = getHolder().createInfoAnnotation(textRange.shiftRight(stmt.getTextRange().getStartOffset()), null);
      annotation.setTextAttributes(PyHighlighter.PY_DOC_COMMENT_TAG);
      pos = textRange.getEndOffset();
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:DocStringAnnotator.java

示例13: checkAccessModifiers

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
private static void checkAccessModifiers(AnnotationHolder holder, @NotNull GrModifierList modifierList, PsiMember member) {
  boolean hasPrivate = modifierList.hasExplicitModifier(PsiModifier.PRIVATE);
  boolean hasPublic = modifierList.hasExplicitModifier(PsiModifier.PUBLIC);
  boolean hasProtected = modifierList.hasExplicitModifier(PsiModifier.PROTECTED);

  if (hasPrivate && hasPublic || hasPrivate && hasProtected || hasPublic && hasProtected) {
    final Annotation annotation = holder.createErrorAnnotation(modifierList, GroovyBundle.message("illegal.combination.of.modifiers"));
    if (hasPrivate) {
      registerFix(annotation, new GrModifierFix(member, PsiModifier.PRIVATE, false, false, GrModifierFix.MODIFIER_LIST), modifierList);
    }
    if (hasProtected) {
      registerFix(annotation, new GrModifierFix(member, PsiModifier.PROTECTED, false, false, GrModifierFix.MODIFIER_LIST), modifierList);
    }
    if (hasPublic) {
      registerFix(annotation, new GrModifierFix(member, PsiModifier.PUBLIC, false, false, GrModifierFix.MODIFIER_LIST), modifierList);
    }
  }
  else if (member instanceof PsiClass &&
           member.getContainingClass() == null &&
           GroovyConfigUtils.getInstance().isVersionAtLeast(member, GroovyConfigUtils.GROOVY2_0)) {
    checkModifierIsNotAllowed(modifierList, PsiModifier.PRIVATE, GroovyBundle.message("top.level.class.maynot.have.private.modifier"), holder);
    checkModifierIsNotAllowed(modifierList, PsiModifier.PROTECTED, GroovyBundle.message("top.level.class.maynot.have.protected.modifier"), holder);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:GroovyAnnotator.java

示例14: visitRegExpNamedGroupRef

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
@Override
public void visitRegExpNamedGroupRef(RegExpNamedGroupRef groupRef) {
  if (!myLanguageHosts.supportsNamedGroupRefSyntax(groupRef)) {
    myHolder.createErrorAnnotation(groupRef, "This named group reference syntax is not supported");
    return;
  }
  if (groupRef.getGroupName() == null) {
    return;
  }
  final RegExpGroup group = groupRef.resolve();
  if (group == null) {
    final Annotation a = myHolder.createErrorAnnotation(groupRef, "Unresolved named group reference");
    if (a != null) {
      // IDEA-9381
      a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
    }
  }
  else if (PsiTreeUtil.isAncestor(group, groupRef, true)) {
    myHolder.createWarningAnnotation(groupRef, "Group reference is nested into the named group it refers to");
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:RegExpAnnotator.java

示例15: createAnnotation

import com.intellij.lang.annotation.Annotation; //導入依賴的package包/類
@Nullable
public static Annotation createAnnotation(final DomElementProblemDescriptor problemDescriptor) {

  return createProblemDescriptors(problemDescriptor, new Function<Pair<TextRange, PsiElement>, Annotation>() {
    @Override
    public Annotation fun(final Pair<TextRange, PsiElement> s) {
      String text = problemDescriptor.getDescriptionTemplate();
      if (StringUtil.isEmpty(text)) text = null;
      final HighlightSeverity severity = problemDescriptor.getHighlightSeverity();

      TextRange range = s.first;
      if (text == null) range = TextRange.from(range.getStartOffset(), 0);
      range = range.shiftRight(s.second.getTextRange().getStartOffset());
      final Annotation annotation = createAnnotation(severity, range, text);

      if (problemDescriptor instanceof DomElementResolveProblemDescriptor) {
        annotation.setTextAttributes(CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES);
      }

      for(LocalQuickFix fix:problemDescriptor.getFixes()) {
        if (fix instanceof IntentionAction) annotation.registerFix((IntentionAction)fix);
      }
      return annotation;
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:DomElementsHighlightingUtil.java


注:本文中的com.intellij.lang.annotation.Annotation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。