Java Code Examples for com.intellij.codeInsight.daemon.impl.HighlightInfo#Builder
The following examples show how to use
com.intellij.codeInsight.daemon.impl.HighlightInfo#Builder .
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: 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 2
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 3
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 4
Source File: ConstructorHighlightUtil.java From consulo-csharp with Apache License 2.0 | 5 votes |
@Nullable @RequiredReadAction public static HighlightInfo checkConstructorDeclaration(@Nonnull CSharpConstructorDeclaration declaration) { PsiElement nameIdentifier = declaration.getNameIdentifier(); if(nameIdentifier == null) { return null; } PsiElement parent = declaration.getParent(); if(!(parent instanceof CSharpTypeDeclaration)) { return null; } String expectedTypeName = ((CSharpTypeDeclaration) parent).getName(); if(expectedTypeName == null) { return null; } if(!Comparing.equal(expectedTypeName, CSharpPsiUtilImpl.getNameWithoutAt(nameIdentifier.getText()))) { HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR); builder = builder.descriptionAndTooltip("Expected method name"); builder = builder.range(nameIdentifier); HighlightInfo highlightInfo = builder.create(); QuickFixAction.registerQuickFixAction(highlightInfo, new RenameQuickFix(expectedTypeName, declaration)); return highlightInfo; } return null; }
Example 5
Source File: ExpectedHighlightingDataTest.java From consulo with Apache License 2.0 | 5 votes |
private static HighlightInfo eolError(int start, int end, @Nonnull String description) { HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR); builder.range(start, end); builder.description(description); builder.endOfLine(); return builder.createUnconditionally(); }
Example 6
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 7
Source File: CSharpHighlightVisitor.java From consulo-csharp with Apache License 2.0 | 4 votes |
@RequiredReadAction private void highlightMaybeImplicit(@Nonnull CSharpCallArgumentListOwner scope) { MethodResolvePriorityInfo methodCalcResult = null; ResolveResult[] resolveResults = scope.multiResolve(false); ResolveResult firstValidResult = CSharpResolveUtil.findFirstValidResult(resolveResults); if(firstValidResult != null) { if(firstValidResult instanceof MethodResolveResult) { methodCalcResult = ((MethodResolveResult) firstValidResult).getCalcResult(); } } if(methodCalcResult == null) { return; } for(NCallArgument nCallArgument : methodCalcResult.getArguments()) { CSharpCallArgument callArgument = nCallArgument.getCallArgument(); if(callArgument == null) { continue; } DotNetExpression argumentExpression = callArgument.getArgumentExpression(); if(argumentExpression == null) { continue; } ImplicitCastInfo implicitCastInfo = nCallArgument.getUserData(ImplicitCastInfo.IMPLICIT_CAST_INFO); if(implicitCastInfo != null) { String text = CSharpErrorBundle.message("impicit.cast.from.0.to.1", CSharpTypeRefPresentationUtil.buildTextWithKeyword(implicitCastInfo.getFromTypeRef(), scope), CSharpTypeRefPresentationUtil.buildTextWithKeyword(implicitCastInfo.getToTypeRef(), scope)); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INFORMATION); builder = builder.range(argumentExpression.getTextRange()); builder = builder.descriptionAndTooltip(text); builder = builder.textAttributes(CSharpHighlightKey.IMPLICIT_OR_EXPLICIT_CAST); myHighlightInfoHolder.add(builder.create()); } } }
Example 8
Source File: ExpectedHighlightingDataTest.java From consulo with Apache License 2.0 | 4 votes |
private static HighlightInfo error(int start, int end, @Nonnull String description) { HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR); builder.range(start, end); builder.descriptionAndTooltip(description); return builder.createUnconditionally(); }
Example 9
Source File: ExpectedHighlightingDataTest.java From consulo with Apache License 2.0 | 4 votes |
private static HighlightInfo warning(int start, int end, @Nonnull String description) { HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING); builder.range(start, end); builder.descriptionAndTooltip(description); return builder.createUnconditionally(); }