From e4ae71f9662d0b9335696aa053f475581bd55f07 Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Fri, 29 May 2020 15:09:43 +0700 Subject: [PATCH] Revert "Deprecated APIs replaced; cleanup" This reverts commit 624f355f GitOrigin-RevId: 63cd2977d3574a158cee7a1663d48e7c51ab6de8 --- .../ExternalAnnotationsManagerImpl.java | 6 ++++- .../quickfix/AccessStaticViaInstanceFix.java | 6 +++-- .../quickfix/RemoveUnusedVariableFix.java | 6 ++++- .../impl/AddOnDemandStaticImportAction.java | 9 ++++--- .../BaseMoveInitializerToMethodAction.java | 7 +++-- .../call/CallHierarchyNodeDescriptor.java | 3 +-- .../extractMethod/ExtractMethodHandler.java | 7 +++-- .../extractMethod/ExtractMethodProcessor.java | 6 ++++- .../extractMethod/newImpl/MethodExtractor.kt | 10 ++++--- .../inline/InlineLocalHandler.java | 27 ++++++++++++------- .../BaseExpressionToFieldHandler.java | 11 ++++++-- .../IntroduceConstantHandler.java | 7 +++-- .../IntroduceVariableBase.java | 6 ++++- .../IntroduceVariableHandler.java | 6 ++++- .../refactoring/util/RefactoringUtil.java | 20 +++++++------- .../util/duplicates/DuplicatesImpl.java | 6 ++++- .../largeFilesEditor/editor/EditorModel.java | 6 ++++- .../changeSignature/CallerChooserBase.java | 10 ++++--- .../inplace/InplaceChangeSignature.java | 6 +++-- .../extractMethod/ExtractMethodHelper.java | 6 ++++- .../lang/ExtractIncludeFileBase.java | 6 ++++- .../com/siyeh/ig/psiutils/HighlightUtils.java | 10 +++++-- .../refactoring/GroovyRefactoringUtil.java | 21 +++++++++------ .../introduce/GrIntroduceHandlerBase.java | 7 +++-- .../MarkdownIntroduceLinkReferenceAction.java | 6 ++++- .../xslt/refactoring/BaseIntroduceAction.java | 4 +-- .../refactoring/VariableInlineHandler.java | 2 +- .../inline/PyInlineLocalHandler.java | 16 +++++++---- 28 files changed, 171 insertions(+), 72 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java index 8c45cf49bd2b..93d70556d6d6 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java @@ -19,9 +19,11 @@ import com.intellij.openapi.command.undo.UndoUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; @@ -732,10 +734,12 @@ public final class ExternalAnnotationsManagerImpl extends ReadableExternalAnnota editor != null && editor.getDocument() == PsiDocumentManager.getInstance(project).getDocument(containingFile); try { if (highlight) { //do not highlight for batch inspections + final EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final TextRange textRange = highlightElement.getTextRange(); HighlightManager.getInstance(project).addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + attributes, true, highlighters); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(textRange.getStartOffset()); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.CENTER); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java index c979ed746e41..00719676dbdc 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AccessStaticViaInstanceFix.java @@ -27,6 +27,8 @@ import com.intellij.openapi.application.WriteAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.util.*; @@ -135,8 +137,8 @@ public class AccessStaticViaInstanceFix extends LocalQuickFixAndIntentionActionO if (editor == null) { return false; } - HighlightManager.getInstance(project).addOccurrenceHighlights(editor, PsiUtilCore.toPsiElementArray(sideEffects), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + HighlightManager.getInstance(project).addOccurrenceHighlights(editor, PsiUtilCore.toPsiElementArray(sideEffects), attributes, true, null); try { hasSideEffects = PsiUtil.isStatement(factory.createStatementFromText(qualifierExpression.getText(), qualifierExpression)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java index 808b800b2977..04072f9cf3a5 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveUnusedVariableFix.java @@ -25,6 +25,8 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.psi.*; import com.intellij.psi.util.JavaElementKind; @@ -123,7 +125,9 @@ public class RemoveUnusedVariableFix implements IntentionAction { Project project = editor.getProject(); HighlightManager highlightManager = HighlightManager.getInstance(project); PsiElement[] elements = PsiUtilCore.toPsiElementArray(sideEffects); - highlightManager.addOccurrenceHighlights(editor, elements, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + EditorColorsManager manager = EditorColorsManager.getInstance(); + TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + highlightManager.addOccurrenceHighlights(editor, elements, attributes, true, null); SideEffectWarningDialog dialog = new SideEffectWarningDialog(project, false, variable, beforeText, afterText, canCopeWithSideEffects); dialog.show(); diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java index 016ec52b3f59..83b246d4cf81 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddOnDemandStaticImportAction.java @@ -22,6 +22,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.wm.WindowManager; @@ -227,9 +228,11 @@ public class AddOnDemandStaticImportAction extends BaseElementAtCaretIntentionAc for (PsiJavaCodeReferenceElement expression : expressionsToDequalify) { if (!expression.isValid()) continue; found = true; - HighlightManager.getInstance(project).addRangeHighlight( - editor, expression.getTextRange().getStartOffset(), expression.getTextRange().getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + HighlightManager.getInstance(project) + .addRangeHighlight(editor, expression.getTextRange().getStartOffset(), expression.getTextRange().getEndOffset(), + EditorColorsManager.getInstance().getGlobalScheme() + .getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES), + true, null); } return found; } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java index 250181d5cadf..fdd8754b044e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java @@ -21,6 +21,8 @@ import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.psi.*; @@ -93,10 +95,11 @@ public abstract class BaseMoveInitializerToMethodAction extends PsiElementBaseIn } private static void highlightRExpression(@NotNull PsiAssignmentExpression assignment, @NotNull Project project, Editor editor) { + final EditorColorsManager manager = EditorColorsManager.getInstance(); + final TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final PsiExpression expression = assignment.getRExpression(); - HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[]{expression}, - EditorColors.SEARCH_RESULT_ATTRIBUTES, false, null); + HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[]{expression}, attributes, false, null); } @NotNull diff --git a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java index beadc9dcad5b..ce5ce1b92974 100644 --- a/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java +++ b/java/java-impl/src/com/intellij/ide/hierarchy/call/CallHierarchyNodeDescriptor.java @@ -183,8 +183,7 @@ public final class CallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i final PsiElement eachMethodCall = eachElement.getParent(); if (eachMethodCall != null) { final TextRange textRange = eachMethodCall.getTextRange(); - highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, false, highlighters); + highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, false, highlighters); } } } diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java index 652f4d2e6b14..2d4e0ccaa752 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHandler.java @@ -29,6 +29,8 @@ import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.project.Project; @@ -281,8 +283,9 @@ public class ExtractMethodHandler implements RefactoringActionHandler, ContextAw if (e.getFile() == file) { final TextRange textRange = e.getTextRange(); final HighlightManager highlightManager = HighlightManager.getInstance(project); - highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, null); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(textRange.getStartOffset()); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE); WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java index 99e39ee69b30..c75caceb0eed 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java @@ -24,6 +24,8 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; @@ -2122,7 +2124,9 @@ public class ExtractMethodProcessor implements MatchProvider { if (myShowErrorDialogs) { HighlightManager highlightManager = HighlightManager.getInstance(myProject); PsiStatement[] exitStatementsArray = myExitStatements.toArray(PsiStatement.EMPTY_ARRAY); - highlightManager.addOccurrenceHighlights(myEditor, exitStatementsArray, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + EditorColorsManager manager = EditorColorsManager.getInstance(); + TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + highlightManager.addOccurrenceHighlights(myEditor, exitStatementsArray, attributes, true, null); String message = RefactoringBundle .getCannotRefactorMessage(JavaRefactoringBundle.message("there.are.multiple.exit.points.in.the.selected.code.fragment")); CommonRefactoringUtil.showErrorHint(myProject, myEditor, message, myRefactoringName, myHelpId); diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/MethodExtractor.kt b/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/MethodExtractor.kt index cfc57e7a317c..fbbe8fdc4629 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/MethodExtractor.kt +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/newImpl/MethodExtractor.kt @@ -9,6 +9,7 @@ import com.intellij.openapi.command.CommandProcessor import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.colors.EditorColors +import com.intellij.openapi.editor.colors.EditorColorsManager import com.intellij.openapi.project.Project import com.intellij.openapi.util.TextRange import com.intellij.openapi.util.registry.Registry @@ -93,7 +94,7 @@ class MethodExtractor { beforeData.addElements(options.elements.toTypedArray()) options.project.messageBus.syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC) .refactoringStarted("refactoring.extract.method", beforeData) - val (method, _) = extractMethod(options) + val (method, callElements) = extractMethod(options) val data = RefactoringEventData() data.addElement(method) options.project.messageBus.syncPublisher(RefactoringEventListener.REFACTORING_EVENT_TOPIC) @@ -165,11 +166,12 @@ class MethodExtractor { val project = editor.project ?: return if (ranges.isEmpty()) return val highlightManager = HighlightManager.getInstance(project) + val colorsManager = EditorColorsManager.getInstance() + val attributes = colorsManager.globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES) ranges.forEach { textRange -> - highlightManager.addRangeHighlight(editor, textRange.startOffset, textRange.endOffset, - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null) + highlightManager.addRangeHighlight(editor, textRange.startOffset, textRange.endOffset, attributes, true, null) } - WindowManager.getInstance().getStatusBar(project).info = RefactoringBundle.message("press.escape.to.remove.the.highlighting") + WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")) } fun extractMethod(extractOptions: ExtractOptions): Pair> { diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java index d5109cbd2422..2686a453103b 100644 --- a/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineLocalHandler.java @@ -17,7 +17,9 @@ import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.ex.EditorSettingsExternalizable; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; @@ -130,9 +132,11 @@ public class InlineLocalHandler extends JavaInlineActionHandler { final PsiElement[] refsToInline = PsiUtilCore.toPsiElementArray(refsToInlineList); PsiExpression defToInline = JavaPsiFacade.getElementFactory(project).createExpressionFromText(initializerText, pattern); + final EditorColorsManager manager = EditorColorsManager.getInstance(); + final TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + if (!ApplicationManager.getApplication().isUnitTestMode()) { - HighlightManager.getInstance(project).addOccurrenceHighlights(editor, refsToInline, - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + HighlightManager.getInstance(project).addOccurrenceHighlights(editor, refsToInline, attributes, true, null); } return () -> { @@ -243,20 +247,24 @@ public class InlineLocalHandler extends JavaInlineActionHandler { final PsiElement[] refsToInline = PsiUtilCore.toPsiElementArray(refsToInlineList); + final EditorColorsManager manager = EditorColorsManager.getInstance(); + final TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + final TextAttributes writeAttributes = manager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES); + if (!ApplicationManager.getApplication().isUnitTestMode()) { // TODO : check if initializer uses fieldNames that possibly will be hidden by other // locals with the same names after inlining highlightManager.addOccurrenceHighlights( editor, refsToInline, - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null + attributes, true, null ); } if (refExpr != null && PsiUtil.isAccessedForReading(refExpr) && ArrayUtil.find(refsToInline, refExpr) < 0) { final PsiElement[] defs = DefUseUtil.getDefs(containerBlock, local, refExpr); LOG.assertTrue(defs.length > 0); - highlightManager.addOccurrenceHighlights(editor, defs, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addOccurrenceHighlights(editor, defs, attributes, true, null); String message = RefactoringBundle.getCannotRefactorMessage(JavaRefactoringBundle.message("variable.is.accessed.for.writing", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(local), HelpID.INLINE_VARIABLE); WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); @@ -291,8 +299,8 @@ public class InlineLocalHandler extends JavaInlineActionHandler { isSameDefinition &= isSameDefinition(def, defToInline); } if (!isSameDefinition) { - highlightManager.addOccurrenceHighlights(editor, defs, EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES, true, null); - highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{ref}, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addOccurrenceHighlights(editor, defs, writeAttributes, true, null); + highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{ref}, attributes, true, null); String message = RefactoringBundle.getCannotRefactorMessage(RefactoringBundle.message("variable.is.accessed.for.writing.and.used.with.inlined", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(local), HelpID.INLINE_VARIABLE); @@ -303,8 +311,7 @@ public class InlineLocalHandler extends JavaInlineActionHandler { final PsiElement writeAccess = checkRefsInAugmentedAssignmentOrUnaryModified(refsToInline, defToInline); if (writeAccess != null) { - HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[]{writeAccess}, - EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES, true, null); + HighlightManager.getInstance(project).addOccurrenceHighlights(editor, new PsiElement[]{writeAccess}, writeAttributes, true, null); String message = RefactoringBundle.getCannotRefactorMessage(JavaRefactoringBundle.message("variable.is.accessed.for.writing", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(local), HelpID.INLINE_VARIABLE); WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); @@ -401,9 +408,11 @@ public class InlineLocalHandler extends JavaInlineActionHandler { static void highlightOccurrences(@NotNull Project project, @Nullable Editor editor, @NotNull List> exprs) { + final EditorColorsManager manager = EditorColorsManager.getInstance(); + final TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); if (editor != null && !ApplicationManager.getApplication().isUnitTestMode()) { PsiExpression[] occurrences = ContainerUtil.map2Array(exprs, new PsiExpression[exprs.size()], SmartPsiElementPointer::getElement); - HighlightManager.getInstance(project).addOccurrenceHighlights(editor, occurrences, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + HighlightManager.getInstance(project).addOccurrenceHighlights(editor, occurrences, attributes, true, null); if (exprs.size() > 1) { Shortcut shortcut = KeymapUtil.getPrimaryShortcut("FindNext"); String message; diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java index 643b00e6dbbd..bbc0f8b5c667 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java @@ -19,7 +19,9 @@ import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; @@ -234,6 +236,12 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase return element; } + private static TextAttributes highlightAttributes() { + return EditorColorsManager.getInstance().getGlobalScheme().getAttributes( + EditorColors.SEARCH_RESULT_ATTRIBUTES + ); + } + @Nullable protected PsiElement isStaticFinalInitializer(PsiExpression expr) { PsiClass parentClass = expr != null ? getParentClass(expr) : null; @@ -820,8 +828,7 @@ public abstract class BaseExpressionToFieldHandler extends IntroduceHandlerBase if (!ApplicationManager.getApplication().isUnitTestMode()) { PsiElement[] exprsToHighlight = PsiUtilCore.toPsiElementArray(array); HighlightManager highlightManager = HighlightManager.getInstance(myProject); - highlightManager.addOccurrenceHighlights(myEditor, exprsToHighlight, - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addOccurrenceHighlights(myEditor, exprsToHighlight, highlightAttributes(), true, null); WindowManager .getInstance().getStatusBar(myProject).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java index 96e22e9b8158..9034d7d6f7a2 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceConstantHandler.java @@ -20,6 +20,8 @@ import com.intellij.java.refactoring.JavaRefactoringBundle; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.wm.WindowManager; @@ -189,9 +191,10 @@ public class IntroduceConstantHandler extends BaseExpressionToFieldHandler { private static void highlightError(Project project, Editor editor, PsiElement errorElement) { if (editor != null) { + final TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final TextRange textRange = errorElement.getTextRange(); - HighlightManager.getInstance(project).addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, new ArrayList<>()); + HighlightManager.getInstance(project).addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, + new ArrayList<>()); } } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java index 13a2b818c45b..9a8d4d4d91fd 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableBase.java @@ -23,6 +23,8 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; @@ -1030,7 +1032,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase { if (editor == null) return; if (ApplicationManager.getApplication().isUnitTestMode()) return; HighlightManager highlightManager = HighlightManager.getInstance(project); - highlightManager.addOccurrenceHighlights(editor, replacedOccurrences, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + highlightManager.addOccurrenceHighlights(editor, replacedOccurrences, attributes, true, null); WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableHandler.java index 38bbf3653293..6b221ebd5245 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceVariable/IntroduceVariableHandler.java @@ -19,7 +19,9 @@ import com.intellij.codeInsight.highlighting.HighlightManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.wm.WindowManager; @@ -60,8 +62,10 @@ public class IntroduceVariableHandler extends IntroduceVariableBase { HighlightManager highlightManager = null; if (editor != null) { highlightManager = HighlightManager.getInstance(project); + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); if (occurrences.length > 1) { - highlightManager.addOccurrenceHighlights(editor, occurrences, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + highlightManager.addOccurrenceHighlights(editor, occurrences, attributes, true, highlighters); } } diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java index 8328da2bf926..1204fb649b5f 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java @@ -12,7 +12,9 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.*; @@ -37,7 +39,6 @@ import com.intellij.refactoring.introduceField.ElementToWorkOn; import com.intellij.refactoring.introduceVariable.IntroduceVariableBase; import com.intellij.util.IncorrectOperationException; import com.intellij.util.ObjectUtils; -import com.intellij.util.containers.Stack; import com.intellij.util.text.UniqueNameGenerator; import gnu.trove.THashMap; import org.jetbrains.annotations.Contract; @@ -534,17 +535,18 @@ public class RefactoringUtil { public static List highlightAllOccurrences(Project project, PsiElement[] occurrences, Editor editor) { ArrayList highlighters = new ArrayList<>(); HighlightManager highlightManager = HighlightManager.getInstance(project); + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); if (occurrences.length > 1) { for (PsiElement occurrence : occurrences) { final RangeMarker rangeMarker = occurrence.getUserData(ElementToWorkOn.TEXT_RANGE); if (rangeMarker != null && rangeMarker.isValid()) { - highlightManager.addRangeHighlight(editor, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + highlightManager + .addRangeHighlight(editor, rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), attributes, true, highlighters); } else { final TextRange textRange = occurrence.getTextRange(); - highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + highlightManager.addRangeHighlight(editor, textRange.getStartOffset(), textRange.getEndOffset(), attributes, true, highlighters); } } } @@ -726,7 +728,7 @@ public class RefactoringUtil { } public static void visitImplicitSuperConstructorUsages(PsiClass subClass, - final ImplicitConstructorUsageVisitor implicitConstructorUsageVisitor, + final ImplicitConstructorUsageVisitor implicitConstructorUsageVistor, PsiClass superClass) { final PsiMethod baseDefaultConstructor = findDefaultConstructor(superClass); final PsiMethod[] constructors = subClass.getConstructors(); @@ -736,12 +738,12 @@ public class RefactoringUtil { if (body == null) continue; final PsiStatement[] statements = body.getStatements(); if (statements.length < 1 || !JavaHighlightUtil.isSuperOrThisCall(statements[0], true, true)) { - implicitConstructorUsageVisitor.visitConstructor(constructor, baseDefaultConstructor); + implicitConstructorUsageVistor.visitConstructor(constructor, baseDefaultConstructor); } } } else { - implicitConstructorUsageVisitor.visitClassWithoutConstructors(subClass); + implicitConstructorUsageVistor.visitClassWithoutConstructors(subClass); } } @@ -1022,7 +1024,7 @@ public class RefactoringUtil { * Returns subset of {@code graph.getVertices()} that is a transitive closure (by graph.getTargets()) * of the following property: initialRelation.value() of vertex or {@code graph.getTargets(vertex)} is true. *

- * Note that {@code graph.getTargets()} is not necessarily a subset of {@code graph.getVertex()} + * Note that {@code graph.getTargets()} is not neccesrily a subset of {@code graph.getVertex()} * * @param graph * @param initialRelation diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java index 7127dff42c19..0b74c4736712 100644 --- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java +++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesImpl.java @@ -29,7 +29,9 @@ import com.intellij.openapi.editor.FoldRegion; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.project.Project; @@ -187,8 +189,10 @@ public class DuplicatesImpl { } public static void highlightMatch(final Project project, Editor editor, final Match match, final ArrayList highlighters) { + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); HighlightManager.getInstance(project).addRangeHighlight(editor, match.getTextRange().getStartOffset(), match.getTextRange().getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + attributes, true, highlighters); } public static void processDuplicates(@NotNull MatchProvider provider, @NotNull Project project, @NotNull Editor editor) { diff --git a/platform/lang-impl/src/com/intellij/largeFilesEditor/editor/EditorModel.java b/platform/lang-impl/src/com/intellij/largeFilesEditor/editor/EditorModel.java index faad91a25de7..71aefa5ef6db 100644 --- a/platform/lang-impl/src/com/intellij/largeFilesEditor/editor/EditorModel.java +++ b/platform/lang-impl/src/com/intellij/largeFilesEditor/editor/EditorModel.java @@ -11,9 +11,11 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; @@ -424,13 +426,15 @@ public class EditorModel { if (!highlightRanges.isEmpty()) { HighlightManager highlightManager = HighlightManager.getInstance(dataProvider.getProject()); + TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme() + .getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); for (TextRange range : highlightRanges) { highlightManager.addRangeHighlight( editor, range.getStartOffset(), range.getEndOffset(), - EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES, true, pageRangeHighlighters); + textAttributes, true, pageRangeHighlighters); } } } diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/CallerChooserBase.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/CallerChooserBase.java index 3e275ffcbcb8..961700e307b1 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/CallerChooserBase.java +++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/CallerChooserBase.java @@ -23,7 +23,9 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.ex.EditorEx; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; @@ -155,13 +157,15 @@ public abstract class CallerChooserBase extends DialogWrap final PsiElement callee = parentNode != null ? parentNode.getElementToSearch() : null; if (caller != null && caller.isPhysical() && callee != null) { HighlightManager highlighter = HighlightManager.getInstance(myProject); + EditorColorsManager colorManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorManager.getGlobalScheme().getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES); int start = getStartOffset(caller); InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(myProject); for (PsiElement element : findElementsToHighlight(caller, callee)) { TextRange textRange = element.getTextRange(); textRange = injectedLanguageManager.injectedToHost(element, textRange); - highlighter.addRangeHighlight(myCallerEditor, textRange.getStartOffset() - start, textRange.getEndOffset() - start, - EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES, false, null); + highlighter.addRangeHighlight(myCallerEditor, textRange.getStartOffset() - start, + textRange.getEndOffset() - start, attributes, false, null); } } } @@ -253,7 +257,7 @@ public abstract class CallerChooserBase extends DialogWrap int row, boolean hasFocus) { if (value instanceof MemberNodeBase) { - ((MemberNodeBase)value).customizeRenderer(getTextRenderer()); + ((MemberNodeBase)value).customizeRenderer(getTextRenderer()); } } }; diff --git a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java index 0ef2484b8f54..f68764ff7c2a 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java +++ b/platform/lang-impl/src/com/intellij/refactoring/changeSignature/inplace/InplaceChangeSignature.java @@ -10,12 +10,14 @@ import com.intellij.openapi.command.impl.StartMarkAction; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.event.DocumentEvent; import com.intellij.openapi.editor.event.DocumentListener; import com.intellij.openapi.editor.ex.EditorEx; import com.intellij.openapi.editor.markup.HighlighterLayer; import com.intellij.openapi.editor.markup.HighlighterTargetArea; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.ui.popup.Balloon; @@ -88,8 +90,8 @@ public class InplaceChangeSignature implements DocumentListener { TextRange highlightingRange = myDetector.getHighlightingRange(myStableChange); HighlightManager highlightManager = HighlightManager.getInstance(myProject); - highlightManager.addRangeHighlight(editor, highlightingRange.getStartOffset(), highlightingRange.getEndOffset(), - EditorColors.LIVE_TEMPLATE_ATTRIBUTES, false, myHighlighters); + TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.LIVE_TEMPLATE_ATTRIBUTES); + highlightManager.addRangeHighlight(editor, highlightingRange.getStartOffset(), highlightingRange.getEndOffset(), attributes, false, myHighlighters); for (RangeHighlighter highlighter : myHighlighters) { highlighter.setGreedyToRight(true); highlighter.setGreedyToLeft(true); diff --git a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java index ee62628f6abc..533741a5ecf6 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java +++ b/platform/lang-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodHelper.java @@ -11,7 +11,9 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; @@ -161,9 +163,11 @@ public class ExtractMethodHelper { @NotNull final Editor editor, Map highlighterMap) { final List highlighters = new ArrayList<>(); final HighlightManager highlightManager = HighlightManager.getInstance(project); + final EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final int startOffset = match.getStartElement().getTextRange().getStartOffset(); final int endOffset = match.getEndElement().getTextRange().getEndOffset(); - highlightManager.addRangeHighlight(editor, startOffset, endOffset, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, highlighters); highlighterMap.put(match, highlighters.get(0)); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE); diff --git a/platform/lang-impl/src/com/intellij/refactoring/lang/ExtractIncludeFileBase.java b/platform/lang-impl/src/com/intellij/refactoring/lang/ExtractIncludeFileBase.java index ac447bbf1c8a..365d29e56a26 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/lang/ExtractIncludeFileBase.java +++ b/platform/lang-impl/src/com/intellij/refactoring/lang/ExtractIncludeFileBase.java @@ -18,6 +18,8 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.LogicalPosition; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; @@ -135,9 +137,11 @@ public abstract class ExtractIncludeFileBase implements Re private static void highlightInEditor(final Project project, final IncludeDuplicate pair, final Editor editor) { final HighlightManager highlightManager = HighlightManager.getInstance(project); + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final int startOffset = pair.getStart().getTextRange().getStartOffset(); final int endOffset = pair.getEnd().getTextRange().getEndOffset(); - highlightManager.addRangeHighlight(editor, startOffset, endOffset, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, null); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE); } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/HighlightUtils.java b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/HighlightUtils.java index d080fd4de6b2..b2f90b9fa9e9 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/HighlightUtils.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/psiutils/HighlightUtils.java @@ -15,6 +15,9 @@ import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.FileEditorManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; @@ -104,8 +107,11 @@ public class HighlightUtils { } final PsiElement firstElement = elements[0]; final Project project = firstElement.getProject(); - if (project.isDisposed() || editor.isDisposed()) return; - HighlightManager.getInstance(project).addOccurrenceHighlights(editor, elements, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + if (project.isDisposed()) return; + if (editor == null || editor.isDisposed()) return; + final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme(); + final TextAttributes textattributes = globalScheme.getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); + HighlightManager.getInstance(project).addOccurrenceHighlights(editor, elements, textattributes, true, null); WindowManager.getInstance().getStatusBar(project).setInfo(statusBarText); final FindManager findmanager = FindManager.getInstance(project); FindModel findmodel = findmanager.getFindNextModel(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java index efb1745b21c3..87c2a938670c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java @@ -8,7 +8,9 @@ import com.intellij.lang.Language; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.TextRange; @@ -132,8 +134,10 @@ public abstract class GroovyRefactoringUtil { if (editor == null) return; ArrayList highlighters = new ArrayList<>(); HighlightManager highlightManager = HighlightManager.getInstance(project); + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); if (elements.length > 0) { - highlightManager.addOccurrenceHighlights(editor, elements, EditorColors.SEARCH_RESULT_ATTRIBUTES, false, highlighters); + highlightManager.addOccurrenceHighlights(editor, elements, attributes, false, highlighters); } } @@ -141,9 +145,10 @@ public abstract class GroovyRefactoringUtil { if (editor == null) return; ArrayList highlighters = new ArrayList<>(); HighlightManager highlightManager = HighlightManager.getInstance(project); + EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); for (TextRange range : ranges) { - highlightManager.addRangeHighlight(editor, range.getStartOffset(), range.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, false, highlighters); + highlightManager.addRangeHighlight(editor, range.getStartOffset(), range.getEndOffset(), attributes, false, highlighters); } } @@ -302,18 +307,18 @@ public abstract class GroovyRefactoringUtil { public static String getMethodSignature(PsiMethod method) { MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY); - StringBuilder s = new StringBuilder(signature.getName() + "("); + String s = signature.getName() + "("; int i = 0; PsiType[] types = signature.getParameterTypes(); for (PsiType type : types) { - s.append(type.getPresentableText()); + s += type.getPresentableText(); if (i < types.length - 1) { - s.append(", "); + s += ", "; } i++; } - s.append(")"); - return s.toString(); + s += ")"; + return s; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java index 4b4145c0e947..c27b9f9c83b3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java @@ -14,7 +14,9 @@ import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.SelectionModel; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pass; import com.intellij.openapi.util.Ref; @@ -583,9 +585,10 @@ public abstract class GrIntroduceHandlerBase 1) { - highlightManager.addOccurrenceHighlights(context.getEditor(), context.getOccurrences(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + highlightManager.addOccurrenceHighlights(context.getEditor(), context.getOccurrences(), attributes, true, highlighters); } } diff --git a/plugins/markdown/src/org/intellij/plugins/markdown/ui/actions/styling/MarkdownIntroduceLinkReferenceAction.java b/plugins/markdown/src/org/intellij/plugins/markdown/ui/actions/styling/MarkdownIntroduceLinkReferenceAction.java index 2fe757b4accb..2b8678517288 100644 --- a/plugins/markdown/src/org/intellij/plugins/markdown/ui/actions/styling/MarkdownIntroduceLinkReferenceAction.java +++ b/plugins/markdown/src/org/intellij/plugins/markdown/ui/actions/styling/MarkdownIntroduceLinkReferenceAction.java @@ -15,7 +15,9 @@ import com.intellij.openapi.application.ApplicationNamesInfo; import com.intellij.openapi.command.WriteCommandAction; import com.intellij.openapi.editor.*; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; @@ -285,9 +287,11 @@ public class MarkdownIntroduceLinkReferenceAction extends AnAction implements Du @NotNull PsiElement element) { final List highlighters = new ArrayList<>(); final HighlightManager highlightManager = HighlightManager.getInstance(project); + final EditorColorsManager colorsManager = EditorColorsManager.getInstance(); + final TextAttributes attributes = colorsManager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); final int startOffset = element.getTextRange().getStartOffset(); final int endOffset = element.getTextRange().getEndOffset(); - highlightManager.addRangeHighlight(editor, startOffset, endOffset, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, highlighters); + highlightManager.addRangeHighlight(editor, startOffset, endOffset, attributes, true, highlighters); highlighterMap.put(element, highlighters.get(0)); final LogicalPosition logicalPosition = editor.offsetToLogicalPosition(startOffset); editor.getScrollingModel().scrollTo(logicalPosition, ScrollType.MAKE_VISIBLE); diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceAction.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceAction.java index d67784bd467e..efb111b4a441 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceAction.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/BaseIntroduceAction.java @@ -112,11 +112,11 @@ public abstract class BaseIntroduceAction e if (matchingExpressions.size() > 0) { final SelectionModel selectionModel = editor.getSelectionModel(); highlightManager.addRangeHighlight(editor, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, false, highlighters); + EditorColors.SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes(), false, highlighters); for (XPathExpression expr : matchingExpressions) { final TextRange range = XsltCodeInsightUtil.getRangeInsideHostingFile(expr); highlightManager.addRangeHighlight(editor, range.getStartOffset(), range.getEndOffset(), - EditorColors.SEARCH_RESULT_ATTRIBUTES, false, highlighters); + EditorColors.SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes(), false, highlighters); final XmlTag tag = PsiTreeUtil.getContextOfType(expr, XmlTag.class, true); assert tag != null; diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/VariableInlineHandler.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/VariableInlineHandler.java index 98293e04fe61..9c26636e5695 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/VariableInlineHandler.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/refactoring/VariableInlineHandler.java @@ -151,7 +151,7 @@ public class VariableInlineHandler extends InlineActionHandler { } highlighter.addOccurrenceHighlights(e, new PsiElement[]{((XsltVariable)variable).getNameIdentifier()}, - EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES, false, highlighters); + EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES.getDefaultAttributes(), false, highlighters); if (!hasExternalRefs) { if (!ApplicationManager.getApplication().isUnitTestMode() && diff --git a/python/src/com/jetbrains/python/refactoring/inline/PyInlineLocalHandler.java b/python/src/com/jetbrains/python/refactoring/inline/PyInlineLocalHandler.java index f2c8669bda42..5ae822bbe192 100644 --- a/python/src/com/jetbrains/python/refactoring/inline/PyInlineLocalHandler.java +++ b/python/src/com/jetbrains/python/refactoring/inline/PyInlineLocalHandler.java @@ -11,6 +11,8 @@ import com.intellij.openapi.command.CommandProcessor; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; @@ -87,6 +89,8 @@ public class PyInlineLocalHandler extends InlineActionHandler { if (!CommonRefactoringUtil.checkReadOnlyStatus(project, local)) return; final HighlightManager highlightManager = HighlightManager.getInstance(project); + final TextAttributes writeAttributes = + EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES); final String localName = local.getName(); final ScopeOwner containerBlock = getContext(local); @@ -103,7 +107,7 @@ public class PyInlineLocalHandler extends InlineActionHandler { } if (def instanceof PyAssignmentStatement && ((PyAssignmentStatement)def).getTargets().length > 1) { - highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{def}, EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{def}, writeAttributes, true, null); final String message = RefactoringBundle.getCannotRefactorMessage(PyBundle.message("refactoring.inline.local.multiassignment", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HELP_ID); @@ -117,8 +121,10 @@ public class PyInlineLocalHandler extends InlineActionHandler { return; } + final TextAttributes attributes = + EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); if (!ApplicationManager.getApplication().isUnitTestMode()) { - highlightManager.addOccurrenceHighlights(editor, refsToInline, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addOccurrenceHighlights(editor, refsToInline, attributes, true, null); final int occurrencesCount = refsToInline.length; final String occurrencesString = RefactoringBundle.message("occurrences.string", occurrencesCount); final String question = RefactoringBundle.message("inline.local.variable.prompt", localName) + " " + occurrencesString; @@ -152,8 +158,8 @@ public class PyInlineLocalHandler extends InlineActionHandler { isSameDefinition &= isSameDefinition(def, otherDef); } if (!isSameDefinition) { - highlightManager.addOccurrenceHighlights(editor, defs, EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES, true, null); - highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{ref}, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addOccurrenceHighlights(editor, defs, writeAttributes, true, null); + highlightManager.addOccurrenceHighlights(editor, new PsiElement[]{ref}, attributes, true, null); final String message = RefactoringBundle.getCannotRefactorMessage( RefactoringBundle.message("variable.is.accessed.for.writing.and.used.with.inlined", localName)); CommonRefactoringUtil.showErrorHint(project, editor, message, getRefactoringName(), HELP_ID); @@ -204,7 +210,7 @@ public class PyInlineLocalHandler extends InlineActionHandler { CodeStyleManager.getInstance(project).reformatText(workingFile, ranges); if (!ApplicationManager.getApplication().isUnitTestMode()) { - highlightManager.addOccurrenceHighlights(editor, exprs, EditorColors.SEARCH_RESULT_ATTRIBUTES, true, null); + highlightManager.addOccurrenceHighlights(editor, exprs, attributes, true, null); WindowManager.getInstance().getStatusBar(project) .setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting")); }