本文整理汇总了Java中com.intellij.lang.annotation.Annotation.setHighlightType方法的典型用法代码示例。如果您正苦于以下问题:Java Annotation.setHighlightType方法的具体用法?Java Annotation.setHighlightType怎么用?Java Annotation.setHighlightType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.lang.annotation.Annotation
的用法示例。
在下文中一共展示了Annotation.setHighlightType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
}
示例2: doApplyInformationToEditor
import com.intellij.lang.annotation.Annotation; //导入方法依赖的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);
}
}
}
示例3: 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);
}
示例4: markUnresolvedVariable
import com.intellij.lang.annotation.Annotation; //导入方法依赖的package包/类
private static void markUnresolvedVariable(XPathVariableReference reference, AnnotationHolder holder) {
final String referencedName = reference.getReferencedName();
// missing name is already flagged by parser
if (referencedName.length() > 0) {
final TextRange range = reference.getTextRange().shiftRight(1).grown(-1);
final Annotation ann = holder.createErrorAnnotation(range, "Unresolved variable '" + referencedName + "'");
ann.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
final VariableContext variableContext = ContextProvider.getContextProvider(reference).getVariableContext();
if (variableContext != null) {
final IntentionAction[] fixes = variableContext.getUnresolvedVariableFixes(reference);
for (IntentionAction fix : fixes) {
ann.registerFix(fix);
}
}
}
}
示例5: 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);
}
}
}
}
}
}
示例6: annotate
import com.intellij.lang.annotation.Annotation; //导入方法依赖的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);
}
}
}
示例7: markError
import com.intellij.lang.annotation.Annotation; //导入方法依赖的package包/类
private void markError(ASTNode parent, @Nullable ASTNode node, String message) {
Annotation annotation;
if (node == null) {
annotation = holder.createErrorAnnotation(parent, message);
} else {
annotation = holder.createErrorAnnotation(node, message);
}
annotation.setHighlightType(ProblemHighlightType.GENERIC_ERROR);
}
示例8: annotate
import com.intellij.lang.annotation.Annotation; //导入方法依赖的package包/类
/**
* The method annotates all nodes which are used in edges but not declared explicitly
*
* @param element element you would like to annotate
* @param holder annotation holder
*/
@Override
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof DotDotgraphStmtImpl) {
for (DotId id : getNotMentionedNodeIds(element)) {
TextRange range = new TextRange(id.getTextRange().getStartOffset(),
id.getTextRange().getEndOffset());
Annotation annotation = holder.createInfoAnnotation(range, "No such such node specified in graph");
annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
}
}
示例9: visitRegExpProperty
import com.intellij.lang.annotation.Annotation; //导入方法依赖的package包/类
public void visitRegExpProperty(RegExpProperty property) {
final ASTNode category = property.getCategoryNode();
if (category == null) {
return;
}
if(!myLanguageHosts.isValidCategory(category.getPsi(), category.getText())) {
final Annotation a = myHolder.createErrorAnnotation(category, "Unknown character category");
if (a != null) {
// IDEA-9381
a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
}
}
}
示例10: visitRegExpBackref
import com.intellij.lang.annotation.Annotation; //导入方法依赖的package包/类
public void visitRegExpBackref(final RegExpBackref backref) {
final RegExpGroup group = backref.resolve();
if (group == null) {
final Annotation a = myHolder.createErrorAnnotation(backref, "Unresolved back reference");
if (a != null) {
// IDEA-9381
a.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
}
}
else if (PsiTreeUtil.isAncestor(group, backref, true)) {
myHolder.createWarningAnnotation(backref, "Back reference is nested into the capturing group it refers to");
}
}
示例11: visitPosixBracketExpression
import com.intellij.lang.annotation.Annotation; //导入方法依赖的package包/类
@Override
public void visitPosixBracketExpression(RegExpPosixBracketExpression posixBracketExpression) {
final String className = posixBracketExpression.getClassName();
if (!POSIX_CHARACTER_CLASSES.contains(className)) {
final Annotation annotation = myHolder.createErrorAnnotation(posixBracketExpression, "Unknown POSIX character class");
if (annotation != null) {
annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
}
}
}
示例12: addError
import com.intellij.lang.annotation.Annotation; //导入方法依赖的package包/类
private void addError(PsiReference reference) {
final TextRange rangeInElement = reference.getRangeInElement();
final TextRange range = TextRange.from(reference.getElement().getTextRange().getStartOffset()
+ rangeInElement.getStartOffset(), rangeInElement.getLength());
final Annotation annotation;
if (reference instanceof EmptyResolveMessageProvider) {
final String s = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern();
annotation = myHolder.createErrorAnnotation(range, MessageFormat.format(s, reference.getCanonicalText()));
}
else {
annotation = myHolder.createErrorAnnotation(range, "Cannot resolve symbol");
}
annotation.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL);
if (reference instanceof LocalQuickFixProvider) {
LocalQuickFix[] fixes = ((LocalQuickFixProvider)reference).getQuickFixes();
if (fixes != null) {
InspectionManager inspectionManager = InspectionManager.getInstance(reference.getElement().getProject());
for (LocalQuickFix fix : fixes) {
ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor(reference.getElement(), annotation.getMessage(), fix,
ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, true);
annotation.registerFix(fix, null, null, descriptor);
}
}
}
}