當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。