当前位置: 首页>>代码示例>>Java>>正文


Java AnnotationHolder.createWarningAnnotation方法代码示例

本文整理汇总了Java中com.intellij.lang.annotation.AnnotationHolder.createWarningAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java AnnotationHolder.createWarningAnnotation方法的具体用法?Java AnnotationHolder.createWarningAnnotation怎么用?Java AnnotationHolder.createWarningAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.annotation.AnnotationHolder的用法示例。


在下文中一共展示了AnnotationHolder.createWarningAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的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

示例2: addMessagesForTreeChild

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private static void addMessagesForTreeChild(final XmlToken childByRole,
                                            final Validator.ValidationHost.ErrorType type,
                                            final String message,
                                            AnnotationHolder myHolder, IntentionAction... actions) {
  if (childByRole != null) {
    Annotation annotation;
    if (type == Validator.ValidationHost.ErrorType.ERROR) {
      annotation = myHolder.createErrorAnnotation(childByRole, message);
    }
    else {
      annotation = myHolder.createWarningAnnotation(childByRole, message);
    }

    appendFixes(annotation, actions);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XMLExternalAnnotator.java

示例3: doApplyInformationToEditor

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void doApplyInformationToEditor() {
  if (myUnusedDeclarations == null || myUnusedImports == null) {
    return;
  }

  AnnotationHolder annotationHolder = new AnnotationHolderImpl(new AnnotationSession(myFile));
  List<HighlightInfo> infos = new ArrayList<HighlightInfo>(myUnusedDeclarations);
  for (GrImportStatement unusedImport : myUnusedImports) {
    Annotation annotation = annotationHolder.createWarningAnnotation(calculateRangeToUse(unusedImport), GroovyInspectionBundle.message("unused.import"));
    annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
    annotation.registerFix(GroovyQuickFixFactory.getInstance().createOptimizeImportsFix(false));
    infos.add(HighlightInfo.fromAnnotation(annotation));
  }

  UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), infos, getColorsScheme(), getId());

  if (myUnusedImports != null && !myUnusedImports.isEmpty()) {
    IntentionAction fix = GroovyQuickFixFactory.getInstance().createOptimizeImportsFix(true);
    if (fix.isAvailable(myProject, myEditor, myFile) && myFile.isWritable()) {
      fix.invoke(myProject, myEditor, myFile);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GroovyPostHighlightingPass.java

示例4: annotateIcon

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private void annotateIcon(PsiElement psiElement, AnnotationHolder annotationHolder, String value) {
    if (IconIndex.getAllAvailableIcons(psiElement.getProject()).contains(value)) {
        annotationHolder.createInfoAnnotation(psiElement, null);
    } else {
        annotationHolder.createWarningAnnotation(psiElement, "Unresolved icon - this may also occur if the icon is defined in your extension, but not in the global icon registry.");
    }
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:8,代码来源:IconAnnotator.java

示例5: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder annotationHolder) {
    if (isConfigFile(psiElement) && psiElement instanceof YAMLKeyValue && isYamlLeaf(psiElement)) {
        if (hasNoConfigurationObject(psiElement) && hasNoExplicitReference(psiElement)) {
            TextRange range = new TextRange(psiElement.getTextRange().getStartOffset(), psiElement.getTextRange().getStartOffset() + ((YAMLKeyValue) psiElement).getKeyText().length());
            Annotation warningAnnotation = annotationHolder.createWarningAnnotation(range, "Unused configuration property");
            warningAnnotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
        }
    }
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:11,代码来源:CoffigYamlAnnotator.java

示例6: apply

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, StylintAnnotationResult annotationResult, @NotNull AnnotationHolder holder) {
    if (annotationResult == null) {
        return;
    }
    InspectionProjectProfileManager inspectionProjectProfileManager = InspectionProjectProfileManager.getInstance(file.getProject());
    SeverityRegistrar severityRegistrar = inspectionProjectProfileManager.getSeverityRegistrar();
    HighlightDisplayKey inspectionKey = getHighlightDisplayKeyByClass();
    EditorColorsScheme colorsScheme = annotationResult.input.colorsScheme;

    Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    if (document == null) {
        return;
    }

    if (annotationResult.fileLevel != null) {
        Annotation annotation = holder.createWarningAnnotation(file, annotationResult.fileLevel);
        annotation.registerFix(new EditSettingsAction(new StylintSettingsPage(file.getProject())));
        annotation.setFileLevelAnnotation(true);
        return;
    }

    // TODO consider adding a fix to edit configuration file
    if (annotationResult.result == null || annotationResult.result.lint == null || annotationResult.result.lint.isEmpty()) {
        return;
    }
    List<Lint.Issue> issues = annotationResult.result.lint;
    if (issues == null) {
        return;
    }
    StylintProjectComponent component = annotationResult.input.project.getComponent(StylintProjectComponent.class);
    int tabSize = 4;
    for (Lint.Issue issue : issues) {
        HighlightSeverity severity = getHighlightSeverity(issue, component.treatAsWarnings);
        TextAttributes forcedTextAttributes = AnnotatorUtils.getTextAttributes(colorsScheme, severityRegistrar, severity);
        createAnnotation(holder, file, document, issue, "Stylint: ", tabSize, severity, forcedTextAttributes, inspectionKey, component);
    }
}
 
开发者ID:sertae,项目名称:stylint-plugin,代码行数:39,代码来源:StylintExternalAnnotator.java

示例7: createAnnotation

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@NotNull
private static Annotation createAnnotation(@NotNull AnnotationHolder holder, @NotNull HighlightSeverity severity, @NotNull TextRange range, @NotNull String message) {
    if (severity.equals(HighlightSeverity.ERROR)) {
        return holder.createErrorAnnotation(range, message);
    }
    return holder.createWarningAnnotation(range, message);
}
 
开发者ID:sertae,项目名称:stylint-plugin,代码行数:8,代码来源:StylintExternalAnnotator.java

示例8: extractSetValue

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private void extractSetValue(EndpointValidationResult result, Set<String> validationSet, String fromElement, PsiElement element,
                             AnnotationHolder holder, CamelAnnotatorEndpointMessage msg, boolean lenient) {
    if (validationSet != null && (lenient || !result.isSuccess())) {

        for (String entry : validationSet) {
            String propertyValue = entry;

            int startIdxQueryParameters = fromElement.indexOf("?" + propertyValue);
            startIdxQueryParameters = (startIdxQueryParameters == -1) ? fromElement.indexOf("&" + propertyValue) : fromElement.indexOf("?");

            int propertyIdx = fromElement.indexOf(propertyValue, startIdxQueryParameters);
            int propertyLength = propertyValue.length();

            propertyIdx = getIdeaUtils().isJavaLanguage(element) || getIdeaUtils().isXmlLanguage(element)  ? propertyIdx + 1  : propertyIdx;

            TextRange range = new TextRange(element.getTextRange().getStartOffset() + propertyIdx,
                element.getTextRange().getStartOffset() + propertyIdx + propertyLength);

            if (msg.isInfoLevel()) {
                holder.createInfoAnnotation(range, summaryMessage(result, propertyValue, msg));
            } else if (msg.isWarnLevel()) {
                holder.createWarningAnnotation(range, summaryMessage(result, propertyValue, msg));
            } else {
                holder.createErrorAnnotation(range, summaryMessage(result, propertyValue, msg));
            }
        }
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:29,代码来源:CamelEndpointAnnotator.java

示例9: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull final AnnotationHolder holder) {
  if (psiElement instanceof PsiFile && !psiElement.getText().contains("xxx")) {
    Annotation annotation = holder.createWarningAnnotation(psiElement, "top level");
    annotation.setFileLevelAnnotation(true);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:LightAdvHighlightingTest.java

示例10: apply

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, MyInfo[] infos, @NotNull AnnotationHolder holder) {
  if (infos == null || infos.length == 0) {
    return;
  }

  final HighlightDisplayLevel displayLevel = getHighlightDisplayLevel(file);

  for (MyInfo info : infos) {
    if (!info.myResult) {
      final PsiElement element = info.myAnchor.retrieve();
      if (element != null) {
        final int start = element.getTextRange().getStartOffset();
        final TextRange range = new TextRange(start + info.myRangeInElement.getStartOffset(),
                                              start + info.myRangeInElement.getEndOffset());
        final String message = getErrorMessage(info.myUrl);

        final Annotation annotation;

        if (displayLevel == HighlightDisplayLevel.ERROR) {
          annotation = holder.createErrorAnnotation(range, message);
        }
        else if (displayLevel == HighlightDisplayLevel.WARNING) {
          annotation = holder.createWarningAnnotation(range, message);
        }
        else if (displayLevel == HighlightDisplayLevel.WEAK_WARNING) {
          annotation = holder.createInfoAnnotation(range, message);
        }
        else {
          annotation = holder.createWarningAnnotation(range, message);
        }

        for (IntentionAction action : getQuickFixes()) {
          annotation.registerFix(action);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:WebReferencesAnnotatorBase.java

示例11: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
  if (psiElement instanceof RegExpFile && psiElement.getCopyableUserData(KEY) == Boolean.TRUE) {
    final PsiElement pattern = psiElement.getFirstChild();
    if (!(pattern instanceof RegExpPattern)) {
      return;
    }

    final RegExpBranch[] branches = ((RegExpPattern)pattern).getBranches();
    if (branches.length == 1 && branches[0].getAtoms().length == 0) {
      return;
    }

    for (RegExpBranch branch : branches) {
      final int[] count = new int[1];
      branch.accept(new RegExpRecursiveElementVisitor() {
        @Override
        public void visitRegExpGroup(RegExpGroup group) {
          if (group.isCapturing()) {
            count[0]++;
          }
          super.visitRegExpGroup(group);
        }
      });

      if (count[0] != 1) {
        holder.createWarningAnnotation(branch, "The pattern should contain exactly one capturing group");
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:ValueRegExpAnnotator.java

示例12: annotate

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
@Override
public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder holder) {
  if (!(psiElement instanceof GroovyFile)) return;

  final GroovyFile groovyFile = (GroovyFile)psiElement;
  if (!GrFileIndexUtil.isGroovySourceFile(groovyFile)) return;
  
  final VirtualFile vfile = groovyFile.getVirtualFile();
  if (!GdslUtil.GDSL_FILTER.value(vfile)) return;
  
  final DslActivationStatus.Status status = GroovyDslFileIndex.getStatus(vfile);
  if (status == ACTIVE) return;

  final String message = status == MODIFIED
                         ? "DSL descriptor file has been changed and isn't currently executed."
                         : "DSL descriptor file has been disabled due to a processing error.";

  final Annotation annotation = holder.createWarningAnnotation(psiElement, message);
  annotation.setFileLevelAnnotation(true);
  if (status == ERROR) {
    final String error = GroovyDslFileIndex.getError(vfile);
    if (error != null) {
      annotation.registerFix(GroovyQuickFixFactory.getInstance().createInvestigateFix(error));
    }
  }
  annotation.registerFix(new ActivateFix(vfile));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:GroovyDslAnnotator.java

示例13: checkOverrideAnnotation

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private static void checkOverrideAnnotation(AnnotationHolder holder, GrModifierList list, GrMethod method) {
  final PsiAnnotation overrideAnnotation = list.findAnnotation("java.lang.Override");
  if (overrideAnnotation == null) {
    return;
  }
  try {
    MethodSignatureBackedByPsiMethod superMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
    if (superMethod == null) {
      holder.createWarningAnnotation(overrideAnnotation, GroovyBundle.message("method.doesnot.override.super"));
    }
  }
  catch (IndexNotReadyException ignored) {
    //nothing to do
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:GroovyAnnotator.java

示例14: checkSillyStep

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private static void checkSillyStep(AnnotationHolder holder, XPathStep step) {
  final XPathExpression previousStep = step.getPreviousStep();
  if (previousStep instanceof XPathStep) {
    final XPathNodeTest nodeTest = ((XPathStep)previousStep).getNodeTest();
    if (nodeTest != null) {
      final XPathNodeTest.PrincipalType principalType = nodeTest.getPrincipalType();
      if (principalType != XPathNodeTest.PrincipalType.ELEMENT) {
        XPathNodeTest test = step.getNodeTest();
        if (test != null) {
          holder.createWarningAnnotation(test, "Silly location step on " + principalType.getType() + " axis");
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:XPathAnnotator.java

示例15: checkSillyNodeTest

import com.intellij.lang.annotation.AnnotationHolder; //导入方法依赖的package包/类
private static void checkSillyNodeTest(AnnotationHolder holder, XPathNodeTest nodeTest) {
  if (nodeTest.getPrincipalType() != XPathNodeTest.PrincipalType.ELEMENT) {
    final XPathNodeTypeTest typeTest = PsiTreeUtil.getChildOfType(nodeTest, XPathNodeTypeTest.class);
    if (typeTest != null) {
      holder.createWarningAnnotation(typeTest, "Silly node type test on axis '" + nodeTest.getPrincipalType().getType() + "'");
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:XPathAnnotator.java


注:本文中的com.intellij.lang.annotation.AnnotationHolder.createWarningAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。