com.intellij.codeInsight.daemon.impl.HighlightInfo Java Examples
The following examples show how to use
com.intellij.codeInsight.daemon.impl.HighlightInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlobalInspectionUtil.java From consulo with Apache License 2.0 | 6 votes |
public static void createProblem(@Nonnull PsiElement elt, @Nonnull HighlightInfo info, TextRange range, @javax.annotation.Nullable ProblemGroup problemGroup, @Nonnull InspectionManager manager, @Nonnull ProblemDescriptionsProcessor problemDescriptionsProcessor, @Nonnull GlobalInspectionContext globalContext) { List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>(); if (info.quickFixActionRanges != null) { for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> actionRange : info.quickFixActionRanges) { final IntentionAction action = actionRange.getFirst().getAction(); if (action instanceof LocalQuickFix) { fixes.add((LocalQuickFix)action); } } } ProblemDescriptor descriptor = manager.createProblemDescriptor(elt, range, createInspectionMessage(StringUtil.notNullize(info.getDescription())), HighlightInfo.convertType(info.type), false, fixes.isEmpty() ? null : fixes.toArray(new LocalQuickFix[fixes.size()])); descriptor.setProblemGroup(problemGroup); problemDescriptionsProcessor.addProblemElement( GlobalInspectionContextUtil.retrieveRefElement(elt, globalContext), descriptor ); }
Example #2
Source File: Inspect.java From neovim-intellij-complete with MIT License | 6 votes |
/** * Runs code analyzis and returns all problems found under cursor (row and col). * * @param path * @param fileContent * @param row * @param col * @return */ public static List<HighlightInfo.IntentionActionDescriptor> getFixes( final String path, @Nullable final String fileContent, final int row, final int col) { List<HighlightInfo.IntentionActionDescriptor> fixes = new ArrayList<>(); Pair<Document, List<HighlightInfo>> problems = getProblems(path, fileContent); Document doc = problems.getFirst(); for (HighlightInfo h : problems.getSecond()) { if (h.quickFixActionRanges == null) continue; for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> p : h.quickFixActionRanges) { int offset = EmbeditorUtil.lineAndColumnToOffset(doc, row, col); if (p.getSecond().contains(offset)) { fixes.add(p.getFirst()); } } } return fixes; }
Example #3
Source File: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 6 votes |
@Override public void visitElement(PsiElement element) { super.visitElement(element); ASTNode node = element.getNode(); if(node != null) { if(node.getElementType() == ShaderLabKeyTokens.VALUE_KEYWORD) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(node).textAttributes(DefaultLanguageHighlighterColors.MACRO_KEYWORD).create()); } else if(node.getElementType() == ShaderLabKeyTokens.START_KEYWORD) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(node).textAttributes(DefaultLanguageHighlighterColors.KEYWORD).create()); } } }
Example #4
Source File: SqliteMagicHighlightErrorFilter.java From sqlitemagic with Apache License 2.0 | 6 votes |
@Override public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile file) { // if (null != file && HighlightSeverity.ERROR.equals(highlightInfo.getSeverity())) { // // String description = StringUtil.notNullize(highlightInfo.getDescription()); // // // Handling LazyGetter // if (uninitializedField(description) && LazyGetterHandler.isLazyGetterHandled(highlightInfo, file)) { // return false; // } // // //Handling onX parameters // if (OnXAnnotationHandler.isOnXParameterAnnotation(highlightInfo, file) // || OnXAnnotationHandler.isOnXParameterValue(highlightInfo, file) // || LOMBOK_ANYANNOTATIONREQUIRED.matcher(description).matches()) { // return false; // } // } return true; }
Example #5
Source File: GenericParameterHighlightUtil.java From consulo-csharp with Apache License 2.0 | 6 votes |
private static void registerInOutProblem(DotNetGenericParameter parameter, HighlightInfoHolder highlightInfoHolder, PsiElement modifierElement, CSharpModifier modifier) { CSharpModifier revertModifier = modifier == CSharpModifier.IN ? CSharpModifier.OUT : CSharpModifier.IN; HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR); builder.descriptionAndTooltip(CSharpErrorBundle.message("conflicting.0.modifier.with.1.modifier", modifier.getPresentableText(), revertModifier.getPresentableText())); builder.range(modifierElement); HighlightInfo info = builder.create(); if(info != null) { QuickFixAction.registerQuickFixAction(info, modifierElement.getTextRange(), new RemoveModifierFix(modifier, parameter)); highlightInfoHolder.add(info); } }
Example #6
Source File: EditorMouseHoverPopupManager.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private VisualPosition getPopupPosition(Editor editor) { HighlightInfo highlightInfo = getHighlightInfo(); if (highlightInfo == null) { int offset = targetOffset; PsiElement elementForQuickDoc = getElementForQuickDoc(); if (elementForQuickDoc != null) { offset = elementForQuickDoc.getTextRange().getStartOffset(); } return editor.offsetToVisualPosition(offset); } else { VisualPosition targetPosition = editor.offsetToVisualPosition(targetOffset); VisualPosition endPosition = editor.offsetToVisualPosition(highlightInfo.getEndOffset()); if (endPosition.line <= targetPosition.line) return targetPosition; Point targetPoint = editor.visualPositionToXY(targetPosition); Point endPoint = editor.visualPositionToXY(endPosition); Point resultPoint = new Point(targetPoint.x, endPoint.x > targetPoint.x ? endPoint.y : editor.visualLineToY(endPosition.line - 1)); return editor.xyToVisualPosition(resultPoint); } }
Example #7
Source File: CSharpHighlightVisitor.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Override public void visitElement(PsiElement element) { ProgressIndicatorProvider.checkCanceled(); IElementType elementType = PsiUtilCore.getElementType(element); if(CSharpSoftTokens.ALL.contains(elementType)) { myHighlightInfoHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(element).textAttributes(CSharpHighlightKey.SOFT_KEYWORD).create()); } else if(elementType == CSharpTokens.NON_ACTIVE_SYMBOL || elementType == CSharpPreprocessorElements.DISABLED_PREPROCESSOR_DIRECTIVE) { if(myDocument == null) { return; } int lineNumber = myDocument.getLineNumber(element.getTextOffset()); if(!myProcessedLines.contains(lineNumber)) { myProcessedLines.add(lineNumber); TextRange textRange = new TextRange(myDocument.getLineStartOffset(lineNumber), myDocument.getLineEndOffset(lineNumber)); myHighlightInfoHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(textRange).textAttributes(CSharpHighlightKey.DISABLED_BLOCK).create()); } } }
Example #8
Source File: OnXAnnotationHandler.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static boolean isOnXParameterAnnotation(HighlightInfo highlightInfo, PsiFile file) { final String description = StringUtil.notNullize(highlightInfo.getDescription()); if (!(ANNOTATION_TYPE_EXPECTED.equals(description) || CANNOT_RESOLVE_SYMBOL_UNDERSCORES_MESSAGE.matcher(description).matches() || CANNOT_RESOLVE_METHOD_UNDERSCORES_MESSAGE.matcher(description).matches())) { return false; } PsiElement highlightedElement = file.findElementAt(highlightInfo.getStartOffset()); PsiNameValuePair nameValuePair = findContainingNameValuePair(highlightedElement); if (nameValuePair == null || !(nameValuePair.getContext() instanceof PsiAnnotationParameterList)) { return false; } String parameterName = nameValuePair.getName(); if (null != parameterName && parameterName.contains("_")) { parameterName = parameterName.substring(0, parameterName.indexOf('_')); } if (!ONX_PARAMETERS.contains(parameterName)) { return false; } PsiElement containingAnnotation = nameValuePair.getContext().getContext(); return containingAnnotation instanceof PsiAnnotation && ONXABLE_ANNOTATIONS.contains(((PsiAnnotation) containingAnnotation).getQualifiedName()); }
Example #9
Source File: PantsScalaHighlightVisitor.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@Override public void visit(@NotNull PsiElement element) { // FIXME: Re-enable quick fix for missing dependencies once it is functional again. // https://github.com/pantsbuild/intellij-pants-plugin/issues/280 if (!ApplicationManager.getApplication().isUnitTestMode()) { return; } final PsiFile containingFile = element.getContainingFile(); if (containingFile == null || DumbService.getInstance(myHolder.getProject()).isDumb()) { return; } int infoSize = myHolder.size(); for (int i = 0; i < infoSize; i++) { final HighlightInfo info = myHolder.get(i); tryToExtendInfo(info, containingFile); } }
Example #10
Source File: ChangeSignaturePassFactory.java From consulo with Apache License 2.0 | 6 votes |
@Override public void doApplyInformationToEditor() { HighlightInfo info = null; final InplaceChangeSignature currentRefactoring = InplaceChangeSignature.getCurrentRefactoring(myEditor); if (currentRefactoring != null) { final ChangeInfo changeInfo = currentRefactoring.getStableChange(); final PsiElement element = changeInfo.getMethod(); int offset = myEditor.getCaretModel().getOffset(); if (element == null || !element.isValid()) return; final TextRange elementTextRange = element.getTextRange(); if (elementTextRange == null || !elementTextRange.contains(offset)) return; final LanguageChangeSignatureDetector<ChangeInfo> detector = LanguageChangeSignatureDetectors.INSTANCE.forLanguage(changeInfo.getLanguage()); TextRange range = detector.getHighlightingRange(changeInfo); TextAttributes attributes = new TextAttributes(null, null, myEditor.getColorsScheme().getAttributes(CodeInsightColors.WEAK_WARNING_ATTRIBUTES) .getEffectColor(), null, Font.PLAIN); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(range); builder.textAttributes(attributes); builder.descriptionAndTooltip(SIGNATURE_SHOULD_BE_POSSIBLY_CHANGED); info = builder.createUnconditionally(); QuickFixAction.registerQuickFixAction(info, new ApplyChangeSignatureAction(currentRefactoring.getInitialName())); } Collection<HighlightInfo> infos = info != null ? Collections.singletonList(info) : Collections.emptyList(); UpdateHighlightersUtil.setHighlightersToEditor(myProject, myDocument, 0, myFile.getTextLength(), infos, getColorsScheme(), getId()); }
Example #11
Source File: TooltipActionProvider.java From consulo with Apache License 2.0 | 6 votes |
@Nullable static TooltipAction calcTooltipAction(@Nonnull final HighlightInfo info, @Nonnull Editor editor) { if (!Registry.is("ide.tooltip.show.with.actions")) return null; Project project = editor.getProject(); if (project == null) return null; PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file == null) return null; for (TooltipActionProvider extension : EXTENSION_POINT_NAME.getExtensionList()) { TooltipAction action = extension.getTooltipAction(info, editor, file); if (action != null) return action; } return null; }
Example #12
Source File: ResolveRedSymbolsAction.java From litho with Apache License 2.0 | 6 votes |
private static Map<String, List<PsiElement>> collectRedSymbols( PsiFile psiFile, Document document, Project project, ProgressIndicator daemonIndicator) { Map<String, List<PsiElement>> redSymbolToElements = new HashMap<>(); List<HighlightInfo> infos = ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project)) .runMainPasses(psiFile, document, daemonIndicator); for (HighlightInfo info : infos) { if (!info.getSeverity().equals(HighlightSeverity.ERROR)) continue; final String redSymbol = document.getText(new TextRange(info.startOffset, info.endOffset)); if (!StringUtil.isJavaIdentifier(redSymbol) || !StringUtil.isCapitalized(redSymbol)) continue; final PsiJavaCodeReferenceElement ref = PsiTreeUtil.findElementOfClassAtOffset( psiFile, info.startOffset, PsiJavaCodeReferenceElement.class, false); if (ref == null) continue; redSymbolToElements.putIfAbsent(redSymbol, new ArrayList<>()); redSymbolToElements.get(redSymbol).add(ref); } return redSymbolToElements; }
Example #13
Source File: CSharpHighlightUtil.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nullable @RequiredReadAction public static HighlightInfo highlightNamed(@Nonnull HighlightInfoHolder holder, @Nullable PsiElement element, @Nullable PsiElement target, @Nullable PsiElement owner) { if(target == null || element == null) { return null; } IElementType elementType = target.getNode().getElementType(); if(CSharpTokenSets.KEYWORDS.contains(elementType)) // don't highlight keywords { return null; } if(isMethodRef(owner, element)) { HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(CSharpHighlightKey.METHOD_REF).create(); holder.add(highlightInfo); } TextAttributesKey defaultTextAttributeKey = getDefaultTextAttributeKey(element, target); if(defaultTextAttributeKey == null) { return null; } HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(defaultTextAttributeKey).create(); holder.add(info); if(!(target instanceof CSharpIdentifier) && DotNetAttributeUtil.hasAttribute(element, DotNetTypes.System.ObsoleteAttribute)) { holder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(target).textAttributes(CodeInsightColors.DEPRECATED_ATTRIBUTES).create()); } return info; }
Example #14
Source File: CompilerCheck.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nullable @Override public HighlightInfo create(boolean insideDoc) { HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(insideDoc ? HighlightInfoType.WEAK_WARNING : getHighlightInfoType()); builder = builder.descriptionAndTooltip(getText()); builder = builder.range(getTextRange()); TextAttributesKey textAttributesKey = getTextAttributesKey(); if(textAttributesKey != null) { builder = builder.textAttributes(textAttributesKey); } return builder.create(); }
Example #15
Source File: CachedIntentions.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull IntentionActionWithTextCaching wrapAction(@Nonnull HighlightInfo.IntentionActionDescriptor descriptor, @Nonnull PsiElement element, @Nonnull PsiFile containingFile, @Nullable Editor containingEditor) { IntentionActionWithTextCaching cachedAction = new IntentionActionWithTextCaching(descriptor, (cached, action) -> { if (action instanceof QuickFixWrapper) { // remove only inspection fixes after invocation, // since intention actions might be still available removeActionFromCached(cached); markInvoked(action); } }); final List<IntentionAction> options = descriptor.getOptions(element, containingEditor); if (options == null) return cachedAction; for (IntentionAction option : options) { Editor editor = ObjectUtils.chooseNotNull(myEditor, containingEditor); if (editor == null) continue; Pair<PsiFile, Editor> availableIn = ShowIntentionActionsHandler.chooseBetweenHostAndInjected(myFile, editor, containingFile, (f, e) -> ShowIntentionActionsHandler.availableFor(f, e, option)); if (availableIn == null) continue; IntentionActionWithTextCaching textCaching = new IntentionActionWithTextCaching(option); boolean isErrorFix = myErrorFixes.contains(textCaching); if (isErrorFix) { cachedAction.addErrorFix(option); } boolean isInspectionFix = myInspectionFixes.contains(textCaching); if (isInspectionFix) { cachedAction.addInspectionFix(option); } else { cachedAction.addIntention(option); } } return cachedAction; }
Example #16
Source File: QuickFixAction.java From consulo with Apache License 2.0 | 5 votes |
public static void registerQuickFixAction(@Nullable HighlightInfo info, @Nullable TextRange fixRange, @Nullable IntentionAction action, @Nullable final HighlightDisplayKey key) { if (info == null) return; info.registerFix(action, null, HighlightDisplayKey.getDisplayNameByKey(key), fixRange, key); }
Example #17
Source File: ExpectedHighlightingData.java From consulo with Apache License 2.0 | 5 votes |
private void compareTexts(Collection<HighlightInfo> infos, String text, String failMessage, @javax.annotation.Nullable String filePath) { String actual = composeText(highlightingTypes, infos, text); if (filePath != null && !myText.equals(actual)) { // uncomment to overwrite, don't forget to revert on commit! //VfsTestUtil.overwriteTestData(filePath, actual); //return; throw new FileComparisonFailure(failMessage, myText, actual, filePath); } Assert.assertEquals(failMessage + "\n", myText, actual); Assert.fail(failMessage); }
Example #18
Source File: ExpectedHighlightingData.java From consulo with Apache License 2.0 | 5 votes |
private static Couple<Integer> composeText(StringBuilder sb, List<Pair<String, HighlightInfo>> list, int index, String text, int endPos, int startPos) { int i = index; while (i < list.size()) { Pair<String, HighlightInfo> pair = list.get(i); HighlightInfo info = pair.second; if (info.endOffset <= startPos) { break; } String severity = pair.first; HighlightInfo prev = i < list.size() - 1 ? list.get(i + 1).second : null; sb.insert(0, text.substring(info.endOffset, endPos)); sb.insert(0, "</" + severity + ">"); endPos = info.endOffset; if (prev != null && prev.endOffset > info.startOffset) { Couple<Integer> result = composeText(sb, list, i + 1, text, endPos, info.startOffset); i = result.first - 1; endPos = result.second; } sb.insert(0, text.substring(info.startOffset, endPos)); sb.insert(0, "<" + severity + " descr=\"" + info.getDescription() + "\">"); endPos = info.startOffset; i++; } return Couple.of(i, endPos); }
Example #19
Source File: ExpectedHighlightingData.java From consulo with Apache License 2.0 | 5 votes |
private boolean expectedInfosContainsInfo(HighlightInfo info) { if (info.getTextAttributes(null, null) == TextAttributes.ERASE_MARKER) return true; final Collection<ExpectedHighlightingSet> expectedHighlights = highlightingTypes.values(); for (ExpectedHighlightingSet highlightingSet : expectedHighlights) { if (highlightingSet.severity != info.getSeverity()) continue; if (!highlightingSet.enabled) return true; final Set<HighlightInfo> infos = highlightingSet.infos; for (HighlightInfo expectedInfo : infos) { if (infoEquals(expectedInfo, info)) { return true; } } } return false; }
Example #20
Source File: ExpectedHighlightingData.java From consulo with Apache License 2.0 | 5 votes |
private static boolean infoEquals(HighlightInfo expectedInfo, HighlightInfo info) { if (expectedInfo == info) return true; return info.getSeverity() == expectedInfo.getSeverity() && info.startOffset == expectedInfo.startOffset && info.endOffset == expectedInfo.endOffset && info.isAfterEndOfLine() == expectedInfo.isAfterEndOfLine() && (expectedInfo.type == WHATEVER || expectedInfo.type.equals(info.type)) && (Comparing.strEqual(ANY_TEXT, expectedInfo.getDescription()) || Comparing.strEqual(info.getDescription(), expectedInfo.getDescription())) && (expectedInfo.forcedTextAttributes == null || Comparing.equal(expectedInfo.getTextAttributes(null, null), info.getTextAttributes(null, null))) && (expectedInfo.forcedTextAttributesKey == null || expectedInfo.forcedTextAttributesKey.equals(info.forcedTextAttributesKey)); }
Example #21
Source File: RainbowHighlighter.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected HighlightInfo.Builder getInfoBuilder(int colorIndex, @Nullable TextAttributesKey colorKey) { if (colorKey == null) { colorKey = DefaultLanguageHighlighterColors.LOCAL_VARIABLE; } return HighlightInfo .newHighlightInfo(RAINBOW_ELEMENT) .textAttributes(TextAttributes .fromFlyweight(myColorsScheme .getAttributes(colorKey) .getFlyweight() .withForeground(calculateForeground(colorIndex)))); }
Example #22
Source File: LombokHighlightErrorFilter.java From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void processHook(@NotNull PsiElement highlightedElement, @NotNull HighlightInfo highlightInfo) { PsiElement importantParent = PsiTreeUtil.getParentOfType(highlightedElement, PsiMethod.class, PsiLambdaExpression.class, PsiMethodReferenceExpression.class, PsiClassInitializer.class ); // applicable only for methods if (importantParent instanceof PsiMethod) { AddAnnotationFix fix = new AddAnnotationFix(SneakyThrows.class.getCanonicalName(), (PsiModifierListOwner) importantParent); highlightInfo.registerFix(fix, null, null, null, null); } }
Example #23
Source File: TemplateLanguageErrorQuickFixProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override public void registerErrorQuickFix(final PsiErrorElement errorElement, final HighlightInfo highlightInfo) { final PsiFile psiFile = errorElement.getContainingFile(); final FileViewProvider provider = psiFile.getViewProvider(); if (!(provider instanceof TemplateLanguageFileViewProvider)) return; if (psiFile.getLanguage() != ((TemplateLanguageFileViewProvider) provider).getTemplateDataLanguage()) return; QuickFixAction.registerQuickFixAction(highlightInfo, createChangeTemplateDataLanguageFix(errorElement)); }
Example #24
Source File: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override @RequiredReadAction public void visitReference(ShaderReference reference) { if(!reference.isSoft()) { PsiElement resolve = reference.resolve(); if(resolve == null) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(reference.getReferenceElement()).descriptionAndTooltip("'" + reference.getReferenceName() + "' is not " + "resolved").create()); } else { ShaderReference.ResolveKind kind = reference.kind(); TextAttributesKey key = null; switch(kind) { case ATTRIBUTE: key = DefaultLanguageHighlighterColors.METADATA; break; case PROPERTY: key = DefaultLanguageHighlighterColors.INSTANCE_FIELD; break; default: return; } myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(reference.getReferenceElement()).textAttributes(key).create()); } } }
Example #25
Source File: BashAnnotatorTest.java From BashSupport with Apache License 2.0 | 5 votes |
@Test public void testIdentifiers() { configureByFile("/editor/annotator/identifiers.bash"); doHighlighting(); List<HighlightInfo> errors = highlightErrors(); Assert.assertEquals("Errors: " + errors, 5, errors.size()); }
Example #26
Source File: BashAnnotatorTest.java From BashSupport with Apache License 2.0 | 5 votes |
public void testEvalVarDef() throws Exception { configureByFile("/editor/annotator/449-eval-vardef.bash"); doHighlighting(); List<HighlightInfo> errors = highlightErrors(); Assert.assertEquals(0, errors.size()); }
Example #27
Source File: RTInfoFilter.java From react-templates-plugin with MIT License | 5 votes |
@Override public boolean accept(@NotNull HighlightInfo highlightInfo, PsiFile psiFile) { if (psiFile != null && psiFile.getName() != null && psiFile.getName().endsWith(".rt") && MSG_EMPTY_TAG.equals(highlightInfo.getDescription())) { return false; } // System.out.println(highlightInfo.getSeverity() + " " + highlightInfo.getDescription()); return true; }
Example #28
Source File: PantsHighlightingIntegrationTest.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
@Nullable protected <T> T findIntention(@NotNull HighlightInfo info, @NotNull Class<T> aClass) { for (Pair<HighlightInfo.IntentionActionDescriptor, RangeMarker> pair : info.quickFixActionMarkers) { final HighlightInfo.IntentionActionDescriptor intensionDescriptor = pair.getFirst(); final IntentionAction action = intensionDescriptor.getAction(); if (aClass.isInstance(action)) { //noinspection unchecked return (T)action; } } return null; }
Example #29
Source File: SyntaxInfoBuilder.java From consulo with Apache License 2.0 | 5 votes |
private void findNextSuitableRange() { myNextAttributes = null; while (myIterator.hasNext()) { RangeHighlighterEx highlighter = myIterator.next(); if (highlighter == null || !highlighter.isValid() || !isInterestedInLayer(highlighter.getLayer())) { continue; } // LINES_IN_RANGE highlighters are not supported currently myNextStart = Math.max(highlighter.getStartOffset(), myStartOffset); myNextEnd = Math.min(highlighter.getEndOffset(), myEndOffset); if (myNextStart >= myEndOffset) { break; } if (myNextStart < myCurrentEnd) { continue; // overlapping ranges withing document markup model are not supported currently } TextAttributes attributes = null; HighlightInfo info = HighlightInfo.fromRangeHighlighter(highlighter); if (info != null) { TextAttributesKey key = info.forcedTextAttributesKey; if (key == null) { HighlightInfoType type = info.type; key = type.getAttributesKey(); } if (key != null) { attributes = myColorsScheme.getAttributes(key); } } if (attributes == null) { continue; } Color foreground = attributes.getForegroundColor(); Color background = attributes.getBackgroundColor(); if ((foreground == null || myDefaultForeground.equals(foreground)) && (background == null || myDefaultBackground.equals(background)) && attributes.getFontType() == Font.PLAIN) { continue; } myNextAttributes = attributes; break; } }
Example #30
Source File: SharpLabHighlightVisitor.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Override public void visitProperty(ShaderPropertyElement p) { super.visitProperty(p); PsiElement nameIdentifier = p.getNameIdentifier(); if(nameIdentifier != null) { myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION).range(nameIdentifier).textAttributes(DefaultLanguageHighlighterColors.INSTANCE_FIELD).create()); } }