本文整理汇总了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));
}
}
}
示例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);
}
}
示例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);
}
}
}
示例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.");
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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));
}
}
}
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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");
}
}
}
}
示例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));
}
示例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
}
}
示例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");
}
}
}
}
}
示例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() + "'");
}
}
}