From a56c7b1535ae5a5492a7fac01d528738b439afe4 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 4 Sep 2013 14:10:01 +0400 Subject: [PATCH] editor api modules refactoring: - editor-ui-api module containing public API editor interfaces - editor-ui-impl module containing editor implementation interfaces - analysis* modules made dependant on editor-ui* modules - highlighting classes moved to *analysis* modules - majority of highlighting quickfixes moved to QuickFixFactory - injections in GeneralHighlightingPass splitted away to InjectedGeneralHighlightingPass --- .idea/modules.xml | 2 + build/scripts/layouts.gant | 26 +- build/scripts/utils.gant | 2 + .../intention/QuickFixFactory.java | 227 +++++++++ .../ChangeVariableTypeQuickFixProvider.java | 4 +- .../daemon/impl/JavaHighlightInfoTypes.java | 8 +- .../daemon/impl/RefCountHolder.java | 0 .../analysis/AnnotationsHighlightUtil.java | 4 +- .../impl/analysis/GenericsHighlightUtil.java | 57 ++- .../impl/analysis/HighlightClassUtil.java | 172 ++----- .../analysis/HighlightControlFlowUtil.java | 44 +- .../impl/analysis/HighlightMethodUtil.java | 151 ++++-- .../impl/analysis/HighlightNamesUtil.java | 2 +- .../daemon/impl/analysis/HighlightUtil.java | 160 +++--- .../impl/analysis/HighlightVisitorImpl.java | 33 +- .../analysis/IncreaseLanguageLevelFix.java | 2 +- .../impl/analysis/QualifyWithThisFix.java | 4 +- .../AddTypeArgumentsConditionalFix.java | 10 +- .../impl/quickfix/AddTypeArgumentsFix.java | 0 .../daemon/impl/quickfix/AddTypeCastFix.java | 0 .../quickfix/ArgumentFixerActionFactory.java | 0 .../impl/quickfix/CastMethodArgumentFix.java | 0 .../quickfix/ChangeNewOperatorTypeFix.java | 2 +- ...ngeStringLiteralToCharInMethodCallFix.java | 0 .../impl/quickfix/ChangeTypeArgumentsFix.java | 0 .../quickfix/ConstructorParametersFixer.java | 0 .../quickfix/ConvertDoubleToFloatFix.java | 4 +- .../daemon/impl/quickfix/ExtendsListFix.java | 2 +- .../impl/quickfix/MethodArgumentFix.java | 13 +- .../impl/quickfix/PermuteArgumentsFix.java | 0 .../impl/quickfix/QualifyThisArgumentFix.java | 21 +- .../quickfix/RemoveRedundantArgumentsFix.java | 0 .../impl/quickfix/WrapExpressionFix.java | 4 +- .../highlighter/JavaHighlightingColors.java | 0 .../daemon/impl/PostHighlightingPass.java | 44 +- .../ChangeMethodSignatureFromUsageFix.java | 38 +- .../quickfix/ChangeParameterClassFix.java | 51 +- .../quickfix/CreateMethodFromUsageFix.java | 20 +- .../quickfix/DefaultQuickFixProvider.java | 4 +- .../ImplementAbstractClassMethodsFix.java | 113 +++++ .../impl/quickfix/ImportClassFixBase.java | 7 +- .../impl/quickfix/PullAsAbstractUpFix.java | 12 +- ...eInaccessibleFieldWithGetterSetterFix.java | 32 +- .../ReplacePrimitiveWithBoxedTypeAction.java | 2 +- .../impl/quickfix/SurroundWithArrayFix.java | 12 +- .../VariableParameterizedTypeFix.java | 60 --- .../quickfix/VariableTypeFromCallFix.java | 52 +- .../impl/config/QuickFixFactoryImpl.java | 403 +++++++++++++++ .../codeInspection/SuppressManagerImpl.java | 14 +- .../intellij/psi/util/TypeConversionUtil.java | 10 + .../processor/VariablesNotProcessor.java | 2 +- .../scope/processor/VariablesProcessor.java | 2 +- .../codeInsight/daemon/ImportHelperTest.java | 10 +- .../codeInsight/daemon/LossyEncodingTest.java | 4 +- .../psi/impl/cache/impl/IdCacheTest.java | 8 +- .../intellij/psi/search/UpdateCacheTest.java | 2 +- .../intention/QuickFixFactory.java | 83 ---- .../projectRoots/JavaSdkVersionUtil.java | 5 +- .../daemon/DaemonAnalyzerTestCase.java | 4 +- platform/analysis-api/analysis-api.iml | 1 + .../BackgroundEditorHighlighter.java | 2 +- .../codeHighlighting/HighlightingPass.java | 16 +- .../codeInsight/daemon/DaemonBundle.java | 0 .../daemon/DaemonCodeAnalyzer.java | 17 +- .../daemon/QuickFixActionRegistrar.java | 2 +- .../highlighting/HighlightErrorFilter.java | 2 +- .../intention/IntentionAction.java | 2 +- .../intention/IntentionActionBean.java | 2 +- .../intention/IntentionManager.java | 6 +- .../CustomSuppressableInspectionTool.java | 4 +- .../intellij/codeInspection/HintAction.java | 2 +- ...uickFixAndIntentionActionOnPsiElement.java | 2 +- .../LocalQuickFixAsIntentionAdapter.java | 0 ...uickFixOnPsiElementAsIntentionAdapter.java | 0 .../SuppressIntentionAction.java | 2 +- .../SuppressableProblemGroup.java | 0 .../com/intellij/lang/LanguageAnnotators.java | 4 +- .../intellij/lang/annotation/Annotation.java | 2 +- .../lang/annotation/AnnotationHolder.java | 0 .../lang/annotation/AnnotationSession.java | 2 +- .../intellij/lang/annotation/Annotator.java | 2 +- .../com/intellij/lang/annotation/package.html | 0 .../src/com/intellij/problems/Problem.java | 0 .../problems/WolfTheProblemSolver.java | 0 platform/analysis-impl/analysis-impl.iml | 2 + .../options/colors/ScopeAttributesUtil.java | 0 ...yScopeTrackingHighlightingPassFactory.java | 2 +- .../MainHighlightingPassFactory.java | 0 .../com/intellij/codeHighlighting/Pass.java | 5 +- .../TextEditorHighlightingPass.java | 15 +- .../TextEditorHighlightingPassFactory.java | 2 +- .../TextEditorHighlightingPassRegistrar.java | 7 +- .../codeInsight/daemon/IdeValidationHost.java | 2 +- .../daemon/impl/AnnotationHolderImpl.java | 4 +- .../daemon/impl/DaemonCodeAnalyzerEx.java | 109 ++++ .../daemon/impl/DaemonProgressIndicator.java | 2 +- .../daemon/impl/DefaultHighlightVisitor.java | 4 +- .../daemon/impl/FileStatusMap.java | 9 +- .../daemon/impl/GeneralHighlightingPass.java | 431 +++------------- .../impl/GeneralHighlightingPassFactory.java | 2 +- .../daemon/impl/HighlightInfo.java | 2 +- .../daemon/impl/HighlightInfoFilter.java | 2 +- .../daemon/impl/HighlightRangeExtension.java | 0 .../daemon/impl/HighlightVisitor.java | 2 +- .../daemon/impl/HighlightersRecycler.java | 64 +++ ...rogressableTextEditorHighlightingPass.java | 39 +- .../impl/TextEditorBackgroundHighlighter.java | 0 ...TextEditorHighlightingPassRegistrarEx.java | 13 +- .../daemon/impl/ThreadLocalAnnotatorMap.java} | 4 +- .../daemon/impl/UpdateHighlightersUtil.java | 276 +++-------- .../impl/VisibleHighlightingPassFactory.java | 0 .../analysis/CustomHighlightInfoHolder.java | 0 .../impl/analysis/ErrorQuickFixProvider.java | 2 +- .../impl/analysis/HighlightInfoHolder.java | 2 +- .../analysis/HighlightingLevelManager.java | 30 ++ .../daemon/impl/quickfix/QuickFixAction.java | 7 +- .../quickfix/QuickFixActionRegistrarImpl.java | 2 +- .../intention/EmptyIntentionAction.java | 2 +- .../codeInsight/problems/ProblemImpl.java | 0 .../UnresolvedReferenceQuickFixProvider.java | 2 +- .../SuppressIntentionActionFromFix.java | 13 +- .../codeInspection/SuppressionUtil.java | 16 + .../actions/CleanupInspectionIntention.java | 2 +- .../codeInspection/ex/QuickFixWrapper.java | 2 +- .../ExportableApplicationComponent.java | 4 +- .../components/ExportableComponent.java | 2 +- .../intellij/openapi/util/AsyncResult.java | 2 +- .../com/intellij/util/PlatformUtilsCore.java | 57 +++ platform/editor-ui-api/editor-ui-api.iml | 16 + .../codeInsight/daemon/GutterMark.java | 2 +- .../src/com/intellij/ide/DataManager.java | 0 .../src/com/intellij/ide/ui/UISettings.java | 10 +- .../intellij/ide/ui/UISettingsListener.java | 2 +- .../openapi/actionSystem/ActionGroup.java | 2 +- .../openapi/actionSystem/ActionManager.java | 2 +- .../openapi/actionSystem/ActionPopupMenu.java | 4 +- .../openapi/actionSystem/ActionToolbar.java | 4 +- .../openapi/actionSystem/AnAction.java | 4 +- .../openapi/actionSystem/AnActionEvent.java | 6 +- .../actionSystem/AnActionEventVisitor.java | 4 +- .../openapi/actionSystem/CommonDataKeys.java | 40 ++ .../actionSystem/CustomShortcutSet.java | 4 +- .../openapi/actionSystem/DataContext.java | 2 +- .../openapi/actionSystem/DataKey.java | 4 +- .../openapi/actionSystem/DataProvider.java | 6 +- .../actionSystem/KeyboardShortcut.java | 4 +- .../openapi/actionSystem/Presentation.java | 0 .../openapi/actionSystem/Shortcut.java | 9 +- .../openapi/actionSystem/ShortcutSet.java | 4 +- .../openapi/actionSystem/TimerListener.java | 2 +- .../actionSystem/ex/AnActionListener.java | 2 +- .../intellij/openapi/editor/CaretModel.java | 6 +- .../DefaultLanguageHighlighterColors.java | 71 +++ .../com/intellij/openapi/editor/Editor.java | 2 +- .../openapi/editor/EditorFactory.java | 2 +- .../intellij/openapi/editor/EditorGutter.java | 2 +- .../openapi/editor/EditorGutterAction.java | 2 +- .../openapi/editor/EditorSettings.java | 4 +- .../intellij/openapi/editor/FoldRegion.java | 4 +- .../intellij/openapi/editor/FoldingModel.java | 2 +- .../openapi/editor/HighlighterColors.java | 2 +- .../openapi/editor/IndentGuideDescriptor.java | 2 +- .../openapi/editor/IndentStrategy.java | 2 +- .../intellij/openapi/editor/IndentsModel.java | 6 +- .../editor/LineWrapPositionStrategy.java | 4 +- .../openapi/editor/LogicalPosition.java | 2 +- .../intellij/openapi/editor/ScrollType.java | 2 +- .../openapi/editor/ScrollingModel.java | 2 +- .../openapi/editor/SelectionModel.java | 16 +- .../com/intellij/openapi/editor/SoftWrap.java | 2 +- .../openapi/editor/SoftWrapModel.java | 2 +- .../editor/SyntaxHighlighterColors.java | 43 ++ .../editor/TextAnnotationGutterProvider.java | 2 +- .../openapi/editor/VisualPosition.java | 8 +- .../openapi/editor/colors/EditorColors.java | 0 .../editor/colors/EditorColorsListener.java | 2 +- .../editor/colors/EditorColorsManager.java | 0 .../editor/colors/EditorColorsScheme.java | 12 +- .../openapi/editor/colors/EditorFontType.java | 2 +- .../editor/colors/FontPreferences.java | 18 +- .../openapi/editor/colors/package.html | 0 .../openapi/editor/event/CaretEvent.java | 2 +- .../openapi/editor/event/CaretListener.java | 2 +- .../editor/event/EditorEventMulticaster.java | 4 +- .../editor/event/EditorFactoryEvent.java | 2 +- .../editor/event/EditorFactoryListener.java | 2 +- .../editor/event/EditorMouseEvent.java | 2 +- .../editor/event/EditorMouseEventArea.java | 2 +- .../editor/event/EditorMouseListener.java | 2 +- .../event/EditorMouseMotionListener.java | 2 +- .../openapi/editor/event/SelectionEvent.java | 6 +- .../editor/event/SelectionListener.java | 2 +- .../editor/event/VisibleAreaEvent.java | 2 +- .../editor/event/VisibleAreaListener.java | 2 +- .../openapi/editor/event/package.html | 0 .../editor/highlighter/EditorHighlighter.java | 2 +- .../editor/highlighter/HighlighterClient.java | 2 +- .../highlighter/HighlighterIterator.java | 2 +- .../editor/markup/ActiveGutterRenderer.java | 2 +- .../markup/CustomHighlighterRenderer.java | 2 +- .../editor/markup/ErrorStripeRenderer.java | 4 +- .../editor/markup/GutterDraggableObject.java | 2 +- .../editor/markup/GutterIconRenderer.java | 4 +- .../editor/markup/HighlighterLayer.java | 2 +- .../editor/markup/HighlighterTargetArea.java | 2 +- .../editor/markup/LineMarkerRenderer.java | 4 +- .../editor/markup/LineSeparatorRenderer.java | 2 +- .../editor/markup/MarkupEditorFilter.java | 2 +- .../openapi/editor/markup/MarkupModel.java | 2 +- .../editor/markup/RangeHighlighter.java | 3 +- .../editor/markup/SeparatorPlacement.java | 2 +- .../openapi/editor/markup/package.html | 0 .../com/intellij/openapi/editor/package.html | 0 .../intellij/openapi/options/FontSize.java | 8 +- .../src/com/intellij/ui/PlaceProvider.java | 2 +- .../ui/switcher/QuickAccessProvider.java | 2 +- .../ui/switcher/QuickActionProvider.java | 2 +- .../intellij/ui/switcher/SwitchProvider.java | 2 +- .../intellij/ui/switcher/SwitchTarget.java | 2 +- platform/editor-ui-impl/editor-ui-impl.iml | 16 + .../injected/editor/MarkupModelWindow.java | 20 + .../openapi/editor/ex/MarkupModelEx.java | 14 + .../openapi/editor/ex/RangeHighlighterEx.java | 0 .../editor/impl/DocumentMarkupModel.java | 36 +- .../impl/DocumentMarkupModelManager.java | 0 .../openapi/editor/impl/EmptyMarkupModel.java | 20 + .../openapi/editor/impl/MarkupModelImpl.java | 26 +- .../impl/PersistentRangeHighlighterImpl.java | 0 .../editor/impl/RangeHighlighterData.java | 5 +- .../editor/impl/RangeHighlighterImpl.java | 3 +- .../editor/impl/RangeHighlighterTree.java | 7 +- .../impl/event/MarkupModelListener.java | 0 .../psi/search/PsiTodoSearchHelper.java | 0 .../intellij/psi/search/TodoAttributes.java | 94 ++-- .../src/com/intellij/psi/search/TodoItem.java | 0 .../com/intellij/psi/search/TodoPattern.java | 17 +- .../openapi/actionSystem/LangDataKeys.java | 3 - .../DefaultLanguageHighlighterColors.java | 112 ----- .../editor/SyntaxHighlighterColors.java | 59 --- .../psi/search/TodoAttributesUtil.java | 35 ++ .../daemon/impl/DaemonCodeAnalyzerImpl.java | 144 +++--- .../daemon/impl/DaemonListeners.java | 82 ++- .../daemon/impl/ExternalToolPass.java | 12 +- .../daemon/impl/GotoNextErrorHandler.java | 2 +- .../daemon/impl/HectorComponent.java | 7 +- .../impl/InjectedGeneralHighlightingPass.java | 469 ++++++++++++++++++ ...njectedGeneralHighlightingPassFactory.java | 63 +++ .../daemon/impl/LineMarkersPass.java | 8 +- .../daemon/impl/LineMarkersUtil.java | 104 ++++ .../daemon/impl/LocalInspectionsPass.java | 18 +- .../daemon/impl/ShowAutoImportPass.java | 9 +- .../daemon/impl/ShowIntentionsPass.java | 69 +-- .../daemon/impl/SlowLineMarkersPass.java | 11 +- .../daemon/impl/StatusBarUpdater.java | 6 +- ...xtEditorHighlightingPassRegistrarImpl.java | 6 +- .../daemon/impl/TrafficLightRenderer.java | 6 +- .../impl/analysis/HighlightLevelUtil.java | 46 -- .../analysis/HighlightingSettingsPerFile.java | 63 ++- .../problems/WolfTheProblemSolverImpl.java | 36 +- .../ex/InspectionManagerEx.java | 70 +-- .../ex/LocalDescriptorsUtil.java | 2 +- .../OfflineProblemDescriptorNode.java | 5 +- .../intellij/ide/todo/TodoConfiguration.java | 10 +- .../ide/todo/configurable/PatternDialog.java | 3 +- .../todo/configurable/TodoConfigurable.java | 3 +- .../wm/impl/status/TogglePopupHintsPanel.java | 6 +- .../InspectionProfileManagerImpl.java | 4 +- .../injected/InjectedLanguageManagerImpl.java | 6 +- platform/platform-api/platform-api.iml | 1 + .../actionSystem/PlatformDataKeys.java | 15 +- .../src/com/intellij/util/PlatformUtils.java | 10 - platform/platform-impl/platform-impl.iml | 3 +- .../ui/playback/util/EditorPlaybackCall.java | 2 +- .../src/META-INF/LangExtensions.xml | 2 +- .../src/componentSets/Lang.xml | 4 + .../impl/CodeInsightTestFixtureImpl.java | 9 +- .../ToggleHighlightingMarkupAction.java | 4 +- .../local/GroovyPostHighlightingPass.java | 28 +- .../psi/DefaultResourceBundleManager.java | 5 +- .../uiDesigner/core/AsmCodeGeneratorTest.java | 2 + .../XmlUnboundNsPrefixInspection.java | 2 +- 281 files changed, 3220 insertions(+), 2211 deletions(-) create mode 100644 java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java rename java/{openapi => java-analysis-api}/src/com/intellij/codeInsight/quickfix/ChangeVariableTypeQuickFixProvider.java (96%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/JavaHighlightInfoTypes.java (86%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java (99%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java (95%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java (83%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java (94%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java (90%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java (99%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java (94%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java (97%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java (99%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java (93%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java (94%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeNewOperatorTypeFix.java (99%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/ConstructorParametersFixer.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java (96%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java (99%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodArgumentFix.java (87%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java (89%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java (100%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java (98%) rename java/{java-impl => java-analysis-impl}/src/com/intellij/ide/highlighter/JavaHighlightingColors.java (100%) create mode 100644 java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementAbstractClassMethodsFix.java rename java/java-impl/src/com/intellij/codeInsight/daemon/impl/{analysis => quickfix}/ReplacePrimitiveWithBoxedTypeAction.java (98%) delete mode 100644 java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableParameterizedTypeFix.java rename java/{java-impl => java-psi-impl}/src/com/intellij/psi/scope/processor/VariablesNotProcessor.java (97%) rename java/{java-impl => java-psi-impl}/src/com/intellij/psi/scope/processor/VariablesProcessor.java (98%) delete mode 100644 java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java rename platform/{platform-api => analysis-api}/src/com/intellij/codeHighlighting/BackgroundEditorHighlighter.java (99%) rename platform/{platform-api => analysis-api}/src/com/intellij/codeHighlighting/HighlightingPass.java (67%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInsight/daemon/DaemonBundle.java (100%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java (75%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInsight/daemon/QuickFixActionRegistrar.java (96%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java (95%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInsight/intention/IntentionAction.java (98%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInsight/intention/IntentionActionBean.java (98%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInsight/intention/IntentionManager.java (97%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInspection/CustomSuppressableInspectionTool.java (97%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInspection/HintAction.java (95%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java (98%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java (100%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInspection/LocalQuickFixOnPsiElementAsIntentionAdapter.java (100%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInspection/SuppressIntentionAction.java (98%) rename platform/{lang-api => analysis-api}/src/com/intellij/codeInspection/SuppressableProblemGroup.java (100%) rename platform/{lang-api => analysis-api}/src/com/intellij/lang/LanguageAnnotators.java (95%) rename platform/{lang-api => analysis-api}/src/com/intellij/lang/annotation/Annotation.java (99%) rename platform/{lang-api => analysis-api}/src/com/intellij/lang/annotation/AnnotationHolder.java (100%) rename platform/{lang-api => analysis-api}/src/com/intellij/lang/annotation/AnnotationSession.java (96%) rename platform/{lang-api => analysis-api}/src/com/intellij/lang/annotation/Annotator.java (97%) rename platform/{lang-api => analysis-api}/src/com/intellij/lang/annotation/package.html (100%) rename platform/{lang-api => analysis-api}/src/com/intellij/problems/Problem.java (100%) rename platform/{lang-api => analysis-api}/src/com/intellij/problems/WolfTheProblemSolver.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/application/options/colors/ScopeAttributesUtil.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeHighlighting/DirtyScopeTrackingHighlightingPassFactory.java (94%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeHighlighting/MainHighlightingPassFactory.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeHighlighting/Pass.java (96%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeHighlighting/TextEditorHighlightingPass.java (90%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeHighlighting/TextEditorHighlightingPassFactory.java (96%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeHighlighting/TextEditorHighlightingPassRegistrar.java (91%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/IdeValidationHost.java (94%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/AnnotationHolderImpl.java (97%) create mode 100644 platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/DaemonProgressIndicator.java (98%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java (97%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java (97%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java (53%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPassFactory.java (98%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java (99%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/HighlightInfoFilter.java (96%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/HighlightRangeExtension.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/HighlightVisitor.java (97%) create mode 100644 platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightersRecycler.java rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java (72%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/TextEditorBackgroundHighlighter.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarEx.java (70%) rename platform/{lang-impl/src/com/intellij/codeInsight/daemon/impl/PerThreadMap.java => analysis-impl/src/com/intellij/codeInsight/daemon/impl/ThreadLocalAnnotatorMap.java} (95%) mode change 100755 => 100644 rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java (68%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/CustomHighlightInfoHolder.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorQuickFixProvider.java (96%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java (98%) create mode 100644 platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingLevelManager.java rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java (91%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixActionRegistrarImpl.java (97%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/intention/EmptyIntentionAction.java (98%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/problems/ProblemImpl.java (100%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInsight/quickfix/UnresolvedReferenceQuickFixProvider.java (98%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInspection/SuppressIntentionActionFromFix.java (83%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java (99%) rename platform/{lang-impl => analysis-impl}/src/com/intellij/codeInspection/ex/QuickFixWrapper.java (98%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/components/ExportableApplicationComponent.java (94%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/components/ExportableComponent.java (96%) rename platform/{platform-api => core-api}/src/com/intellij/openapi/util/AsyncResult.java (99%) create mode 100644 platform/editor-ui-api/editor-ui-api.iml rename platform/{analysis-api => editor-ui-api}/src/com/intellij/codeInsight/daemon/GutterMark.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ide/DataManager.java (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ide/ui/UISettings.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ide/ui/UISettingsListener.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/ActionGroup.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/ActionManager.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/ActionPopupMenu.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/ActionToolbar.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/AnAction.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/AnActionEvent.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/AnActionEventVisitor.java (95%) create mode 100644 platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/DataContext.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/DataKey.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/DataProvider.java (87%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/Presentation.java (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/Shortcut.java (83%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/ShortcutSet.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/TimerListener.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/actionSystem/ex/AnActionListener.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/CaretModel.java (98%) create mode 100644 platform/editor-ui-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/Editor.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/EditorFactory.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/EditorGutter.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/EditorGutterAction.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/EditorSettings.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/FoldRegion.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/FoldingModel.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/HighlighterColors.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/IndentGuideDescriptor.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/IndentStrategy.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/IndentsModel.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/LogicalPosition.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/ScrollType.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/ScrollingModel.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/SelectionModel.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/SoftWrap.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/SoftWrapModel.java (99%) create mode 100644 platform/editor-ui-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/TextAnnotationGutterProvider.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/VisualPosition.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/colors/EditorColors.java (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/colors/EditorColorsListener.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/colors/EditorColorsManager.java (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/colors/EditorFontType.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/colors/FontPreferences.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/colors/package.html (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/CaretEvent.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/CaretListener.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/EditorFactoryListener.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/EditorMouseEvent.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/EditorMouseListener.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/EditorMouseMotionListener.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/SelectionEvent.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/SelectionListener.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/VisibleAreaListener.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/event/package.html (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/highlighter/EditorHighlighter.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/highlighter/HighlighterClient.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/CustomHighlighterRenderer.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/HighlighterLayer.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/HighlighterTargetArea.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/LineMarkerRenderer.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/LineSeparatorRenderer.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/MarkupEditorFilter.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/MarkupModel.java (99%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/RangeHighlighter.java (98%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/SeparatorPlacement.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/markup/package.html (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/editor/package.html (100%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/openapi/options/FontSize.java (97%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ui/PlaceProvider.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ui/switcher/QuickAccessProvider.java (94%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ui/switcher/QuickActionProvider.java (96%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ui/switcher/SwitchProvider.java (95%) rename platform/{platform-api => editor-ui-api}/src/com/intellij/ui/switcher/SwitchTarget.java (95%) create mode 100644 platform/editor-ui-impl/editor-ui-impl.iml rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/injected/editor/MarkupModelWindow.java (93%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/ex/MarkupModelEx.java (86%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/ex/RangeHighlighterEx.java (100%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/DocumentMarkupModel.java (80%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/DocumentMarkupModelManager.java (100%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java (90%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java (92%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java (100%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java (97%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java (97%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/RangeHighlighterTree.java (93%) rename platform/{platform-impl => editor-ui-impl}/src/com/intellij/openapi/editor/impl/event/MarkupModelListener.java (100%) rename platform/{lang-api => indexing-api}/src/com/intellij/psi/search/PsiTodoSearchHelper.java (100%) rename platform/{lang-api => indexing-api}/src/com/intellij/psi/search/TodoAttributes.java (69%) rename platform/{lang-api => indexing-api}/src/com/intellij/psi/search/TodoItem.java (100%) rename platform/{lang-api => indexing-api}/src/com/intellij/psi/search/TodoPattern.java (89%) delete mode 100644 platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java delete mode 100644 platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java create mode 100644 platform/lang-api/src/com/intellij/psi/search/TodoAttributesUtil.java create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPassFactory.java create mode 100644 platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java diff --git a/.idea/modules.xml b/.idea/modules.xml index d0662cd6e07d..88366cc3906d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -160,6 +160,8 @@ + + diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant index 655b0b560cd6..4e0429785968 100644 --- a/build/scripts/layouts.gant +++ b/build/scripts/layouts.gant @@ -49,25 +49,24 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir //noinspection GroovyAssignabilityCheck List openapiModules = [platformApiModules, - "java-psi-api", - "java-analysis-api", - "java-indexing-api", - "openapi", - "testFramework-java", - "debugger-openapi", "compiler-openapi", - "remote-servers-api", - "remote-servers-java-api", + "debugger-openapi", "dom-openapi", "execution-openapi", + "java-analysis-api", + "java-indexing-api", + "java-psi-api", "jsp-openapi", - "jsp-base-openapi"].flatten() + "jsp-base-openapi", + "openapi", + "remote-servers-api", + "remote-servers-java-api", + "testFramework-java", + ].flatten() //noinspection GroovyAssignabilityCheck List implementationModules = [platformImplementationModules, "compiler-impl", - "remote-servers-impl", - "remote-servers-java-impl", "debugger-impl", "dom-impl", "execution-impl", @@ -81,8 +80,11 @@ def layoutFull(String home, String targetDirectory, String patchedDescriptorDir "jsp-spi", "manifest", "platform-main", + "remote-servers-impl", + "remote-servers-java-impl", "testFramework", - "tests_bootstrap"].flatten() + "tests_bootstrap", + ].flatten() ant.patternset(id: "resources.included") { include(name: "**/*.properties") diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 28edd4acdd82..eb0e9f1d6d66 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -247,6 +247,7 @@ binding.setVariable("classPathLibs", [ binding.setVariable("platformApiModules", [ "analysis-api", "core-api", + "editor-ui-api", "external-system-api", "indexing-api", "jps-model-api", @@ -266,6 +267,7 @@ binding.setVariable("platformImplementationModules", [ "analysis-impl", "core-impl", "dvcs", + "editor-ui-impl", "images", "indexing-impl", "jps-model-impl", diff --git a/java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java b/java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java new file mode 100644 index 000000000000..f14f9ec0c4ac --- /dev/null +++ b/java/java-analysis-api/src/com/intellij/codeInsight/intention/QuickFixFactory.java @@ -0,0 +1,227 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.intention; + +import com.intellij.codeInsight.daemon.QuickFixActionRegistrar; +import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement; +import com.intellij.codeInspection.LocalQuickFixOnPsiElement; +import com.intellij.openapi.components.ServiceManager; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.*; +import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.PropertyMemberType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author cdr + */ +public abstract class QuickFixFactory { + public static QuickFixFactory getInstance() { + return ServiceManager.getService(QuickFixFactory.class); + } + + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createModifierListFix(@NotNull PsiModifierList modifierList, + @PsiModifier.ModifierConstant @NotNull String modifier, + boolean shouldHave, + final boolean showContainingClass); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createModifierListFix(@NotNull PsiModifierListOwner owner, + @PsiModifier.ModifierConstant @NotNull String modifier, + boolean shouldHave, + final boolean showContainingClass); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodReturnFix(@NotNull PsiMethod method, @NotNull PsiType toReturn, boolean fixWholeHierarchy); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddMethodFix(@NotNull PsiMethod method, @NotNull PsiClass toClass); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddMethodFix(@NotNull String methodText, @NotNull PsiClass toClass, @NotNull String... exceptions); + + /** + * @param psiElement psiClass or enum constant without class initializer + */ + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createImplementMethodsFix(@NotNull PsiElement psiElement); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createImplementMethodsFix(@NotNull PsiClass psiElement); + @NotNull + public abstract LocalQuickFixOnPsiElement createMethodThrowsFix(@NotNull PsiMethod method, @NotNull PsiClassType exceptionClass, boolean shouldThrow, boolean showContainingClass); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddDefaultConstructorFix(@NotNull PsiClass aClass); + @Nullable + public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddConstructorFix(@NotNull PsiClass aClass, @PsiModifier.ModifierConstant @NotNull String modifier); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodParameterTypeFix(@NotNull PsiMethod method, int index, @NotNull PsiType newType, boolean fixWholeHierarchy); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createMakeClassInterfaceFix(@NotNull PsiClass aClass); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createMakeClassInterfaceFix(@NotNull PsiClass aClass, final boolean makeInterface); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClassType typeToExtendFrom, boolean toAdd); + @NotNull + public abstract LocalQuickFixAndIntentionActionOnPsiElement createRemoveUnusedParameterFix(@NotNull PsiParameter parameter); + @NotNull + public abstract IntentionAction createRemoveUnusedVariableFix(@NotNull PsiVariable variable); + + @Nullable + public abstract IntentionAction createCreateClassOrPackageFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass); + @Nullable + public abstract IntentionAction createCreateClassOrInterfaceFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass); + @NotNull + public abstract IntentionAction createCreateFieldOrPropertyFix(@NotNull PsiClass aClass, @NotNull String name, @NotNull PsiType type, @NotNull PropertyMemberType targetMember, @NotNull PsiAnnotation... annotations); + + @NotNull + public abstract IntentionAction createSetupJDKFix(); + + @NotNull public abstract IntentionAction createAddExceptionToCatchFix(); + + @NotNull public abstract IntentionAction createAddExceptionToThrowsFix(@NotNull PsiElement element); + + @NotNull public abstract IntentionAction createSurroundWithTryCatchFix(@NotNull PsiElement element); + + @NotNull public abstract IntentionAction createGeneralizeCatchFix(@NotNull PsiElement element, @NotNull PsiClassType type); + + @NotNull public abstract IntentionAction createChangeToAppendFix(@NotNull IElementType sign, @NotNull PsiType type, @NotNull PsiAssignmentExpression assignment); + + @NotNull public abstract IntentionAction createAddTypeCastFix(@NotNull PsiType type, @NotNull PsiExpression expression); + + @NotNull public abstract IntentionAction createWrapExpressionFix(@NotNull PsiType type, @NotNull PsiExpression expression); + + @NotNull public abstract IntentionAction createReuseVariableDeclarationFix(@NotNull PsiLocalVariable variable); + + @NotNull public abstract IntentionAction createConvertToStringLiteralAction(); + + @NotNull public abstract IntentionAction createDeleteCatchFix(@NotNull PsiParameter parameter); + + @NotNull public abstract IntentionAction createDeleteMultiCatchFix(@NotNull PsiTypeElement element); + + @NotNull public abstract IntentionAction createConvertSwitchToIfIntention(@NotNull PsiSwitchStatement statement); + + @NotNull public abstract IntentionAction createNegationBroadScopeFix(@NotNull PsiPrefixExpression expr); + + @NotNull public abstract IntentionAction createCreateFieldFromUsageFix(@NotNull PsiReferenceExpression place); + + @NotNull public abstract IntentionAction createReplaceWithListAccessFix(@NotNull PsiArrayAccessExpression expression); + + @NotNull public abstract IntentionAction createAddNewArrayExpressionFix(@NotNull PsiArrayInitializerExpression expression); + + @NotNull public abstract IntentionAction createMoveCatchUpFix(@NotNull PsiCatchSection section, @NotNull PsiCatchSection section1); + + @NotNull public abstract IntentionAction createRenameWrongRefFix(@NotNull PsiReferenceExpression ref); + + @NotNull public abstract IntentionAction createRemoveQualifierFix(@NotNull PsiExpression qualifier, @NotNull PsiReferenceExpression expression, @NotNull PsiClass resolved); + + @NotNull public abstract IntentionAction createRemoveParameterListFix(@NotNull PsiMethod parent); + + @NotNull public abstract IntentionAction createShowModulePropertiesFix(@NotNull PsiElement element); + + @NotNull public abstract IntentionAction createIncreaseLanguageLevelFix(@NotNull LanguageLevel level); + + @NotNull public abstract IntentionAction createChangeParameterClassFix(@NotNull PsiClass aClass, @NotNull PsiClassType type); + + @NotNull public abstract IntentionAction createReplaceInaccessibleFieldWithGetterSetterFix(@NotNull PsiElement element, @NotNull PsiMethod getter, boolean isSetter); + + @NotNull public abstract IntentionAction createSurroundWithArrayFix(@Nullable PsiCall methodCall, @Nullable PsiExpression expression); + + @NotNull public abstract IntentionAction createImplementAbstractClassMethodsFix(@NotNull PsiElement elementToHighlight); + + @NotNull public abstract IntentionAction createMoveClassToSeparateFileFix(@NotNull PsiClass aClass); + + @NotNull public abstract IntentionAction createRenameFileFix(@NotNull String newName); + + @NotNull public abstract IntentionAction createRenameElementFix(@NotNull PsiNamedElement element); + @NotNull public abstract IntentionAction createRenameElementFix(@NotNull PsiNamedElement element, @NotNull String newName); + + @NotNull public abstract IntentionAction createChangeExtendsToImplementsFix(@NotNull PsiClass aClass, @NotNull PsiClassType classToExtendFrom); + + @NotNull public abstract IntentionAction createCreateConstructorMatchingSuperFix(@NotNull PsiClass aClass); + + @NotNull public abstract IntentionAction createRemoveNewQualifierFix(@NotNull PsiNewExpression expression, @Nullable PsiClass aClass); + + @NotNull public abstract IntentionAction createSuperMethodReturnFix(@NotNull PsiMethod superMethod, @NotNull PsiType superMethodType); + + @NotNull public abstract IntentionAction createInsertNewFix(@NotNull PsiMethodCallExpression call, @NotNull PsiClass aClass); + + @NotNull public abstract IntentionAction createAddMethodBodyFix(@NotNull PsiMethod method); + + @NotNull public abstract IntentionAction createDeleteMethodBodyFix(@NotNull PsiMethod method); + + @NotNull public abstract IntentionAction createInsertSuperFix(@NotNull PsiMethod constructor); + + @NotNull public abstract IntentionAction createChangeMethodSignatureFromUsageFix(@NotNull PsiMethod targetMethod, + @NotNull PsiExpression[] expressions, + @NotNull PsiSubstitutor substitutor, + @NotNull PsiElement context, + boolean changeAllUsages, int minUsagesNumberToShowDialog); + + @NotNull public abstract IntentionAction createChangeMethodSignatureFromUsageReverseOrderFix(@NotNull PsiMethod targetMethod, + @NotNull PsiExpression[] expressions, + @NotNull PsiSubstitutor substitutor, + @NotNull PsiElement context, + boolean changeAllUsages, + int minUsagesNumberToShowDialog); + + @NotNull public abstract IntentionAction createCreateMethodFromUsageFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createCreateAbstractMethodFromUsageFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createCreatePropertyFromUsageFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createCreateConstructorFromSuperFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createCreateConstructorFromThisFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createCreateGetterSetterPropertyFromUsageFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createStaticImportMethodFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createReplaceAddAllArrayToCollectionFix(@NotNull PsiMethodCallExpression call); + + @NotNull public abstract IntentionAction createCreateConstructorFromCallFix(@NotNull PsiConstructorCall call); + + @NotNull + public abstract List getVariableTypeFromCallFixes(@NotNull PsiMethodCallExpression call, @NotNull PsiExpressionList list); + + @NotNull public abstract IntentionAction createAddReturnFix(@NotNull PsiMethod method); + + @NotNull public abstract IntentionAction createAddVariableInitializerFix(@NotNull PsiVariable variable); + + @NotNull public abstract IntentionAction createDeferFinalAssignmentFix(@NotNull PsiVariable variable, @NotNull PsiReferenceExpression expression); + + @NotNull public abstract IntentionAction createVariableAccessFromInnerClassFix(@NotNull PsiVariable variable, @NotNull PsiClass aClass); + + @NotNull public abstract IntentionAction createCreateConstructorParameterFromFieldFix(@NotNull PsiField field); + + @NotNull public abstract IntentionAction createInitializeFinalFieldInConstructorFix(@NotNull PsiField field); + + @NotNull public abstract IntentionAction createRemoveTypeArgumentsFix(@NotNull PsiElement variable); + + @NotNull public abstract IntentionAction createChangeClassSignatureFromUsageFix(@NotNull PsiClass owner, @NotNull PsiReferenceParameterList parameterList); + + @NotNull public abstract IntentionAction createReplacePrimitiveWithBoxedTypeAction(@NotNull PsiTypeElement element, @NotNull String typeName, @NotNull String boxedTypeName); + + @NotNull public abstract IntentionAction createMakeVarargParameterLastFix(@NotNull PsiParameter parameter); + + @NotNull public abstract IntentionAction createMoveBoundClassToFrontFix(@NotNull PsiClass aClass, @NotNull PsiClassType type); + + public abstract void registerPullAsAbstractUpFixes(@NotNull PsiMethod method, @NotNull QuickFixActionRegistrar registrar); + + public abstract IntentionAction createCreateAnnotationMethodFromUsageFix(PsiNameValuePair pair); + +} diff --git a/java/openapi/src/com/intellij/codeInsight/quickfix/ChangeVariableTypeQuickFixProvider.java b/java/java-analysis-api/src/com/intellij/codeInsight/quickfix/ChangeVariableTypeQuickFixProvider.java similarity index 96% rename from java/openapi/src/com/intellij/codeInsight/quickfix/ChangeVariableTypeQuickFixProvider.java rename to java/java-analysis-api/src/com/intellij/codeInsight/quickfix/ChangeVariableTypeQuickFixProvider.java index f420e78e47ee..4cbf02326172 100644 --- a/java/openapi/src/com/intellij/codeInsight/quickfix/ChangeVariableTypeQuickFixProvider.java +++ b/java/java-analysis-api/src/com/intellij/codeInsight/quickfix/ChangeVariableTypeQuickFixProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,4 +31,4 @@ public interface ChangeVariableTypeQuickFixProvider { @NotNull IntentionAction[] getFixes(@NotNull PsiVariable variable, @NotNull PsiType toReturn); -} \ No newline at end of file +} diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaHighlightInfoTypes.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/JavaHighlightInfoTypes.java similarity index 86% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaHighlightInfoTypes.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/JavaHighlightInfoTypes.java index 5aa830993cb2..6e69b5a157a9 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/JavaHighlightInfoTypes.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/JavaHighlightInfoTypes.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection; import com.intellij.ide.highlighter.JavaHighlightingColors; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.openapi.editor.SyntaxHighlighterColors; import com.intellij.openapi.editor.colors.CodeInsightColors; /** @@ -28,8 +27,7 @@ import com.intellij.openapi.editor.colors.CodeInsightColors; */ public interface JavaHighlightInfoTypes extends HighlightInfoType { HighlightInfoType UNUSED_IMPORT = new HighlightInfoType.HighlightInfoTypeSeverityByKey( - HighlightDisplayKey.findOrRegister(UnusedImportLocalInspection.SHORT_NAME, UnusedImportLocalInspection.DISPLAY_NAME), - CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES); + HighlightDisplayKey.findOrRegister(UnusedImportLocalInspection.SHORT_NAME, UnusedImportLocalInspection.DISPLAY_NAME), CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES); HighlightInfoType JAVA_KEYWORD = new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.INFORMATION, JavaHighlightingColors.KEYWORD); -} \ No newline at end of file +} diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RefCountHolder.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java similarity index 99% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java index 6c9723698a8d..e11e2c016e56 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java @@ -19,9 +19,9 @@ import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.JavaErrorMessages; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; -import com.intellij.codeInsight.daemon.impl.quickfix.CreateAnnotationMethodFromUsageFix; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; @@ -64,7 +64,7 @@ public class AnnotationsHighlightUtil { PsiElement element = ref.getElement(); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(element).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(highlightInfo, new CreateAnnotationMethodFromUsageFix(pair)); + QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixFactory.getInstance().createCreateAnnotationMethodFromUsageFix(pair)); return highlightInfo; } else { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java similarity index 95% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index ac90dce8ec82..6914e84e9395 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -18,10 +18,11 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.daemon.JavaErrorMessages; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; -import com.intellij.codeInsight.daemon.impl.quickfix.*; -import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; +import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl; import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdkVersion; @@ -32,6 +33,7 @@ import com.intellij.openapi.util.TextRange; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.psi.search.PsiShortNamesCache; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.search.searches.SuperMethodsSearch; import com.intellij.psi.util.*; @@ -152,12 +154,12 @@ public class GenericsHighlightUtil { PsiElement variable = grandParent.getParent(); if (variable instanceof PsiVariable) { if (targetParametersNum == 0) { - QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveTypeArgumentsFix(variable)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createRemoveTypeArgumentsFix(variable)); } if (typeParameterListOwner instanceof PsiClass) { - QuickFixAction.registerQuickFixAction(highlightInfo, new ChangeClassSignatureFromUsageFix((PsiClass)typeParameterListOwner, referenceParameterList)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createChangeClassSignatureFromUsageFix((PsiClass)typeParameterListOwner, referenceParameterList)); } - VariableParameterizedTypeFix.registerIntentions(highlightInfo, (PsiVariable)variable, referenceParameterList); + registerVariableParameterizedTypeFixes(highlightInfo, (PsiVariable)variable, referenceParameterList); } } } @@ -377,15 +379,14 @@ public class GenericsHighlightUtil { errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); PsiClassType type = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(extendFrom, resolveResult.getSubstitutor()); - QuickFixAction.registerQuickFixAction(errorResult, new MoveBoundClassToFrontFix(aClass, type), null); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMoveBoundClassToFrontFix(aClass, type), null); } else if (referenceElements.length != 0 && element != referenceElements[0] && referenceElements[0].resolve() instanceof PsiTypeParameter) { final String description = JavaErrorMessages.message("type.parameter.cannot.be.followed.by.other.bounds"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); PsiClassType type = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(extendFrom, resolveResult.getSubstitutor()); - IntentionAction fix = QUICK_FIX_FACTORY.createExtendsListFix(aClass, type, false); - QuickFixAction.registerQuickFixAction(errorResult, fix, null); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createExtendsListFix(aClass, type, false), null); } if (errorResult == null && languageLevel.isAtLeast(LanguageLevel.JDK_1_7) && referenceElements.length > 1) { @@ -683,7 +684,7 @@ public class GenericsHighlightUtil { final PsiClassType boxedType = ((PsiPrimitiveType)toConvert).getBoxedType(typeElement); if (boxedType != null) { QuickFixAction.registerQuickFixAction(highlightInfo, - new ReplacePrimitiveWithBoxedTypeAction(typeElement, toConvert.getPresentableText(), ((PsiPrimitiveType)toConvert).getBoxedTypeName())); + QUICK_FIX_FACTORY.createReplacePrimitiveWithBoxedTypeAction(typeElement, toConvert.getPresentableText(), ((PsiPrimitiveType)toConvert).getBoxedTypeName())); } } return highlightInfo; @@ -938,7 +939,7 @@ public class GenericsHighlightUtil { String description = JavaErrorMessages.message("method.does.not.override.super"); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(overrideAnnotation).descriptionAndTooltip(description).create(); - PullAsAbstractUpFix.registerQuickFix(highlightInfo, method); + QUICK_FIX_FACTORY.registerPullAsAbstractUpFixes(method, new QuickFixActionRegistrarImpl(highlightInfo)); return highlightInfo; } PsiClass superClass = superMethod.getMethod().getContainingClass(); @@ -948,7 +949,7 @@ public class GenericsHighlightUtil { String description = JavaErrorMessages.message("override.not.allowed.in.interfaces"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(overrideAnnotation).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(LanguageLevel.JDK_1_6)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createIncreaseLanguageLevelFix(LanguageLevel.JDK_1_6)); return info; } return null; @@ -1052,7 +1053,7 @@ public class GenericsHighlightUtil { if (params[params.length - 1] != parameter) { String description = JavaErrorMessages.message("vararg.not.last.parameter"); info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new MakeVarargParameterLastFix(parameter)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createMakeVarargParameterLastFix(parameter)); return info; } } @@ -1291,5 +1292,37 @@ public class GenericsHighlightUtil { } return false; } + + public static void registerVariableParameterizedTypeFixes(HighlightInfo highlightInfo, + @NotNull PsiVariable variable, + @NotNull PsiReferenceParameterList parameterList) { + PsiType type = variable.getType(); + if (!(type instanceof PsiClassType)) return; + + if (DumbService.getInstance(variable.getProject()).isDumb()) return; + + String shortName = ((PsiClassType)type).getClassName(); + PsiManager manager = parameterList.getManager(); + final JavaPsiFacade facade = JavaPsiFacade.getInstance(manager.getProject()); + PsiShortNamesCache shortNamesCache = PsiShortNamesCache.getInstance(parameterList.getProject()); + PsiClass[] classes = shortNamesCache.getClassesByName(shortName, GlobalSearchScope.allScope(manager.getProject())); + PsiElementFactory factory = facade.getElementFactory(); + JavaSdkVersion version = JavaVersionService.getInstance().getJavaSdkVersion(parameterList); + for (PsiClass aClass : classes) { + if (checkReferenceTypeArgumentList(aClass, parameterList, PsiSubstitutor.EMPTY, false, version) == null) { + PsiType[] actualTypeParameters = parameterList.getTypeArguments(); + PsiTypeParameter[] classTypeParameters = aClass.getTypeParameters(); + Map map = new java.util.HashMap(); + for (int j = 0; j < classTypeParameters.length; j++) { + PsiTypeParameter classTypeParameter = classTypeParameters[j]; + PsiType actualTypeParameter = actualTypeParameters[j]; + map.put(classTypeParameter, actualTypeParameter); + } + PsiSubstitutor substitutor = factory.createSubstitutor(map); + PsiType suggestedType = factory.createType(aClass, substitutor); + HighlightUtil.registerChangeVariableTypeFixes(variable, suggestedType, highlightInfo); + } + } + } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java similarity index 83% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java index 945c1b6b7c95..a8c3f898d603 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java @@ -23,22 +23,14 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.ClassUtil; import com.intellij.codeInsight.ExceptionUtil; -import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.JavaErrorMessages; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.RefCountHolder; -import com.intellij.codeInsight.daemon.impl.quickfix.*; -import com.intellij.codeInsight.generation.OverrideImplementUtil; -import com.intellij.codeInsight.generation.PsiMethodMember; -import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.codeInsight.intention.QuickFixFactory; -import com.intellij.ide.util.MemberChooser; +import com.intellij.ide.highlighter.JavaFileType; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.Result; -import com.intellij.openapi.command.WriteCommandAction; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; @@ -50,11 +42,13 @@ import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.util.*; import com.intellij.refactoring.util.RefactoringChangeUtil; -import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; public class HighlightClassUtil { private static final QuickFixFactory QUICK_FIX_FACTORY = QuickFixFactory.getInstance(); @@ -119,8 +113,7 @@ public class HighlightClassUtil { } if (!(aClass instanceof PsiAnonymousClass) && HighlightUtil.getIncompatibleModifier(PsiModifier.ABSTRACT, aClass.getModifierList()) == null) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.ABSTRACT, true, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.ABSTRACT, true, false)); } return errorResult; } @@ -149,11 +142,11 @@ public class HighlightClassUtil { final PsiMethod anyAbstractMethod = ClassUtil.getAnyAbstractMethod(aClass); if (!aClass.isInterface() && anyAbstractMethod == null) { // suggest to make not abstract only if possible - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.ABSTRACT, false, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, + QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.ABSTRACT, false, false)); } if (anyAbstractMethod != null && parent instanceof PsiNewExpression && ((PsiNewExpression)parent).getClassReference() != null) { - QuickFixAction.registerQuickFixAction(errorResult, new ImplementAbstractClassMethodsFix(parent)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createImplementAbstractClassMethodsFix(parent)); } } return errorResult; @@ -267,11 +260,11 @@ public class HighlightClassUtil { String message = JavaErrorMessages.message("public.class.should.be.named.after.file", aClass.getName()); TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(psiModifierList, PsiModifier.PUBLIC, false, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, + QUICK_FIX_FACTORY.createModifierListFix(psiModifierList, PsiModifier.PUBLIC, false, false)); PsiClass[] classes = file.getClasses(); if (classes.length > 1) { - QuickFixAction.registerQuickFixAction(errorResult, new MoveClassToSeparateFileFix(aClass)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMoveClassToSeparateFileFix(aClass)); } for (PsiClass otherClass : classes) { if (!otherClass.getManager().areElementsEquivalent(otherClass, aClass) && @@ -280,8 +273,8 @@ public class HighlightClassUtil { return errorResult; } } - QuickFixAction.registerQuickFixAction(errorResult, new RenameFileFix(aClass.getName() + "." + StdFileTypes.JAVA.getDefaultExtension())); - QuickFixAction.registerQuickFixAction(errorResult, new RenameElementFix(aClass)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createRenameFileFix(aClass.getName() + JavaFileType.DOT_DEFAULT_EXTENSION)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createRenameElementFix(aClass)); } return errorResult; } @@ -346,10 +339,8 @@ public class HighlightClassUtil { if (PsiUtilCore.hasErrorElementChild(method)) return null; String message = JavaErrorMessages.message("static.declaration.in.inner.class"); HighlightInfo result = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); - IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.STATIC, false, false); - QuickFixAction.registerQuickFixAction(result, fix1); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix((PsiClass)keyword.getParent().getParent().getParent(), PsiModifier.STATIC, true, false); - QuickFixAction.registerQuickFixAction(result, fix); + QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.STATIC, false, false)); + QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createModifierListFix((PsiClass)keyword.getParent().getParent().getParent(), PsiModifier.STATIC, true, false)); return result; } @@ -362,11 +353,9 @@ public class HighlightClassUtil { if (PsiUtilCore.hasErrorElementChild(initializer)) return null; String message = JavaErrorMessages.message("static.declaration.in.inner.class"); HighlightInfo result = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); - IntentionAction fix1 = QUICK_FIX_FACTORY.createModifierListFix(initializer, PsiModifier.STATIC, false, false); - QuickFixAction.registerQuickFixAction(result, fix1); + QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createModifierListFix(initializer, PsiModifier.STATIC, false, false)); PsiClass owner = (PsiClass)keyword.getParent().getParent().getParent(); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(owner, PsiModifier.STATIC, true, false); - QuickFixAction.registerQuickFixAction(result, fix); + QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createModifierListFix(owner, PsiModifier.STATIC, true, false)); return result; } @@ -412,11 +401,10 @@ public class HighlightClassUtil { String message = JavaErrorMessages.message("static.declaration.in.inner.class"); HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create(); if (context != keyword) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false)); } - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass.getContainingClass(), PsiModifier.STATIC, true, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, + QUICK_FIX_FACTORY.createModifierListFix(aClass.getContainingClass(), PsiModifier.STATIC, true, false)); return errorResult; } @@ -460,7 +448,7 @@ public class HighlightClassUtil { HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); final PsiClassType[] referencedTypes = list.getReferencedTypes(); if (referencedTypes.length > 0) { - QuickFixAction.registerQuickFixAction(result, new ChangeExtendsToImplementsFix(aClass, referencedTypes[0])); + QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createChangeExtendsToImplementsFix(aClass, referencedTypes[0])); } return result; } @@ -485,7 +473,7 @@ public class HighlightClassUtil { errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(message).create(); PsiClassType type = JavaPsiFacade.getInstance(aClass.getProject()).getElementFactory().createType(ref); - QuickFixAction.registerQuickFixAction(errorResult, new ChangeExtendsToImplementsFix(aClass, type)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createChangeExtendsToImplementsFix(aClass, type)); } return errorResult; } @@ -497,8 +485,8 @@ public class HighlightClassUtil { String message = JavaErrorMessages.message("inheritance.from.final.class", superClass.getQualifiedName()); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(message).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(superClass, PsiModifier.FINAL, false, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, + QUICK_FIX_FACTORY.createModifierListFix(superClass, PsiModifier.FINAL, false, false)); } return errorResult; } @@ -529,9 +517,9 @@ public class HighlightClassUtil { } @Nullable - public static HighlightInfo checkClassDoesNotCallSuperConstructorOrHandleExceptions(PsiClass aClass, + public static HighlightInfo checkClassDoesNotCallSuperConstructorOrHandleExceptions(@NotNull PsiClass aClass, RefCountHolder refCountHolder, - final PsiResolveHelper resolveHelper) { + @NotNull PsiResolveHelper resolveHelper) { if (aClass.isEnum()) return null; // check only no-ctr classes. Problem with specific constructor will be highlighted inside it if (aClass.getConstructors().length != 0) return null; @@ -540,10 +528,10 @@ public class HighlightClassUtil { return checkBaseClassDefaultConstructorProblem(aClass, refCountHolder, resolveHelper, textRange, PsiClassType.EMPTY_ARRAY); } - public static HighlightInfo checkBaseClassDefaultConstructorProblem(PsiClass aClass, + public static HighlightInfo checkBaseClassDefaultConstructorProblem(@NotNull PsiClass aClass, RefCountHolder refCountHolder, - PsiResolveHelper resolveHelper, - TextRange range, + @NotNull PsiResolveHelper resolveHelper, + @NotNull TextRange range, @NotNull PsiClassType[] handledExceptions) { PsiClass baseClass = aClass.getSuperClass(); if (baseClass == null) return null; @@ -559,7 +547,7 @@ public class HighlightClassUtil { String description = checkDefaultConstructorThrowsException(constructor, handledExceptions); if (description != null) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new CreateConstructorMatchingSuperFix(aClass)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createCreateConstructorMatchingSuperFix(aClass)); return info; } if (refCountHolder != null) { @@ -573,7 +561,7 @@ public class HighlightClassUtil { String description = JavaErrorMessages.message("no.default.constructor.available", HighlightUtil.formatClass(baseClass)); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new CreateConstructorMatchingSuperFix(aClass)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createCreateConstructorMatchingSuperFix(aClass)); return info; } @@ -701,7 +689,7 @@ public class HighlightClassUtil { String description = JavaErrorMessages.message("invalid.qualified.new"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new RemoveNewQualifierFix(expression, null)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRemoveNewQualifierFix(expression, null)); return info; } PsiClass aClass = PsiUtil.resolveClassInType(type); @@ -711,8 +699,7 @@ public class HighlightClassUtil { String description = JavaErrorMessages.message("qualified.new.of.static.class"); info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); if (!aClass.isEnum()) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false); - QuickFixAction.registerQuickFixAction(info, fix); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false)); } } else if (aClass instanceof PsiAnonymousClass) { @@ -722,7 +709,7 @@ public class HighlightClassUtil { .descriptionAndTooltip("Anonymous class implements interface; cannot have qualifier for new").create(); } } - QuickFixAction.registerQuickFixAction(info, new RemoveNewQualifierFix(expression, aClass)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRemoveNewQualifierFix(expression, aClass)); } return info; } @@ -910,93 +897,14 @@ public class HighlightClassUtil { HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create(); // make context not static or referenced class static - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(staticParent, PsiModifier.STATIC, false, false); - QuickFixAction.registerQuickFixAction(highlightInfo, fix); + QuickFixAction.registerQuickFixAction(highlightInfo, + QUICK_FIX_FACTORY.createModifierListFix(staticParent, PsiModifier.STATIC, false, false)); if (aClass != null && HighlightUtil.getIncompatibleModifier(PsiModifier.STATIC, aClass.getModifierList()) == null) { - IntentionAction fix2 = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, true, false); - QuickFixAction.registerQuickFixAction(highlightInfo, fix2); + QuickFixAction.registerQuickFixAction(highlightInfo, + QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, true, false)); } return highlightInfo; } return null; } - - private static class ImplementAbstractClassMethodsFix extends ImplementMethodsFix { - public ImplementAbstractClassMethodsFix(PsiElement highlightElement) { - super(highlightElement); - } - - @Override - public boolean isAvailable(@NotNull Project project, - @NotNull PsiFile file, - @NotNull PsiElement startElement, - @NotNull PsiElement endElement) { - if (startElement instanceof PsiNewExpression) { - final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); - String startElementText = startElement.getText(); - try { - PsiNewExpression newExpression = - (PsiNewExpression)elementFactory.createExpressionFromText(startElementText + "{}", startElement); - if (newExpression.getAnonymousClass() == null) { - try { - newExpression = (PsiNewExpression)elementFactory.createExpressionFromText(startElementText + "){}", startElement); - } - catch (IncorrectOperationException e) { - return false; - } - if (newExpression.getAnonymousClass() == null) return false; - } - } - catch (IncorrectOperationException e) { - return false; - } - return true; - } - return false; - } - - @Override - public void invoke(@NotNull final Project project, - @NotNull PsiFile file, - @Nullable("is null when called from inspection") final Editor editor, - @NotNull final PsiElement startElement, - @NotNull PsiElement endElement) { - final PsiFile containingFile = startElement.getContainingFile(); - if (editor == null || !FileModificationService.getInstance().prepareFileForWrite(containingFile)) return; - PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)startElement).getClassReference(); - if (classReference == null) return; - final PsiClass psiClass = (PsiClass)classReference.resolve(); - if (psiClass == null) return; - final MemberChooser chooser = chooseMethodsToImplement(editor, startElement, psiClass, false); - if (chooser == null) return; - - final List selectedElements = chooser.getSelectedElements(); - if (selectedElements == null || selectedElements.isEmpty()) return; - - new WriteCommandAction(project, file) { - @Override - protected void run(final Result result) throws Throwable { - PsiNewExpression newExpression = - (PsiNewExpression)JavaPsiFacade.getElementFactory(project).createExpressionFromText(startElement.getText() + "{}", startElement); - newExpression = (PsiNewExpression)startElement.replace(newExpression); - final PsiClass psiClass = newExpression.getAnonymousClass(); - if (psiClass == null) return; - Map subst = new HashMap(); - for (PsiMethodMember selectedElement : selectedElements) { - final PsiClass baseClass = selectedElement.getElement().getContainingClass(); - if (baseClass != null) { - PsiSubstitutor substitutor = subst.get(baseClass); - if (substitutor == null) { - substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, psiClass, PsiSubstitutor.EMPTY); - subst.put(baseClass, substitutor); - } - selectedElement.setSubstitutor(substitutor); - } - } - OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(editor, psiClass, selectedElements, chooser.isCopyJavadoc(), - chooser.isInsertOverrideAnnotation()); - } - }.execute(); - } - } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java similarity index 94% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java index 7cc7879c2206..6b0ac54e43fe 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java @@ -18,8 +18,7 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.daemon.JavaErrorMessages; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; -import com.intellij.codeInsight.daemon.impl.quickfix.*; -import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.openapi.project.IndexNotReadyException; import com.intellij.openapi.util.TextRange; @@ -29,14 +28,17 @@ import com.intellij.psi.controlFlow.*; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.FileTypeUtils; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.Processor; -import com.intellij.psi.util.FileTypeUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; /** * @author cdr @@ -65,9 +67,8 @@ public class HighlightControlFlowUtil { PsiElement parent = body.getParent(); if (parent instanceof PsiMethod) { PsiMethod method = (PsiMethod)parent; - QuickFixAction.registerQuickFixAction(info, new AddReturnFix(method)); - IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.VOID, true); - QuickFixAction.registerQuickFixAction(info, fix); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddReturnFix(method)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.VOID, true)); } return info; } @@ -234,14 +235,13 @@ public class HighlightControlFlowUtil { String description = JavaErrorMessages.message("variable.not.initialized", field.getName()); TextRange range = HighlightNamesUtil.getFieldDeclarationTextRange(field); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), new CreateConstructorParameterFromFieldFix(field)); - QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), new InitializeFinalFieldInConstructorFix(field)); + QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), QUICK_FIX_FACTORY.createCreateConstructorParameterFromFieldFix(field)); + QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), QUICK_FIX_FACTORY.createInitializeFinalFieldInConstructorFix(field)); final PsiClass containingClass = field.getContainingClass(); if (containingClass != null && !containingClass.isInterface()) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(field, PsiModifier.FINAL, false, false); - QuickFixAction.registerQuickFixAction(highlightInfo, fix); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createModifierListFix(field, PsiModifier.FINAL, false, false)); } - QuickFixAction.registerQuickFixAction(highlightInfo, new AddVariableInitializerFix(field)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createAddVariableInitializerFix(field)); return highlightInfo; } @@ -379,7 +379,7 @@ public class HighlightControlFlowUtil { String description = JavaErrorMessages.message("variable.not.initialized", name); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(highlightInfo, new AddVariableInitializerFix(variable)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createAddVariableInitializerFix(variable)); return highlightInfo; } @@ -503,9 +503,9 @@ public class HighlightControlFlowUtil { String description = JavaErrorMessages.message("variable.already.assigned", variable.getName()); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(variable, PsiModifier.FINAL, false, false); - QuickFixAction.registerQuickFixAction(highlightInfo, fix); - QuickFixAction.registerQuickFixAction(highlightInfo, new DeferFinalAssignmentFix(variable, expression)); + QuickFixAction.registerQuickFixAction(highlightInfo, + QUICK_FIX_FACTORY.createModifierListFix(variable, PsiModifier.FINAL, false, false)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createDeferFinalAssignmentFix(variable, expression)); return highlightInfo; } @@ -535,8 +535,8 @@ public class HighlightControlFlowUtil { String description = JavaErrorMessages.message("variable.assigned.in.loop", ((PsiVariable)resolved).getName()); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix((PsiVariable)resolved, PsiModifier.FINAL, false, false); - QuickFixAction.registerQuickFixAction(highlightInfo, fix); + QuickFixAction.registerQuickFixAction(highlightInfo, + QUICK_FIX_FACTORY.createModifierListFix((PsiVariable)resolved, PsiModifier.FINAL, false, false)); return highlightInfo; } return null; @@ -576,11 +576,11 @@ public class HighlightControlFlowUtil { HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(reference.getTextRange()).descriptionAndTooltip(description).create(); final PsiClass innerClass = getInnerClassVariableReferencedFrom(variable, expression); if (innerClass == null || variable instanceof PsiField) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(variable, PsiModifier.FINAL, false, false); - QuickFixAction.registerQuickFixAction(highlightInfo, fix); + QuickFixAction.registerQuickFixAction(highlightInfo, + QUICK_FIX_FACTORY.createModifierListFix(variable, PsiModifier.FINAL, false, false)); } else { - QuickFixAction.registerQuickFixAction(highlightInfo, new VariableAccessFromInnerClassFix(variable, innerClass)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createVariableAccessFromInnerClassFix(variable, innerClass)); } return highlightInfo; } @@ -642,7 +642,7 @@ public class HighlightControlFlowUtil { final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(context).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(highlightInfo, new VariableAccessFromInnerClassFix(variable, innerClass)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createVariableAccessFromInnerClassFix(variable, innerClass)); return highlightInfo; } final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(context, PsiLambdaExpression.class); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java similarity index 90% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index 3266e9685dc2..1acf4e73621f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -112,8 +112,8 @@ public class HighlightMethodUtil { textRange = TextRange.EMPTY_RANGE; } HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiUtil.getAccessModifier(superAccessLevel), true, false); - QuickFixAction.registerQuickFixAction(highlightInfo, fix); + QuickFixAction.registerQuickFixAction(highlightInfo, + QUICK_FIX_FACTORY.createModifierListFix(method, PsiUtil.getAccessModifier(superAccessLevel), true, false)); return highlightInfo; } return null; @@ -143,7 +143,7 @@ public class HighlightMethodUtil { return null; } - private static HighlightInfo checkSuperMethodSignature(PsiMethod superMethod, + private static HighlightInfo checkSuperMethodSignature(@NotNull PsiMethod superMethod, MethodSignatureBackedByPsiMethod superMethodSignature, PsiType superReturnType, PsiMethod method, @@ -187,17 +187,16 @@ public class HighlightMethodUtil { private static HighlightInfo createIncompatibleReturnTypeMessage(PsiMethod methodToHighlight, PsiMethod method, - PsiMethod superMethod, + @NotNull PsiMethod superMethod, boolean includeRealPositionInfo, PsiType substitutedSuperReturnType, - PsiType returnType, + @NotNull PsiType returnType, String detailMessage) { String description = MessageFormat.format("{0}; {1}", createClashMethodMessage(method, superMethod, true), detailMessage); TextRange textRange = includeRealPositionInfo ? methodToHighlight.getReturnTypeElement().getTextRange() : TextRange.EMPTY_RANGE; HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, substitutedSuperReturnType, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); - QuickFixAction.registerQuickFixAction(errorResult, new SuperMethodReturnFix(superMethod, returnType)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodReturnFix(method, substitutedSuperReturnType, false)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createSuperMethodReturnFix(superMethod, returnType)); return errorResult; } @@ -223,8 +222,8 @@ public class HighlightMethodUtil { HighlightUtil.formatClass(superMethod.getContainingClass())); TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(superMethod, PsiModifier.FINAL, false, true); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, + QUICK_FIX_FACTORY.createModifierListFix(superMethod, PsiModifier.FINAL, false, true)); return errorResult; } return null; @@ -381,13 +380,13 @@ public class HighlightMethodUtil { highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(methodCall).descriptionAndTooltip(description).create(); if (resolved instanceof PsiClass) { - QuickFixAction.registerQuickFixAction(highlightInfo, new InsertNewFix(methodCall, (PsiClass)resolved)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createInsertNewFix(methodCall, (PsiClass)resolved)); } else { TextRange range = getFixRange(methodCall); - QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreateMethodFromUsageFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreateAbstractMethodFromUsageFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, range, new CreatePropertyFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, range, QUICK_FIX_FACTORY.createCreateMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, range, QUICK_FIX_FACTORY.createCreateAbstractMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, range, QUICK_FIX_FACTORY.createCreatePropertyFromUsageFix(methodCall)); } } } @@ -497,7 +496,7 @@ public class HighlightMethodUtil { CastMethodArgumentFix.REGISTRAR.registerCastActions(candidates, methodCall, info, fixRange); PermuteArgumentsFix.registerFix(info, methodCall, candidates, fixRange); WrapExpressionFix.registerWrapAction(candidates, list.getExpressions(), info); - ChangeParameterClassFix.registerQuickFixActions(methodCall, list, info); + registerChangeParameterClassFix(methodCall, list, info); return info; } @@ -517,28 +516,30 @@ public class HighlightMethodUtil { PsiExpressionList list, PsiResolveHelper resolveHelper) { TextRange fixRange = getFixRange(methodCall); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateMethodFromUsageFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateAbstractMethodFromUsageFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateConstructorFromSuperFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateConstructorFromThisFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreatePropertyFromUsageFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new CreateGetterSetterPropertyFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createCreateMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createCreateAbstractMethodFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createCreateConstructorFromSuperFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createCreateConstructorFromThisFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createCreatePropertyFromUsageFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createCreateGetterSetterPropertyFromUsageFix(methodCall)); CandidateInfo[] methodCandidates = resolveHelper.getReferencedMethodCandidates(methodCall, false); CastMethodArgumentFix.REGISTRAR.registerCastActions(methodCandidates, methodCall, highlightInfo, fixRange); PermuteArgumentsFix.registerFix(highlightInfo, methodCall, methodCandidates, fixRange); AddTypeArgumentsFix.REGISTRAR.registerCastActions(methodCandidates, methodCall, highlightInfo, fixRange); registerMethodAccessLevelIntentions(methodCandidates, methodCall, list, highlightInfo); - ChangeMethodSignatureFromUsageFix.registerIntentions(methodCandidates, list, highlightInfo, fixRange); + registerChangeMethodSignatureFromUsageIntentions(methodCandidates, list, highlightInfo, fixRange); RemoveRedundantArgumentsFix.registerIntentions(methodCandidates, list, highlightInfo, fixRange); ConvertDoubleToFloatFix.registerIntentions(methodCandidates, list, highlightInfo, fixRange); WrapExpressionFix.registerWrapAction(methodCandidates, list.getExpressions(), highlightInfo); - ChangeParameterClassFix.registerQuickFixActions(methodCall, list, highlightInfo); + registerChangeParameterClassFix(methodCall, list, highlightInfo); if (methodCandidates.length == 0) { - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new StaticImportMethodFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createStaticImportMethodFix(methodCall)); } - VariableTypeFromCallFix.registerQuickFixActions(methodCall, list, highlightInfo); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ReplaceAddAllArrayToCollectionFix(methodCall)); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new SurroundWithArrayFix(methodCall)); + for (IntentionAction action : QUICK_FIX_FACTORY.getVariableTypeFromCallFixes(methodCall, list)) { + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, action); + } + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createReplaceAddAllArrayToCollectionFix(methodCall)); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, QUICK_FIX_FACTORY.createSurroundWithArrayFix(methodCall,null)); QualifyThisArgumentFix.registerQuickFixAction(methodCandidates, methodCall, highlightInfo, fixRange); CandidateInfo[] candidates = resolveHelper.getReferencedMethodCandidates(methodCall, true); @@ -791,10 +792,10 @@ public class HighlightMethodUtil { String description = JavaErrorMessages.message("missing.method.body"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(start, end).descriptionAndTooltip(description).create(); if (HighlightUtil.getIncompatibleModifier(PsiModifier.ABSTRACT, method.getModifierList()) == null) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, true, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, + QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, true, false)); } - QuickFixAction.registerQuickFixAction(errorResult, new AddMethodBodyFix(method)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createAddMethodBodyFix(method)); } return errorResult; } @@ -812,12 +813,11 @@ public class HighlightMethodUtil { errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create(); if (method.getBody() != null) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, + QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false)); } - QuickFixAction.registerQuickFixAction(errorResult, new AddMethodBodyFix(method)); - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.ABSTRACT, true, false); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createAddMethodBodyFix(method)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.ABSTRACT, true, false)); } return errorResult; } @@ -835,7 +835,7 @@ public class HighlightMethodUtil { String description = JavaErrorMessages.message("missing.return.type"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); if (className != null) { - QuickFixAction.registerQuickFixAction(errorResult, new RenameElementFix(method, className)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createRenameElementFix(method, className)); } } } @@ -881,7 +881,7 @@ public class HighlightMethodUtil { if (hasNoBody) { if (isExtension) { description = JavaErrorMessages.message("extension.method.should.have.a.body"); - additionalFixes.add(new AddMethodBodyFix(method)); + additionalFixes.add(QUICK_FIX_FACTORY.createAddMethodBodyFix(method)); } else if (isInterface && isStatic) { description = "Static methods in interfaces should have a body"; @@ -913,7 +913,7 @@ public class HighlightMethodUtil { TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); if (!hasNoBody) { - QuickFixAction.registerQuickFixAction(info, new DeleteMethodBodyFix(method)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteMethodBodyFix(method)); } if (method.hasModifierProperty(PsiModifier.ABSTRACT) && !isInterface) { QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.ABSTRACT, false, false)); @@ -981,7 +981,7 @@ public class HighlightMethodUtil { PsiClassType[] handledExceptions = constructor.getThrowsList().getReferencedTypes(); HighlightInfo info = HighlightClassUtil.checkBaseClassDefaultConstructorProblem(aClass, refCountHolder, resolveHelper, textRange, handledExceptions); if (info != null) { - QuickFixAction.registerQuickFixAction(info, new InsertSuperFix(constructor)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createInsertSuperFix(constructor)); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddDefaultConstructorFix(aClass.getSuperClass())); } return info; @@ -1047,13 +1047,13 @@ public class HighlightMethodUtil { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); if (!isSuperMethodStatic || HighlightUtil.getIncompatibleModifier(PsiModifier.STATIC, modifierList) == null) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.STATIC, isSuperMethodStatic, false); - QuickFixAction.registerQuickFixAction(info, fix); + QuickFixAction.registerQuickFixAction(info, + QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.STATIC, isSuperMethodStatic, false)); } if (manager.isInProject(superMethod) && (!isMethodStatic || HighlightUtil.getIncompatibleModifier(PsiModifier.STATIC, superModifierList) == null)) { - IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(superMethod, PsiModifier.STATIC, isMethodStatic, true); - QuickFixAction.registerQuickFixAction(info, fix); + QuickFixAction.registerQuickFixAction(info, + QUICK_FIX_FACTORY.createModifierListFix(superMethod, PsiModifier.STATIC, isMethodStatic, true)); } return info; } @@ -1268,7 +1268,7 @@ public class HighlightMethodUtil { String description = JavaErrorMessages.message("wrong.constructor.arguments", constructorName+"()", argTypes); String tooltip = createMismatchedArgumentsHtmlTooltip(list, PsiParameter.EMPTY_ARRAY, constructorName, PsiSubstitutor.EMPTY, aClass); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).description(description).escapedToolTip(tooltip).navigationShift(+1).create(); - QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall)); + QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), QUICK_FIX_FACTORY.createCreateConstructorFromCallFix(constructorCall)); if (classReference != null) { ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info,getFixRange(list)); } @@ -1311,7 +1311,7 @@ public class HighlightMethodUtil { name += buildArgTypesList(list); String description = JavaErrorMessages.message("cannot.resolve.constructor", name); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).navigationShift(+1).create(); - QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall)); + QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), QUICK_FIX_FACTORY.createCreateConstructorFromCallFix(constructorCall)); if (classReference != null) { ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info,getFixRange(list)); PermuteArgumentsFix.registerFix(info, constructorCall, toMethodCandidates(results), getFixRange(list)); @@ -1334,15 +1334,15 @@ public class HighlightMethodUtil { PsiElement infoElement = list.getTextLength() > 0 ? list : constructorCall; HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(infoElement).description(description).escapedToolTip(toolTip).navigationShift(+1).create(); if (info != null) { - QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), new CreateConstructorFromCallFix(constructorCall)); + QuickFixAction.registerQuickFixAction(info, constructorCall.getTextRange(), QUICK_FIX_FACTORY.createCreateConstructorFromCallFix(constructorCall)); if (classReference != null) { ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info, getFixRange(infoElement)); - ChangeMethodSignatureFromUsageFix.registerIntentions(results, list, info, null); + registerChangeMethodSignatureFromUsageIntentions(results, list, info, null); ChangeTypeArgumentsFix.registerIntentions(results, list, info, aClass); ConvertDoubleToFloatFix.registerIntentions(results, list, info, null); PermuteArgumentsFix.registerFix(info, constructorCall, toMethodCandidates(results), getFixRange(list)); - ChangeParameterClassFix.registerQuickFixActions(constructorCall, list, info); - QuickFixAction.registerQuickFixAction(info, getFixRange(list), new SurroundWithArrayFix(constructorCall)); + registerChangeParameterClassFix(constructorCall, list, info); + QuickFixAction.registerQuickFixAction(info, getFixRange(list), QUICK_FIX_FACTORY.createSurroundWithArrayFix(constructorCall,null)); } holder.add(info); ChangeStringLiteralToCharInMethodCallFix.registerFixes(constructors, constructorCall, info); @@ -1402,4 +1402,57 @@ public class HighlightMethodUtil { builder.append(")"); return builder.toString(); } + + private static void registerChangeParameterClassFix(PsiCall methodCall, PsiExpressionList list, HighlightInfo highlightInfo) { + final JavaResolveResult result = methodCall.resolveMethodGenerics(); + PsiMethod method = (PsiMethod)result.getElement(); + final PsiSubstitutor substitutor = result.getSubstitutor(); + PsiExpression[] expressions = list.getExpressions(); + if (method == null) return; + final PsiParameter[] parameters = method.getParameterList().getParameters(); + if (parameters.length != expressions.length) return; + for (int i = 0; i < expressions.length; i++) { + final PsiExpression expression = expressions[i]; + final PsiParameter parameter = parameters[i]; + final PsiType expressionType = expression.getType(); + final PsiType parameterType = substitutor.substitute(parameter.getType()); + if (expressionType == null || expressionType instanceof PsiPrimitiveType || TypeConversionUtil.isNullType(expressionType) || expressionType instanceof PsiArrayType) continue; + if (parameterType instanceof PsiPrimitiveType || TypeConversionUtil.isNullType(parameterType) || parameterType instanceof PsiArrayType) continue; + if (parameterType.isAssignableFrom(expressionType)) continue; + PsiClass parameterClass = PsiUtil.resolveClassInType(parameterType); + PsiClass expressionClass = PsiUtil.resolveClassInType(expressionType); + if (parameterClass == null || expressionClass == null) continue; + if (expressionClass instanceof PsiAnonymousClass) continue; + if (parameterClass.isInheritor(expressionClass, true)) continue; + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createChangeParameterClassFix(expressionClass, (PsiClassType)parameterType)); + } + } + + public static void registerChangeMethodSignatureFromUsageIntentions(@NotNull JavaResolveResult[] candidates, + @NotNull PsiExpressionList list, + @Nullable HighlightInfo highlightInfo, + TextRange fixRange) { + if (candidates.length == 0) return; + PsiExpression[] expressions = list.getExpressions(); + for (JavaResolveResult candidate : candidates) { + registerChangeMethodSignatureFromUsageIntention(expressions, highlightInfo, fixRange, candidate, list); + } + } + + private static void registerChangeMethodSignatureFromUsageIntention(@NotNull PsiExpression[] expressions, + @Nullable HighlightInfo highlightInfo, + TextRange fixRange, + @NotNull JavaResolveResult candidate, + @NotNull PsiElement context) { + if (!candidate.isStaticsScopeCorrect()) return; + PsiMethod method = (PsiMethod)candidate.getElement(); + PsiSubstitutor substitutor = candidate.getSubstitutor(); + if (method != null && context.getManager().isInProject(method)) { + IntentionAction fix = QUICK_FIX_FACTORY.createChangeMethodSignatureFromUsageFix(method, expressions, substitutor, context, false, 2); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, fix); + IntentionAction f2 = QUICK_FIX_FACTORY.createChangeMethodSignatureFromUsageReverseOrderFix(method, expressions, substitutor, context, + false, 2); + QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, f2); + } + } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java similarity index 99% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java index b9ea90cc1dc7..e7b162fbcc4b 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightNamesUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java similarity index 94% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index 5a47829341ad..de435809ff41 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -61,7 +61,6 @@ import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.UIUtil; import com.intellij.xml.util.XmlStringUtil; -import com.intellij.psi.util.FileTypeUtils; import gnu.trove.THashMap; import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.NonNls; @@ -190,7 +189,8 @@ public class HighlightUtil extends HighlightUtilBase { if (qualifier instanceof PsiExpression) { accessObjectClass = (PsiClass)PsiUtil.getAccessObjectClass((PsiExpression)qualifier).getElement(); } - ReplaceInaccessibleFieldWithGetterSetterFix.registerQuickFix(refElement, place, accessObjectClass, errorResult); + registerReplaceInaccessibleFieldWithGetterSetterFix(refElement, place, accessObjectClass, + errorResult); if (refElement instanceof PsiCompiledElement) return; PsiModifierList modifierList = refElement.getModifierList(); @@ -353,7 +353,7 @@ public class HighlightUtil extends HighlightUtilBase { JavaHighlightUtil.formatType(rType)); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(assignment).descriptionAndTooltip(message).create(); - QuickFixAction.registerQuickFixAction(errorResult, new ChangeToAppendFix(eqOpSign, lType, assignment)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createChangeToAppendFix(eqOpSign, lType, assignment)); } return errorResult; } @@ -448,10 +448,10 @@ public class HighlightUtil extends HighlightUtilBase { } HighlightInfo highlightInfo = createIncompatibleTypeHighlightInfo(lType, rType, textRange, navigationShift); if (rType != null && expression != null && isCastIntentionApplicable(expression, lType)) { - QuickFixAction.registerQuickFixAction(highlightInfo, new AddTypeCastFix(lType, expression)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createAddTypeCastFix(lType, expression)); } if (expression != null && lType != null) { - QuickFixAction.registerQuickFixAction(highlightInfo, new WrapExpressionFix(lType, expression)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createWrapExpressionFix(lType, expression)); AddTypeArgumentsConditionalFix.register(highlightInfo, expression, lType); } ChangeNewOperatorTypeFix.register(highlightInfo, expression, lType); @@ -497,24 +497,17 @@ public class HighlightUtil extends HighlightUtilBase { errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create(); if (valueType != null) { - IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, valueType, true); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodReturnFix(method, valueType, true)); } } else { TextRange textRange = statement.getTextRange(); errorResult = checkAssignability(returnType, valueType, returnValue, textRange, returnValue.getStartOffsetInParent()); if (errorResult != null && valueType != null) { - IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, valueType, true); - QuickFixAction.registerQuickFixAction(errorResult, fix); - ChangeParameterClassFix.registerQuickFixAction(returnType, valueType, errorResult); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodReturnFix(method, valueType, true)); + registerChangeParameterClassFix(returnType, valueType, errorResult); if (returnType instanceof PsiArrayType && TypeConversionUtil.isAssignable(((PsiArrayType)returnType).getComponentType(), valueType)) { - QuickFixAction.registerQuickFixAction(errorResult, new SurroundWithArrayFix(null) { - @Override - protected PsiExpression getExpression(final PsiElement element) { - return returnValue.isValid() ? returnValue : null; - } - }); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createSurroundWithArrayFix(null, returnValue)); } } } @@ -523,8 +516,7 @@ public class HighlightUtil extends HighlightUtilBase { if (!isMethodVoid) { description = JavaErrorMessages.message("missing.return.value"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).navigationShift(PsiKeyword.RETURN.length()).create(); - IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.VOID, true); - QuickFixAction.registerQuickFixAction(errorResult, fix); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.VOID, true)); } } } @@ -613,7 +605,7 @@ public class HighlightUtil extends HighlightUtilBase { HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(description).create(); if (variable instanceof PsiLocalVariable) { - QuickFixAction.registerQuickFixAction(highlightInfo, new ReuseVariableDeclarationFix((PsiLocalVariable)variable)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createReuseVariableDeclarationFix((PsiLocalVariable)variable)); } return highlightInfo; } @@ -685,11 +677,11 @@ public class HighlightUtil extends HighlightUtilBase { private static void registerUnhandledExceptionFixes(@NotNull final PsiElement element, final HighlightInfo errorResult, @NotNull final List unhandled) { - QuickFixAction.registerQuickFixAction(errorResult, new AddExceptionToCatchFix()); - QuickFixAction.registerQuickFixAction(errorResult, new AddExceptionToThrowsFix(element)); - QuickFixAction.registerQuickFixAction(errorResult, new SurroundWithTryCatchFix(element)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createAddExceptionToCatchFix()); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createAddExceptionToThrowsFix(element)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createSurroundWithTryCatchFix(element)); if (unhandled.size() == 1) { - QuickFixAction.registerQuickFixAction(errorResult, new GeneralizeCatchFix(element, unhandled.get(0))); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createGeneralizeCatchFix(element, unhandled.get(0))); } } @@ -974,7 +966,7 @@ public class HighlightUtil extends HighlightUtilBase { final String message = JavaErrorMessages.message("too.many.characters.in.character.literal"); final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); - QuickFixAction.registerQuickFixAction(info, new ConvertToStringLiteralAction()); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createConvertToStringLiteralAction()); return info; } else if (length == 0) { @@ -1018,7 +1010,7 @@ public class HighlightUtil extends HighlightUtilBase { final String message = JavaErrorMessages.message("floating.point.number.too.large"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } - if (number.floatValue() == 0 && !isFPZero(text)) { + if (number.floatValue() == 0 && !TypeConversionUtil.isFPZero(text)) { final String message = JavaErrorMessages.message("floating.point.number.too.small"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } @@ -1029,7 +1021,7 @@ public class HighlightUtil extends HighlightUtilBase { final String message = JavaErrorMessages.message("floating.point.number.too.large"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } - if (number.doubleValue() == 0 && !isFPZero(text)) { + if (number.doubleValue() == 0 && !TypeConversionUtil.isFPZero(text)) { final String message = JavaErrorMessages.message("floating.point.number.too.small"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } @@ -1076,16 +1068,6 @@ public class HighlightUtil extends HighlightUtilBase { return null; } - // true if floating point literal consists of zeros only - public static boolean isFPZero(@NotNull final String text) { - for (int i = 0; i < text.length(); i++) { - final char c = text.charAt(i); - if (Character.isDigit(c) && c != '0') return false; - if (Character.toUpperCase(c) == 'E') break; - } - return true; - } - @Nullable static HighlightInfo checkMustBeBoolean(@NotNull PsiExpression expr, PsiType type) { PsiElement parent = expr.getParent(); @@ -1100,8 +1082,7 @@ public class HighlightUtil extends HighlightUtilBase { final PsiMethodCallExpression methodCall = (PsiMethodCallExpression)expr; final PsiMethod method = methodCall.resolveMethod(); if (method != null && PsiType.VOID.equals(method.getReturnType())) { - IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.BOOLEAN, true); - QuickFixAction.registerQuickFixAction(info, fix); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.BOOLEAN, true)); } } return info; @@ -1157,7 +1138,7 @@ public class HighlightUtil extends HighlightUtilBase { final String description = JavaErrorMessages.message("exception.never.thrown.try", JavaHighlightUtil.formatType(caughtType)); final HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(errorResult, new DeleteCatchFix(parameter)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createDeleteCatchFix(parameter)); return Collections.singleton(errorResult); } @@ -1182,7 +1163,7 @@ public class HighlightUtil extends HighlightUtilBase { final String description = JavaErrorMessages.message("exception.never.thrown.try", JavaHighlightUtil.formatType(catchType)); final HighlightInfo highlight = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(highlight, new DeleteMultiCatchFix(typeElement)); + QuickFixAction.registerQuickFixAction(highlight, QUICK_FIX_FACTORY.createDeleteMultiCatchFix(typeElement)); highlights.add(highlight); } } @@ -1244,10 +1225,10 @@ public class HighlightUtil extends HighlightUtilBase { final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(catchSection).descriptionAndTooltip(message).create(); if (isMultiCatch) { - QuickFixAction.registerQuickFixAction(highlightInfo, new DeleteMultiCatchFix(catchTypeElement)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createDeleteMultiCatchFix(catchTypeElement)); } else { - QuickFixAction.registerQuickFixAction(highlightInfo, new DeleteCatchFix(parameter)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createDeleteCatchFix(parameter)); } result.add(highlightInfo); } @@ -1280,9 +1261,9 @@ public class HighlightUtil extends HighlightUtilBase { JavaErrorMessages.message("incompatible.types", JavaErrorMessages.message("valid.switch.selector.types"), JavaHighlightUtil.formatType( type)); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); - QuickFixAction.registerQuickFixAction(errorResult, new ConvertSwitchToIfIntention(statement)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createConvertSwitchToIfIntention(statement)); if (PsiType.LONG.equals(type) || PsiType.FLOAT.equals(type) || PsiType.DOUBLE.equals(type)) { - QuickFixAction.registerQuickFixAction(errorResult, new AddTypeCastFix(PsiType.INT, expression)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createAddTypeCastFix(PsiType.INT, expression)); } } else { @@ -1344,7 +1325,7 @@ public class HighlightUtil extends HighlightUtilBase { HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parentExpr).descriptionAndTooltip(message).create(); if (parentExpr instanceof PsiPrefixExpression && token.getTokenType() == JavaTokenType.EXCL) { - QuickFixAction.registerQuickFixAction(highlightInfo, new NegationBroadScopeFix((PsiPrefixExpression)parentExpr)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createNegationBroadScopeFix((PsiPrefixExpression)parentExpr)); } return highlightInfo; } @@ -1448,7 +1429,7 @@ public class HighlightUtil extends HighlightUtilBase { QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createModifierListFix(staticParent, PsiModifier.STATIC, false, false)); } if (place instanceof PsiReferenceExpression && refElement instanceof PsiField) { - QuickFixAction.registerQuickFixAction(errorResult, new CreateFieldFromUsageFix((PsiReferenceExpression)place)); + QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createCreateFieldFromUsageFix((PsiReferenceExpression)place)); } } @@ -1523,7 +1504,7 @@ public class HighlightUtil extends HighlightUtilBase { final String description = JavaErrorMessages.message("array.type.expected", JavaHighlightUtil.formatType(arrayExpressionType)); final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(arrayExpression).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new ReplaceWithListAccessFix(arrayAccessExpression)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createReplaceWithListAccessFix(arrayAccessExpression)); return info; } @@ -1628,7 +1609,7 @@ public class HighlightUtil extends HighlightUtilBase { String description = JavaErrorMessages.message("array.initializer.not.allowed"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new AddNewArrayExpressionFix(expression)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddNewArrayExpressionFix(expression)); return info; } @@ -2167,12 +2148,12 @@ public class HighlightUtil extends HighlightUtilBase { HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); result.add(highlightInfo); - QuickFixAction.registerQuickFixAction(highlightInfo, new MoveCatchUpFix(catchSection, upperCatchSection)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createMoveCatchUpFix(catchSection, upperCatchSection)); if (isInMultiCatch) { - QuickFixAction.registerQuickFixAction(highlightInfo, new DeleteMultiCatchFix(typeElement)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createDeleteMultiCatchFix(typeElement)); } else { - QuickFixAction.registerQuickFixAction(highlightInfo, new DeleteCatchFix(parameter)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createDeleteCatchFix(parameter)); } } } @@ -2379,7 +2360,7 @@ public class HighlightUtil extends HighlightUtilBase { HighlightInfo highlightInfo = createIncompatibleTypeHighlightInfo(throwable, type, context.getTextRange(), 0); if (addCastIntention && TypeConversionUtil.areTypesConvertible(type, throwable)) { if (context instanceof PsiExpression) { - QuickFixAction.registerQuickFixAction(highlightInfo, new AddTypeCastFix(throwable, (PsiExpression)context)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createAddTypeCastFix(throwable, (PsiExpression)context)); } } return highlightInfo; @@ -2470,7 +2451,7 @@ public class HighlightUtil extends HighlightUtilBase { if (result.isStaticsScopeCorrect()) { registerAccessQuickFixAction((PsiMember)resolved, ref, info, result.getCurrentFileResolveScope()); if (ref instanceof PsiReferenceExpression) { - QuickFixAction.registerQuickFixAction(info, new RenameWrongRefFix((PsiReferenceExpression)ref)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRenameWrongRefFix((PsiReferenceExpression)ref)); } } UnresolvedReferenceQuickFixProvider.registerReferenceFixes(ref, new QuickFixActionRegistrarImpl(info)); @@ -2483,7 +2464,7 @@ public class HighlightUtil extends HighlightUtilBase { HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refName).descriptionAndTooltip(description).create(); registerStaticProblemQuickFixAction(resolved, info, ref); if (ref instanceof PsiReferenceExpression) { - QuickFixAction.registerQuickFixAction(info, new RenameWrongRefFix((PsiReferenceExpression)ref)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRenameWrongRefFix((PsiReferenceExpression)ref)); } return info; } @@ -2600,20 +2581,28 @@ public class HighlightUtil extends HighlightUtilBase { String description = JavaErrorMessages.message("expected.class.or.package"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(qualifier).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, new RemoveQualifierFix(qualifier, expression, (PsiClass)resolved)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRemoveQualifierFix(qualifier, expression, (PsiClass)resolved)); return info; } - public static void registerChangeVariableTypeFixes(@NotNull PsiVariable parameter, PsiType itemType, HighlightInfo highlightInfo) { - if (itemType instanceof PsiMethodReferenceType) return; + public static void registerChangeVariableTypeFixes(@NotNull PsiVariable parameter, PsiType itemType, @NotNull HighlightInfo highlightInfo) { + for (IntentionAction action : getChangeVariableTypeFixes(parameter, itemType)) { + QuickFixAction.registerQuickFixAction(highlightInfo, action); + } + } + + @NotNull + public static List getChangeVariableTypeFixes(@NotNull PsiVariable parameter, PsiType itemType) { + if (itemType instanceof PsiMethodReferenceType) return Collections.emptyList(); + List result = new ArrayList(); if (itemType != null) { for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) { - for (IntentionAction action : fixProvider.getFixes(parameter, itemType)) { - QuickFixAction.registerQuickFixAction(highlightInfo, action); - } + Collections.addAll(result, fixProvider.getFixes(parameter, itemType)); } } - ChangeParameterClassFix.registerQuickFixAction(parameter.getType(), itemType, highlightInfo); + IntentionAction changeFix = getChangeParameterClassFix(parameter.getType(), itemType); + if (changeFix != null) result.add(changeFix); + return result; } @Nullable @@ -2623,7 +2612,7 @@ public class HighlightUtil extends HighlightUtilBase { final String message = JavaErrorMessages.message("annotation.interface.members.may.not.have.parameters"); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(message).create(); - QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveParameterListFix((PsiMethod)parent)); + QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createRemoveParameterListFix((PsiMethod)parent)); return highlightInfo; } return null; @@ -2642,6 +2631,49 @@ public class HighlightUtil extends HighlightUtilBase { return null; } + private static void registerChangeParameterClassFix(PsiType lType, PsiType rType, HighlightInfo info) { + QuickFixAction.registerQuickFixAction(info, getChangeParameterClassFix(lType, rType)); + } + @Nullable + private static IntentionAction getChangeParameterClassFix(PsiType lType, PsiType rType) { + final PsiClass lClass = PsiUtil.resolveClassInClassTypeOnly(lType); + final PsiClass rClass = PsiUtil.resolveClassInClassTypeOnly(rType); + + if (rClass == null || lClass == null) return null; + if (rClass instanceof PsiAnonymousClass) return null; + if (rClass.isInheritor(lClass, true)) return null; + if (lClass.isInheritor(rClass, true)) return null; + if (lClass == rClass) return null; + + return QUICK_FIX_FACTORY.createChangeParameterClassFix(rClass, (PsiClassType)lType); + } + + private static void registerReplaceInaccessibleFieldWithGetterSetterFix(PsiMember refElement, + PsiJavaCodeReferenceElement place, + PsiClass accessObjectClass, + HighlightInfo error) { + if (refElement instanceof PsiField && place instanceof PsiReferenceExpression) { + final PsiField psiField = (PsiField)refElement; + final PsiClass containingClass = psiField.getContainingClass(); + if (containingClass != null) { + if (PsiUtil.isOnAssignmentLeftHand((PsiExpression)place)) { + final PsiMethod setterPrototype = PropertyUtil.generateSetterPrototype(psiField); + final PsiMethod setter = containingClass.findMethodBySignature(setterPrototype, true); + if (setter != null && PsiUtil.isAccessible(setter, place, accessObjectClass)) { + QuickFixAction.registerQuickFixAction(error, QUICK_FIX_FACTORY.createReplaceInaccessibleFieldWithGetterSetterFix(place, setter, true)); + } + } + else if (PsiUtil.isAccessedForReading((PsiExpression)place)) { + final PsiMethod getterPrototype = PropertyUtil.generateGetterPrototype(psiField); + final PsiMethod getter = containingClass.findMethodBySignature(getterPrototype, true); + if (getter != null && PsiUtil.isAccessible(getter, place, accessObjectClass)) { + QuickFixAction.registerQuickFixAction(error, QUICK_FIX_FACTORY.createReplaceInaccessibleFieldWithGetterSetterFix(place, getter, false)); + } + } + } + } + } + private enum Feature { GENERICS(LanguageLevel.JDK_1_5, "feature.generics"), ANNOTATIONS(LanguageLevel.JDK_1_5, "feature.annotations"), @@ -2678,8 +2710,8 @@ public class HighlightUtil extends HighlightUtilBase { if (containingFile.getManager().isInProject(containingFile) && !languageLevel.isAtLeast(feature.level)) { String message = JavaErrorMessages.message("insufficient.language.level", JavaErrorMessages.message(feature.key)); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(message).create(); - QuickFixAction.registerQuickFixAction(info, new IncreaseLanguageLevelFix(feature.level)); - QuickFixAction.registerQuickFixAction(info, new ShowModulePropertiesFix(element)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createIncreaseLanguageLevelFix(feature.level)); + QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createShowModulePropertiesFix(element)); return info; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java similarity index 97% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index 4f70b16045d9..0aeb2bb8d1bd 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -16,11 +16,11 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeHighlighting.Pass; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx; import com.intellij.codeInsight.daemon.JavaErrorMessages; import com.intellij.codeInsight.daemon.impl.*; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; -import com.intellij.codeInsight.daemon.impl.quickfix.SetupJDKFix; +import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.TextAttributesScheme; @@ -37,12 +37,10 @@ import com.intellij.psi.*; import com.intellij.psi.controlFlow.ControlFlowUtil; import com.intellij.psi.impl.source.javadoc.PsiDocMethodOrFieldRef; import com.intellij.psi.impl.source.resolve.JavaResolveUtil; -import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; import com.intellij.psi.impl.source.tree.java.PsiReferenceExpressionImpl; import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.javadoc.PsiDocTagValue; import com.intellij.psi.util.*; -import com.intellij.psi.xml.XmlAttributeValue; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.MostlySingularMultiMap; import gnu.trove.THashMap; @@ -128,13 +126,15 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh element.accept(this); } - private void registerReferencesFromInjectedFragments(final PsiElement element) { - InjectedLanguageUtil.enumerate(element, myFile, false, new PsiLanguageInjectionHost.InjectedPsiVisitor() { - @Override - public void visit(@NotNull final PsiFile injectedPsi, @NotNull final List places) { - injectedPsi.accept(REGISTER_REFERENCES_VISITOR); - } - }); + private void registerReferencesFromInjectedFragments(@NotNull PsiElement element) { + InjectedLanguageManager.getInstance(myFile.getProject()).enumerateEx(element, myFile, false, + new PsiLanguageInjectionHost.InjectedPsiVisitor() { + @Override + public void visit(@NotNull final PsiFile injectedPsi, + @NotNull final List places) { + injectedPsi.accept(REGISTER_REFERENCES_VISITOR); + } + }); } @Override @@ -150,8 +150,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh myJavaSdkVersion = ObjectUtils.notNull(JavaVersionService.getInstance().getJavaSdkVersion(file), JavaSdkVersion.fromLanguageLevel(myLanguageLevel)); if (updateWholeFile) { Project project = file.getProject(); - DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(project); - FileStatusMap fileStatusMap = ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).getFileStatusMap(); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(project); + FileStatusMap fileStatusMap = daemonCodeAnalyzer.getFileStatusMap(); ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator == null) throw new IllegalStateException("Must be run under progress"); RefCountHolder refCountHolder = RefCountHolder.startUsing(file, indicator); @@ -183,10 +183,11 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh @Override public void visitElement(final PsiElement element) { - if (element instanceof XmlAttributeValue) { + if (myRefCountHolder != null && myFile instanceof ServerPageFile) { + // in jsp XmlAttributeValue may contain java references try { for (PsiReference reference : element.getReferences()) { - if(reference instanceof PsiJavaReference && myRefCountHolder != null){ + if(reference instanceof PsiJavaReference){ final PsiJavaReference psiJavaReference = (PsiJavaReference)reference; myRefCountHolder.registerReference(psiJavaReference, psiJavaReference.advancedResolve(false)); } @@ -612,7 +613,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh assert nameElement != null : ref; final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(nameElement).descriptionAndTooltip(description).create(); - QuickFixAction.registerQuickFixAction(info, SetupJDKFix.getInstance()); + QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createSetupJDKFix()); myHolder.add(info); } else { diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java similarity index 99% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java index a3f235e8a638..be85a959b55d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/IncreaseLanguageLevelFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java similarity index 93% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java index bfe2d8c45b33..cebb50c019ea 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ class QualifyWithThisFix implements IntentionAction { private final PsiClass myContainingClass; private final PsiElement myExpression; - public QualifyWithThisFix(PsiClass containingClass, PsiElement expression) { + public QualifyWithThisFix(@NotNull PsiClass containingClass, @NotNull PsiElement expression) { myContainingClass = containingClass; myExpression = expression; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java similarity index 94% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java index 0057749d056b..f574b49dc551 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsConditionalFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,12 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy; +import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.TypeConversionUtil; -import com.intellij.refactoring.util.RefactoringUtil; import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * User: anna @@ -83,7 +84,7 @@ public class AddTypeArgumentsConditionalFix implements IntentionAction { withTypeArgsText = expression.getText(); } else { - if (RefactoringUtil.isInStaticContext(myExpression, null) || myMethod.hasModifierProperty(PsiModifier.STATIC)) { + if (isInStaticContext(myExpression, null) || myMethod.hasModifierProperty(PsiModifier.STATIC)) { final PsiClass aClass = myMethod.getContainingClass(); LOG.assertTrue(aClass != null); withTypeArgsText = aClass.getQualifiedName(); @@ -97,6 +98,9 @@ public class AddTypeArgumentsConditionalFix implements IntentionAction { myExpression.replace(withTypeArgs); } + public static boolean isInStaticContext(PsiElement element, @Nullable final PsiClass aClass) { + return PsiUtil.getEnclosingStaticElement(element, aClass) != null; + } @Override public boolean startInWriteAction() { return true; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeCastFix.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ArgumentFixerActionFactory.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CastMethodArgumentFix.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeNewOperatorTypeFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeNewOperatorTypeFix.java similarity index 99% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeNewOperatorTypeFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeNewOperatorTypeFix.java index aad8171a4ba3..6fedf26f4e8d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeNewOperatorTypeFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeNewOperatorTypeFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeStringLiteralToCharInMethodCallFix.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeTypeArgumentsFix.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConstructorParametersFixer.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConstructorParametersFixer.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConstructorParametersFixer.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConstructorParametersFixer.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java similarity index 96% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java index 4a5189ec1935..6368386b29d1 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ConvertDoubleToFloatFix.java @@ -16,13 +16,13 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.daemon.impl.HighlightInfo; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; +import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -56,7 +56,7 @@ public class ConvertDoubleToFloatFix implements IntentionAction { if (!StringUtil.endsWithIgnoreCase(myExpression.getText(), "f")) { final PsiLiteralExpression expression = (PsiLiteralExpression)createFloatingPointExpression(project); final Object value = expression.getValue(); - return value instanceof Float && !((Float)value).isInfinite() && !(((Float)value).floatValue() == 0 && !HighlightUtil.isFPZero(expression.getText())); + return value instanceof Float && !((Float)value).isInfinite() && !(((Float)value).floatValue() == 0 && !TypeConversionUtil.isFPZero(expression.getText())); } } return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java similarity index 99% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java index 0b987facaea6..ae5493c272dc 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ExtendsListFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodArgumentFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodArgumentFix.java similarity index 87% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodArgumentFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodArgumentFix.java index afed0b1946b7..79fa60140959 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodArgumentFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/MethodArgumentFix.java @@ -36,7 +36,7 @@ public abstract class MethodArgumentFix implements IntentionAction { private final ArgumentFixerActionFactory myArgumentFixerActionFactory; protected final PsiType myToType; - protected MethodArgumentFix(PsiExpressionList list, int i, PsiType toType, ArgumentFixerActionFactory fixerActionFactory) { + protected MethodArgumentFix(@NotNull PsiExpressionList list, int i, @NotNull PsiType toType, @NotNull ArgumentFixerActionFactory fixerActionFactory) { myArgList = list; myIndex = i; myArgumentFixerActionFactory = fixerActionFactory; @@ -46,12 +46,11 @@ public abstract class MethodArgumentFix implements IntentionAction { @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return - myToType != null - && myToType.isValid() - && myArgList != null - && myArgList.getExpressions().length > myIndex - && myArgList.getExpressions()[myIndex] != null - && myArgList.getExpressions()[myIndex].isValid(); + myToType != null && + myToType.isValid() && + myArgList.getExpressions().length > myIndex && + myArgList.getExpressions()[myIndex] != null && + myArgList.getExpressions()[myIndex].isValid(); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/PermuteArgumentsFix.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java similarity index 89% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java index 1fdef3108ea3..4eeb1d7ee730 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java @@ -24,7 +24,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.daemon.impl.HighlightInfo; -import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; +import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; @@ -40,9 +40,10 @@ import org.jetbrains.annotations.NotNull; import java.util.HashSet; import java.util.Set; -public class QualifyThisArgumentFix extends PsiElementBaseIntentionAction { +public class QualifyThisArgumentFix implements IntentionAction { private final PsiThisExpression myExpression; private final PsiClass myPsiClass; + private String myText; public QualifyThisArgumentFix(@NotNull PsiThisExpression expression, @NotNull PsiClass psiClass) { @@ -50,12 +51,22 @@ public class QualifyThisArgumentFix extends PsiElementBaseIntentionAction { myPsiClass = psiClass; } + @Override + public boolean startInWriteAction() { + return true; + } + + @NotNull + @Override + public String getText() { + return myText; + } @Override - public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { if (!myExpression.isValid()) return false; if (!myPsiClass.isValid()) return false; - setText("Qualify this expression with \'" + myPsiClass.getQualifiedName() + "\'"); + myText = "Qualify this expression with \'" + myPsiClass.getQualifiedName() + "\'"; return true; } @@ -66,7 +77,7 @@ public class QualifyThisArgumentFix extends PsiElementBaseIntentionAction { } @Override - public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { myExpression.replace(RefactoringChangeUtil.createThisExpression(PsiManager.getInstance(project), myPsiClass)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java similarity index 100% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/RemoveRedundantArgumentsFix.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java similarity index 98% rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java index eab73d92313e..2f5d02264b9a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/WrapExpressionFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public class WrapExpressionFix implements IntentionAction { private final PsiClassType myExpectedType; private final boolean myPrimitiveExpected; - public WrapExpressionFix(PsiType expectedType, PsiExpression expression) { + public WrapExpressionFix(@NotNull PsiType expectedType, @NotNull PsiExpression expression) { myExpression = expression; myExpectedType = getClassType(expectedType, expression); myPrimitiveExpected = expectedType instanceof PsiPrimitiveType; diff --git a/java/java-impl/src/com/intellij/ide/highlighter/JavaHighlightingColors.java b/java/java-analysis-impl/src/com/intellij/ide/highlighter/JavaHighlightingColors.java similarity index 100% rename from java/java-impl/src/com/intellij/ide/highlighter/JavaHighlightingColors.java rename to java/java-analysis-impl/src/com/intellij/ide/highlighter/JavaHighlightingColors.java diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java index 8af7f8bd9c53..97629fbaff71 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/PostHighlightingPass.java @@ -18,10 +18,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.Pass; import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.CodeInsightSettings; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.daemon.HighlightDisplayKey; -import com.intellij.codeInsight.daemon.ImplicitUsageProvider; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.*; import com.intellij.codeInsight.daemon.impl.analysis.*; import com.intellij.codeInsight.daemon.impl.quickfix.*; import com.intellij.codeInsight.intention.EmptyIntentionAction; @@ -29,7 +26,6 @@ import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.IntentionManager; import com.intellij.codeInspection.*; import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection; -import com.intellij.codeInspection.ex.InspectionManagerEx; import com.intellij.codeInspection.reference.UnusedDeclarationFixProvider; import com.intellij.codeInspection.unusedImport.UnusedImportLocalInspection; import com.intellij.codeInspection.unusedParameters.UnusedParametersInspection; @@ -57,6 +53,7 @@ import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.PomNamedTarget; import com.intellij.profile.codeInspection.InspectionProjectProfileManager; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; @@ -123,15 +120,15 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { @Override public void doCollectInformation(@NotNull final ProgressIndicator progress) { - DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject); - final FileStatusMap fileStatusMap = ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).getFileStatusMap(); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + final FileStatusMap fileStatusMap = daemonCodeAnalyzer.getFileStatusMap(); final List highlights = new ArrayList(); final FileViewProvider viewProvider = myFile.getViewProvider(); final Set relevantLanguages = viewProvider.getLanguages(); final Set elementSet = new THashSet(); for (Language language : relevantLanguages) { PsiElement psiRoot = viewProvider.getPsi(language); - if (!HighlightLevelUtil.shouldHighlight(psiRoot)) continue; + if (!HighlightingLevelManager.getInstance(myProject).shouldHighlight(psiRoot)) continue; List elements = CollectHighlightsUtil.getElementsInRange(psiRoot, myStartOffset, myEndOffset); elementSet.addAll(elements); } @@ -282,7 +279,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { } } } - if (unusedImportEnabled && myFile instanceof PsiJavaFile && HighlightLevelUtil.shouldHighlight(myFile)) { + if (unusedImportEnabled && myFile instanceof PsiJavaFile && HighlightingLevelManager.getInstance(myProject).shouldHighlight(myFile)) { PsiImportList importList = ((PsiJavaFile)myFile).getImportList(); if (importList != null) { final PsiImportStatementBase[] imports = importList.getAllImportStatements(); @@ -302,7 +299,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { @Nullable private HighlightInfo processIdentifier(PsiIdentifier identifier, ProgressIndicator progress, GlobalUsageHelper helper) { - if (InspectionManagerEx.inspectionResultSuppressed(identifier, myUnusedSymbolInspection)) return null; + if (SuppressionUtil.inspectionResultSuppressed(identifier, myUnusedSymbolInspection)) return null; PsiElement parent = identifier.getParent(); if (PsiUtilCore.hasErrorElementChild(parent)) return null; @@ -504,7 +501,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { options.addAll(IntentionManager.getInstance().getStandardIntentionOptions(myUnusedSymbolKey, myFile)); if (myUnusedParametersInspection != null) { SuppressQuickFix[] batchSuppressActions = myUnusedParametersInspection.getBatchSuppressActions(parameter); - Collections.addAll(options, SuppressManagerImpl.convertBatchToSuppressIntentionActions(batchSuppressActions)); + Collections.addAll(options, SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions)); } //need suppress from Unused Parameters but settings from Unused Symbol QuickFixAction.registerQuickFixAction(highlightInfo, new RemoveUnusedParameterFix(parameter), @@ -764,12 +761,12 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { PsiJavaCodeReferenceElement reference = importStatement.getImportReference(); PsiElement resolved = reference == null ? null : reference.resolve(); if (resolved instanceof PsiPackage) { - isRedundant = packageName.equals(((PsiPackage)resolved).getQualifiedName()); + isRedundant = packageName.equals(((PsiQualifiedNamedElement)resolved).getQualifiedName()); } else if (resolved instanceof PsiClass && !importStatement.isOnDemand()) { String qName = ((PsiClass)resolved).getQualifiedName(); if (qName != null) { - String name = ((PsiClass)resolved).getName(); + String name = ((PomNamedTarget)resolved).getName(); isRedundant = qName.equals(packageName + '.' + name); } } @@ -803,7 +800,7 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { private boolean timeToOptimizeImports() { if (!CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY) return false; - DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject); + DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument); // dont optimize out imports in JSP since it can be included in other JSP if (file == null || !codeAnalyzer.isHighlightingAvailable(file) || !(file instanceof PsiJavaFile) || file instanceof ServerPageFile) return false; @@ -811,22 +808,23 @@ public class PostHighlightingPass extends TextEditorHighlightingPass { if (!codeAnalyzer.isErrorAnalyzingFinished(file)) return false; boolean errors = containsErrorsPreventingOptimize(file); - return !errors && codeAnalyzer.canChangeFileSilently(myFile); + return !errors && DaemonListeners.canChangeFileSilently(myFile); } private boolean containsErrorsPreventingOptimize(@NotNull PsiFile file) { // ignore unresolved imports errors PsiImportList importList = ((PsiJavaFile)file).getImportList(); final TextRange importsRange = importList == null ? TextRange.EMPTY_RANGE : importList.getTextRange(); - boolean hasErrorsExceptUnresolvedImports = !DaemonCodeAnalyzerImpl.processHighlights(myDocument, myProject, HighlightSeverity.ERROR, 0, myDocument.getTextLength(), new Processor() { - @Override - public boolean process(HighlightInfo error) { - int infoStart = error.getActualStartOffset(); - int infoEnd = error.getActualEndOffset(); + boolean hasErrorsExceptUnresolvedImports = !DaemonCodeAnalyzerEx + .processHighlights(myDocument, myProject, HighlightSeverity.ERROR, 0, myDocument.getTextLength(), new Processor() { + @Override + public boolean process(HighlightInfo error) { + int infoStart = error.getActualStartOffset(); + int infoEnd = error.getActualEndOffset(); - return importsRange.containsRange(infoStart,infoEnd) && error.type.equals(HighlightInfoType.WRONG_REF); - } - }); + return importsRange.containsRange(infoStart, infoEnd) && error.type.equals(HighlightInfoType.WRONG_REF); + } + }); return hasErrorsExceptUnresolvedImports; } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java index 1fecce120b74..dbf454207cca 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeMethodSignatureFromUsageFix.java @@ -18,7 +18,6 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.TargetElementUtil; import com.intellij.codeInsight.daemon.QuickFixBundle; -import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.find.FindManager; @@ -34,7 +33,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; @@ -71,11 +69,11 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig ParameterInfoImpl[] myNewParametersInfo; private static final Logger LOG = Logger.getInstance(ChangeMethodSignatureFromUsageFix.class); - ChangeMethodSignatureFromUsageFix(@NotNull PsiMethod targetMethod, - @NotNull PsiExpression[] expressions, - @NotNull PsiSubstitutor substitutor, - @NotNull PsiElement context, - boolean changeAllUsages, int minUsagesNumberToShowDialog) { + public ChangeMethodSignatureFromUsageFix(@NotNull PsiMethod targetMethod, + @NotNull PsiExpression[] expressions, + @NotNull PsiSubstitutor substitutor, + @NotNull PsiElement context, + boolean changeAllUsages, int minUsagesNumberToShowDialog) { myTargetMethod = targetMethod; myExpressions = expressions; mySubstitutor = substitutor; @@ -457,32 +455,6 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig } } - public static void registerIntentions(@NotNull JavaResolveResult[] candidates, - @NotNull PsiExpressionList list, - @Nullable HighlightInfo highlightInfo, - TextRange fixRange) { - if (candidates.length == 0) return; - PsiExpression[] expressions = list.getExpressions(); - for (JavaResolveResult candidate : candidates) { - registerIntention(expressions, highlightInfo, fixRange, candidate, list); - } - } - - private static void registerIntention(@NotNull PsiExpression[] expressions, - @Nullable HighlightInfo highlightInfo, - TextRange fixRange, - @NotNull JavaResolveResult candidate, - @NotNull PsiElement context) { - if (!candidate.isStaticsScopeCorrect()) return; - PsiMethod method = (PsiMethod)candidate.getElement(); - PsiSubstitutor substitutor = candidate.getSubstitutor(); - if (method != null && context.getManager().isInProject(method)) { - ChangeMethodSignatureFromUsageFix fix = new ChangeMethodSignatureFromUsageFix(method, expressions, substitutor, context, false, 2); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, fix); - QuickFixAction.registerQuickFixAction(highlightInfo, fixRange, new ChangeMethodSignatureFromUsageReverseOrderFix(method, expressions, substitutor, context, false, 2)); - } - } - @Override public boolean startInWriteAction() { return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeParameterClassFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeParameterClassFix.java index b6b13a4cc9e8..80df581fc014 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeParameterClassFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ChangeParameterClassFix.java @@ -26,17 +26,18 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.CodeInsightUtil; import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.QuickFixBundle; -import com.intellij.codeInsight.daemon.impl.HighlightInfo; +import com.intellij.codeInsight.generation.OverrideImplementExploreUtil; import com.intellij.codeInsight.generation.OverrideImplementUtil; import com.intellij.codeInsight.generation.PsiMethodMember; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.undo.UndoUtil; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.psi.*; +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiClassType; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.infos.CandidateInfo; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.TypeConversionUtil; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -45,7 +46,7 @@ import org.jetbrains.annotations.Nullable; import java.util.Collection; public class ChangeParameterClassFix extends ExtendsListFix { - private ChangeParameterClassFix(PsiClass aClassToExtend, PsiClassType parameterClass) { + public ChangeParameterClassFix(@NotNull PsiClass aClassToExtend, @NotNull PsiClassType parameterClass) { super(aClassToExtend, parameterClass, true); } @@ -86,7 +87,7 @@ public class ChangeParameterClassFix extends ExtendsListFix { ); final Editor editor1 = CodeInsightUtil.positionCursor(project, myClass.getContainingFile(), myClass); if (editor1 == null) return; - final Collection toImplement = OverrideImplementUtil.getMethodsToOverrideImplement(myClass, true); + final Collection toImplement = OverrideImplementExploreUtil.getMethodsToOverrideImplement(myClass, true); if (!toImplement.isEmpty()) { if (ApplicationManager.getApplication().isUnitTestMode()) { ApplicationManager.getApplication().runWriteAction( @@ -114,44 +115,6 @@ public class ChangeParameterClassFix extends ExtendsListFix { UndoUtil.markPsiFileForUndo(file); } - public static void registerQuickFixAction(PsiType lType, PsiType rType, HighlightInfo info) { - final PsiClass lClass = PsiUtil.resolveClassInClassTypeOnly(lType); - final PsiClass rClass = PsiUtil.resolveClassInClassTypeOnly(rType); - - if (rClass == null || lClass == null) return; - if (rClass instanceof PsiAnonymousClass) return; - if (rClass.isInheritor(lClass, true)) return; - if (lClass.isInheritor(rClass, true)) return; - if (lClass == rClass) return; - - QuickFixAction.registerQuickFixAction(info, new ChangeParameterClassFix(rClass, (PsiClassType)lType)); - } - - public static void registerQuickFixActions(PsiCall methodCall, PsiExpressionList list, HighlightInfo highlightInfo) { - final JavaResolveResult result = methodCall.resolveMethodGenerics(); - PsiMethod method = (PsiMethod)result.getElement(); - final PsiSubstitutor substitutor = result.getSubstitutor(); - PsiExpression[] expressions = list.getExpressions(); - if (method == null) return; - final PsiParameter[] parameters = method.getParameterList().getParameters(); - if (parameters.length != expressions.length) return; - for (int i = 0; i < expressions.length; i++) { - final PsiExpression expression = expressions[i]; - final PsiParameter parameter = parameters[i]; - final PsiType expressionType = expression.getType(); - final PsiType parameterType = substitutor.substitute(parameter.getType()); - if (expressionType == null || expressionType instanceof PsiPrimitiveType || TypeConversionUtil.isNullType(expressionType) || expressionType instanceof PsiArrayType) continue; - if (parameterType instanceof PsiPrimitiveType || TypeConversionUtil.isNullType(parameterType) || parameterType instanceof PsiArrayType) continue; - if (parameterType.isAssignableFrom(expressionType)) continue; - PsiClass parameterClass = PsiUtil.resolveClassInType(parameterType); - PsiClass expressionClass = PsiUtil.resolveClassInType(expressionType); - if (parameterClass == null || expressionClass == null) continue; - if (expressionClass instanceof PsiAnonymousClass) continue; - if (parameterClass.isInheritor(expressionClass, true)) continue; - QuickFixAction.registerQuickFixAction(highlightInfo, new ChangeParameterClassFix(expressionClass, (PsiClassType)parameterType)); - } - } - @Override public boolean startInWriteAction() { return false; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java index 73751439f21e..3f02e6edc72d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java @@ -17,8 +17,8 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.CodeInsightUtilCore; import com.intellij.codeInsight.ExpectedTypeInfo; +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx; import com.intellij.codeInsight.daemon.QuickFixBundle; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.template.Template; import com.intellij.codeInsight.template.TemplateBuilderImpl; @@ -94,15 +94,15 @@ public class CreateMethodFromUsageFix extends CreateFromUsageBaseFix { PsiExpressionList argumentList = call.getArgumentList(); final TextRange argRange = argumentList.getTextRange(); - return !DaemonCodeAnalyzerImpl.processHighlights(document, project, HighlightSeverity.ERROR, - //strictly inside arg list - argRange.getStartOffset()+1, - argRange.getEndOffset()-1, new Processor() { - @Override - public boolean process(HighlightInfo info) { - return !(info.getActualStartOffset() > argRange.getStartOffset() && info.getActualEndOffset() < argRange.getEndOffset()); - } - }); + return !DaemonCodeAnalyzerEx.processHighlights(document, project, HighlightSeverity.ERROR, + //strictly inside arg list + argRange.getStartOffset() + 1, + argRange.getEndOffset() - 1, new Processor() { + @Override + public boolean process(HighlightInfo info) { + return !(info.getActualStartOffset() > argRange.getStartOffset() && info.getActualEndOffset() < argRange.getEndOffset()); + } + }); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DefaultQuickFixProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DefaultQuickFixProvider.java index 06704aaed162..f69714427d29 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DefaultQuickFixProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/DefaultQuickFixProvider.java @@ -18,6 +18,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.daemon.QuickFixActionRegistrar; import com.intellij.codeInsight.daemon.impl.analysis.HighlightMethodUtil; import com.intellij.codeInsight.intention.IntentionAction; +import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.codeInsight.intention.impl.PriorityIntentionActionWrapper; import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider; import com.intellij.openapi.util.TextRange; @@ -34,8 +35,9 @@ import java.util.Map; public class DefaultQuickFixProvider extends UnresolvedReferenceQuickFixProvider { @Override public void registerFixes(@NotNull PsiJavaCodeReferenceElement ref, @NotNull QuickFixActionRegistrar registrar) { + QuickFixFactory factory = QuickFixFactory.getInstance(); registrar.register(new ImportClassFix(ref)); - registrar.register(SetupJDKFix.getInstance()); + registrar.register(factory.createSetupJDKFix()); OrderEntryFix.registerFixes(registrar, ref); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementAbstractClassMethodsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementAbstractClassMethodsFix.java new file mode 100644 index 000000000000..d9c2dbbfb19a --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImplementAbstractClassMethodsFix.java @@ -0,0 +1,113 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.quickfix; + +import com.intellij.codeInsight.FileModificationService; +import com.intellij.codeInsight.generation.OverrideImplementUtil; +import com.intellij.codeInsight.generation.PsiMethodMember; +import com.intellij.ide.util.MemberChooser; +import com.intellij.openapi.application.Result; +import com.intellij.openapi.command.WriteCommandAction; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.psi.*; +import com.intellij.psi.util.TypeConversionUtil; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ImplementAbstractClassMethodsFix extends ImplementMethodsFix { + public ImplementAbstractClassMethodsFix(PsiElement highlightElement) { + super(highlightElement); + } + + @Override + public boolean isAvailable(@NotNull Project project, + @NotNull PsiFile file, + @NotNull PsiElement startElement, + @NotNull PsiElement endElement) { + if (startElement instanceof PsiNewExpression) { + final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); + String startElementText = startElement.getText(); + try { + PsiNewExpression newExpression = + (PsiNewExpression)elementFactory.createExpressionFromText(startElementText + "{}", startElement); + if (newExpression.getAnonymousClass() == null) { + try { + newExpression = (PsiNewExpression)elementFactory.createExpressionFromText(startElementText + "){}", startElement); + } + catch (IncorrectOperationException e) { + return false; + } + if (newExpression.getAnonymousClass() == null) return false; + } + } + catch (IncorrectOperationException e) { + return false; + } + return true; + } + return false; + } + + @Override + public void invoke(@NotNull final Project project, + @NotNull PsiFile file, + @Nullable("is null when called from inspection") final Editor editor, + @NotNull final PsiElement startElement, + @NotNull PsiElement endElement) { + final PsiFile containingFile = startElement.getContainingFile(); + if (editor == null || !FileModificationService.getInstance().prepareFileForWrite(containingFile)) return; + PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)startElement).getClassReference(); + if (classReference == null) return; + final PsiClass psiClass = (PsiClass)classReference.resolve(); + if (psiClass == null) return; + final MemberChooser chooser = chooseMethodsToImplement(editor, startElement, psiClass, false); + if (chooser == null) return; + + final List selectedElements = chooser.getSelectedElements(); + if (selectedElements == null || selectedElements.isEmpty()) return; + + new WriteCommandAction(project, file) { + @Override + protected void run(final Result result) throws Throwable { + PsiNewExpression newExpression = + (PsiNewExpression)JavaPsiFacade.getElementFactory(project).createExpressionFromText(startElement.getText() + "{}", startElement); + newExpression = (PsiNewExpression)startElement.replace(newExpression); + final PsiClass psiClass = newExpression.getAnonymousClass(); + if (psiClass == null) return; + Map subst = new HashMap(); + for (PsiMethodMember selectedElement : selectedElements) { + final PsiClass baseClass = selectedElement.getElement().getContainingClass(); + if (baseClass != null) { + PsiSubstitutor substitutor = subst.get(baseClass); + if (substitutor == null) { + substitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, psiClass, PsiSubstitutor.EMPTY); + subst.put(baseClass, substitutor); + } + selectedElement.setSubstitutor(substitutor); + } + } + OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(editor, psiClass, selectedElements, chooser.isCopyJavadoc(), + chooser.isInsertOverrideAnnotation()); + } + }.execute(); + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java index abc31adfaf57..ad235264421d 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/ImportClassFixBase.java @@ -19,10 +19,9 @@ import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.CodeInsightUtil; import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.completion.JavaCompletionUtil; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings; import com.intellij.codeInsight.daemon.QuickFixBundle; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; +import com.intellij.codeInsight.daemon.impl.DaemonListeners; import com.intellij.codeInsight.daemon.impl.ShowAutoImportPass; import com.intellij.codeInsight.daemon.impl.actions.AddImportAction; import com.intellij.codeInsight.hint.HintManager; @@ -282,8 +281,6 @@ public abstract class ImportClassFixBase map = new HashMap(); - for (int j = 0; j < classTypeParameters.length; j++) { - PsiTypeParameter classTypeParameter = classTypeParameters[j]; - PsiType actualTypeParameter = actualTypeParameters[j]; - map.put(classTypeParameter, actualTypeParameter); - } - PsiSubstitutor substitutor = factory.createSubstitutor(map); - PsiType suggestedType = factory.createType(aClass, substitutor); - HighlightUtil.registerChangeVariableTypeFixes(variable, suggestedType, highlightInfo); - } - } - } -} diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java index 1b43c1b75008..e2a70d8dfada 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/VariableTypeFromCallFix.java @@ -21,7 +21,6 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.daemon.QuickFixBundle; -import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.Editor; @@ -34,15 +33,18 @@ import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; import com.intellij.refactoring.typeMigration.TypeMigrationProcessor; import com.intellij.refactoring.typeMigration.TypeMigrationRules; import com.intellij.usageView.UsageViewUtil; -import com.intellij.usages.impl.UsageViewImpl; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + public class VariableTypeFromCallFix implements IntentionAction { private final PsiType myExpressionType; private final PsiVariable myVar; - public VariableTypeFromCallFix(PsiClassType type, PsiVariable var) { + private VariableTypeFromCallFix(@NotNull PsiClassType type, @NotNull PsiVariable var) { myExpressionType = type; myVar = var; } @@ -82,13 +84,16 @@ public class VariableTypeFromCallFix implements IntentionAction { } - public static void registerQuickFixActions(PsiMethodCallExpression methodCall, PsiExpressionList list, HighlightInfo highlightInfo) { + @NotNull + public static List getQuickFixActions(@NotNull PsiMethodCallExpression methodCall, + @NotNull PsiExpressionList list) { final JavaResolveResult result = methodCall.getMethodExpression().advancedResolve(false); PsiMethod method = (PsiMethod) result.getElement(); final PsiSubstitutor substitutor = result.getSubstitutor(); PsiExpression[] expressions = list.getExpressions(); - if (method == null || method.getParameterList().getParametersCount() != expressions.length) return; + if (method == null || method.getParameterList().getParametersCount() != expressions.length) return Collections.emptyList(); final PsiParameter[] parameters = method.getParameterList().getParameters(); + List actions = new ArrayList(); for (int i = 0; i < expressions.length; i++) { final PsiExpression expression = expressions[i]; PsiType expressionType = expression.getType(); @@ -116,32 +121,35 @@ public class VariableTypeFromCallFix implements IntentionAction { DefaultParameterTypeInferencePolicy.INSTANCE); final PsiClassType appropriateVarType = JavaPsiFacade.getElementFactory(expression.getProject()).createType(varClass, psiSubstitutor); if (!varType.equals(appropriateVarType)) { - QuickFixAction.registerQuickFixAction(highlightInfo, new VariableTypeFromCallFix(appropriateVarType, (PsiVariable) resolved)); + actions.add(new VariableTypeFromCallFix(appropriateVarType, (PsiVariable)resolved)); } break; } } } - registerParameterTypeChange(highlightInfo, method, expression, parameterType); + actions.addAll(getParameterTypeChangeFixes(method, expression, parameterType)); } + return actions; } - private static void registerParameterTypeChange(HighlightInfo highlightInfo, - PsiMethod method, - PsiExpression expression, - PsiType parameterType) { - if (expression instanceof PsiReferenceExpression) { - final PsiManager manager = method.getManager(); - if (manager.isInProject(method)) { - final PsiMethod[] superMethods = method.findDeepestSuperMethods(); - for (PsiMethod superMethod : superMethods) { - if (!manager.isInProject(superMethod)) return; - } - final PsiElement resolve = ((PsiReferenceExpression)expression).resolve(); - if (resolve instanceof PsiVariable) { - HighlightUtil.registerChangeVariableTypeFixes((PsiVariable)resolve, parameterType, highlightInfo); - } + private static List getParameterTypeChangeFixes(@NotNull PsiMethod method, + @NotNull PsiExpression expression, + PsiType parameterType) { + if (!(expression instanceof PsiReferenceExpression)) { + return Collections.emptyList(); + } + List result = new ArrayList(); + final PsiManager manager = method.getManager(); + if (manager.isInProject(method)) { + final PsiMethod[] superMethods = method.findDeepestSuperMethods(); + for (PsiMethod superMethod : superMethods) { + if (!manager.isInProject(superMethod)) return Collections.emptyList(); + } + final PsiElement resolve = ((PsiReferenceExpression)expression).resolve(); + if (resolve instanceof PsiVariable) { + result.addAll(HighlightUtil.getChangeVariableTypeFixes((PsiVariable)resolve, parameterType)); } } + return result; } } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java index 6ba29bbc1c45..dcbf1a7bd045 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java @@ -15,6 +15,9 @@ */ package com.intellij.codeInsight.intention.impl.config; +import com.intellij.codeInsight.daemon.QuickFixActionRegistrar; +import com.intellij.codeInsight.daemon.impl.analysis.IncreaseLanguageLevelFix; +import com.intellij.codeInsight.daemon.impl.quickfix.ReplacePrimitiveWithBoxedTypeAction; import com.intellij.codeInsight.daemon.impl.quickfix.*; import com.intellij.codeInsight.daemon.quickFix.CreateClassOrPackageFix; import com.intellij.codeInsight.daemon.quickFix.CreateFieldOrPropertyFix; @@ -22,12 +25,16 @@ import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement; import com.intellij.codeInspection.LocalQuickFixOnPsiElement; +import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.*; +import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PropertyMemberType; import com.intellij.psi.util.ClassKind; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; + /** * @author cdr */ @@ -163,4 +170,400 @@ public class QuickFixFactoryImpl extends QuickFixFactory { return new CreateFieldOrPropertyFix(aClass, name, type, targetMember, annotations); } + @NotNull + @Override + public IntentionAction createSetupJDKFix() { + return SetupJDKFix.getInstance(); + } + + @NotNull + @Override + public IntentionAction createAddExceptionToCatchFix() { + return new AddExceptionToCatchFix(); + } + + @NotNull + @Override + public IntentionAction createAddExceptionToThrowsFix(@NotNull PsiElement element) { + return new AddExceptionToThrowsFix(element); + } + + @NotNull + @Override + public IntentionAction createSurroundWithTryCatchFix(@NotNull PsiElement element) { + return new SurroundWithTryCatchFix(element); + } + + @NotNull + @Override + public IntentionAction createGeneralizeCatchFix(@NotNull PsiElement element, @NotNull PsiClassType type) { + return new GeneralizeCatchFix(element, type); + } + + @NotNull + @Override + public IntentionAction createChangeToAppendFix(@NotNull IElementType sign, + @NotNull PsiType type, + @NotNull PsiAssignmentExpression assignment) { + return new ChangeToAppendFix(sign, type, assignment); + } + + @NotNull + @Override + public IntentionAction createAddTypeCastFix(@NotNull PsiType type, @NotNull PsiExpression expression) { + return new AddTypeCastFix(type, expression); + } + + @NotNull + @Override + public IntentionAction createWrapExpressionFix(@NotNull PsiType type, @NotNull PsiExpression expression) { + return new WrapExpressionFix(type, expression); + } + + @NotNull + @Override + public IntentionAction createReuseVariableDeclarationFix(@NotNull PsiLocalVariable variable) { + return new ReuseVariableDeclarationFix(variable); + } + + @NotNull + @Override + public IntentionAction createConvertToStringLiteralAction() { + return new ConvertToStringLiteralAction(); + } + + @NotNull + @Override + public IntentionAction createDeleteCatchFix(@NotNull PsiParameter parameter) { + return new DeleteCatchFix(parameter); + } + + @NotNull + @Override + public IntentionAction createDeleteMultiCatchFix(@NotNull PsiTypeElement element) { + return new DeleteMultiCatchFix(element); + } + + @NotNull + @Override + public IntentionAction createConvertSwitchToIfIntention(@NotNull PsiSwitchStatement statement) { + return new ConvertSwitchToIfIntention(statement); + } + + @NotNull + @Override + public IntentionAction createNegationBroadScopeFix(@NotNull PsiPrefixExpression expr) { + return new NegationBroadScopeFix(expr); + } + + @NotNull + @Override + public IntentionAction createCreateFieldFromUsageFix(@NotNull PsiReferenceExpression place) { + return new CreateFieldFromUsageFix(place); + } + + @NotNull + @Override + public IntentionAction createReplaceWithListAccessFix(@NotNull PsiArrayAccessExpression expression) { + return new ReplaceWithListAccessFix(expression); + } + + @NotNull + @Override + public IntentionAction createAddNewArrayExpressionFix(@NotNull PsiArrayInitializerExpression expression) { + return new AddNewArrayExpressionFix(expression); + } + + @NotNull + @Override + public IntentionAction createMoveCatchUpFix(@NotNull PsiCatchSection section, @NotNull PsiCatchSection section1) { + return new MoveCatchUpFix(section, section1); + } + + @NotNull + @Override + public IntentionAction createRenameWrongRefFix(@NotNull PsiReferenceExpression ref) { + return new RenameWrongRefFix(ref); + } + + @NotNull + @Override + public IntentionAction createRemoveQualifierFix(@NotNull PsiExpression qualifier, + @NotNull PsiReferenceExpression expression, + @NotNull PsiClass resolved) { + return new RemoveQualifierFix(qualifier, expression, resolved); + } + + @NotNull + @Override + public IntentionAction createRemoveParameterListFix(@NotNull PsiMethod parent) { + return new RemoveParameterListFix(parent); + } + + @NotNull + @Override + public IntentionAction createShowModulePropertiesFix(@NotNull PsiElement element) { + return new ShowModulePropertiesFix(element); + } + + @NotNull + @Override + public IntentionAction createIncreaseLanguageLevelFix(@NotNull LanguageLevel level) { + return new IncreaseLanguageLevelFix(level); + } + + @NotNull + @Override + public IntentionAction createChangeParameterClassFix(@NotNull PsiClass aClass, @NotNull PsiClassType type) { + return new ChangeParameterClassFix(aClass, type); + } + + @NotNull + @Override + public IntentionAction createReplaceInaccessibleFieldWithGetterSetterFix(@NotNull PsiElement element, @NotNull PsiMethod getter, boolean isSetter) { + return new ReplaceInaccessibleFieldWithGetterSetterFix(element, getter, isSetter); + } + + @NotNull + @Override + public IntentionAction createSurroundWithArrayFix(@Nullable PsiCall methodCall, @Nullable PsiExpression expression) { + return new SurroundWithArrayFix(methodCall, expression); + } + + @NotNull + @Override + public IntentionAction createImplementAbstractClassMethodsFix(@NotNull PsiElement elementToHighlight) { + return new ImplementAbstractClassMethodsFix(elementToHighlight); + } + + @NotNull + @Override + public IntentionAction createMoveClassToSeparateFileFix(@NotNull PsiClass aClass) { + return new MoveClassToSeparateFileFix(aClass); + } + + @NotNull + @Override + public IntentionAction createRenameFileFix(@NotNull String newName) { + return new RenameFileFix(newName); + } + + @NotNull + @Override + public IntentionAction createRenameElementFix(@NotNull PsiNamedElement element) { + return new RenameElementFix(element); + } + + @NotNull + @Override + public IntentionAction createRenameElementFix(@NotNull PsiNamedElement element, @NotNull String newName) { + return new RenameElementFix(element, newName); + } + + @NotNull + @Override + public IntentionAction createChangeExtendsToImplementsFix(@NotNull PsiClass aClass, @NotNull PsiClassType classToExtendFrom) { + return new ChangeExtendsToImplementsFix(aClass, classToExtendFrom); + } + + @NotNull + @Override + public IntentionAction createCreateConstructorMatchingSuperFix(@NotNull PsiClass aClass) { + return new CreateConstructorMatchingSuperFix(aClass); + } + + @NotNull + @Override + public IntentionAction createRemoveNewQualifierFix(@NotNull PsiNewExpression expression, PsiClass aClass) { + return new RemoveNewQualifierFix(expression, aClass); + } + + @NotNull + @Override + public IntentionAction createSuperMethodReturnFix(@NotNull PsiMethod superMethod, @NotNull PsiType superMethodType) { + return new SuperMethodReturnFix(superMethod, superMethodType); + } + + @NotNull + @Override + public IntentionAction createInsertNewFix(@NotNull PsiMethodCallExpression call, @NotNull PsiClass aClass) { + return new InsertNewFix(call, aClass); + } + + @NotNull + @Override + public IntentionAction createAddMethodBodyFix(@NotNull PsiMethod method) { + return new AddMethodBodyFix(method); + } + + @NotNull + @Override + public IntentionAction createDeleteMethodBodyFix(@NotNull PsiMethod method) { + return new DeleteMethodBodyFix(method); + } + + @NotNull + @Override + public IntentionAction createInsertSuperFix(@NotNull PsiMethod constructor) { + return new InsertSuperFix(constructor); + } + + @NotNull + @Override + public IntentionAction createChangeMethodSignatureFromUsageFix(@NotNull PsiMethod targetMethod, + @NotNull PsiExpression[] expressions, + @NotNull PsiSubstitutor substitutor, + @NotNull PsiElement context, + boolean changeAllUsages, + int minUsagesNumberToShowDialog) { + return new ChangeMethodSignatureFromUsageFix(targetMethod, expressions, substitutor, context, changeAllUsages, minUsagesNumberToShowDialog); + } + + @NotNull + @Override + public IntentionAction createChangeMethodSignatureFromUsageReverseOrderFix(@NotNull PsiMethod targetMethod, + @NotNull PsiExpression[] expressions, + @NotNull PsiSubstitutor substitutor, + @NotNull PsiElement context, + boolean changeAllUsages, + int minUsagesNumberToShowDialog) { + return new ChangeMethodSignatureFromUsageReverseOrderFix(targetMethod, expressions, substitutor, context, changeAllUsages, minUsagesNumberToShowDialog); + } + + @NotNull + @Override + public IntentionAction createCreateMethodFromUsageFix(@NotNull PsiMethodCallExpression call) { + return new CreateMethodFromUsageFix(call); + } + + @NotNull + @Override + public IntentionAction createCreateAbstractMethodFromUsageFix(@NotNull PsiMethodCallExpression call) { + return new CreateAbstractMethodFromUsageFix(call); + } + + @NotNull + @Override + public IntentionAction createCreatePropertyFromUsageFix(@NotNull PsiMethodCallExpression call) { + return new CreatePropertyFromUsageFix(call); + } + + @NotNull + @Override + public IntentionAction createCreateConstructorFromSuperFix(@NotNull PsiMethodCallExpression call) { + return new CreateConstructorFromSuperFix(call); + } + + @NotNull + @Override + public IntentionAction createCreateConstructorFromThisFix(@NotNull PsiMethodCallExpression call) { + return new CreateConstructorFromThisFix(call); + } + + @NotNull + @Override + public IntentionAction createCreateGetterSetterPropertyFromUsageFix(@NotNull PsiMethodCallExpression call) { + return new CreateGetterSetterPropertyFromUsageFix(call); + } + + @NotNull + @Override + public IntentionAction createStaticImportMethodFix(@NotNull PsiMethodCallExpression call) { + return new StaticImportMethodFix(call); + } + + @NotNull + @Override + public IntentionAction createReplaceAddAllArrayToCollectionFix(@NotNull PsiMethodCallExpression call) { + return new ReplaceAddAllArrayToCollectionFix(call); + } + + @NotNull + @Override + public IntentionAction createCreateConstructorFromCallFix(@NotNull PsiConstructorCall call) { + return new CreateConstructorFromCallFix(call); + } + + @NotNull + @Override + public List getVariableTypeFromCallFixes(@NotNull PsiMethodCallExpression call, @NotNull PsiExpressionList list) { + return VariableTypeFromCallFix.getQuickFixActions(call, list); + } + + @NotNull + @Override + public IntentionAction createAddReturnFix(@NotNull PsiMethod method) { + return new AddReturnFix(method); + } + + @NotNull + @Override + public IntentionAction createAddVariableInitializerFix(@NotNull PsiVariable variable) { + return new AddVariableInitializerFix(variable); + } + + @NotNull + @Override + public IntentionAction createDeferFinalAssignmentFix(@NotNull PsiVariable variable, @NotNull PsiReferenceExpression expression) { + return new DeferFinalAssignmentFix(variable, expression); + } + + @NotNull + @Override + public IntentionAction createVariableAccessFromInnerClassFix(@NotNull PsiVariable variable, @NotNull PsiClass aClass) { + return new VariableAccessFromInnerClassFix(variable, aClass); + } + + @NotNull + @Override + public IntentionAction createCreateConstructorParameterFromFieldFix(@NotNull PsiField field) { + return new CreateConstructorParameterFromFieldFix(field); + } + + @NotNull + @Override + public IntentionAction createInitializeFinalFieldInConstructorFix(@NotNull PsiField field) { + return new InitializeFinalFieldInConstructorFix(field); + } + + @NotNull + @Override + public IntentionAction createRemoveTypeArgumentsFix(@NotNull PsiElement variable) { + return new RemoveTypeArgumentsFix(variable); + } + + @NotNull + @Override + public IntentionAction createChangeClassSignatureFromUsageFix(@NotNull PsiClass owner, @NotNull PsiReferenceParameterList parameterList) { + return new ChangeClassSignatureFromUsageFix(owner, parameterList); + } + + @NotNull + @Override + public IntentionAction createReplacePrimitiveWithBoxedTypeAction(@NotNull PsiTypeElement element, @NotNull String typeName, @NotNull String boxedTypeName) { + return new ReplacePrimitiveWithBoxedTypeAction(element, typeName, boxedTypeName); + } + + @NotNull + @Override + public IntentionAction createMakeVarargParameterLastFix(@NotNull PsiParameter parameter) { + return new MakeVarargParameterLastFix(parameter); + } + + @NotNull + @Override + public IntentionAction createMoveBoundClassToFrontFix(@NotNull PsiClass aClass, @NotNull PsiClassType type) { + return new MoveBoundClassToFrontFix(aClass, type); + } + + @Override + public void registerPullAsAbstractUpFixes(@NotNull PsiMethod method, @NotNull QuickFixActionRegistrar registrar) { + PullAsAbstractUpFix.registerQuickFix(method, registrar); + } + + @Override + public IntentionAction createCreateAnnotationMethodFromUsageFix(PsiNameValuePair pair) { + return new CreateAnnotationMethodFromUsageFix(pair); + } + } diff --git a/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java index c67f925d6c09..ca3131d325eb 100644 --- a/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java @@ -24,8 +24,6 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.psi.PsiDocCommentOwner; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiModifierListOwner; -import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -36,17 +34,7 @@ public class SuppressManagerImpl extends SuppressManager { @NotNull public SuppressIntentionAction[] createSuppressActions(@NotNull final HighlightDisplayKey displayKey) { SuppressQuickFix[] batchSuppressActions = createBatchSuppressActions(displayKey); - return convertBatchToSuppressIntentionActions(batchSuppressActions); - } - - @NotNull - public static SuppressIntentionAction[] convertBatchToSuppressIntentionActions(@NotNull SuppressQuickFix[] actions) { - return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function() { - @Override - public SuppressIntentionAction fun(SuppressQuickFix fix) { - return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction(fix); - } - }); + return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions); } @Override diff --git a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java index 7887f0dca5f8..c86cbc4057b0 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/TypeConversionUtil.java @@ -1444,6 +1444,16 @@ public class TypeConversionUtil { return null; } + // true if floating point literal consists of zeros only + public static boolean isFPZero(@NotNull final String text) { + for (int i = 0; i < text.length(); i++) { + final char c = text.charAt(i); + if (Character.isDigit(c) && c != '0') return false; + if (Character.toUpperCase(c) == 'E') break; + } + return true; + } + private interface Caster { Object cast(Object operand); } diff --git a/java/java-impl/src/com/intellij/psi/scope/processor/VariablesNotProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesNotProcessor.java similarity index 97% rename from java/java-impl/src/com/intellij/psi/scope/processor/VariablesNotProcessor.java rename to java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesNotProcessor.java index d36a0c0f1792..41e0b1715a1e 100644 --- a/java/java-impl/src/com/intellij/psi/scope/processor/VariablesNotProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesNotProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/java-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java b/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java similarity index 98% rename from java/java-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java rename to java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java index 08ecc5379f0b..6f9d64c105d8 100644 --- a/java/java-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/processor/VariablesProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java index 221bff09ccd2..1ff6b6a441bf 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/ImportHelperTest.java @@ -1,7 +1,7 @@ package com.intellij.codeInsight.daemon; import com.intellij.codeInsight.CodeInsightSettings; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; +import com.intellij.codeInsight.daemon.impl.DaemonListeners; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFix; import com.intellij.codeInsight.daemon.impl.quickfix.ImportClassFixBase; @@ -337,18 +337,18 @@ public class ImportHelperTest extends DaemonAnalyzerTestCase { configureByText(StdFileTypes.JAVA, text); ((UndoManagerImpl)UndoManager.getInstance(getProject())).flushCurrentCommandMerger(); ((UndoManagerImpl)UndoManager.getInstance(getProject())).clearUndoRedoQueueInTests(getFile().getVirtualFile()); - assertFalse(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile())); + assertFalse(DaemonListeners.canChangeFileSilently(getFile())); doHighlighting(); - assertFalse(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile())); + assertFalse(DaemonListeners.canChangeFileSilently(getFile())); type(" "); - assertTrue(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile())); + assertTrue(DaemonListeners.canChangeFileSilently(getFile())); undo(); - assertFalse(((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).canChangeFileSilently(getFile()));//CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old; + assertFalse(DaemonListeners.canChangeFileSilently(getFile()));//CodeInsightSettings.getInstance().ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = old; } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java index 3eb104103972..8fc78918cd10 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LossyEncodingTest.java @@ -24,7 +24,7 @@ */ package com.intellij.codeInsight.daemon; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.LossyEncodingInspection; @@ -130,7 +130,7 @@ public class LossyEncodingTest extends LightDaemonAnalyzerTestCase { virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET); doHighlighting(); - List infos = DaemonCodeAnalyzerImpl.getFileLevelHighlights(getProject(), getFile()); + List infos = DaemonCodeAnalyzerEx.getInstanceEx(getProject()).getFileLevelHighlights(getProject(), getFile()); HighlightInfo info = assertOneElement(infos); assertEquals("File was loaded in the wrong encoding: 'UTF-8'", info.getDescription()); } diff --git a/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/IdCacheTest.java b/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/IdCacheTest.java index b86eef0fb3c4..34a66d93c262 100644 --- a/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/IdCacheTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/impl/cache/impl/IdCacheTest.java @@ -20,7 +20,6 @@ import com.intellij.codeInsight.CodeInsightTestCase; import com.intellij.ide.todo.TodoConfiguration; import com.intellij.ide.todo.TodoIndexPatternProvider; import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.projectRoots.impl.JavaSdkImpl; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -30,10 +29,7 @@ import com.intellij.psi.impl.cache.CacheManager; import com.intellij.psi.impl.cache.TodoCacheManager; import com.intellij.psi.impl.cache.impl.id.IdIndex; import com.intellij.psi.impl.cache.impl.todo.TodoIndex; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.TodoAttributes; -import com.intellij.psi.search.TodoPattern; -import com.intellij.psi.search.UsageSearchContext; +import com.intellij.psi.search.*; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.PsiTestUtil; import com.intellij.util.ArrayUtil; @@ -132,7 +128,7 @@ public class IdCacheTest extends CodeInsightTestCase{ } public void testUpdateOnTodoChange() throws Exception { - TodoPattern pattern = new TodoPattern("newtodo", TodoAttributes.createDefault(), true); + TodoPattern pattern = new TodoPattern("newtodo", TodoAttributesUtil.createDefault(), true); TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns(); TodoConfiguration.getInstance().setTodoPatterns(new TodoPattern[]{pattern}); diff --git a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java index fe43ca04330e..d08c536b95be 100644 --- a/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java +++ b/java/java-tests/testSrc/com/intellij/psi/search/UpdateCacheTest.java @@ -220,7 +220,7 @@ public class UpdateCacheTest extends PsiTestCase{ } public void testTodoConfigurationChange() throws Exception{ - TodoPattern pattern = new TodoPattern("newtodo", TodoAttributes.createDefault(), true); + TodoPattern pattern = new TodoPattern("newtodo", TodoAttributesUtil.createDefault(), true); TodoPattern[] oldPatterns = TodoConfiguration.getInstance().getTodoPatterns(); checkTodos(new String[]{"2.java"}); diff --git a/java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java b/java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java deleted file mode 100644 index b422156ba792..000000000000 --- a/java/openapi/src/com/intellij/codeInsight/intention/QuickFixFactory.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInsight.intention; - -import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement; -import com.intellij.codeInspection.LocalQuickFixOnPsiElement; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.psi.*; -import com.intellij.psi.util.PropertyMemberType; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author cdr - */ -public abstract class QuickFixFactory { - public static QuickFixFactory getInstance() { - return ServiceManager.getService(QuickFixFactory.class); - } - - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createModifierListFix(@NotNull PsiModifierList modifierList, - @PsiModifier.ModifierConstant @NotNull String modifier, - boolean shouldHave, - final boolean showContainingClass); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createModifierListFix(@NotNull PsiModifierListOwner owner, - @PsiModifier.ModifierConstant @NotNull String modifier, - boolean shouldHave, - final boolean showContainingClass); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodReturnFix(@NotNull PsiMethod method, @NotNull PsiType toReturn, boolean fixWholeHierarchy); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddMethodFix(@NotNull PsiMethod method, @NotNull PsiClass toClass); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddMethodFix(@NotNull String methodText, @NotNull PsiClass toClass, @NotNull String... exceptions); - - /** - * @param psiElement psiClass or enum constant without class initializer - */ - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createImplementMethodsFix(@NotNull PsiElement psiElement); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createImplementMethodsFix(@NotNull PsiClass psiElement); - @NotNull - public abstract LocalQuickFixOnPsiElement createMethodThrowsFix(@NotNull PsiMethod method, @NotNull PsiClassType exceptionClass, boolean shouldThrow, boolean showContainingClass); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddDefaultConstructorFix(@NotNull PsiClass aClass); - @Nullable - public abstract LocalQuickFixAndIntentionActionOnPsiElement createAddConstructorFix(@NotNull PsiClass aClass, @PsiModifier.ModifierConstant @NotNull String modifier); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createMethodParameterTypeFix(@NotNull PsiMethod method, int index, @NotNull PsiType newType, boolean fixWholeHierarchy); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createMakeClassInterfaceFix(@NotNull PsiClass aClass); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createMakeClassInterfaceFix(@NotNull PsiClass aClass, final boolean makeInterface); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createExtendsListFix(@NotNull PsiClass aClass, @NotNull PsiClassType typeToExtendFrom, boolean toAdd); - @NotNull - public abstract LocalQuickFixAndIntentionActionOnPsiElement createRemoveUnusedParameterFix(@NotNull PsiParameter parameter); - @NotNull - public abstract IntentionAction createRemoveUnusedVariableFix(@NotNull PsiVariable variable); - - @Nullable - public abstract IntentionAction createCreateClassOrPackageFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass); - @Nullable - public abstract IntentionAction createCreateClassOrInterfaceFix(@NotNull PsiElement context, @NotNull String qualifiedName, final boolean createClass, final String superClass); - @NotNull - public abstract IntentionAction createCreateFieldOrPropertyFix(@NotNull PsiClass aClass, @NotNull String name, @NotNull PsiType type, @NotNull PropertyMemberType targetMember, @NotNull PsiAnnotation... annotations); -} diff --git a/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersionUtil.java b/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersionUtil.java index ff226475e84c..9d8c10413c08 100644 --- a/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersionUtil.java +++ b/java/openapi/src/com/intellij/openapi/projectRoots/JavaSdkVersionUtil.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull; * Date: 3/28/12 */ public class JavaSdkVersionUtil { - public static boolean isAtLeast(PsiElement element, JavaSdkVersion minVersion) { + public static boolean isAtLeast(@NotNull PsiElement element, @NotNull JavaSdkVersion minVersion) { JavaSdkVersion version = getJavaSdkVersion(element); return version == null || version.isAtLeast(minVersion); } @@ -36,7 +36,8 @@ public class JavaSdkVersionUtil { if (module != null) { final Sdk sdk = ModuleRootManager.getInstance(module).getSdk(); if (sdk != null && sdk.getSdkType() instanceof JavaSdk) { - return JavaSdk.getInstance().getVersion(sdk); + String version = sdk.getVersionString(); + return version == null ? null : JdkVersionUtil.getVersion(version); } } return null; diff --git a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java index b3230893f501..a0c5bfaa53ce 100644 --- a/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java +++ b/java/testFramework/src/com/intellij/codeInsight/daemon/DaemonAnalyzerTestCase.java @@ -18,6 +18,7 @@ package com.intellij.codeInsight.daemon; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeHighlighting.Pass; import com.intellij.codeInsight.CodeInsightTestCase; +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx; import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; @@ -365,7 +366,8 @@ public abstract class DaemonAnalyzerTestCase extends CodeInsightTestCase { if (!canChange) { Document document = getDocument(getFile()); - ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(getProject())).getFileStatusMap().assertAllDirtyScopesAreNull(document); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + daemonCodeAnalyzer.getFileStatusMap().assertAllDirtyScopesAreNull(document); } return infos; diff --git a/platform/analysis-api/analysis-api.iml b/platform/analysis-api/analysis-api.iml index 9d483ed1ea84..f2337e3c286d 100644 --- a/platform/analysis-api/analysis-api.iml +++ b/platform/analysis-api/analysis-api.iml @@ -12,6 +12,7 @@ + diff --git a/platform/platform-api/src/com/intellij/codeHighlighting/BackgroundEditorHighlighter.java b/platform/analysis-api/src/com/intellij/codeHighlighting/BackgroundEditorHighlighter.java similarity index 99% rename from platform/platform-api/src/com/intellij/codeHighlighting/BackgroundEditorHighlighter.java rename to platform/analysis-api/src/com/intellij/codeHighlighting/BackgroundEditorHighlighter.java index 69dd0bb10d6b..4aa13d4f8681 100644 --- a/platform/platform-api/src/com/intellij/codeHighlighting/BackgroundEditorHighlighter.java +++ b/platform/analysis-api/src/com/intellij/codeHighlighting/BackgroundEditorHighlighter.java @@ -22,4 +22,4 @@ public interface BackgroundEditorHighlighter { HighlightingPass[] createPassesForEditor(); @NotNull HighlightingPass[] createPassesForVisibleArea(); -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/codeHighlighting/HighlightingPass.java b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightingPass.java similarity index 67% rename from platform/platform-api/src/com/intellij/codeHighlighting/HighlightingPass.java rename to platform/analysis-api/src/com/intellij/codeHighlighting/HighlightingPass.java index 447d4f414b04..0cfcd95ebd3b 100644 --- a/platform/platform-api/src/com/intellij/codeHighlighting/HighlightingPass.java +++ b/platform/analysis-api/src/com/intellij/codeHighlighting/HighlightingPass.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,21 +18,25 @@ package com.intellij.codeHighlighting; import com.intellij.openapi.progress.ProgressIndicator; import org.jetbrains.annotations.NotNull; +/** + * Pass performs analysis in background and highlights found issues in the editor. + */ public interface HighlightingPass { HighlightingPass[] EMPTY_ARRAY = new HighlightingPass[0]; + /** - * pass is intended to perform analysis stuff and hold collected information internally - * until {@link #collectInformation(com.intellij.openapi.progress.ProgressIndicator)} is called. + * Asks this pass to start analysis and hold collected information. * This method is called from a background thread. * - * @param progress to check for highlighting process is cancelled. Pass is to check progress.isCanceled() as often as possible and - * throw {@link com.intellij.openapi.progress.ProcessCanceledException} if true is returned. + * @param progress to check if highlighting process is cancelled. Pass is to check progress.isCanceled() as often as possible and + * throw {@link com.intellij.openapi.progress.ProcessCanceledException} if true is returned. + * See also {@link com.intellij.openapi.progress.ProgressIndicator#checkCanceled()}. */ void collectInformation(@NotNull ProgressIndicator progress); /** * Called to apply information collected by {@linkplain #collectInformation(com.intellij.openapi.progress.ProgressIndicator)} to the editor. * This method is called from the event dispatch thread. - */ + */ void applyInformationToEditor(); } diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java rename to platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonBundle.java diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java similarity index 75% rename from platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java rename to platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java index b91e1dee7e53..8318f3475280 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/daemon/DaemonCodeAnalyzer.java @@ -1,6 +1,5 @@ - /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,23 +40,31 @@ public abstract class DaemonCodeAnalyzer { public abstract boolean isHighlightingAvailable(@Nullable PsiFile file); public abstract void setImportHintsEnabled(@NotNull PsiFile file, boolean value); - public abstract void resetImportHintsEnabledForProject(); + public abstract void resetImportHintsEnabledForProject(); public abstract void setHighlightingEnabled(@NotNull PsiFile file, boolean value); public abstract boolean isImportHintsEnabled(@NotNull PsiFile file); public abstract boolean isAutohintsAvailable(@Nullable PsiFile file); /** * Force rehighlighting for all files - */ + */ public abstract void restart(); public abstract void restart(@NotNull PsiFile file); public abstract void autoImportReferenceAtCursor(@NotNull Editor editor, @NotNull PsiFile file); - public static final Topic DAEMON_EVENT_TOPIC = new Topic("DAEMON_EVENT_TOPIC", DaemonListener.class); + public static final Topic DAEMON_EVENT_TOPIC = Topic.create("DAEMON_EVENT_TOPIC", DaemonListener.class); public interface DaemonListener { void daemonFinished(); void daemonCancelEventOccurred(); + void passProgressHasAdvanced(@NotNull PsiFile file, double progress); + void visibleAreaHighlighted(@NotNull PsiFile file, Editor editor); + } + public abstract static class DaemonListenerAdapter implements DaemonListener { + @Override public void daemonFinished() {} + @Override public void daemonCancelEventOccurred() {} + @Override public void passProgressHasAdvanced(@NotNull PsiFile file, double progress){} + @Override public void visibleAreaHighlighted(@NotNull PsiFile file, Editor editor){} } } diff --git a/platform/lang-api/src/com/intellij/codeInsight/daemon/QuickFixActionRegistrar.java b/platform/analysis-api/src/com/intellij/codeInsight/daemon/QuickFixActionRegistrar.java similarity index 96% rename from platform/lang-api/src/com/intellij/codeInsight/daemon/QuickFixActionRegistrar.java rename to platform/analysis-api/src/com/intellij/codeInsight/daemon/QuickFixActionRegistrar.java index 2194bbe5eacb..d670dd4dce85 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/daemon/QuickFixActionRegistrar.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/daemon/QuickFixActionRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java b/platform/analysis-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java similarity index 95% rename from platform/lang-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java rename to platform/analysis-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java index 7ef76677ed4e..172e4520c6e3 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/highlighting/HighlightErrorFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionAction.java b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java similarity index 98% rename from platform/lang-api/src/com/intellij/codeInsight/intention/IntentionAction.java rename to platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java index 946e31137556..aad4afca4b40 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionAction.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionActionBean.java b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionActionBean.java similarity index 98% rename from platform/lang-api/src/com/intellij/codeInsight/intention/IntentionActionBean.java rename to platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionActionBean.java index 7be2dde69bb6..cbcabc3209de 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionActionBean.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionActionBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionManager.java b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionManager.java similarity index 97% rename from platform/lang-api/src/com/intellij/codeInsight/intention/IntentionManager.java rename to platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionManager.java index 890066c38df1..aeb671df1e84 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/intention/IntentionManager.java +++ b/platform/analysis-api/src/com/intellij/codeInsight/intention/IntentionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -101,7 +101,7 @@ public abstract class IntentionManager { /** * @deprecated custom directory name causes problem with internationalization of intention descriptions. - * Register intention class via extension point {@link IntentionManager.EP_INTENTION_ACTIONS} instead. + * Register intention class via extension point {@link IntentionManager#EP_INTENTION_ACTIONS} instead. */ @Deprecated public abstract void registerIntentionAndMetaData(@NotNull IntentionAction action, @@ -120,7 +120,7 @@ public abstract class IntentionManager { /** * @return actions used as additional options for the given problem. * E.g. actions for suppress the problem via comment, javadoc or annotation, - * and edit corresponding inspection settings. + * and edit corresponding inspection settings. */ @NotNull public abstract List getStandardIntentionOptions(@NotNull HighlightDisplayKey displayKey, @NotNull PsiElement context); diff --git a/platform/lang-api/src/com/intellij/codeInspection/CustomSuppressableInspectionTool.java b/platform/analysis-api/src/com/intellij/codeInspection/CustomSuppressableInspectionTool.java similarity index 97% rename from platform/lang-api/src/com/intellij/codeInspection/CustomSuppressableInspectionTool.java rename to platform/analysis-api/src/com/intellij/codeInspection/CustomSuppressableInspectionTool.java index d8d5142188de..04c4148de1b0 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/CustomSuppressableInspectionTool.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/CustomSuppressableInspectionTool.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,4 +44,4 @@ public interface CustomSuppressableInspectionTool { * @return true if the inspection is suppressed, false otherwise. */ boolean isSuppressedFor(@NotNull PsiElement element); -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/codeInspection/HintAction.java b/platform/analysis-api/src/com/intellij/codeInspection/HintAction.java similarity index 95% rename from platform/lang-api/src/com/intellij/codeInspection/HintAction.java rename to platform/analysis-api/src/com/intellij/codeInspection/HintAction.java index 02421be3d873..6e583cd6437d 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/HintAction.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/HintAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java similarity index 98% rename from platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java rename to platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java index 78bed6f7b77c..0ac3cd40a7bb 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java rename to platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixOnPsiElementAsIntentionAdapter.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixOnPsiElementAsIntentionAdapter.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixOnPsiElementAsIntentionAdapter.java rename to platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixOnPsiElementAsIntentionAdapter.java diff --git a/platform/lang-api/src/com/intellij/codeInspection/SuppressIntentionAction.java b/platform/analysis-api/src/com/intellij/codeInspection/SuppressIntentionAction.java similarity index 98% rename from platform/lang-api/src/com/intellij/codeInspection/SuppressIntentionAction.java rename to platform/analysis-api/src/com/intellij/codeInspection/SuppressIntentionAction.java index 204b9f36bc27..31066062ca28 100644 --- a/platform/lang-api/src/com/intellij/codeInspection/SuppressIntentionAction.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/SuppressIntentionAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/codeInspection/SuppressableProblemGroup.java b/platform/analysis-api/src/com/intellij/codeInspection/SuppressableProblemGroup.java similarity index 100% rename from platform/lang-api/src/com/intellij/codeInspection/SuppressableProblemGroup.java rename to platform/analysis-api/src/com/intellij/codeInspection/SuppressableProblemGroup.java diff --git a/platform/lang-api/src/com/intellij/lang/LanguageAnnotators.java b/platform/analysis-api/src/com/intellij/lang/LanguageAnnotators.java similarity index 95% rename from platform/lang-api/src/com/intellij/lang/LanguageAnnotators.java rename to platform/analysis-api/src/com/intellij/lang/LanguageAnnotators.java index 8e0336183fcf..a1baea2ba61c 100644 --- a/platform/lang-api/src/com/intellij/lang/LanguageAnnotators.java +++ b/platform/analysis-api/src/com/intellij/lang/LanguageAnnotators.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,4 +29,4 @@ public class LanguageAnnotators extends LanguageExtension { private LanguageAnnotators() { super(EP_NAME); } -} \ No newline at end of file +} diff --git a/platform/lang-api/src/com/intellij/lang/annotation/Annotation.java b/platform/analysis-api/src/com/intellij/lang/annotation/Annotation.java similarity index 99% rename from platform/lang-api/src/com/intellij/lang/annotation/Annotation.java rename to platform/analysis-api/src/com/intellij/lang/annotation/Annotation.java index 3236b162f8a7..2750d29ed800 100644 --- a/platform/lang-api/src/com/intellij/lang/annotation/Annotation.java +++ b/platform/analysis-api/src/com/intellij/lang/annotation/Annotation.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/lang/annotation/AnnotationHolder.java b/platform/analysis-api/src/com/intellij/lang/annotation/AnnotationHolder.java similarity index 100% rename from platform/lang-api/src/com/intellij/lang/annotation/AnnotationHolder.java rename to platform/analysis-api/src/com/intellij/lang/annotation/AnnotationHolder.java diff --git a/platform/lang-api/src/com/intellij/lang/annotation/AnnotationSession.java b/platform/analysis-api/src/com/intellij/lang/annotation/AnnotationSession.java similarity index 96% rename from platform/lang-api/src/com/intellij/lang/annotation/AnnotationSession.java rename to platform/analysis-api/src/com/intellij/lang/annotation/AnnotationSession.java index b33ab13a6d2d..7aa742dbb329 100644 --- a/platform/lang-api/src/com/intellij/lang/annotation/AnnotationSession.java +++ b/platform/analysis-api/src/com/intellij/lang/annotation/AnnotationSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/lang/annotation/Annotator.java b/platform/analysis-api/src/com/intellij/lang/annotation/Annotator.java similarity index 97% rename from platform/lang-api/src/com/intellij/lang/annotation/Annotator.java rename to platform/analysis-api/src/com/intellij/lang/annotation/Annotator.java index e8068a5823fa..b83762b18d85 100644 --- a/platform/lang-api/src/com/intellij/lang/annotation/Annotator.java +++ b/platform/analysis-api/src/com/intellij/lang/annotation/Annotator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-api/src/com/intellij/lang/annotation/package.html b/platform/analysis-api/src/com/intellij/lang/annotation/package.html similarity index 100% rename from platform/lang-api/src/com/intellij/lang/annotation/package.html rename to platform/analysis-api/src/com/intellij/lang/annotation/package.html diff --git a/platform/lang-api/src/com/intellij/problems/Problem.java b/platform/analysis-api/src/com/intellij/problems/Problem.java similarity index 100% rename from platform/lang-api/src/com/intellij/problems/Problem.java rename to platform/analysis-api/src/com/intellij/problems/Problem.java diff --git a/platform/lang-api/src/com/intellij/problems/WolfTheProblemSolver.java b/platform/analysis-api/src/com/intellij/problems/WolfTheProblemSolver.java similarity index 100% rename from platform/lang-api/src/com/intellij/problems/WolfTheProblemSolver.java rename to platform/analysis-api/src/com/intellij/problems/WolfTheProblemSolver.java diff --git a/platform/analysis-impl/analysis-impl.iml b/platform/analysis-impl/analysis-impl.iml index 78ece770f82c..34cdcbacb6a3 100644 --- a/platform/analysis-impl/analysis-impl.iml +++ b/platform/analysis-impl/analysis-impl.iml @@ -14,6 +14,8 @@ + + diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ScopeAttributesUtil.java b/platform/analysis-impl/src/com/intellij/application/options/colors/ScopeAttributesUtil.java similarity index 100% rename from platform/lang-impl/src/com/intellij/application/options/colors/ScopeAttributesUtil.java rename to platform/analysis-impl/src/com/intellij/application/options/colors/ScopeAttributesUtil.java diff --git a/platform/lang-impl/src/com/intellij/codeHighlighting/DirtyScopeTrackingHighlightingPassFactory.java b/platform/analysis-impl/src/com/intellij/codeHighlighting/DirtyScopeTrackingHighlightingPassFactory.java similarity index 94% rename from platform/lang-impl/src/com/intellij/codeHighlighting/DirtyScopeTrackingHighlightingPassFactory.java rename to platform/analysis-impl/src/com/intellij/codeHighlighting/DirtyScopeTrackingHighlightingPassFactory.java index 01e718583fec..5313c2ca713f 100644 --- a/platform/lang-impl/src/com/intellij/codeHighlighting/DirtyScopeTrackingHighlightingPassFactory.java +++ b/platform/analysis-impl/src/com/intellij/codeHighlighting/DirtyScopeTrackingHighlightingPassFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeHighlighting/MainHighlightingPassFactory.java b/platform/analysis-impl/src/com/intellij/codeHighlighting/MainHighlightingPassFactory.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeHighlighting/MainHighlightingPassFactory.java rename to platform/analysis-impl/src/com/intellij/codeHighlighting/MainHighlightingPassFactory.java diff --git a/platform/lang-impl/src/com/intellij/codeHighlighting/Pass.java b/platform/analysis-impl/src/com/intellij/codeHighlighting/Pass.java similarity index 96% rename from platform/lang-impl/src/com/intellij/codeHighlighting/Pass.java rename to platform/analysis-impl/src/com/intellij/codeHighlighting/Pass.java index b43a35dbe5ca..138ea879bda4 100644 --- a/platform/lang-impl/src/com/intellij/codeHighlighting/Pass.java +++ b/platform/analysis-impl/src/com/intellij/codeHighlighting/Pass.java @@ -1,6 +1,5 @@ - /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,4 +31,4 @@ public interface Pass { int LINE_MARKERS = 11; int LAST_PASS = LINE_MARKERS; -} \ No newline at end of file +} diff --git a/platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPass.java b/platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPass.java similarity index 90% rename from platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPass.java rename to platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPass.java index f6a44ddce93d..77231dd883b8 100644 --- a/platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPass.java +++ b/platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPass.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,7 @@ */ package com.intellij.codeHighlighting; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -39,10 +38,10 @@ public abstract class TextEditorHighlightingPass implements HighlightingPass { @NotNull protected final Project myProject; private final boolean myRunIntentionPassAfter; private final long myInitialStamp; - private int[] myCompletionPredecessorIds = ArrayUtil.EMPTY_INT_ARRAY; - private int[] myStartingPredecessorIds = ArrayUtil.EMPTY_INT_ARRAY; - private int myId; - private boolean myDumb; + private volatile int[] myCompletionPredecessorIds = ArrayUtil.EMPTY_INT_ARRAY; + private volatile int[] myStartingPredecessorIds = ArrayUtil.EMPTY_INT_ARRAY; + private volatile int myId; + private volatile boolean myDumb; private EditorColorsScheme myColorsScheme; protected TextEditorHighlightingPass(@NotNull final Project project, @Nullable final Document document, boolean runIntentionPassAfter) { @@ -96,7 +95,7 @@ public abstract class TextEditorHighlightingPass implements HighlightingPass { Document document = getDocument(); PsiFile file = document == null ? null : PsiDocumentManager.getInstance(myProject).getPsiFile(document); if (file != null) { - ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap().markFileUpToDate(getDocument(), getId()); + DaemonCodeAnalyzerEx.getInstanceEx(myProject).getFileStatusMap().markFileUpToDate(getDocument(), getId()); } return; } diff --git a/platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassFactory.java b/platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassFactory.java similarity index 96% rename from platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassFactory.java rename to platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassFactory.java index dd9dd4d656d1..34c531535cf7 100644 --- a/platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassFactory.java +++ b/platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassRegistrar.java b/platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassRegistrar.java similarity index 91% rename from platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassRegistrar.java rename to platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassRegistrar.java index f6b311336dd5..59443453c2c5 100644 --- a/platform/lang-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassRegistrar.java +++ b/platform/analysis-impl/src/com/intellij/codeHighlighting/TextEditorHighlightingPassRegistrar.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,10 @@ public abstract class TextEditorHighlightingPassRegistrar { * @param inPostHighlightingPass * @return the id of the new pass which e.g. can be used as an anchor for the other pass. */ - public int registerTextEditorHighlightingPass(final TextEditorHighlightingPassFactory factory, final Anchor anchor, final int anchorPassId, boolean needAdditionalIntentionsPass, + public int registerTextEditorHighlightingPass(final TextEditorHighlightingPassFactory factory, + final Anchor anchor, + final int anchorPassId, + boolean needAdditionalIntentionsPass, boolean inPostHighlightingPass) { int[] ids = null; switch (anchor) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java similarity index 94% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java index 6d14422276a9..213738ce993f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/IdeValidationHost.java @@ -23,5 +23,5 @@ import org.jetbrains.annotations.NotNull; * @author yole */ public interface IdeValidationHost extends Validator.ValidationHost { - void addMessageWithFixes(PsiElement context, String message, @NotNull ErrorType type, IntentionAction... fixes); + void addMessageWithFixes(PsiElement context, String message, @NotNull ErrorType type, @NotNull IntentionAction... fixes); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/AnnotationHolderImpl.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/AnnotationHolderImpl.java similarity index 97% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/AnnotationHolderImpl.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/AnnotationHolderImpl.java index e26b0100b96c..533f62a95e73 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/AnnotationHolderImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/AnnotationHolderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -142,7 +142,7 @@ public class AnnotationHolderImpl extends SmartList implements Annot //noinspection HardCodedStringLiteral //TODO: FIXME @NonNls - String tooltip = message == null ? null : "" + XmlStringUtil.escapeString(message) + ""; + String tooltip = message == null ? null : XmlStringUtil.wrapInHtml(XmlStringUtil.escapeString(message)); Annotation annotation = new Annotation(range.getStartOffset(), range.getEndOffset(), severity, message, tooltip); add(annotation); return annotation; diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java new file mode 100644 index 000000000000..cc8c91e958c5 --- /dev/null +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerEx.java @@ -0,0 +1,109 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl; + +import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.lang.annotation.HighlightSeverity; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.ex.MarkupModelEx; +import com.intellij.openapi.editor.ex.RangeHighlighterEx; +import com.intellij.openapi.editor.impl.DocumentMarkupModel; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiFile; +import com.intellij.util.CommonProcessors; +import com.intellij.util.Processor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; + +import java.util.List; + +public abstract class DaemonCodeAnalyzerEx extends DaemonCodeAnalyzer { + private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx"); + public static DaemonCodeAnalyzerEx getInstanceEx(Project project) { + return (DaemonCodeAnalyzerEx)project.getComponent(DaemonCodeAnalyzer.class); + } + + public static boolean processHighlights(@NotNull Document document, + @NotNull Project project, + @Nullable("null means all") final HighlightSeverity minSeverity, + final int startOffset, + final int endOffset, + @NotNull final Processor processor) { + LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed()); + + final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project); + MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); + return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor() { + @Override + public boolean process(@NotNull RangeHighlighterEx marker) { + Object tt = marker.getErrorStripeTooltip(); + if (!(tt instanceof HighlightInfo)) return true; + HighlightInfo info = (HighlightInfo)tt; + return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0 + || info.highlighter == null + || processor.process(info); + } + }); + } + + static boolean processHighlightsOverlappingOutside(@NotNull Document document, + @NotNull Project project, + @Nullable("null means all") final HighlightSeverity minSeverity, + final int startOffset, + final int endOffset, + @NotNull final Processor processor) { + LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed()); + + final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project); + MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); + return model.processRangeHighlightersOutside(startOffset, endOffset, new Processor() { + @Override + public boolean process(@NotNull RangeHighlighterEx marker) { + Object tt = marker.getErrorStripeTooltip(); + if (!(tt instanceof HighlightInfo)) return true; + HighlightInfo info = (HighlightInfo)tt; + return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0 + || info.highlighter == null + || processor.process(info); + } + }); + } + + static boolean hasErrors(@NotNull Project project, @NotNull Document document) { + return !processHighlights(document, project, HighlightSeverity.ERROR, 0, document.getTextLength(), + CommonProcessors.alwaysFalse()); + } + + public abstract boolean isErrorAnalyzingFinished(@NotNull PsiFile file); + + @NotNull + public abstract FileStatusMap getFileStatusMap(); + + @NotNull + @TestOnly + public abstract List getFileLevelHighlights(@NotNull Project project, @NotNull PsiFile file); + + public abstract void cleanFileLevelHighlights(@NotNull Project project, int group, PsiFile psiFile); + + public abstract void addFileLevelHighlight(@NotNull final Project project, + final int group, + @NotNull final HighlightInfo info, + @NotNull final PsiFile psiFile); + +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonProgressIndicator.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonProgressIndicator.java similarity index 98% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonProgressIndicator.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonProgressIndicator.java index 2941115f80de..9a3e52cc750b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonProgressIndicator.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DaemonProgressIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java similarity index 97% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java index 35980dd4959f..0a793add6253 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/DefaultHighlightVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +121,7 @@ public class DefaultHighlightVisitor implements HighlightVisitor, DumbAware { return 2; } - private static final PerThreadMap cachedAnnotators = new PerThreadMap() { + private static final ThreadLocalAnnotatorMap cachedAnnotators = new ThreadLocalAnnotatorMap() { @NotNull @Override public Collection initialValue(@NotNull Language key) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java similarity index 97% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java index f62fe0d1eda8..904f41865330 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/FileStatusMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.DirtyScopeTrackingHighlightingPassFactory; import com.intellij.codeHighlighting.Pass; import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.ProblemHighlightFilter; import com.intellij.openapi.Disposable; import com.intellij.openapi.diagnostic.Logger; @@ -58,11 +57,11 @@ public class FileStatusMap implements Disposable { markAllFilesDirty(); } - @Nullable + @Nullable("null means the file is clean") public static TextRange getDirtyTextRange(@NotNull Editor editor, int passId) { Document document = editor.getDocument(); - FileStatusMap me = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(editor.getProject())).getFileStatusMap(); + FileStatusMap me = DaemonCodeAnalyzerEx.getInstanceEx(editor.getProject()).getFileStatusMap(); TextRange dirtyScope = me.getFileDirtyScope(document, passId); if (dirtyScope == null) return null; TextRange documentRange = TextRange.from(0, document.getTextLength()); @@ -106,7 +105,7 @@ public class FileStatusMap implements Disposable { dirtyScopes.put(Pass.UPDATE_ALL, WHOLE_FILE_DIRTY_MARKER); dirtyScopes.put(Pass.EXTERNAL_TOOLS, WHOLE_FILE_DIRTY_MARKER); dirtyScopes.put(Pass.LOCAL_INSPECTIONS, WHOLE_FILE_DIRTY_MARKER); - TextEditorHighlightingPassRegistrarImpl registrar = (TextEditorHighlightingPassRegistrarImpl) TextEditorHighlightingPassRegistrar.getInstance(project); + TextEditorHighlightingPassRegistrarEx registrar = (TextEditorHighlightingPassRegistrarEx) TextEditorHighlightingPassRegistrar.getInstance(project); for(DirtyScopeTrackingHighlightingPassFactory factory: registrar.getDirtyScopeTrackingFactories()) { dirtyScopes.put(factory.getPassId(), WHOLE_FILE_DIRTY_MARKER); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java similarity index 53% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java index 013db8f5c931..e094a32d7491 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPass.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,35 +22,24 @@ import com.intellij.codeInsight.daemon.DaemonBundle; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.impl.analysis.CustomHighlightInfoHolder; import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.codeInsight.problems.ProblemImpl; -import com.intellij.codeInsight.problems.WolfTheProblemSolverImpl; -import com.intellij.concurrency.JobLauncher; -import com.intellij.injected.editor.DocumentWindow; -import com.intellij.lang.Language; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.HighlighterColors; 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.colors.EditorColorsScheme; -import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.markup.MarkupModel; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.fileTypes.SyntaxHighlighter; -import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.DumbAware; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.IndexNotReadyException; @@ -59,12 +48,12 @@ import com.intellij.openapi.util.*; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.problems.Problem; import com.intellij.problems.WolfTheProblemSolver; -import com.intellij.psi.*; -import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; -import com.intellij.psi.impl.source.tree.injected.Place; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiErrorElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiManager; import com.intellij.psi.search.PsiTodoSearchHelper; import com.intellij.psi.search.TodoItem; -import com.intellij.psi.tree.IElementType; import com.intellij.util.Processor; import com.intellij.util.SmartList; import com.intellij.util.containers.Stack; @@ -76,30 +65,27 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; -import java.awt.*; import java.util.*; -import java.util.List; import java.util.concurrent.atomic.AtomicInteger; public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingPass implements DumbAware { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass"); static final String PRESENTABLE_NAME = DaemonBundle.message("pass.syntax"); private static final Key HAS_ERROR_ELEMENT = Key.create("HAS_ERROR_ELEMENT"); - private static final JobLauncher JobUtil = JobLauncher.getInstance(); - private static final Condition FILE_FILTER = new Condition() { + protected static final Condition FILE_FILTER = new Condition() { @Override public boolean value(PsiFile file) { - return HighlightLevelUtil.shouldHighlight(file); + return HighlightingLevelManager.getInstance(file.getProject()).shouldHighlight(file); } }; - private final int myStartOffset; - private final int myEndOffset; - private final boolean myUpdateAll; - private final ProperTextRange myPriorityRange; - private final Editor myEditor; + protected final int myStartOffset; + protected final int myEndOffset; + protected final boolean myUpdateAll; + protected final ProperTextRange myPriorityRange; + protected final Editor myEditor; - private final List myHighlights = new ArrayList(); + protected final List myHighlights = new ArrayList(); protected volatile boolean myHasErrorElement; private volatile boolean myErrorFound; @@ -110,7 +96,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP } }; private volatile Runnable myApplyCommand; - private final EditorColorsScheme myGlobalScheme; + protected final EditorColorsScheme myGlobalScheme; public GeneralHighlightingPass(@NotNull Project project, @NotNull PsiFile file, @@ -138,15 +124,15 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP LOG.assertTrue(file.isValid()); setId(Pass.UPDATE_ALL); myHasErrorElement = !isWholeFileHighlighting() && Boolean.TRUE.equals(myFile.getUserData(HAS_ERROR_ELEMENT)); - FileStatusMap fileStatusMap = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap(); + final DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + FileStatusMap fileStatusMap = daemonCodeAnalyzer.getFileStatusMap(); myErrorFound = !isWholeFileHighlighting() && fileStatusMap.wasErrorFound(myDocument); - myApplyCommand = new Runnable() { @Override public void run() { ProperTextRange range = new ProperTextRange(myStartOffset, myEndOffset); MarkupModel model = DocumentMarkupModel.forDocument(myDocument, myProject, true); - UpdateHighlightersUtil.cleanFileLevelHighlights(myProject, Pass.UPDATE_ALL,myFile); + daemonCodeAnalyzer.cleanFileLevelHighlights(myProject, Pass.UPDATE_ALL, myFile); final EditorColorsScheme colorsScheme = getColorsScheme(); UpdateHighlightersUtil.setHighlightersInRange(myProject, myDocument, range, colorsScheme, myHighlights, (MarkupModelEx)model, Pass.UPDATE_ALL); } @@ -159,7 +145,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP private static final Key HIGHLIGHT_VISITOR_INSTANCE_COUNT = new Key("HIGHLIGHT_VISITOR_INSTANCE_COUNT"); @NotNull - private HighlightVisitor[] getHighlightVisitors() { + protected HighlightVisitor[] getHighlightVisitors() { int oldCount = incVisitorUsageCount(1); HighlightVisitor[] highlightVisitors = createHighlightVisitors(); if (oldCount != 0) { @@ -180,7 +166,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP } // returns old value - private int incVisitorUsageCount(int delta) { + protected int incVisitorUsageCount(int delta) { AtomicInteger count = myProject.getUserData(HIGHLIGHT_VISITOR_INSTANCE_COUNT); if (count == null) { count = ((UserDataHolderEx)myProject).putUserDataIfAbsent(HIGHLIGHT_VISITOR_INSTANCE_COUNT, new AtomicInteger(0)); @@ -191,11 +177,11 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP } @Override - protected void collectInformationWithProgress(final ProgressIndicator progress) { + protected void collectInformationWithProgress(@NotNull final ProgressIndicator progress) { final Set gotHighlights = new THashSet(100); final Set outsideResult = new THashSet(100); - DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); HighlightVisitor[] highlightVisitors = getHighlightVisitors(); final List inside = new ArrayList(); final List outside = new ArrayList(); @@ -217,31 +203,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP Runnable after1 = new Runnable() { @Override public void run() { - // all infos for the "injected fragment for the host which is inside" are indeed inside - // but some of the infos for the "injected fragment for the host which is outside" can be still inside - Set injectedResult = new THashSet(); - final Set injected = new THashSet(); - getInjectedPsiFiles(inside, outside, progress, injected); - if (!addInjectedPsiHighlights(injected, progress, Collections.synchronizedSet(injectedResult))) - throw new ProcessCanceledException(); - final List injectionsOutside = new ArrayList(gotHighlights.size()); - - Set result; - synchronized (injectedResult) { - // sync here because all writes happened in another thread - result = injectedResult; - } - for (HighlightInfo info : result) { - if (myPriorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) { - gotHighlights.add(info); - } - else { - // nonconditionally apply injected results regardless whether they are in myStartOffset,myEndOffset - injectionsOutside.add(info); - } - } - - if (outsideResult.isEmpty() && injectionsOutside.isEmpty()) { + if (outsideResult.isEmpty()) { return; // apply only result (by default apply command) and only within inside } @@ -263,7 +225,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP UpdateHighlightersUtil.setHighlightersInRange(myProject, myDocument, priorityIntersection, getColorsScheme(), toApplyInside, (MarkupModelEx)markupModel, Pass.UPDATE_ALL); if (myEditor != null) { - new ShowAutoImportPass(myProject, myFile, myEditor).applyInformationToEditor(); + myProject.getMessageBus().syncPublisher(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC).visibleAreaHighlighted(myFile, myEditor); } } }); @@ -281,7 +243,6 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP toApply.add(info); } } - toApply.addAll(injectionsOutside); UpdateHighlightersUtil.setHighlightersOutsideRange(myProject, myDocument, toApply, getColorsScheme(), myStartOffset, myEndOffset, myPriorityRange, Pass.UPDATE_ALL); @@ -292,7 +253,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP collectHighlights(inside, insideRanges, after1, outside, outsideRanges, progress, filteredVisitors, gotHighlights, forceHighlightParents); if (myUpdateAll) { - ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).getFileStatusMap().setErrorFoundFlag(myDocument, myErrorFound); + daemonCodeAnalyzer.getFileStatusMap().setErrorFoundFlag(myDocument, myErrorFound); } } finally { @@ -301,277 +262,10 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP myHighlights.addAll(gotHighlights); } - private void getInjectedPsiFiles(@NotNull final List elements1, - @NotNull final List elements2, - @NotNull final ProgressIndicator progress, - @NotNull final Set outInjected) { - List injected = InjectedLanguageUtil.getCachedInjectedDocuments(myFile); - Collection hosts = new THashSet(elements1.size() + elements2.size() + injected.size()); - - //rehighlight all injected PSI regardless the range, - //since change in one place can lead to invalidation of injected PSI in (completely) other place. - for (DocumentWindow documentRange : injected) { - progress.checkCanceled(); - if (!documentRange.isValid()) continue; - PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(documentRange); - if (file == null) continue; - PsiElement context = InjectedLanguageManager.getInstance(file.getProject()).getInjectionHost(file); - if (context != null - && context.isValid() - && !file.getProject().isDisposed() - && (myUpdateAll || new ProperTextRange(myStartOffset, myEndOffset).intersects(context.getTextRange()))) { - hosts.add(context); - } - } - hosts.addAll(elements1); - hosts.addAll(elements2); - - final PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() { - @Override - public void visit(@NotNull PsiFile injectedPsi, @NotNull List places) { - synchronized (outInjected) { - outInjected.add(injectedPsi); - } - } - }; - if (!JobUtil.invokeConcurrentlyUnderProgress(new ArrayList(hosts), progress, true, - new Processor() { - @Override - public boolean process(PsiElement element) { - progress.checkCanceled(); - InjectedLanguageUtil.enumerate(element, myFile, false, visitor); - return true; - } - })) { - throw new ProcessCanceledException(); - } - } - - // returns false if canceled - private boolean addInjectedPsiHighlights(@NotNull final Set injectedFiles, - @NotNull final ProgressIndicator progress, - @NotNull final Collection outInfos) { - if (injectedFiles.isEmpty()) return true; - final InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(myProject); - final TextAttributes injectedAttributes = myGlobalScheme.getAttributes(EditorColors.INJECTED_LANGUAGE_FRAGMENT); - - return JobUtil.invokeConcurrentlyUnderProgress(new ArrayList(injectedFiles), progress, isFailFastOnAcquireReadAction(), - new Processor() { - @Override - public boolean process(final PsiFile injectedPsi) { - DocumentWindow documentWindow = (DocumentWindow)PsiDocumentManager.getInstance(myProject).getCachedDocument(injectedPsi); - if (documentWindow == null) return true; - Place places = InjectedLanguageUtil.getShreds(injectedPsi); - for (PsiLanguageInjectionHost.Shred place : places) { - TextRange textRange = place.getRangeInsideHost().shiftRight(place.getHost().getTextRange().getStartOffset()); - if (textRange.isEmpty()) continue; - String desc = injectedPsi.getLanguage().getDisplayName() + ": " + injectedPsi.getText(); - HighlightInfo.Builder - builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_BACKGROUND).range(textRange); - if (injectedAttributes != null) { - builder.textAttributes(injectedAttributes); - } - builder.unescapedToolTip(desc); - HighlightInfo info = builder.createUnconditionally(); - info.setFromInjection(true); - outInfos.add(info); - } - - HighlightInfoHolder holder = createInfoHolder(injectedPsi); - runHighlightVisitorsForInjected(injectedPsi, holder, progress); - for (int i = 0; i < holder.size(); i++) { - HighlightInfo info = holder.get(i); - final int startOffset = documentWindow.injectedToHost(info.startOffset); - final TextRange fixedTextRange = getFixedTextRange(documentWindow, startOffset); - addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, fixedTextRange, outInfos); - } - int injectedStart = holder.size(); - highlightInjectedSyntax(injectedPsi, holder); - for (int i = injectedStart; i < holder.size(); i++) { - HighlightInfo info = holder.get(i); - final int startOffset = info.startOffset; - final TextRange fixedTextRange = getFixedTextRange(documentWindow, startOffset); - if (fixedTextRange == null) { - info.setFromInjection(true); - outInfos.add(info); - } - else { - HighlightInfo patched = new HighlightInfo(info.forcedTextAttributes, info.forcedTextAttributesKey, - info.type, fixedTextRange.getStartOffset(), fixedTextRange.getEndOffset(), - info.getDescription(), info.getToolTip(), info.type.getSeverity(null), - info.isAfterEndOfLine(), null, false, 0); - patched.setFromInjection(true); - outInfos.add(patched); - } - } - - if (!isDumbMode()) { - List todos = new ArrayList(); - highlightTodos(injectedPsi, injectedPsi.getText(), 0, injectedPsi.getTextLength(), progress, myPriorityRange, todos, todos); - for (HighlightInfo info : todos) { - addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, null, outInfos); - } - } - return true; - } - }); - } - protected boolean isFailFastOnAcquireReadAction() { return true; } - @Nullable("null means invalid") - private static TextRange getFixedTextRange(@NotNull DocumentWindow documentWindow, int startOffset) { - final TextRange fixedTextRange; - TextRange textRange = documentWindow.getHostRange(startOffset); - if (textRange == null) { - // todo[cdr] check this fix. prefix/suffix code annotation case - textRange = findNearestTextRange(documentWindow, startOffset); - if (textRange == null) return null; - final boolean isBefore = startOffset < textRange.getStartOffset(); - fixedTextRange = new ProperTextRange(isBefore ? textRange.getStartOffset() - 1 : textRange.getEndOffset(), - isBefore ? textRange.getStartOffset() : textRange.getEndOffset() + 1); - } - else { - fixedTextRange = null; - } - return fixedTextRange; - } - - private static void addPatchedInfos(@NotNull HighlightInfo info, - @NotNull PsiFile injectedPsi, - @NotNull DocumentWindow documentWindow, - @NotNull InjectedLanguageManager injectedLanguageManager, - @Nullable TextRange fixedTextRange, - @NotNull Collection out) { - ProperTextRange textRange = new ProperTextRange(info.startOffset, info.endOffset); - List editables = injectedLanguageManager.intersectWithAllEditableFragments(injectedPsi, textRange); - for (TextRange editable : editables) { - TextRange hostRange = fixedTextRange == null ? documentWindow.injectedToHost(editable) : fixedTextRange; - - boolean isAfterEndOfLine = info.isAfterEndOfLine(); - if (isAfterEndOfLine) { - // convert injected afterEndOfLine to either host' afterEndOfLine or not-afterEndOfLine highlight of the injected fragment boundary - int hostEndOffset = hostRange.getEndOffset(); - int lineNumber = documentWindow.getDelegate().getLineNumber(hostEndOffset); - int hostLineEndOffset = documentWindow.getDelegate().getLineEndOffset(lineNumber); - if (hostEndOffset < hostLineEndOffset) { - // convert to non-afterEndOfLine - isAfterEndOfLine = false; - hostRange = new ProperTextRange(hostRange.getStartOffset(), hostEndOffset+1); - } - } - - HighlightInfo patched = - new HighlightInfo(info.forcedTextAttributes, info.forcedTextAttributesKey, info.type, - hostRange.getStartOffset(), hostRange.getEndOffset(), - info.getDescription(), info.getToolTip(), info.type.getSeverity(null), isAfterEndOfLine, null, false, 0); - patched.setHint(info.hasHint()); - patched.setGutterIconRenderer(info.getGutterIconRenderer()); - - if (info.quickFixActionRanges != null) { - for (Pair pair : info.quickFixActionRanges) { - TextRange quickfixTextRange = pair.getSecond(); - List editableQF = injectedLanguageManager.intersectWithAllEditableFragments(injectedPsi, quickfixTextRange); - for (TextRange editableRange : editableQF) { - HighlightInfo.IntentionActionDescriptor descriptor = pair.getFirst(); - if (patched.quickFixActionRanges == null) patched.quickFixActionRanges = new ArrayList>(); - TextRange hostEditableRange = documentWindow.injectedToHost(editableRange); - patched.quickFixActionRanges.add(Pair.create(descriptor, hostEditableRange)); - } - } - } - patched.setFromInjection(true); - out.add(patched); - } - } - - // finds the first nearest text range - @Nullable("null means invalid") - private static TextRange findNearestTextRange(final DocumentWindow documentWindow, final int startOffset) { - TextRange textRange = null; - for (Segment marker : documentWindow.getHostRanges()) { - TextRange curRange = ProperTextRange.create(marker); - if (curRange.getStartOffset() > startOffset && textRange != null) break; - textRange = curRange; - } - return textRange; - } - - private void runHighlightVisitorsForInjected(@NotNull PsiFile injectedPsi, - @NotNull final HighlightInfoHolder holder, - @NotNull final ProgressIndicator progress) { - HighlightVisitor[] visitors = getHighlightVisitors(); - try { - HighlightVisitor[] filtered = filterVisitors(visitors, injectedPsi); - final List elements = CollectHighlightsUtil.getElementsInRange(injectedPsi, 0, injectedPsi.getTextLength()); - for (final HighlightVisitor visitor : filtered) { - visitor.analyze(injectedPsi, true, holder, new Runnable() { - @Override - public void run() { - for (PsiElement element : elements) { - progress.checkCanceled(); - visitor.visit(element); - } - } - }); - } - } - finally { - incVisitorUsageCount(-1); - } - } - - private void highlightInjectedSyntax(@NotNull PsiFile injectedPsi, @NotNull HighlightInfoHolder holder) { - List, TextRange>> tokens = InjectedLanguageUtil - .getHighlightTokens(injectedPsi); - if (tokens == null) return; - - final Language injectedLanguage = injectedPsi.getLanguage(); - Project project = injectedPsi.getProject(); - SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(injectedLanguage, project, injectedPsi.getVirtualFile()); - final TextAttributes defaultAttrs = myGlobalScheme.getAttributes(HighlighterColors.TEXT); - - for (Trinity, TextRange> token : tokens) { - ProgressManager.checkCanceled(); - IElementType tokenType = token.getFirst(); - PsiLanguageInjectionHost injectionHost = token.getSecond().getElement(); - if (injectionHost == null) continue; - TextRange textRange = token.getThird(); - TextAttributesKey[] keys = syntaxHighlighter.getTokenHighlights(tokenType); - if (textRange.getLength() == 0) continue; - - TextRange annRange = textRange.shiftRight(injectionHost.getTextRange().getStartOffset()); - // force attribute colors to override host' ones - TextAttributes attributes = null; - for(TextAttributesKey key:keys) { - TextAttributes attrs2 = myGlobalScheme.getAttributes(key); - if (attrs2 != null) { - attributes = attributes == null ? attrs2 : TextAttributes.merge(attributes, attrs2); - } - } - TextAttributes forcedAttributes; - if (attributes == null || attributes.isEmpty() || attributes.equals(defaultAttrs)) { - forcedAttributes = TextAttributes.ERASE_MARKER; - } - else { - HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT).range(annRange).textAttributes( - TextAttributes.ERASE_MARKER).createUnconditionally(); - holder.add(info); - - Color back = attributes.getBackgroundColor() == null ? myGlobalScheme.getDefaultBackground() : attributes.getBackgroundColor(); - Color fore = attributes.getForegroundColor() == null ? myGlobalScheme.getDefaultForeground() : attributes.getForegroundColor(); - forcedAttributes = new TextAttributes(fore, back, attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType()); - } - - HighlightInfo info = - HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT).range(annRange).textAttributes(forcedAttributes) - .createUnconditionally(); - holder.add(info); - } - } - private boolean isWholeFileHighlighting() { return myUpdateAll && myStartOffset == 0 && myEndOffset == myDocument.getTextLength(); } @@ -664,9 +358,6 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP catch (IndexNotReadyException e) { throw e; } - catch (WolfTheProblemSolverImpl.HaveGotErrorException e) { - throw e; - } catch (Exception e) { if (!failed) { LOG.error(e); @@ -738,32 +429,33 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP protected void killAbandonedHighlightsUnder(@NotNull final TextRange range, @Nullable final List holder, @NotNull final ProgressIndicator progress) { - DaemonCodeAnalyzerImpl.processHighlights(getDocument(), myProject, null, range.getStartOffset(), range.getEndOffset(), new Processor() { - @Override - public boolean process(final HighlightInfo existing) { - if (existing.isBijective() && - existing.getGroup() == Pass.UPDATE_ALL && - range.equalsToRange(existing.getActualStartOffset(), existing.getActualEndOffset())) { - if (holder != null) { - for (HighlightInfo created : holder) { - if (existing.equalsByActualOffset(created)) return true; - } - } - // seems that highlight info "existing" is going to disappear - // remove it earlier - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - RangeHighlighterEx highlighter = existing.highlighter; - if (!progress.isCanceled() && highlighter != null) { - highlighter.dispose(); + DaemonCodeAnalyzerEx + .processHighlights(getDocument(), myProject, null, range.getStartOffset(), range.getEndOffset(), new Processor() { + @Override + public boolean process(final HighlightInfo existing) { + if (existing.isBijective() && + existing.getGroup() == Pass.UPDATE_ALL && + range.equalsToRange(existing.getActualStartOffset(), existing.getActualEndOffset())) { + if (holder != null) { + for (HighlightInfo created : holder) { + if (existing.equalsByActualOffset(created)) return true; } } - }); + // seems that highlight info "existing" is going to disappear + // remove it earlier + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + RangeHighlighterEx highlighter = existing.highlighter; + if (!progress.isCanceled() && highlighter != null) { + highlighter.dispose(); + } + } + }); + } + return true; } - return true; - } - }); + }); } private void analyzeByVisitors(@NotNull final ProgressIndicator progress, @@ -787,7 +479,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP } @NotNull - private static HighlightVisitor[] filterVisitors(@NotNull HighlightVisitor[] highlightVisitors, @NotNull PsiFile file) { + protected static HighlightVisitor[] filterVisitors(@NotNull HighlightVisitor[] highlightVisitors, @NotNull PsiFile file) { final List visitors = new ArrayList(highlightVisitors.length); List list = Arrays.asList(highlightVisitors); for (HighlightVisitor visitor : DumbService.getInstance(file.getProject()).filterByDumbAwareness(list)) { @@ -803,7 +495,6 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP static void cancelAndRestartDaemonLater(@NotNull ProgressIndicator progress, @NotNull final Project project, @NotNull TextEditorHighlightingPass passCalledFrom) throws ProcessCanceledException { - PassExecutorService.log(progress, passCalledFrom, "Cancel and restart"); progress.cancel(); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override @@ -836,14 +527,14 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP return new CustomHighlightInfoHolder(file, getColorsScheme(), filters); } - private static void highlightTodos(@NotNull PsiFile file, - @NotNull CharSequence text, - int startOffset, - int endOffset, - @NotNull ProgressIndicator progress, - @NotNull ProperTextRange priorityRange, - @NotNull Collection result, - @NotNull Collection outsideResult) { + protected static void highlightTodos(@NotNull PsiFile file, + @NotNull CharSequence text, + int startOffset, + int endOffset, + @NotNull ProgressIndicator progress, + @NotNull ProperTextRange priorityRange, + @NotNull Collection result, + @NotNull Collection outsideResult) { PsiTodoSearchHelper helper = PsiTodoSearchHelper.SERVICE.getInstance(file.getProject()); TodoItem[] todoItems = helper.findTodoItems(file, startOffset, endOffset); if (todoItems.length == 0) return; @@ -854,9 +545,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP String description = text.subSequence(range.getStartOffset(), range.getEndOffset()).toString(); TextAttributes attributes = todoItem.getPattern().getAttributes().getTextAttributes(); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.TODO).range(range); - if (attributes != null) { - builder.textAttributes(attributes); - } + builder.textAttributes(attributes); builder.descriptionAndTooltip(description); HighlightInfo info = builder.createUnconditionally(); if (priorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) { @@ -878,7 +567,7 @@ public class GeneralHighlightingPass extends ProgressableTextEditorHighlightingP List problems = convertToProblems(getInfos(), file, myHasErrorElement); WolfTheProblemSolver wolf = WolfTheProblemSolver.getInstance(project); - boolean hasErrors = DaemonCodeAnalyzerImpl.hasErrors(project, getDocument()); + boolean hasErrors = DaemonCodeAnalyzerEx.hasErrors(project, getDocument()); if (!hasErrors || isWholeFileHighlighting()) { wolf.reportProblems(file, problems); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPassFactory.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPassFactory.java similarity index 98% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPassFactory.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPassFactory.java index c96c5085ca41..7d9b26762821 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPassFactory.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/GeneralHighlightingPassFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java similarity index 99% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java index 5ce6e13e5a95..b130f0c87b1b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoFilter.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoFilter.java similarity index 96% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoFilter.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoFilter.java index e8b7b4ebefef..fa4185a4c38c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoFilter.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfoFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightRangeExtension.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightRangeExtension.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightRangeExtension.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightRangeExtension.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightVisitor.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightVisitor.java similarity index 97% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightVisitor.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightVisitor.java index 9ab4fe74bdd8..45b910ff4e71 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightVisitor.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightersRecycler.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightersRecycler.java new file mode 100644 index 000000000000..631be5c2c184 --- /dev/null +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/HighlightersRecycler.java @@ -0,0 +1,64 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl; + +import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.util.ProperTextRange; +import com.intellij.openapi.util.TextRange; +import com.intellij.util.SmartList; +import com.intellij.util.containers.MultiMap; +import gnu.trove.THashMap; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Map; + +class HighlightersRecycler { + private final MultiMap incinerator = new MultiMap(){ + @Override + protected Map> createMap() { + return new THashMap>(); + } + + @Override + protected Collection createCollection() { + return new SmartList(); + } + }; + + void recycleHighlighter(@NotNull RangeHighlighter highlighter) { + if (highlighter.isValid()) { + incinerator.putValue(ProperTextRange.create(highlighter), highlighter); + } + } + + RangeHighlighter pickupHighlighterFromGarbageBin(int startOffset, int endOffset, int layer){ + TextRange range = new TextRange(startOffset, endOffset); + Collection collection = incinerator.get(range); + for (RangeHighlighter highlighter : collection) { + if (highlighter.isValid() && highlighter.getLayer() == layer) { + incinerator.removeValue(range, highlighter); + return highlighter; + } + } + return null; + } + + @NotNull + Collection forAllInGarbageBin() { + return incinerator.values(); + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java similarity index 72% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java index 3d2f180e6c71..17924b51254d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/ProgressableTextEditorHighlightingPass.java @@ -18,15 +18,10 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.impl.EditorMarkupModelImpl; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiUtilBase; -import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -56,7 +51,7 @@ public abstract class ProgressableTextEditorHighlightingPass extends TextEditorH public final void doCollectInformation(@NotNull final ProgressIndicator progress) { myFinished = false; collectInformationWithProgress(progress); - repaintTrafficIcon(); + fireProgressHasAdvanced(); } protected abstract void collectInformationWithProgress(@NotNull ProgressIndicator progress); @@ -65,9 +60,13 @@ public abstract class ProgressableTextEditorHighlightingPass extends TextEditorH public final void doApplyInformationToEditor() { myFinished = true; applyInformationWithProgress(); - DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject); - ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).getFileStatusMap().markFileUpToDate(myDocument, getId()); - repaintTrafficIcon(); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + daemonCodeAnalyzer.getFileStatusMap().markFileUpToDate(myDocument, getId()); + fireProgressHasAdvanced(); + } + + private void fireProgressHasAdvanced() { + myProject.getMessageBus().syncPublisher(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC).passProgressHasAdvanced(myFile, getProgress()); } protected abstract void applyInformationWithProgress(); @@ -101,27 +100,9 @@ public abstract class ProgressableTextEditorHighlightingPass extends TextEditorH myProgessLimit = limit; } - private final Alarm repaintIconAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); public void advanceProgress(long delta) { myProgressCount.addAndGet(delta); - repaintTrafficIcon(); - } - - private void repaintTrafficIcon() { - if (ApplicationManager.getApplication().isCommandLine()) return; - - if (repaintIconAlarm.isEmpty() || getProgressCount() >= getProgressLimit()) { - repaintIconAlarm.addRequest(new Runnable() { - @Override - public void run() { - if (myProject.isDisposed()) return; - Editor editor = myFile == null ? null : PsiUtilBase.findEditor(myFile); - if (editor == null || editor.isDisposed()) return; - EditorMarkupModelImpl markup = (EditorMarkupModelImpl)editor.getMarkupModel(); - markup.repaintTrafficLightIcon(); - } - }, 50, null); - } + fireProgressHasAdvanced(); } public static class EmptyPass extends TextEditorHighlightingPass { @@ -135,7 +116,7 @@ public abstract class ProgressableTextEditorHighlightingPass extends TextEditorH @Override public void doApplyInformationToEditor() { - FileStatusMap statusMap = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap(); + FileStatusMap statusMap = DaemonCodeAnalyzerEx.getInstanceEx(myProject).getFileStatusMap(); statusMap.markFileUpToDate(getDocument(), getId()); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorBackgroundHighlighter.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorBackgroundHighlighter.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorBackgroundHighlighter.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorBackgroundHighlighter.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarEx.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarEx.java similarity index 70% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarEx.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarEx.java index 1c2cf3a89a4e..420dcafc36f8 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarEx.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarEx.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.intellij.codeInsight.daemon.impl; +import com.intellij.codeHighlighting.DirtyScopeTrackingHighlightingPassFactory; import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar; import com.intellij.openapi.editor.Document; @@ -36,7 +37,11 @@ public abstract class TextEditorHighlightingPassRegistrarEx extends TextEditorHi return (TextEditorHighlightingPassRegistrarEx)getInstance(project); } - @NotNull public abstract List instantiatePasses(@NotNull PsiFile psiFile, @NotNull Editor editor, @NotNull int[] passesToIgnore); - @NotNull public abstract List instantiateMainPasses(@NotNull PsiFile psiFile, - @NotNull Document document); + @NotNull + public abstract List instantiatePasses(@NotNull PsiFile psiFile, @NotNull Editor editor, @NotNull int[] passesToIgnore); + @NotNull + public abstract List instantiateMainPasses(@NotNull PsiFile psiFile, @NotNull Document document); + + @NotNull + public abstract List getDirtyScopeTrackingFactories(); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PerThreadMap.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/ThreadLocalAnnotatorMap.java old mode 100755 new mode 100644 similarity index 95% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PerThreadMap.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/ThreadLocalAnnotatorMap.java index edf3a8a0225b..3449607a8322 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/PerThreadMap.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/ThreadLocalAnnotatorMap.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import java.util.Map; /** * User: cdr */ -public abstract class PerThreadMap { +abstract class ThreadLocalAnnotatorMap { private volatile int version; @NotNull public abstract Collection initialValue(@NotNull KeyT key); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java similarity index 68% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java index e2d5df0b12c2..e6b8ce379824 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/UpdateHighlightersUtil.java @@ -17,10 +17,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeInsight.daemon.GutterMark; -import com.intellij.codeInsight.daemon.LineMarkerInfo; -import com.intellij.codeInsight.intention.impl.FileLevelIntentionComponent; import com.intellij.lang.annotation.HighlightSeverity; -import com.intellij.lang.injection.InjectedLanguageManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.RangeMarker; @@ -34,24 +31,16 @@ import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.impl.RangeMarkerTree; import com.intellij.openapi.editor.impl.RedBlackTree; import com.intellij.openapi.editor.markup.*; -import com.intellij.openapi.fileEditor.FileEditor; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.TextEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.util.Consumer; import com.intellij.util.Processor; -import com.intellij.util.SmartList; import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.containers.MultiMap; import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; import java.awt.*; import java.util.*; @@ -89,67 +78,10 @@ public class UpdateHighlightersUtil { } }; - private static final Key> FILE_LEVEL_HIGHLIGHTS = Key.create("FILE_LEVEL_HIGHLIGHTS"); - - static void cleanFileLevelHighlights(@NotNull Project project, final int group, PsiFile psiFile) { - if (psiFile == null || !psiFile.getViewProvider().isPhysical()) return; - VirtualFile vFile = psiFile.getViewProvider().getVirtualFile(); - final FileEditorManager manager = FileEditorManager.getInstance(project); - for (FileEditor fileEditor : manager.getEditors(vFile)) { - final List infos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS); - if (infos == null) continue; - List infosToRemove = new ArrayList(); - for (HighlightInfo info : infos) { - if (info.getGroup() == group) { - manager.removeTopComponent(fileEditor, info.fileLevelComponent); - infosToRemove.add(info); - } - } - infos.removeAll(infosToRemove); - } - } - private static boolean isCoveredByOffsets(HighlightInfo info, HighlightInfo coveredBy) { return coveredBy.startOffset <= info.startOffset && info.endOffset <= coveredBy.endOffset && info.getGutterIconRenderer() == null; } - private static class HighlightersRecycler { - private final MultiMap incinerator = new MultiMap(){ - @Override - protected Map> createMap() { - return new THashMap>(); - } - - @Override - protected Collection createCollection() { - return new SmartList(); - } - }; - - private void recycleHighlighter(@NotNull RangeHighlighter highlighter) { - if (highlighter.isValid()) { - incinerator.putValue(ProperTextRange.create(highlighter), highlighter); - } - } - - private RangeHighlighter pickupHighlighterFromGarbageBin(int startOffset, int endOffset, int layer){ - TextRange range = new TextRange(startOffset, endOffset); - Collection collection = incinerator.get(range); - for (RangeHighlighter highlighter : collection) { - if (highlighter.isValid() && highlighter.getLayer() == layer) { - incinerator.removeValue(range, highlighter); - return highlighter; - } - } - return null; - } - - @NotNull - private Collection forAllInGarbageBin() { - return incinerator.values(); - } - } - static void addHighlighterToEditorIncrementally(@NotNull Project project, @NotNull Document document, @NotNull PsiFile file, @@ -176,9 +108,9 @@ public class UpdateHighlightersUtil { return oldInfo.getGroup() != group || !oldInfo.equalsByActualOffset(info); } }; - boolean allIsClear = DaemonCodeAnalyzerImpl.processHighlights(document, project, - null, info.getActualStartOffset(), info.getActualEndOffset(), - otherHighlightInTheWayProcessor); + boolean allIsClear = DaemonCodeAnalyzerEx.processHighlights(document, project, + null, info.getActualStartOffset(), info.getActualEndOffset(), + otherHighlightInTheWayProcessor); if (!allIsClear) { return; } @@ -200,7 +132,8 @@ public class UpdateHighlightersUtil { ApplicationManager.getApplication().assertIsDispatchThread(); PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); - cleanFileLevelHighlights(project, group, psiFile); + final DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(project); + codeAnalyzer.cleanFileLevelHighlights(project, group, psiFile); MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true); assertMarkupConsistent(markup, project); @@ -231,7 +164,8 @@ public class UpdateHighlightersUtil { ApplicationManager.getApplication().assertIsDispatchThread(); final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); - cleanFileLevelHighlights(project, group, psiFile); + final DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(project); + codeAnalyzer.cleanFileLevelHighlights(project, group, psiFile); final MarkupModel markup = DocumentMarkupModel.forDocument(document, project, true); assertMarkupConsistent(markup, project); @@ -240,25 +174,29 @@ public class UpdateHighlightersUtil { final HighlightersRecycler infosToRemove = new HighlightersRecycler(); ContainerUtil.quickSort(infos, BY_START_OFFSET_NODUPS); - DaemonCodeAnalyzerImpl.processHighlightsOverlappingOutside(document, project, null, range.getStartOffset(), range.getEndOffset(), new Processor() { - @Override - public boolean process(HighlightInfo info) { - if (info.getGroup() == group) { - RangeHighlighter highlighter = info.highlighter; - int hiStart = highlighter.getStartOffset(); - int hiEnd = highlighter.getEndOffset(); - if (!info.isFromInjection() && hiEnd < document.getTextLength() && (hiEnd <= startOffset || hiStart>=endOffset)) return true; // injections are oblivious to restricting range - boolean toRemove = !(hiEnd == document.getTextLength() && range.getEndOffset() == document.getTextLength()) && - !range.containsRange(hiStart, hiEnd) - ; - if (toRemove) { - infosToRemove.recycleHighlighter(highlighter); - info.highlighter = null; - } - } - return true; - } - }); + DaemonCodeAnalyzerEx.processHighlightsOverlappingOutside(document, project, null, range.getStartOffset(), range.getEndOffset(), + new Processor() { + @Override + public boolean process(HighlightInfo info) { + if (info.getGroup() == group) { + RangeHighlighter highlighter = info.highlighter; + int hiStart = highlighter.getStartOffset(); + int hiEnd = highlighter.getEndOffset(); + if (!info.isFromInjection() && + hiEnd < document.getTextLength() && + (hiEnd <= startOffset || hiStart >= endOffset)) + return true; // injections are oblivious to restricting range + boolean toRemove = !(hiEnd == document.getTextLength() && + range.getEndOffset() == document.getTextLength()) && + !range.containsRange(hiStart, hiEnd); + if (toRemove) { + infosToRemove.recycleHighlighter(highlighter); + info.highlighter = null; + } + } + return true; + } + }); final Map ranges2markersCache = new THashMap(10); final boolean[] changed = {false}; @@ -274,7 +212,7 @@ public class UpdateHighlightersUtil { if (!info.isFromInjection() && info.getEndOffset() < document.getTextLength() && (info.getEndOffset() <= startOffset || info.getStartOffset()>=endOffset)) return true; // injections are oblivious to restricting range if (info.isFileLevelAnnotation() && psiFile != null && psiFile.getViewProvider().isPhysical()) { - addFileLevelHighlight(project, group, info, psiFile); + codeAnalyzer.addFileLevelHighlight(project, group, info, psiFile); changed[0] = true; return true; } @@ -311,27 +249,29 @@ public class UpdateHighlightersUtil { final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project); final HighlightersRecycler infosToRemove = new HighlightersRecycler(); - DaemonCodeAnalyzerImpl.processHighlights(document, project, null, range.getStartOffset(), range.getEndOffset(), new Processor() { - @Override - public boolean process(HighlightInfo info) { - if (info.getGroup() == group) { - RangeHighlighter highlighter = info.highlighter; - int hiStart = highlighter.getStartOffset(); - int hiEnd = highlighter.getEndOffset(); - boolean willBeRemoved = hiEnd == document.getTextLength() && range.getEndOffset() == document.getTextLength() + DaemonCodeAnalyzerEx + .processHighlights(document, project, null, range.getStartOffset(), range.getEndOffset(), new Processor() { + @Override + public boolean process(HighlightInfo info) { + if (info.getGroup() == group) { + RangeHighlighter highlighter = info.highlighter; + int hiStart = highlighter.getStartOffset(); + int hiEnd = highlighter.getEndOffset(); + boolean willBeRemoved = hiEnd == document.getTextLength() && range.getEndOffset() == document.getTextLength() /*|| range.intersectsStrict(hiStart, hiEnd)*/ || range.containsRange(hiStart, hiEnd) /*|| hiStart <= range.getStartOffset() && hiEnd >= range.getEndOffset()*/; - if (willBeRemoved) { - infosToRemove.recycleHighlighter(highlighter); - info.highlighter = null; + if (willBeRemoved) { + infosToRemove.recycleHighlighter(highlighter); + info.highlighter = null; + } } + return true; } - return true; - } - }); + }); ContainerUtil.quickSort(highlights, BY_START_OFFSET_NODUPS); final Map ranges2markersCache = new THashMap(10); final PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); + final DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(project); final boolean[] changed = {false}; RangeMarkerTree.sweep(new RangeMarkerTree.Generator(){ @Override @@ -345,7 +285,7 @@ public class UpdateHighlightersUtil { return true; } if (info.isFileLevelAnnotation() && psiFile != null && psiFile.getViewProvider().isPhysical()) { - addFileLevelHighlight(project, group, info, psiFile); + codeAnalyzer.addFileLevelHighlight(project, group, info, psiFile); changed[0] = true; return true; } @@ -500,93 +440,6 @@ public class UpdateHighlightersUtil { return marker; } - private static void addFileLevelHighlight(@NotNull final Project project, final int group, @NotNull final HighlightInfo info, @NotNull final PsiFile psiFile) { - VirtualFile vFile = psiFile.getViewProvider().getVirtualFile(); - final FileEditorManager manager = FileEditorManager.getInstance(project); - for (FileEditor fileEditor : manager.getEditors(vFile)) { - if (fileEditor instanceof TextEditor) { - FileLevelIntentionComponent component = new FileLevelIntentionComponent(info.getDescription(), info.getSeverity(), info.quickFixActionRanges, - project, psiFile, ((TextEditor)fileEditor).getEditor()); - manager.addTopComponent(fileEditor, component); - List fileLevelInfos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS); - if (fileLevelInfos == null) { - fileLevelInfos = new ArrayList(); - fileEditor.putUserData(FILE_LEVEL_HIGHLIGHTS, fileLevelInfos); - } - info.fileLevelComponent = component; - info.setGroup(group); - fileLevelInfos.add(info); - } - } - } - - static void setLineMarkersToEditor(@NotNull Project project, - @NotNull Document document, - int startOffset, - int endOffset, - @NotNull Collection markers, - int group) { - ApplicationManager.getApplication().assertIsDispatchThread(); - - List oldMarkers = DaemonCodeAnalyzerImpl.getLineMarkers(document, project); - List array = new ArrayList(oldMarkers == null ? markers.size() : oldMarkers.size()); - MarkupModel markupModel = DocumentMarkupModel.forDocument(document, project, true); - HighlightersRecycler toReuse = new HighlightersRecycler(); - if (oldMarkers != null) { - for (LineMarkerInfo info : oldMarkers) { - RangeHighlighter highlighter = info.highlighter; - boolean toRemove = !highlighter.isValid() || - info.updatePass == group && - startOffset <= highlighter.getStartOffset() && - (highlighter.getEndOffset() < endOffset || highlighter.getEndOffset() == document.getTextLength()); - - if (toRemove) { - toReuse.recycleHighlighter(highlighter); - } - else { - array.add(info); - } - } - } - - for (LineMarkerInfo info : markers) { - PsiElement element = info.getElement(); - if (element == null) { - continue; - } - - TextRange textRange = element.getTextRange(); - if (textRange == null) continue; - TextRange elementRange = InjectedLanguageManager.getInstance(project).injectedToHost(element, textRange); - if (startOffset > elementRange.getStartOffset() || elementRange.getEndOffset() > endOffset) { - continue; - } - RangeHighlighter marker = toReuse.pickupHighlighterFromGarbageBin(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX); - if (marker == null) { - marker = markupModel.addRangeHighlighter(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.EXACT_RANGE); - } - LineMarkerInfo.LineMarkerGutterIconRenderer renderer = (LineMarkerInfo.LineMarkerGutterIconRenderer)info.createGutterRenderer(); - LineMarkerInfo.LineMarkerGutterIconRenderer oldRenderer = marker.getGutterIconRenderer() instanceof LineMarkerInfo.LineMarkerGutterIconRenderer ? (LineMarkerInfo.LineMarkerGutterIconRenderer)marker.getGutterIconRenderer() : null; - if (oldRenderer == null || renderer == null || !renderer.equals(oldRenderer)) { - marker.setGutterIconRenderer(renderer); - } - if (!Comparing.equal(marker.getLineSeparatorColor(), info.separatorColor)) { - marker.setLineSeparatorColor(info.separatorColor); - } - if (!Comparing.equal(marker.getLineSeparatorPlacement(), info.separatorPlacement)) { - marker.setLineSeparatorPlacement(info.separatorPlacement); - } - info.highlighter = marker; - array.add(info); - } - - for (RangeHighlighter highlighter : toReuse.forAllInGarbageBin()) { - highlighter.dispose(); - } - - DaemonCodeAnalyzerImpl.setLineMarkers(document, array, project); - } - private static final Key TYPING_INSIDE_HIGHLIGHTER_OCCURRED = Key.create("TYPING_INSIDE_HIGHLIGHTER_OCCURRED"); static boolean isWhitespaceOptimizationAllowed(@NotNull Document document) { return document.getUserData(TYPING_INSIDE_HIGHLIGHTER_OCCURRED) == null; @@ -611,7 +464,7 @@ public class UpdateHighlightersUtil { final int end = start + Math.max(e.getOldLength(), e.getNewLength()); final List toRemove = new ArrayList(); - DaemonCodeAnalyzerImpl.processHighlights(document, project, null, start, end, new Processor() { + DaemonCodeAnalyzerEx.processHighlights(document, project, null, start, end, new Processor() { @Override public boolean process(HighlightInfo info) { RangeHighlighter highlighter = info.highlighter; @@ -651,28 +504,12 @@ public class UpdateHighlightersUtil { } } - @NotNull - @TestOnly - static List getFileLevelHighlights(@NotNull Project project, @NotNull PsiFile file) { - VirtualFile vFile = file.getViewProvider().getVirtualFile(); - final FileEditorManager manager = FileEditorManager.getInstance(project); - List result = new ArrayList(); - for (FileEditor fileEditor : manager.getEditors(vFile)) { - final List infos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS); - if (infos == null) continue; - for (HighlightInfo info : infos) { - result.add(info); - } - } - return result; - } - private static void assertMarkupConsistent(@NotNull final MarkupModel markup, @NotNull Project project) { if (!RedBlackTree.VERIFY) { return; } Document document = markup.getDocument(); - DaemonCodeAnalyzerImpl.processHighlights(document, project, null, 0, document.getTextLength(), new Processor() { + DaemonCodeAnalyzerEx.processHighlights(document, project, null, 0, document.getTextLength(), new Processor() { @Override public boolean process(HighlightInfo info) { assert ((MarkupModelEx)markup).containsHighlighter(info.highlighter); @@ -687,12 +524,13 @@ public class UpdateHighlightersUtil { continue; } final HighlightInfo info = (HighlightInfo)tooltip; - boolean contains = !DaemonCodeAnalyzerImpl.processHighlights(document, project, null, info.getActualStartOffset(), info.getActualEndOffset(), new Processor() { - @Override - public boolean process(HighlightInfo highlightInfo) { - return BY_START_OFFSET_NODUPS.compare(highlightInfo, info) != 0; - } - }); + boolean contains = !DaemonCodeAnalyzerEx + .processHighlights(document, project, null, info.getActualStartOffset(), info.getActualEndOffset(), new Processor() { + @Override + public boolean process(HighlightInfo highlightInfo) { + return BY_START_OFFSET_NODUPS.compare(highlightInfo, info) != 0; + } + }); assert contains: info; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/VisibleHighlightingPassFactory.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/CustomHighlightInfoHolder.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/CustomHighlightInfoHolder.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/CustomHighlightInfoHolder.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/CustomHighlightInfoHolder.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorQuickFixProvider.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorQuickFixProvider.java similarity index 96% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorQuickFixProvider.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorQuickFixProvider.java index 3a87ff346d22..5b5688ee785f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorQuickFixProvider.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorQuickFixProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java similarity index 98% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java index 42ffe5885324..490947a3a696 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightInfoHolder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingLevelManager.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingLevelManager.java new file mode 100644 index 000000000000..ee7c17b3f344 --- /dev/null +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingLevelManager.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl.analysis; + +import com.intellij.openapi.components.ServiceManager; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; + +public abstract class HighlightingLevelManager { + public static HighlightingLevelManager getInstance(Project project) { + return ServiceManager.getService(project, HighlightingLevelManager.class); + } + + public abstract boolean shouldHighlight(@NotNull PsiElement psiRoot); + public abstract boolean shouldInspect(@NotNull PsiElement psiRoot); +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java similarity index 91% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java index 671f58b27456..1bf49bfba637 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,9 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.openapi.util.Condition; -import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Iterator; import java.util.List; /** diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixActionRegistrarImpl.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixActionRegistrarImpl.java similarity index 97% rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixActionRegistrarImpl.java rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixActionRegistrarImpl.java index 3a44379f8901..a6179cdf448d 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixActionRegistrarImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QuickFixActionRegistrarImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/intention/EmptyIntentionAction.java b/platform/analysis-impl/src/com/intellij/codeInsight/intention/EmptyIntentionAction.java similarity index 98% rename from platform/lang-impl/src/com/intellij/codeInsight/intention/EmptyIntentionAction.java rename to platform/analysis-impl/src/com/intellij/codeInsight/intention/EmptyIntentionAction.java index f4a32a6da98a..76b6b70ae6e4 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/intention/EmptyIntentionAction.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/intention/EmptyIntentionAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInsight/problems/ProblemImpl.java b/platform/analysis-impl/src/com/intellij/codeInsight/problems/ProblemImpl.java similarity index 100% rename from platform/lang-impl/src/com/intellij/codeInsight/problems/ProblemImpl.java rename to platform/analysis-impl/src/com/intellij/codeInsight/problems/ProblemImpl.java diff --git a/platform/lang-impl/src/com/intellij/codeInsight/quickfix/UnresolvedReferenceQuickFixProvider.java b/platform/analysis-impl/src/com/intellij/codeInsight/quickfix/UnresolvedReferenceQuickFixProvider.java similarity index 98% rename from platform/lang-impl/src/com/intellij/codeInsight/quickfix/UnresolvedReferenceQuickFixProvider.java rename to platform/analysis-impl/src/com/intellij/codeInsight/quickfix/UnresolvedReferenceQuickFixProvider.java index 07022bc87263..a1ef1edeb97b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/quickfix/UnresolvedReferenceQuickFixProvider.java +++ b/platform/analysis-impl/src/com/intellij/codeInsight/quickfix/UnresolvedReferenceQuickFixProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInspection/SuppressIntentionActionFromFix.java b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressIntentionActionFromFix.java similarity index 83% rename from platform/lang-impl/src/com/intellij/codeInspection/SuppressIntentionActionFromFix.java rename to platform/analysis-impl/src/com/intellij/codeInspection/SuppressIntentionActionFromFix.java index d90efd796555..0da83b4e86c6 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/SuppressIntentionActionFromFix.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressIntentionActionFromFix.java @@ -16,11 +16,12 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.impl.actions.AbstractBatchSuppressByNoInspectionCommentFix; -import com.intellij.codeInspection.*; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; +import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; public class SuppressIntentionActionFromFix extends SuppressIntentionAction { @@ -35,6 +36,16 @@ public class SuppressIntentionActionFromFix extends SuppressIntentionAction { return new SuppressIntentionActionFromFix(fix); } + @NotNull + public static SuppressIntentionAction[] convertBatchToSuppressIntentionActions(@NotNull SuppressQuickFix[] actions) { + return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function() { + @Override + public SuppressIntentionAction fun(SuppressQuickFix fix) { + return convertBatchToSuppressIntentionAction(fix); + } + }); + } + @Override public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { PsiElement container = myFix instanceof AbstractBatchSuppressByNoInspectionCommentFix diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java index 6aa8adb51b36..b2f0c8ee2cc7 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java @@ -194,4 +194,20 @@ public class SuppressionUtil { } return false; } + + public static boolean inspectionResultSuppressed(@NotNull PsiElement place, @NotNull LocalInspectionTool tool) { + if (tool instanceof CustomSuppressableInspectionTool) { + return ((CustomSuppressableInspectionTool)tool).isSuppressedFor(place); + } + if (tool instanceof BatchSuppressableTool) { + return ((BatchSuppressableTool)tool).isSuppressedFor(place); + } + String alternativeId; + String id; + + return isSuppressed(place, id = tool.getID()) || + (alternativeId = tool.getAlternativeID()) != null && + !alternativeId.equals(id) && + isSuppressed(place, alternativeId); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java b/platform/analysis-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java similarity index 99% rename from platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java rename to platform/analysis-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java index adb1c2922275..d28c9a3874f5 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/actions/CleanupInspectionIntention.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java similarity index 98% rename from platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java rename to platform/analysis-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java index 98c183c6028d..251226105993 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/QuickFixWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/components/ExportableApplicationComponent.java b/platform/core-api/src/com/intellij/openapi/components/ExportableApplicationComponent.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/components/ExportableApplicationComponent.java rename to platform/core-api/src/com/intellij/openapi/components/ExportableApplicationComponent.java index dbbb7bc6717b..bc683e53605e 100644 --- a/platform/platform-api/src/com/intellij/openapi/components/ExportableApplicationComponent.java +++ b/platform/core-api/src/com/intellij/openapi/components/ExportableApplicationComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,4 +16,4 @@ package com.intellij.openapi.components; public interface ExportableApplicationComponent extends ApplicationComponent, ExportableComponent { -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/openapi/components/ExportableComponent.java b/platform/core-api/src/com/intellij/openapi/components/ExportableComponent.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/components/ExportableComponent.java rename to platform/core-api/src/com/intellij/openapi/components/ExportableComponent.java index 17db49444cad..e0bce1e50233 100644 --- a/platform/platform-api/src/com/intellij/openapi/components/ExportableComponent.java +++ b/platform/core-api/src/com/intellij/openapi/components/ExportableComponent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/util/AsyncResult.java b/platform/core-api/src/com/intellij/openapi/util/AsyncResult.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/util/AsyncResult.java rename to platform/core-api/src/com/intellij/openapi/util/AsyncResult.java index bc0710b62e56..c8839c881508 100644 --- a/platform/platform-api/src/com/intellij/openapi/util/AsyncResult.java +++ b/platform/core-api/src/com/intellij/openapi/util/AsyncResult.java @@ -222,4 +222,4 @@ public class AsyncResult extends ActionCallback { subResult.setDone(); } } -} \ No newline at end of file +} diff --git a/platform/core-api/src/com/intellij/util/PlatformUtilsCore.java b/platform/core-api/src/com/intellij/util/PlatformUtilsCore.java index 421be827f5c4..a1a88c623024 100644 --- a/platform/core-api/src/com/intellij/util/PlatformUtilsCore.java +++ b/platform/core-api/src/com/intellij/util/PlatformUtilsCore.java @@ -17,4 +17,61 @@ package com.intellij.util; public class PlatformUtilsCore { public static final String PLATFORM_PREFIX_KEY = "idea.platform.prefix"; + public static final String IDEA_PREFIX = "idea"; + public static final String COMMUNITY_PREFIX = "Idea"; + public static final String APPCODE_PREFIX = "AppCode"; + public static final String CPP_PREFIX = "CppIde"; + public static final String PYCHARM_PREFIX = "Python"; + public static final String RUBY_PREFIX = "Ruby"; + public static final String PHP_PREFIX = "PhpStorm"; + public static final String WEB_PREFIX = "WebStorm"; + public static final String FLEX_PREFIX = "Flex"; + + public static String getPlatformPrefix() { + return getPlatformPrefix(IDEA_PREFIX); + } + + public static String getPlatformPrefix(String defaultPrefix) { + return System.getProperty(PLATFORM_PREFIX_KEY, defaultPrefix); + } + + public static boolean isIdea() { + return IDEA_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isCommunity() { + return COMMUNITY_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isRubyMine() { + return RUBY_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isAppCode() { + return APPCODE_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isCppIde() { + return CPP_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isPyCharm() { + return PYCHARM_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isPhpStorm() { + return PHP_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isWebStorm() { + return WEB_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isFlexIde() { + return FLEX_PREFIX.equals(getPlatformPrefix()); + } + + public static boolean isIntelliJ() { + return isIdea() || isCommunity(); + } } diff --git a/platform/editor-ui-api/editor-ui-api.iml b/platform/editor-ui-api/editor-ui-api.iml new file mode 100644 index 000000000000..a47a2d5b756f --- /dev/null +++ b/platform/editor-ui-api/editor-ui-api.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/platform/analysis-api/src/com/intellij/codeInsight/daemon/GutterMark.java b/platform/editor-ui-api/src/com/intellij/codeInsight/daemon/GutterMark.java similarity index 97% rename from platform/analysis-api/src/com/intellij/codeInsight/daemon/GutterMark.java rename to platform/editor-ui-api/src/com/intellij/codeInsight/daemon/GutterMark.java index fa24951087d6..6534a8236c53 100644 --- a/platform/analysis-api/src/com/intellij/codeInsight/daemon/GutterMark.java +++ b/platform/editor-ui-api/src/com/intellij/codeInsight/daemon/GutterMark.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/ide/DataManager.java b/platform/editor-ui-api/src/com/intellij/ide/DataManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/ide/DataManager.java rename to platform/editor-ui-api/src/com/intellij/ide/DataManager.java diff --git a/platform/platform-api/src/com/intellij/ide/ui/UISettings.java b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java similarity index 97% rename from platform/platform-api/src/com/intellij/ide/ui/UISettings.java rename to platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java index e62921dace35..f76c85bf2b4b 100644 --- a/platform/platform-api/src/com/intellij/ide/ui/UISettings.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.java @@ -25,7 +25,7 @@ import com.intellij.openapi.components.*; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; -import com.intellij.util.PlatformUtils; +import com.intellij.util.PlatformUtilsCore; import com.intellij.util.SystemProperties; import com.intellij.util.ui.UIUtil; import com.intellij.util.xmlb.Accessor; @@ -74,14 +74,14 @@ public class UISettings implements PersistentStateComponent, Exporta public boolean SHOW_NAVIGATION_BAR = true; public boolean ALWAYS_SHOW_WINDOW_BUTTONS = false; public boolean CYCLE_SCROLLING = true; - public boolean SCROLL_TAB_LAYOUT_IN_EDITOR = PlatformUtils.isAppCode(); + public boolean SCROLL_TAB_LAYOUT_IN_EDITOR = PlatformUtilsCore.isAppCode(); public boolean SHOW_CLOSE_BUTTON = true; public int EDITOR_TAB_PLACEMENT = 1; public boolean HIDE_KNOWN_EXTENSION_IN_TABS = false; public boolean SHOW_ICONS_IN_QUICK_NAVIGATION = true; public boolean CLOSE_NON_MODIFIED_FILES_FIRST = false; public boolean ACTIVATE_MRU_EDITOR_ON_CLOSE = false; - public boolean ACTIVATE_RIGHT_EDITOR_ON_CLOSE = PlatformUtils.isAppCode(); + public boolean ACTIVATE_RIGHT_EDITOR_ON_CLOSE = PlatformUtilsCore.isAppCode(); public boolean ANTIALIASING_IN_EDITOR = true; public boolean MOVE_MOUSE_ON_DEFAULT_BUTTON = false; public boolean ENABLE_ALPHA_MODE = false; @@ -106,7 +106,7 @@ public class UISettings implements PersistentStateComponent, Exporta * Defines whether asterisk is shown on modified editor tab or not */ public boolean MARK_MODIFIED_TABS_WITH_ASTERISK = false; - + public boolean SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = false; /** @@ -122,7 +122,7 @@ public class UISettings implements PersistentStateComponent, Exporta private void tweakPlatformDefaults() { // TODO: Make it pluggable - if (PlatformUtils.isAppCode()) { + if (PlatformUtilsCore.isAppCode()) { SHOW_MAIN_TOOLBAR = false; SHOW_ICONS_IN_MENUS = false; SHOW_MEMORY_INDICATOR = false; diff --git a/platform/platform-api/src/com/intellij/ide/ui/UISettingsListener.java b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java similarity index 95% rename from platform/platform-api/src/com/intellij/ide/ui/UISettingsListener.java rename to platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java index 8baf2ddd768b..035fb700e481 100644 --- a/platform/platform-api/src/com/intellij/ide/ui/UISettingsListener.java +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettingsListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionGroup.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionGroup.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/ActionGroup.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionGroup.java index 320b3d8719ea..a0b40adb954c 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionGroup.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionGroup.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionManager.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionManager.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/ActionManager.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionManager.java index dc8e19779532..5077b0ae8fcf 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionManager.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPopupMenu.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionPopupMenu.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPopupMenu.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionPopupMenu.java index 4555c0fab8c4..79531dc2f71f 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionPopupMenu.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionPopupMenu.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import javax.swing.*; /** * Represents a popup menu with a visual presentation. * - * @see ActionManager#createActionPopupMenu(String, ActionGroup) + * @see ActionManager#createActionPopupMenu(String, ActionGroup) */ public interface ActionPopupMenu { /** diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java index fde4ca3fa590..31924b6b80c6 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ActionToolbar.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -106,7 +106,7 @@ public interface ActionToolbar extends SwitchProvider, QuickActionProvider { void updateActionsImmediately(); boolean hasVisibleActions(); - + /** * @param component will be used for datacontext computations */ diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/AnAction.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/AnAction.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java index 87bfa50df32c..7a6a0cf04361 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/AnAction.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -316,7 +316,7 @@ public abstract class AnAction implements PossiblyDumbAware { @Nullable public static Project getEventProject(AnActionEvent e) { - return e == null ? null : e.getData(PlatformDataKeys.PROJECT); + return e == null ? null : e.getData(CommonDataKeys.PROJECT); } @Override diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java index 37035e382e14..f394776a20ca 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,7 +93,7 @@ public class AnActionEvent implements PlaceProvider { */ @Nullable public Project getProject() { - return getData(PlatformDataKeys.PROJECT); + return getData(CommonDataKeys.PROJECT); } @NonNls @@ -107,7 +107,7 @@ public class AnActionEvent implements PlaceProvider { return injected; } } - + @NonNls public static String uninjectedId(@NotNull String dataId) { return StringUtil.trimStart(dataId, ourInjectedPrefix); diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/AnActionEventVisitor.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEventVisitor.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/AnActionEventVisitor.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEventVisitor.java index e3910fbede79..fc078061347c 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/AnActionEventVisitor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnActionEventVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,4 +33,4 @@ public class AnActionEventVisitor { visitEvent(e); } -} \ No newline at end of file +} diff --git a/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java new file mode 100644 index 000000000000..cb7449a2c914 --- /dev/null +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CommonDataKeys.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.actionSystem; + +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.Navigatable; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; + +public class CommonDataKeys { + public static final DataKey PROJECT = DataKey.create("project"); + public static final DataKey EDITOR = DataKey.create("editor"); + + /** + * Returns com.intellij.openapi.editor.Editor even if focus currently is in find bar + */ + public static final DataKey EDITOR_EVEN_IF_INACTIVE = DataKey.create("editor.even.if.inactive"); + public static final DataKey NAVIGATABLE = DataKey.create("Navigatable"); + public static final DataKey NAVIGATABLE_ARRAY = DataKey.create("NavigatableArray"); + public static final DataKey VIRTUAL_FILE = DataKey.create("virtualFile"); + public static final DataKey VIRTUAL_FILE_ARRAY = DataKey.create("virtualFileArray"); + + public static final DataKey PSI_ELEMENT = DataKey.create("psi.Element"); + public static final DataKey PSI_FILE = DataKey.create("psi.File"); +} diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java index 61060869d9e1..b0cd58e4f7c9 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/CustomShortcutSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,4 +73,4 @@ public final class CustomShortcutSet implements ShortcutSet { } return new CustomShortcutSet(shortcuts); } -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataContext.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContext.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/DataContext.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContext.java index 21d2141ce8f3..2e7770865918 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataContext.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataContext.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataKey.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataKey.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/DataKey.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataKey.java index e6bf2e36b339..4066a8141789 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataKey.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataKey.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,4 +80,4 @@ public class DataKey { //noinspection unchecked return (T) dataProvider.getData(myName); } -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataProvider.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataProvider.java similarity index 87% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/DataProvider.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataProvider.java index 53a59cb912b3..9699af282c21 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/DataProvider.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/DataProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +23,8 @@ import org.jetbrains.annotations.Nullable; * data item is requested, the component hierarchy is walked up from the currently focused component, * and every component implementing the DataProvider interface is queried for the data * until one of them returns the data. Data items can also be mapped to each other - for example, - * if a data provider provides an item for {@link PlatformDataKeys#NAVIGATABLE}, an item for - * {@link PlatformDataKeys#NAVIGATABLE_ARRAY} can be generated from it automatically. + * if a data provider provides an item for {@link CommonDataKeys#NAVIGATABLE}, an item for + * {@link CommonDataKeys#NAVIGATABLE_ARRAY} can be generated from it automatically. * * @see DataContext */ diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java index 066b8a639917..ff6ffc93c574 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/KeyboardShortcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public final class KeyboardShortcut extends Shortcut { public boolean startsWith(final Shortcut sc) { if (sc instanceof KeyboardShortcut) { final KeyboardShortcut other = (KeyboardShortcut)sc; - return myFirstKeyStroke.equals(other.myFirstKeyStroke) && (other.mySecondKeyStroke == null || other.mySecondKeyStroke.equals(mySecondKeyStroke)); + return myFirstKeyStroke.equals(other.myFirstKeyStroke) && (other.mySecondKeyStroke == null || other.mySecondKeyStroke.equals(mySecondKeyStroke)); } else { return false; diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/Presentation.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/Presentation.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Presentation.java diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/Shortcut.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Shortcut.java similarity index 83% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/Shortcut.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Shortcut.java index f62581cd05f6..084e1f6e5955 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/Shortcut.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/Shortcut.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,6 @@ */ package com.intellij.openapi.actionSystem; -import com.intellij.openapi.keymap.KeymapUtil; - /** * A keyboard or mouse shortcut which can be used for invoking an action. * @@ -30,9 +28,4 @@ public abstract class Shortcut { public abstract boolean isKeyboard(); public abstract boolean startsWith(final Shortcut sc); - - @Override - public String toString() { - return KeymapUtil.getShortcutText(this); - } } diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ShortcutSet.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ShortcutSet.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/ShortcutSet.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ShortcutSet.java index d7b34b3ba5bb..a5944cddf96d 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ShortcutSet.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ShortcutSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import org.jetbrains.annotations.NotNull; /** * Represents a set of keyboard and/or mouse shortcuts. - * + * * @see AnAction#getShortcutSet() * @see AnAction#setShortcutSet(ShortcutSet) */ diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/TimerListener.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/TimerListener.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/TimerListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/TimerListener.java index a3ccaf4190aa..0e43da8ad4bf 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/TimerListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/TimerListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/AnActionListener.java b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ex/AnActionListener.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/actionSystem/ex/AnActionListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ex/AnActionListener.java index 15e4de089927..f494fdc710ad 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/ex/AnActionListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/ex/AnActionListener.java @@ -19,7 +19,7 @@ * User: max * Date: May 15, 2002 * Time: 9:58:27 PM - * To change template for new class use + * To change template for new class use * Code Style | Class Templates options (Tools | IDE Options). */ package com.intellij.openapi.actionSystem.ex; diff --git a/platform/platform-api/src/com/intellij/openapi/editor/CaretModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/CaretModel.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java index e49f35131b4b..a83020bd6384 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/CaretModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/CaretModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,7 +83,7 @@ public interface CaretModel { * @return true if caret position is up-to-date for now; false otherwise */ boolean isUpToDate(); - + /** * Returns the logical position of the caret. * @@ -116,7 +116,7 @@ public interface CaretModel { /** * Removes a listener for receiving notifications about caret movement. - * + * * @param listener the listener instance. */ void removeCaretListener(@NotNull CaretListener listener); diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java new file mode 100644 index 000000000000..bbcaff285aa6 --- /dev/null +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java @@ -0,0 +1,71 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.editor; + +import com.intellij.openapi.editor.colors.TextAttributesKey; + +/** + * Base highlighter colors for multiple languages. + * + * @author Rustam Vishnyakov + */ +public class DefaultLanguageHighlighterColors { + public static final TextAttributesKey TEMPLATE_LANGUAGE_COLOR = TextAttributesKey.createTextAttributesKey("DEFAULT_TEMPLATE_LANGUAGE_COLOR", HighlighterColors.TEXT); + public static final TextAttributesKey IDENTIFIER = TextAttributesKey.createTextAttributesKey("DEFAULT_IDENTIFIER", HighlighterColors.TEXT); + public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("DEFAULT_NUMBER"); + public static final TextAttributesKey KEYWORD = TextAttributesKey.createTextAttributesKey("DEFAULT_KEYWORD"); + public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("DEFAULT_STRING"); + public static final TextAttributesKey BLOCK_COMMENT = TextAttributesKey.createTextAttributesKey("DEFAULT_BLOCK_COMMENT"); + public static final TextAttributesKey LINE_COMMENT = TextAttributesKey.createTextAttributesKey("DEFAULT_LINE_COMMENT"); + public static final TextAttributesKey DOC_COMMENT = TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT"); + public static final TextAttributesKey OPERATION_SIGN = TextAttributesKey.createTextAttributesKey("DEFAULT_OPERATION_SIGN"); + public static final TextAttributesKey BRACES = TextAttributesKey.createTextAttributesKey("DEFAULT_BRACES"); + public static final TextAttributesKey DOT = TextAttributesKey.createTextAttributesKey("DEFAULT_DOT"); + public static final TextAttributesKey SEMICOLON = TextAttributesKey.createTextAttributesKey("DEFAULT_SEMICOLON"); + public static final TextAttributesKey COMMA = TextAttributesKey.createTextAttributesKey("DEFAULT_COMMA"); + public static final TextAttributesKey PARENTHESES = TextAttributesKey.createTextAttributesKey("DEFAULT_PARENTHS"); + public static final TextAttributesKey BRACKETS = TextAttributesKey.createTextAttributesKey("DEFAULT_BRACKETS"); + + public static final TextAttributesKey LABEL = TextAttributesKey.createTextAttributesKey("DEFAULT_LABEL", IDENTIFIER); + public static final TextAttributesKey CONSTANT = TextAttributesKey.createTextAttributesKey("DEFAULT_CONSTANT", IDENTIFIER); + public static final TextAttributesKey LOCAL_VARIABLE = TextAttributesKey.createTextAttributesKey("DEFAULT_LOCAL_VARIABLE", IDENTIFIER); + public static final TextAttributesKey GLOBAL_VARIABLE = TextAttributesKey.createTextAttributesKey("DEFAULT_GLOBAL_VARIABLE", IDENTIFIER); + + public static final TextAttributesKey FUNCTION_DECLARATION = TextAttributesKey.createTextAttributesKey("DEFAULT_FUNCTION_DECLARATION", IDENTIFIER); + public static final TextAttributesKey FUNCTION_CALL = TextAttributesKey.createTextAttributesKey("DEFAULT_FUNCTION_CALL", IDENTIFIER); + public static final TextAttributesKey PARAMETER = TextAttributesKey.createTextAttributesKey("DEFAULT_PARAMETER", IDENTIFIER); + public static final TextAttributesKey CLASS_NAME = TextAttributesKey.createTextAttributesKey("DEFAULT_CLASS_NAME", IDENTIFIER); + public static final TextAttributesKey INTERFACE_NAME = TextAttributesKey.createTextAttributesKey("DEFAULT_INTERFACE_NAME", IDENTIFIER); + public static final TextAttributesKey CLASS_REFERENCE = TextAttributesKey.createTextAttributesKey("DEFAULT_CLASS_REFERENCE", IDENTIFIER); + public static final TextAttributesKey INSTANCE_METHOD = TextAttributesKey.createTextAttributesKey("DEFAULT_INSTANCE_METHOD", FUNCTION_DECLARATION); + public static final TextAttributesKey INSTANCE_FIELD = TextAttributesKey.createTextAttributesKey("DEFAULT_INSTANCE_FIELD", IDENTIFIER); + public static final TextAttributesKey STATIC_METHOD = TextAttributesKey.createTextAttributesKey("DEFAULT_STATIC_METHOD", FUNCTION_DECLARATION); + public static final TextAttributesKey STATIC_FIELD = TextAttributesKey.createTextAttributesKey("DEFAULT_STATIC_FIELD", IDENTIFIER); + + public static final TextAttributesKey DOC_COMMENT_MARKUP = TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_MARKUP"); + public static final TextAttributesKey DOC_COMMENT_TAG = TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT_TAG"); + public static final TextAttributesKey DOC_COMMENT_TAG_VALUE = TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT_TAG_VALUE"); + public static final TextAttributesKey VALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey("DEFAULT_VALID_STRING_ESCAPE"); + public static final TextAttributesKey INVALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey("DEFAULT_INVALID_STRING_ESCAPE"); + + public static final TextAttributesKey PREDEFINED_SYMBOL = TextAttributesKey.createTextAttributesKey("DEFAULT_PREDEFINED_SYMBOL", IDENTIFIER); + + public static final TextAttributesKey METADATA = TextAttributesKey.createTextAttributesKey("DEFAULT_METADATA", HighlighterColors.TEXT); + + public static final TextAttributesKey MARKUP_TAG = TextAttributesKey.createTextAttributesKey("DEFAULT_TAG", HighlighterColors.TEXT); + public static final TextAttributesKey MARKUP_ATTRIBUTE = TextAttributesKey.createTextAttributesKey("DEFAULT_ATTRIBUTE", IDENTIFIER); + public static final TextAttributesKey MARKUP_ENTITY = TextAttributesKey.createTextAttributesKey("DEFAULT_ENTITY", IDENTIFIER); +} diff --git a/platform/platform-api/src/com/intellij/openapi/editor/Editor.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/editor/Editor.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java index 3ac00e644d86..bd63b43f1af3 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/Editor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/Editor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorFactory.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorFactory.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/editor/EditorFactory.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/EditorFactory.java index 741ac113450d..de3fc9beb902 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/EditorFactory.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorGutter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorGutter.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/EditorGutter.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/EditorGutter.java index e83d6a73c6c3..a1befee4b630 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/EditorGutter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorGutter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorGutterAction.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorGutterAction.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/EditorGutterAction.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/EditorGutterAction.java index 4a17b7df2b82..0332849ab324 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/EditorGutterAction.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorGutterAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorSettings.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/EditorSettings.java index 565748eafae2..59f568bc0d5c 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/EditorSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ public interface EditorSettings { boolean isAllowSingleLogicalLineFolding(); void setAllowSingleLogicalLineFolding(boolean allow); - + boolean isPreselectRename(); void setPreselectRename(final boolean val); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/FoldRegion.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/FoldRegion.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/editor/FoldRegion.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/FoldRegion.java index 819e87c84639..7cf7d922713d 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/FoldRegion.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/FoldRegion.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; * Represents a region of text in the editor which can be folded. * * @see FoldingModel#addFoldRegion(int, int, String) - * @see FoldingModel#addFoldRegion(FoldRegion) + * @see FoldingModel#addFoldRegion(FoldRegion) * @see FoldingModel#getAllFoldRegions() */ public interface FoldRegion extends RangeMarker { diff --git a/platform/platform-api/src/com/intellij/openapi/editor/FoldingModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/FoldingModel.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/FoldingModel.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/FoldingModel.java index 586109c68146..dca85b604208 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/FoldingModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/FoldingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/HighlighterColors.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/HighlighterColors.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/editor/HighlighterColors.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/HighlighterColors.java index 76641a869f08..0bf091032ef6 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/HighlighterColors.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/HighlighterColors.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java index f0ead0728c05..04ee76b7c013 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentGuideDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/IndentStrategy.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentStrategy.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/IndentStrategy.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/IndentStrategy.java index 60391d813916..7ebb2bf409de 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/IndentStrategy.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/IndentsModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentsModel.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/IndentsModel.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/IndentsModel.java index 8cad0420b19d..83dd12cf1763 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/IndentsModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/IndentsModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public interface IndentsModel { /** * Tries to return a descriptor (if any) that defines indent guide for the given lines. - * + * * @param startLine logical line where target indent guide is started * @param endLine logical line where target indent guide is ended * @return indent guide descriptor registered for the given lines at the current model previously if any; @@ -39,5 +39,5 @@ public interface IndentsModel { IndentGuideDescriptor getDescriptor(int startLine, int endLine); void assumeIndents(List descriptors); - + } diff --git a/platform/platform-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java index d4ec5493437c..e27fedbdf9ff 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/LineWrapPositionStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,7 +45,7 @@ public interface LineWrapPositionStrategy { * @param allowToBeyondMaxPreferredOffset indicates if it's allowed to return value from * (maxPreferredOffset; endOffset] interval in case of inability to * find appropriate offset from (startOffset; maxPreferredOffset] interval - * @param virtual identifies if current request is for virtual wrap (soft wrap) position + * @param virtual identifies if current request is for virtual wrap (soft wrap) position * @return offset from (startOffset; endOffset) interval where * target line should be wrapped OR -1 if no wrapping should be performed */ diff --git a/platform/platform-api/src/com/intellij/openapi/editor/LogicalPosition.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/editor/LogicalPosition.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java index 3a38a722fa29..fe767643b73e 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/LogicalPosition.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/LogicalPosition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/ScrollType.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollType.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/editor/ScrollType.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollType.java index c878ef721c66..7551f00a53c2 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/ScrollType.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/ScrollingModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollingModel.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/ScrollingModel.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollingModel.java index bebbc40a82ae..2c40c1f55cc5 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/ScrollingModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/ScrollingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/SelectionModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/SelectionModel.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/editor/SelectionModel.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/SelectionModel.java index b56dde27edd2..077ddd590003 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/SelectionModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/SelectionModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,7 +44,7 @@ public interface SelectionModel { */ @Nullable VisualPosition getSelectionStartPosition(); - + /** * Returns the end offset in the document of the selected text range, or the caret * position if there is currently no selection. @@ -58,7 +58,7 @@ public interface SelectionModel { */ @Nullable VisualPosition getSelectionEndPosition(); - + /** * Returns the text selected in the editor (or the concatenation of text ranges selected * in each line, if block selection mode is used). @@ -83,7 +83,7 @@ public interface SelectionModel { */ @Nullable VisualPosition getLeadSelectionPosition(); - + /** * Checks if a range of text is currently selected in regular (non-block) selection mode. * @@ -105,19 +105,19 @@ public interface SelectionModel { * Selects target range providing information about visual boundary of selection end. *

* That is the case for soft wraps-aware processing where the whole soft wraps virtual space is matched to the same offset. - * + * * @param startOffset start selection offset * @param endPosition end visual position of the text range to select (null argument means that * no specific visual position should be used) * @param endOffset end selection offset */ void setSelection(int startOffset, @Nullable VisualPosition endPosition, int endOffset); - + /** * Selects target range based on its visual boundaries. *

* That is the case for soft wraps-aware processing where the whole soft wraps virtual space is matched to the same offset. - * + * * @param startPosition start visual position of the text range to select (null argument means that * no specific visual position should be used) * @param endPosition end visual position of the text range to select (null argument means that @@ -126,7 +126,7 @@ public interface SelectionModel { * @param endOffset end selection offset */ void setSelection(@Nullable VisualPosition startPosition, int startOffset, @Nullable VisualPosition endPosition, int endOffset); - + /** * Removes the selection in the editor. */ diff --git a/platform/platform-api/src/com/intellij/openapi/editor/SoftWrap.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/SoftWrap.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/SoftWrap.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/SoftWrap.java index 6a0a9241ea87..9ea348750f56 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/SoftWrap.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/SoftWrap.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/SoftWrapModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/SoftWrapModel.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/editor/SoftWrapModel.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/SoftWrapModel.java index 05f7b6e53745..cc99831be130 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/SoftWrapModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/SoftWrapModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/editor-ui-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java new file mode 100644 index 000000000000..ab6cd2dd77b0 --- /dev/null +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.openapi.editor; + +import com.intellij.openapi.editor.colors.TextAttributesKey; + +/** + * @author yole + * @deprecated Use {@link DefaultLanguageHighlighterColors} to inherit default attributes. + */ +public class SyntaxHighlighterColors { + public static final TextAttributesKey LINE_COMMENT = TextAttributesKey.createTextAttributesKey("JAVA_LINE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); + public static final TextAttributesKey JAVA_BLOCK_COMMENT = TextAttributesKey.createTextAttributesKey("JAVA_BLOCK_COMMENT", DefaultLanguageHighlighterColors.BLOCK_COMMENT); + public static final TextAttributesKey DOC_COMMENT = TextAttributesKey.createTextAttributesKey("JAVA_DOC_COMMENT", DefaultLanguageHighlighterColors.DOC_COMMENT); + public static final TextAttributesKey KEYWORD = TextAttributesKey.createTextAttributesKey("JAVA_KEYWORD", DefaultLanguageHighlighterColors.KEYWORD); + public static final TextAttributesKey NUMBER = TextAttributesKey.createTextAttributesKey("JAVA_NUMBER", DefaultLanguageHighlighterColors.NUMBER); + public static final TextAttributesKey STRING = TextAttributesKey.createTextAttributesKey("JAVA_STRING", DefaultLanguageHighlighterColors.STRING); + public static final TextAttributesKey OPERATION_SIGN = TextAttributesKey.createTextAttributesKey("JAVA_OPERATION_SIGN", DefaultLanguageHighlighterColors.OPERATION_SIGN); + public static final TextAttributesKey PARENTHS = TextAttributesKey.createTextAttributesKey("JAVA_PARENTH", DefaultLanguageHighlighterColors.PARENTHESES); + public static final TextAttributesKey BRACKETS = TextAttributesKey.createTextAttributesKey("JAVA_BRACKETS", DefaultLanguageHighlighterColors.BRACKETS); + public static final TextAttributesKey BRACES = TextAttributesKey.createTextAttributesKey("JAVA_BRACES", DefaultLanguageHighlighterColors.BRACES); + public static final TextAttributesKey COMMA = TextAttributesKey.createTextAttributesKey("JAVA_COMMA", DefaultLanguageHighlighterColors.COMMA); + public static final TextAttributesKey DOT = TextAttributesKey.createTextAttributesKey("JAVA_DOT", DefaultLanguageHighlighterColors.DOT); + public static final TextAttributesKey JAVA_SEMICOLON = TextAttributesKey.createTextAttributesKey("JAVA_SEMICOLON", DefaultLanguageHighlighterColors.SEMICOLON); + public static final TextAttributesKey DOC_COMMENT_TAG = TextAttributesKey.createTextAttributesKey("JAVA_DOC_TAG", DefaultLanguageHighlighterColors.DOC_COMMENT_TAG); + public static final TextAttributesKey DOC_COMMENT_MARKUP = TextAttributesKey.createTextAttributesKey("JAVA_DOC_MARKUP", DefaultLanguageHighlighterColors.DOC_COMMENT_MARKUP); + public static final TextAttributesKey VALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey("JAVA_VALID_STRING_ESCAPE", DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE); + public static final TextAttributesKey INVALID_STRING_ESCAPE = TextAttributesKey.createTextAttributesKey("JAVA_INVALID_STRING_ESCAPE", DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE); +} diff --git a/platform/platform-api/src/com/intellij/openapi/editor/TextAnnotationGutterProvider.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/TextAnnotationGutterProvider.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/TextAnnotationGutterProvider.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/TextAnnotationGutterProvider.java index b57f180933c3..42e8c296a08e 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/TextAnnotationGutterProvider.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/TextAnnotationGutterProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/VisualPosition.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/VisualPosition.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java index 0e3b48135bee..3b54cc64613c 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/VisualPosition.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/VisualPosition.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull; * @see LogicalPosition * @see Editor#logicalToVisualPosition(LogicalPosition) * @see Editor#offsetToVisualPosition(int) - * @see Editor#xyToVisualPosition(java.awt.Point) + * @see Editor#xyToVisualPosition(java.awt.Point) */ public class VisualPosition { public final int line; @@ -49,7 +49,7 @@ public class VisualPosition { *

  • it has the same visual line but its column is greater;
  • * * - * + * * @param other visual position to compare with the current one * @return true if current position is 'after' the given one; false otherwise */ @@ -59,7 +59,7 @@ public class VisualPosition { } return line > other.line; } - + @NonNls public String toString() { return "VisualPosition: (" + line + ", " + column+")"; diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColors.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColors.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColors.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColors.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsListener.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsListener.java index 4fa3d6350ab6..a24064308d67 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsManager.java diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java index 3b57b7a75530..989ddac83728 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,22 +49,22 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, TextA * However, old single font-based API is still here in order to preserve backward compatibility ({@link #getEditorFontName()} and * {@link #getEditorFontSize()}). I.e. those methods are just re-written in order to use {@link FontPreferences} object exposed * by this method. - * + * * @return font preferences to use */ @NotNull FontPreferences getFontPreferences(); void setFontPreferences(@NotNull FontPreferences preferences); - + String getEditorFontName(); void setEditorFontName(String fontName); - + int getEditorFontSize(); void setEditorFontSize(int fontSize); - + FontSize getQuickDocFontSize(); void setQuickDocFontSize(@NotNull FontSize fontSize); - + Font getFont(EditorFontType key); void setFont(EditorFontType key, Font font); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorFontType.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontType.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/colors/EditorFontType.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontType.java index 766d4e9e143a..e98a742e5417 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorFontType.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/EditorFontType.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java index 3ca505d22858..557d41435878 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/FontPreferences.java @@ -32,7 +32,7 @@ import java.util.List; * The basic idea is to allow end-user to configure not a single font but fonts list instead - every time particular font is unable * to display particular char, next font is tried. This is an improvement over an old approach when it was possible to configure * only a single font family. Fallback fonts were chosen randomly when that font family was unable to display particular char then. - * + * * @author Denis Zhdanov * @since 12/20/12 9:37 PM */ @@ -44,11 +44,11 @@ public class FontPreferences { @NotNull private final TObjectIntHashMap myFontSizes = new TObjectIntHashMap(); @NotNull private final List myEffectiveFontFamilies = ContainerUtilRt.newArrayList(); @NotNull private final List myRealFontFamilies = ContainerUtilRt.newArrayList(); - + @Nullable Runnable myChangeListener; /** - * Font size to use by default. Default value is {@link #DEFAULT_FONT_SIZE}. + * Font size to use by default. Default value is {@link #DEFAULT_FONT_SIZE}. */ private int myTemplateFontSize = DEFAULT_FONT_SIZE; @@ -77,7 +77,7 @@ public class FontPreferences { myChangeListener.run(); } } - + public boolean hasSize(@NotNull String fontName) { return myFontSizes.containsKey(fontName); } @@ -105,7 +105,7 @@ public class FontPreferences { *

    * Effective fonts will hold fallback values for such font families then (exposed by the current method), 'real fonts' will * be available via {@link #getRealFontFamilies()}. - * + * * @return effective font families to use */ @NotNull @@ -115,13 +115,13 @@ public class FontPreferences { /** * @return 'real' font families - * @see #getEffectiveFontFamilies() + * @see #getEffectiveFontFamilies() */ @NotNull public List getRealFontFamilies() { return myRealFontFamilies; } - + public void register(@NotNull String fontFamily, int size) { String fallbackFontFamily = getFallbackName(fontFamily, size, null); if (!myRealFontFamilies.contains(fontFamily)) { @@ -156,7 +156,7 @@ public class FontPreferences { myChangeListener.run(); } } - + public void copyTo(@NotNull final FontPreferences preferences) { preferences.myEffectiveFontFamilies.clear(); preferences.myEffectiveFontFamilies.addAll(myEffectiveFontFamilies); @@ -211,7 +211,7 @@ public class FontPreferences { * {@code new Font("Monaco", style, size)}, it creates a font object which has font family "Monaco" but is a "Dialog" font. *

    * That's why we have a special check for such a situation. - * + * * @param fontName font family name to check * @param fontSize target font size * @param fallbackScheme colors scheme to use for fallback fonts retrieval (if necessary); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/package.html b/platform/editor-ui-api/src/com/intellij/openapi/editor/colors/package.html similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/colors/package.html rename to platform/editor-ui-api/src/com/intellij/openapi/editor/colors/package.html diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/CaretEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretEvent.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/event/CaretEvent.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretEvent.java index 4f491287cfa4..5d37f95faf1c 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/CaretEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/CaretListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretListener.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/event/CaretListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretListener.java index 82f7c353068a..d99649c97d2f 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/CaretListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/CaretListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java index d5bcfb2ba228..a475c05588c7 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull; * Allows to attach listeners which receive notifications about changes in any currently open * editor. * - * @see com.intellij.openapi.editor.EditorFactory#getEventMulticaster() + * @see com.intellij.openapi.editor.EditorFactory#getEventMulticaster() */ public interface EditorEventMulticaster { void addDocumentListener(@NotNull DocumentListener listener); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java index c5d06eca1929..0ff1d0394f06 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorFactoryListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryListener.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/event/EditorFactoryListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryListener.java index faf45bdb8ae4..b855a0c5f834 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorFactoryListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorFactoryListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java index 50c7e3600e6b..29de2f6a8c8a 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java index 3da706c8c6f3..5242d958a9fe 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseEventArea.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseListener.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseListener.java index 0e0eba4c0d87..80b0bd980816 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseMotionListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseMotionListener.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseMotionListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseMotionListener.java index eaf76eb05f1e..b7dad9fc620a 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/EditorMouseMotionListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorMouseMotionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/SelectionEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/SelectionEvent.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/event/SelectionEvent.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/SelectionEvent.java index 3592cd386325..6aadb1a931f1 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/SelectionEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/SelectionEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,11 +59,11 @@ public class SelectionEvent extends EventObject { public TextRange getNewRange() { return getRange(myNewRanges); } - + public TextRange[] getOldRanges() { return myOldRanges; } - + public TextRange[] getNewRanges() { return myNewRanges; } diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/SelectionListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/SelectionListener.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/event/SelectionListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/SelectionListener.java index 25249f2efddb..cbc696781b97 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/SelectionListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/SelectionListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java index 424caf4213a7..64932f90f5e5 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/VisibleAreaListener.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaListener.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/event/VisibleAreaListener.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaListener.java index 5f0753ed8eae..ae9d9ef46c83 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/event/VisibleAreaListener.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/VisibleAreaListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/event/package.html b/platform/editor-ui-api/src/com/intellij/openapi/editor/event/package.html similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/event/package.html rename to platform/editor-ui-api/src/com/intellij/openapi/editor/event/package.html diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighter.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighter.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighter.java index cb09d0a18b45..14d1eddd9748 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/EditorHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterClient.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/HighlighterClient.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterClient.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/HighlighterClient.java index 762835849060..9fe0430a0a27 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterClient.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/HighlighterClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java index 336a86977b4c..a7234df1c29b 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/highlighter/HighlighterIterator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java index d26ae1b8480d..5f5a9576be89 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ActiveGutterRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/CustomHighlighterRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/CustomHighlighterRenderer.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/CustomHighlighterRenderer.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/CustomHighlighterRenderer.java index 223b219c0e39..d0fe0c4cb996 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/CustomHighlighterRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/CustomHighlighterRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java index fd85a283bb33..3eab4483d884 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/ErrorStripeRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,4 +20,4 @@ import java.awt.*; public interface ErrorStripeRenderer { @Deprecated String getTooltipMessage(); void paint(Component c, Graphics g, Rectangle r); -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java index 653a9fcdc736..9e0fb32f1267 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterDraggableObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java index cfbf096d3ff9..9ffb962dc306 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,7 @@ public abstract class GutterIconRenderer implements GutterMark { /** * Returns the callback which can be used to handle drag and drop of the gutter icon. - * + * * @return the drag handler callback, or null if no drag and drop of the icon is required. */ @Nullable diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/HighlighterLayer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/HighlighterLayer.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/HighlighterLayer.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/HighlighterLayer.java index 5901edd56abb..da21cde7e1e3 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/HighlighterLayer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/HighlighterLayer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/HighlighterTargetArea.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/HighlighterTargetArea.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/HighlighterTargetArea.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/HighlighterTargetArea.java index 32c2b2ec50ce..134f55b67e5c 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/HighlighterTargetArea.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/HighlighterTargetArea.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/LineMarkerRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/LineMarkerRenderer.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/LineMarkerRenderer.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/LineMarkerRenderer.java index 94cd96272690..b4659fb37b7f 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/LineMarkerRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/LineMarkerRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,4 +38,4 @@ public interface LineMarkerRenderer { * and the bottom of the last line). */ void paint(Editor editor, Graphics g, Rectangle r); -} \ No newline at end of file +} diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/LineSeparatorRenderer.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/LineSeparatorRenderer.java similarity index 95% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/LineSeparatorRenderer.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/LineSeparatorRenderer.java index e4131943e78e..fbe5f86bd8de 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/LineSeparatorRenderer.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/LineSeparatorRenderer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/MarkupEditorFilter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupEditorFilter.java similarity index 96% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/MarkupEditorFilter.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupEditorFilter.java index 5d18dbde5cbb..9890998a4706 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/MarkupEditorFilter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupEditorFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/MarkupModel.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupModel.java similarity index 99% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/MarkupModel.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupModel.java index dd21ec66cc04..5b52dc1ffb97 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/MarkupModel.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/MarkupModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java similarity index 98% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java index 0092c5a55f33..099c27077f1f 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/RangeHighlighter.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,6 @@ */ package com.intellij.openapi.editor.markup; -import com.intellij.codeInsight.daemon.GutterMark; import com.intellij.openapi.editor.RangeMarker; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/SeparatorPlacement.java b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/SeparatorPlacement.java similarity index 94% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/SeparatorPlacement.java rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/SeparatorPlacement.java index e5bebc607311..f83577d6e4f7 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/markup/SeparatorPlacement.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/SeparatorPlacement.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/package.html b/platform/editor-ui-api/src/com/intellij/openapi/editor/markup/package.html similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/markup/package.html rename to platform/editor-ui-api/src/com/intellij/openapi/editor/markup/package.html diff --git a/platform/platform-api/src/com/intellij/openapi/editor/package.html b/platform/editor-ui-api/src/com/intellij/openapi/editor/package.html similarity index 100% rename from platform/platform-api/src/com/intellij/openapi/editor/package.html rename to platform/editor-ui-api/src/com/intellij/openapi/editor/package.html diff --git a/platform/platform-api/src/com/intellij/openapi/options/FontSize.java b/platform/editor-ui-api/src/com/intellij/openapi/options/FontSize.java similarity index 97% rename from platform/platform-api/src/com/intellij/openapi/options/FontSize.java rename to platform/editor-ui-api/src/com/intellij/openapi/options/FontSize.java index b17bdaaad822..fb8da74071f2 100644 --- a/platform/platform-api/src/com/intellij/openapi/options/FontSize.java +++ b/platform/editor-ui-api/src/com/intellij/openapi/options/FontSize.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,16 +25,16 @@ import javax.swing.text.html.StyleSheet; *

    * Note that such elements selection (and this enum existence at all) is based on the fact that standard Swing {@link JEditorPane} * used by IJ for providing quick doc works only with predefined set of font sizes (see {@link StyleSheet#sizeMapDefault}). - * + * * @author Denis Zhdanov * @since 1/26/11 10:22 AM */ public enum FontSize { - + XX_SMALL(8), X_SMALL(10), SMALL(12), MEDIUM(14), LARGE(18), X_LARGE(24), XX_LARGE(36); private final int mySize; - + FontSize(int size) { mySize = size; } diff --git a/platform/platform-api/src/com/intellij/ui/PlaceProvider.java b/platform/editor-ui-api/src/com/intellij/ui/PlaceProvider.java similarity index 94% rename from platform/platform-api/src/com/intellij/ui/PlaceProvider.java rename to platform/editor-ui-api/src/com/intellij/ui/PlaceProvider.java index c74cbc5e79b4..6f0f4c26e151 100644 --- a/platform/platform-api/src/com/intellij/ui/PlaceProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ui/PlaceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/ui/switcher/QuickAccessProvider.java b/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickAccessProvider.java similarity index 94% rename from platform/platform-api/src/com/intellij/ui/switcher/QuickAccessProvider.java rename to platform/editor-ui-api/src/com/intellij/ui/switcher/QuickAccessProvider.java index be4bbca32420..cc88b950eb51 100644 --- a/platform/platform-api/src/com/intellij/ui/switcher/QuickAccessProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickAccessProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/ui/switcher/QuickActionProvider.java b/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java similarity index 96% rename from platform/platform-api/src/com/intellij/ui/switcher/QuickActionProvider.java rename to platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java index d6f157f24916..7de29e05f281 100644 --- a/platform/platform-api/src/com/intellij/ui/switcher/QuickActionProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ui/switcher/QuickActionProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/ui/switcher/SwitchProvider.java b/platform/editor-ui-api/src/com/intellij/ui/switcher/SwitchProvider.java similarity index 95% rename from platform/platform-api/src/com/intellij/ui/switcher/SwitchProvider.java rename to platform/editor-ui-api/src/com/intellij/ui/switcher/SwitchProvider.java index 484083849149..2f12f2cd9240 100644 --- a/platform/platform-api/src/com/intellij/ui/switcher/SwitchProvider.java +++ b/platform/editor-ui-api/src/com/intellij/ui/switcher/SwitchProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/platform-api/src/com/intellij/ui/switcher/SwitchTarget.java b/platform/editor-ui-api/src/com/intellij/ui/switcher/SwitchTarget.java similarity index 95% rename from platform/platform-api/src/com/intellij/ui/switcher/SwitchTarget.java rename to platform/editor-ui-api/src/com/intellij/ui/switcher/SwitchTarget.java index bb410b2d247c..114362e3cda9 100644 --- a/platform/platform-api/src/com/intellij/ui/switcher/SwitchTarget.java +++ b/platform/editor-ui-api/src/com/intellij/ui/switcher/SwitchTarget.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2013 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/platform/editor-ui-impl/editor-ui-impl.iml b/platform/editor-ui-impl/editor-ui-impl.iml new file mode 100644 index 000000000000..7d91a314d5d0 --- /dev/null +++ b/platform/editor-ui-impl/editor-ui-impl.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/platform/platform-impl/src/com/intellij/injected/editor/MarkupModelWindow.java b/platform/editor-ui-impl/src/com/intellij/injected/editor/MarkupModelWindow.java similarity index 93% rename from platform/platform-impl/src/com/intellij/injected/editor/MarkupModelWindow.java rename to platform/editor-ui-impl/src/com/intellij/injected/editor/MarkupModelWindow.java index 84f1e31ac753..abe37908f9db 100644 --- a/platform/platform-impl/src/com/intellij/injected/editor/MarkupModelWindow.java +++ b/platform/editor-ui-impl/src/com/intellij/injected/editor/MarkupModelWindow.java @@ -155,4 +155,24 @@ public class MarkupModelWindow extends UserDataHolderBase implements MarkupModel // todo convert return myHostModel.sweep(start, end, sweepProcessor); } + + @Override + public void fireAttributesChanged(@NotNull RangeHighlighterEx segmentHighlighter) { + + } + + @Override + public void fireAfterAdded(@NotNull RangeHighlighterEx segmentHighlighter) { + + } + + @Override + public void fireBeforeRemoved(@NotNull RangeHighlighterEx segmentHighlighter) { + + } + + @Override + public void addRangeHighlighter(RangeHighlighterEx marker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { + + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java similarity index 86% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java index 396eb5cddbea..e5cb4d3fe8f3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java +++ b/platform/editor-ui-impl/src/com/intellij/openapi/editor/ex/MarkupModelEx.java @@ -34,8 +34,22 @@ public interface MarkupModelEx extends MarkupModel { @Nullable RangeHighlighter addPersistentLineHighlighter(int lineNumber, int layer, TextAttributes textAttributes); + + void fireAttributesChanged(@NotNull RangeHighlighterEx segmentHighlighter); + + void fireAfterAdded(@NotNull RangeHighlighterEx segmentHighlighter); + + void fireBeforeRemoved(@NotNull RangeHighlighterEx segmentHighlighter); + boolean containsHighlighter(@NotNull RangeHighlighter highlighter); + void addRangeHighlighter(RangeHighlighterEx marker, + int start, + int end, + boolean greedyToLeft, + boolean greedyToRight, + int layer); + void addMarkupModelListener(@NotNull Disposable parentDisposable, @NotNull MarkupModelListener listener); void setRangeHighlighterAttributes(@NotNull RangeHighlighter highlighter, @NotNull TextAttributes textAttributes); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/RangeHighlighterEx.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/ex/RangeHighlighterEx.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/ex/RangeHighlighterEx.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/ex/RangeHighlighterEx.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModel.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModel.java similarity index 80% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModel.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModel.java index b9b2f781c6bb..524fbdd35512 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModel.java +++ b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModel.java @@ -23,6 +23,8 @@ import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.markup.MarkupModel; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.UserDataHolderEx; +import com.intellij.util.ConcurrencyUtil; import com.intellij.util.containers.ConcurrentHashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,8 +37,6 @@ import java.util.concurrent.ConcurrentMap; * @author yole */ public class DocumentMarkupModel { - private static final Object lock = new Object(); - private static final Key MARKUP_MODEL_KEY = Key.create("DocumentMarkupModel.MarkupModel"); private static final Key> MARKUP_MODEL_MAP_KEY = Key.create("DocumentMarkupModel.MarkupModelMap"); @@ -64,12 +64,9 @@ public class DocumentMarkupModel { if (project == null) { MarkupModelEx markupModel = document.getUserData(MARKUP_MODEL_KEY); if (create && markupModel == null) { - synchronized (lock) { - markupModel = document.getUserData(MARKUP_MODEL_KEY); - if (markupModel == null) { - markupModel = new MarkupModelImpl((DocumentEx)document); - document.putUserData(MARKUP_MODEL_KEY, markupModel); - } + MarkupModelEx newModel = new MarkupModelImpl((DocumentEx)document); + if ((markupModel = ((UserDataHolderEx)document).putUserDataIfAbsent(MARKUP_MODEL_KEY, newModel)) != newModel) { + newModel.dispose(); } } return markupModel; @@ -85,13 +82,12 @@ public class DocumentMarkupModel { MarkupModelImpl model = markupModelMap.get(project); if (create && model == null) { - synchronized (lock) { - model = markupModelMap.get(project); - if (model == null) { - model = new MarkupModelImpl((DocumentImpl)document); - markupModelMap.put(project, model); - documentMarkupModelManager.registerDocument((DocumentImpl)document); - } + MarkupModelImpl newModel = new MarkupModelImpl((DocumentEx)document); + if ((model = ConcurrencyUtil.cacheOrGet(markupModelMap, project, newModel)) == newModel) { + documentMarkupModelManager.registerDocument((DocumentImpl)document); + } + else { + newModel.dispose(); } } @@ -101,14 +97,8 @@ public class DocumentMarkupModel { private static ConcurrentMap getMarkupModelMap(@NotNull Document document) { ConcurrentMap markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY); if (markupModelMap == null) { - synchronized (lock) { - markupModelMap = document.getUserData(MARKUP_MODEL_MAP_KEY); - if (markupModelMap == null) { - markupModelMap = new ConcurrentHashMap(); - document.putUserData(MARKUP_MODEL_MAP_KEY, markupModelMap); - } - - } + ConcurrentMap newMap = new ConcurrentHashMap(); + markupModelMap = ((UserDataHolderEx)document).putUserDataIfAbsent(MARKUP_MODEL_MAP_KEY, newMap); } return markupModelMap; } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModelManager.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModelManager.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModelManager.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/DocumentMarkupModelManager.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java similarity index 90% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java index cdc7cce02ca1..7c384f05ca6a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java +++ b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/EmptyMarkupModel.java @@ -132,4 +132,24 @@ public class EmptyMarkupModel implements MarkupModelEx { public boolean sweep(int start, int end, @NotNull SweepProcessor sweepProcessor) { return false; } + + @Override + public void fireAttributesChanged(@NotNull RangeHighlighterEx segmentHighlighter) { + + } + + @Override + public void fireAfterAdded(@NotNull RangeHighlighterEx segmentHighlighter) { + + } + + @Override + public void fireBeforeRemoved(@NotNull RangeHighlighterEx segmentHighlighter) { + + } + + @Override + public void addRangeHighlighter(RangeHighlighterEx marker, int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { + + } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java similarity index 92% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java index fa01ff5f5f8c..1d671d2b2ac9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java +++ b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/MarkupModelImpl.java @@ -150,14 +150,15 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx } } - IntervalTreeImpl.IntervalNode addRangeHighlighter(RangeHighlighterEx marker, - int start, - int end, - boolean greedyToLeft, - boolean greedyToRight, - int layer) { + @Override + public void addRangeHighlighter(RangeHighlighterEx marker, + int start, + int end, + boolean greedyToLeft, + boolean greedyToRight, + int layer) { ApplicationManager.getApplication().assertIsDispatchThread(); - return myHighlighterTree.addInterval(marker, start, end, greedyToLeft, greedyToRight, layer); + myHighlighterTree.addInterval(marker, start, end, greedyToLeft, greedyToRight, layer); } @Override @@ -212,22 +213,25 @@ public class MarkupModelImpl extends UserDataHolderBase implements MarkupModelEx @Override public void setRangeHighlighterAttributes(@NotNull final RangeHighlighter highlighter, @NotNull final TextAttributes textAttributes) { ApplicationManager.getApplication().assertIsDispatchThread(); - ((RangeHighlighterImpl)highlighter).setTextAttributes(textAttributes); + ((RangeHighlighterEx)highlighter).setTextAttributes(textAttributes); } - protected void fireAttributesChanged(RangeHighlighterEx segmentHighlighter) { + @Override + public void fireAttributesChanged(@NotNull RangeHighlighterEx segmentHighlighter) { for (MarkupModelListener listener : myListeners) { listener.attributesChanged(segmentHighlighter); } } - private void fireAfterAdded(RangeHighlighterEx segmentHighlighter) { + @Override + public void fireAfterAdded(@NotNull RangeHighlighterEx segmentHighlighter) { for (MarkupModelListener listener : myListeners) { listener.afterAdded(segmentHighlighter); } } - void fireBeforeRemoved(RangeHighlighterEx segmentHighlighter) { + @Override + public void fireBeforeRemoved(@NotNull RangeHighlighterEx segmentHighlighter) { for (MarkupModelListener listener : myListeners) { listener.beforeRemoved(segmentHighlighter); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/PersistentRangeHighlighterImpl.java diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java similarity index 97% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java index d001a9306632..4e3a0f6355cb 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java +++ b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterData.java @@ -18,6 +18,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.codeInsight.daemon.GutterMark; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.markup.*; import com.intellij.openapi.util.Comparing; @@ -212,12 +213,12 @@ abstract class RangeHighlighterData { } private void fireChanged() { - if (myModel instanceof MarkupModelImpl) { + if (myModel instanceof MarkupModelEx) { if (isFlagSet(IN_BATCH_CHANGE_FLAG)) { setFlag(CHANGED_FLAG, true); } else { - ((MarkupModelImpl)myModel).fireAttributesChanged(getRangeHighlighter()); + ((MarkupModelEx)myModel).fireAttributesChanged(getRangeHighlighter()); } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java similarity index 97% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java index 664dd861855f..0ad4c7396337 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java +++ b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterImpl.java @@ -16,6 +16,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.openapi.editor.ex.DocumentEx; +import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.markup.*; import com.intellij.openapi.util.Getter; @@ -58,7 +59,7 @@ class RangeHighlighterImpl extends RangeMarkerImpl implements RangeHighlighterEx @Override protected void registerInTree(int start, int end, boolean greedyToLeft, boolean greedyToRight, int layer) { // we store highlighters in MarkupModel - ((MarkupModelImpl)data.getMarkupModel()).addRangeHighlighter(this, start, end, greedyToLeft, greedyToRight, layer); + ((MarkupModelEx)data.getMarkupModel()).addRangeHighlighter(this, start, end, greedyToLeft, greedyToRight, layer); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterTree.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterTree.java similarity index 93% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterTree.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterTree.java index e6bb73d4e028..3b9dd10ff0ba 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterTree.java +++ b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/RangeHighlighterTree.java @@ -16,6 +16,7 @@ package com.intellij.openapi.editor.impl; import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.util.Getter; import org.jetbrains.annotations.NotNull; @@ -24,9 +25,9 @@ import org.jetbrains.annotations.NotNull; * User: cdr */ public class RangeHighlighterTree extends RangeMarkerTree { - private final MarkupModelImpl myMarkupModel; + private final MarkupModelEx myMarkupModel; - public RangeHighlighterTree(@NotNull Document document, @NotNull MarkupModelImpl markupModel) { + public RangeHighlighterTree(@NotNull Document document, @NotNull MarkupModelEx markupModel) { super(document); myMarkupModel = markupModel; } @@ -65,7 +66,7 @@ public class RangeHighlighterTree extends RangeMarkerTree { //range highlighters are strongly referenced @Override protected Getter createGetter(@NotNull RangeHighlighterEx interval) { - return (RangeHighlighterImpl)interval; + return (Getter)interval; } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/event/MarkupModelListener.java b/platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/event/MarkupModelListener.java similarity index 100% rename from platform/platform-impl/src/com/intellij/openapi/editor/impl/event/MarkupModelListener.java rename to platform/editor-ui-impl/src/com/intellij/openapi/editor/impl/event/MarkupModelListener.java diff --git a/platform/lang-api/src/com/intellij/psi/search/PsiTodoSearchHelper.java b/platform/indexing-api/src/com/intellij/psi/search/PsiTodoSearchHelper.java similarity index 100% rename from platform/lang-api/src/com/intellij/psi/search/PsiTodoSearchHelper.java rename to platform/indexing-api/src/com/intellij/psi/search/PsiTodoSearchHelper.java diff --git a/platform/lang-api/src/com/intellij/psi/search/TodoAttributes.java b/platform/indexing-api/src/com/intellij/psi/search/TodoAttributes.java similarity index 69% rename from platform/lang-api/src/com/intellij/psi/search/TodoAttributes.java rename to platform/indexing-api/src/com/intellij/psi/search/TodoAttributes.java index 0c7f2e1143af..d92e9565b92f 100644 --- a/platform/lang-api/src/com/intellij/psi/search/TodoAttributes.java +++ b/platform/indexing-api/src/com/intellij/psi/search/TodoAttributes.java @@ -16,21 +16,19 @@ package com.intellij.psi.search; import com.intellij.icons.AllIcons; -import com.intellij.openapi.editor.colors.CodeInsightColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.util.WriteExternalException; import org.jdom.Element; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import javax.swing.*; /** * @author Vladimir Kondratyev */ -public class TodoAttributes implements JDOMExternalizable, Cloneable { +public class TodoAttributes implements Cloneable { private Icon myIcon; private TextAttributes myTextAttributes = new TextAttributes(); @@ -43,44 +41,7 @@ public class TodoAttributes implements JDOMExternalizable, Cloneable { @NonNls private static final String ELEMENT_OPTION = "option"; @NonNls private static final String USE_CUSTOM_COLORS_ATT = "useCustomColors"; - public TodoAttributes() { - } - - private TodoAttributes(Icon icon, TextAttributes textAttributes){ - myIcon = icon; - myTextAttributes = textAttributes; - } - - public Icon getIcon(){ - return myIcon; - } - - public TextAttributes getTextAttributes() { - return shouldUseCustomTodoColor() - ? getCustomizedTextAttributes() - : getDefaultColorSchemeTextAttributes(); - } - - public TextAttributes getCustomizedTextAttributes() { - return myTextAttributes; - } - - - public void setIcon(Icon icon) { - myIcon = icon; - } - - public static TodoAttributes createDefault() { - final TextAttributes textAttributes = getDefaultColorSchemeTextAttributes().clone(); - return new TodoAttributes(AllIcons.General.TodoDefault, textAttributes); - } - - private static TextAttributes getDefaultColorSchemeTextAttributes() { - return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.TODO_DEFAULT_ATTRIBUTES).clone(); - } - - @Override - public void readExternal(Element element) throws InvalidDataException { + public TodoAttributes(@NotNull Element element, @NotNull TextAttributes defaultTodoAttributes) throws InvalidDataException { String icon = element.getAttributeValue(ATTRIBUTE_ICON,ICON_DEFAULT); if (ICON_DEFAULT.equals(icon)){ @@ -97,19 +58,37 @@ public class TodoAttributes implements JDOMExternalizable, Cloneable { } myTextAttributes.readExternal(element); if (element.getChild(ELEMENT_OPTION) == null) { - myTextAttributes = getDefaultColorSchemeTextAttributes(); + myTextAttributes = defaultTodoAttributes; } // default color setting final String useCustomColors = element.getAttributeValue(USE_CUSTOM_COLORS_ATT); - if (useCustomColors == null) { - myShouldUseCustomColors = false; - } else { - myShouldUseCustomColors = Boolean.valueOf(useCustomColors).booleanValue(); - } + myShouldUseCustomColors = useCustomColors != null && Boolean.valueOf(useCustomColors).booleanValue(); + } + + TodoAttributes(@NotNull Icon icon, @NotNull TextAttributes textAttributes){ + myIcon = icon; + myTextAttributes = textAttributes; + } + + public Icon getIcon(){ + return myIcon; + } + + @NotNull + public TextAttributes getTextAttributes() { + return getCustomizedTextAttributes(); + } + + @NotNull + public TextAttributes getCustomizedTextAttributes() { + return myTextAttributes; + } + + public void setIcon(Icon icon) { + myIcon = icon; } - @Override public void writeExternal(Element element) throws WriteExternalException { String icon; if (myIcon == AllIcons.General.TodoDefault){ @@ -137,17 +116,15 @@ public class TodoAttributes implements JDOMExternalizable, Cloneable { final TodoAttributes attributes = (TodoAttributes)o; - if (myIcon != attributes.myIcon) return false; - if (myTextAttributes != null ? !myTextAttributes.equals(attributes.myTextAttributes) : attributes.myTextAttributes != null) return false; - if (myShouldUseCustomColors != attributes.myShouldUseCustomColors) return false; - return true; + return myIcon == attributes.myIcon && + !(myTextAttributes != null ? !myTextAttributes.equals(attributes.myTextAttributes) : attributes.myTextAttributes != null) && + myShouldUseCustomColors == attributes.myShouldUseCustomColors; } public int hashCode() { - int result; - result = myIcon != null ? myIcon.hashCode() : 0; + int result = myIcon != null ? myIcon.hashCode() : 0; result = 29 * result + (myTextAttributes != null ? myTextAttributes.hashCode() : 0); - result = 29 * result + (Boolean.valueOf(myShouldUseCustomColors).hashCode()); + result = 29 * result + Boolean.valueOf(myShouldUseCustomColors).hashCode(); return result; } @@ -156,8 +133,11 @@ public class TodoAttributes implements JDOMExternalizable, Cloneable { return myShouldUseCustomColors; } - public void setUseCustomTodoColor(boolean useCustomColors) { + public void setUseCustomTodoColor(boolean useCustomColors, @NotNull TextAttributes defaultTodoAttributes) { myShouldUseCustomColors = useCustomColors; + if (!useCustomColors) { + myTextAttributes = defaultTodoAttributes; + } } diff --git a/platform/lang-api/src/com/intellij/psi/search/TodoItem.java b/platform/indexing-api/src/com/intellij/psi/search/TodoItem.java similarity index 100% rename from platform/lang-api/src/com/intellij/psi/search/TodoItem.java rename to platform/indexing-api/src/com/intellij/psi/search/TodoItem.java diff --git a/platform/lang-api/src/com/intellij/psi/search/TodoPattern.java b/platform/indexing-api/src/com/intellij/psi/search/TodoPattern.java similarity index 89% rename from platform/lang-api/src/com/intellij/psi/search/TodoPattern.java rename to platform/indexing-api/src/com/intellij/psi/search/TodoPattern.java index 71a6dda0a229..6322d28aac34 100644 --- a/platform/lang-api/src/com/intellij/psi/search/TodoPattern.java +++ b/platform/indexing-api/src/com/intellij/psi/search/TodoPattern.java @@ -16,9 +16,9 @@ package com.intellij.psi.search; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.util.WriteExternalException; import org.jdom.Element; import org.jetbrains.annotations.NonNls; @@ -29,7 +29,7 @@ import java.util.regex.Pattern; /** * @author Vladimir Kondratyev */ -public class TodoPattern implements Cloneable, JDOMExternalizable { +public class TodoPattern implements Cloneable { private static final Logger LOG = Logger.getInstance("#com.intellij.psi.search.TodoPattern"); private IndexPattern myIndexPattern; @@ -42,11 +42,11 @@ public class TodoPattern implements Cloneable, JDOMExternalizable { @NonNls private static final String CASE_SENS_ATT = "case-sensitive"; @NonNls private static final String PATTERN_ATT = "pattern"; - public TodoPattern(){ - this("", TodoAttributes.createDefault(), false); + public TodoPattern(@NotNull TodoAttributes attributes){ + this("", attributes, false); } - public TodoPattern(@NotNull @NonNls String patternString, @NotNull TodoAttributes attributes, boolean caseSensitive){ + public TodoPattern(@NotNull @NonNls String patternString, @NotNull TodoAttributes attributes, boolean caseSensitive) { myIndexPattern = new IndexPattern(patternString, caseSensitive); myAttributes = attributes; } @@ -95,10 +95,8 @@ public class TodoPattern implements Cloneable, JDOMExternalizable { return myIndexPattern.getPattern(); } - @Override - public void readExternal(Element element) throws InvalidDataException { - myAttributes = new TodoAttributes(); - myAttributes.readExternal(element); + public void readExternal(Element element, @NotNull TextAttributes defaultTodoAttributes) throws InvalidDataException { + myAttributes = new TodoAttributes(element,defaultTodoAttributes); myIndexPattern.setCaseSensitive(Boolean.valueOf(element.getAttributeValue(CASE_SENS_ATT)).booleanValue()); String attributeValue = element.getAttributeValue(PATTERN_ATT); if (attributeValue != null){ @@ -106,7 +104,6 @@ public class TodoPattern implements Cloneable, JDOMExternalizable { } } - @Override public void writeExternal(Element element) throws WriteExternalException { myAttributes.writeExternal(element); element.setAttribute(CASE_SENS_ATT, Boolean.toString(myIndexPattern.isCaseSensitive())); diff --git a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java index a7235246ee96..c3f1bc3cb2fd 100644 --- a/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java +++ b/platform/lang-api/src/com/intellij/openapi/actionSystem/LangDataKeys.java @@ -25,7 +25,6 @@ import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.ui.popup.JBPopup; import com.intellij.openapi.util.Condition; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; /** * @author yole @@ -39,8 +38,6 @@ public class LangDataKeys extends PlatformDataKeys { public static final DataKey MODULE_CONTEXT_ARRAY = DataKey.create("context.Module.Array"); public static final DataKey MODIFIABLE_MODULE_MODEL = DataKey.create("modifiable.module.model"); - public static final DataKey PSI_ELEMENT = DataKey.create("psi.Element"); - public static final DataKey PSI_FILE = DataKey.create("psi.File"); public static final DataKey LANGUAGE = DataKey.create("Language"); public static final DataKey CONTEXT_LANGUAGES = DataKey.create("context.Languages"); public static final DataKey PSI_ELEMENT_ARRAY = DataKey.create("psi.Element.array"); diff --git a/platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java b/platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java deleted file mode 100644 index bf1d18a7a5ca..000000000000 --- a/platform/lang-api/src/com/intellij/openapi/editor/DefaultLanguageHighlighterColors.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.openapi.editor; - -import com.intellij.openapi.editor.colors.TextAttributesKey; -import com.intellij.openapi.editor.markup.TextAttributes; - -/** - * Base highlighter colors for multiple languages. - * - * @author Rustam Vishnyakov - */ -public class DefaultLanguageHighlighterColors { - - public final static TextAttributesKey TEMPLATE_LANGUAGE_COLOR = - TextAttributesKey.createTextAttributesKey("DEFAULT_TEMPLATE_LANGUAGE_COLOR", HighlighterColors.TEXT); - public final static TextAttributesKey IDENTIFIER = - TextAttributesKey.createTextAttributesKey("DEFAULT_IDENTIFIER", HighlighterColors.TEXT); - public final static TextAttributesKey NUMBER = - TextAttributesKey.createTextAttributesKey("DEFAULT_NUMBER"); - public final static TextAttributesKey KEYWORD = - TextAttributesKey.createTextAttributesKey("DEFAULT_KEYWORD"); - public final static TextAttributesKey STRING = - TextAttributesKey.createTextAttributesKey("DEFAULT_STRING"); - public final static TextAttributesKey BLOCK_COMMENT = - TextAttributesKey.createTextAttributesKey("DEFAULT_BLOCK_COMMENT"); - public final static TextAttributesKey LINE_COMMENT = - TextAttributesKey.createTextAttributesKey("DEFAULT_LINE_COMMENT"); - public final static TextAttributesKey DOC_COMMENT = - TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT"); - public final static TextAttributesKey OPERATION_SIGN = - TextAttributesKey.createTextAttributesKey("DEFAULT_OPERATION_SIGN"); - public final static TextAttributesKey BRACES = - TextAttributesKey.createTextAttributesKey("DEFAULT_BRACES"); - public final static TextAttributesKey DOT = - TextAttributesKey.createTextAttributesKey("DEFAULT_DOT"); - public final static TextAttributesKey SEMICOLON = - TextAttributesKey.createTextAttributesKey("DEFAULT_SEMICOLON"); - public final static TextAttributesKey COMMA = - TextAttributesKey.createTextAttributesKey("DEFAULT_COMMA"); - public final static TextAttributesKey PARENTHESES = - TextAttributesKey.createTextAttributesKey("DEFAULT_PARENTHS"); - public final static TextAttributesKey BRACKETS = - TextAttributesKey.createTextAttributesKey("DEFAULT_BRACKETS"); - - public final static TextAttributesKey LABEL = - TextAttributesKey.createTextAttributesKey("DEFAULT_LABEL", IDENTIFIER); - public final static TextAttributesKey CONSTANT = - TextAttributesKey.createTextAttributesKey("DEFAULT_CONSTANT", IDENTIFIER); - public final static TextAttributesKey LOCAL_VARIABLE = - TextAttributesKey.createTextAttributesKey("DEFAULT_LOCAL_VARIABLE", IDENTIFIER); - public final static TextAttributesKey GLOBAL_VARIABLE = - TextAttributesKey.createTextAttributesKey("DEFAULT_GLOBAL_VARIABLE", IDENTIFIER); - - public final static TextAttributesKey FUNCTION_DECLARATION = - TextAttributesKey.createTextAttributesKey("DEFAULT_FUNCTION_DECLARATION", IDENTIFIER); - public final static TextAttributesKey FUNCTION_CALL = - TextAttributesKey.createTextAttributesKey("DEFAULT_FUNCTION_CALL", IDENTIFIER); - public final static TextAttributesKey PARAMETER = - TextAttributesKey.createTextAttributesKey("DEFAULT_PARAMETER", IDENTIFIER); - public final static TextAttributesKey CLASS_NAME = - TextAttributesKey.createTextAttributesKey("DEFAULT_CLASS_NAME", IDENTIFIER); - public final static TextAttributesKey INTERFACE_NAME = - TextAttributesKey.createTextAttributesKey("DEFAULT_INTERFACE_NAME", IDENTIFIER); - public final static TextAttributesKey CLASS_REFERENCE = - TextAttributesKey.createTextAttributesKey("DEFAULT_CLASS_REFERENCE", IDENTIFIER); - public final static TextAttributesKey INSTANCE_METHOD = - TextAttributesKey.createTextAttributesKey("DEFAULT_INSTANCE_METHOD", FUNCTION_DECLARATION); - public final static TextAttributesKey INSTANCE_FIELD = - TextAttributesKey.createTextAttributesKey("DEFAULT_INSTANCE_FIELD", IDENTIFIER); - public final static TextAttributesKey STATIC_METHOD = - TextAttributesKey.createTextAttributesKey("DEFAULT_STATIC_METHOD", FUNCTION_DECLARATION); - public final static TextAttributesKey STATIC_FIELD = - TextAttributesKey.createTextAttributesKey("DEFAULT_STATIC_FIELD", IDENTIFIER); - - public final static TextAttributesKey DOC_COMMENT_MARKUP = - TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_MARKUP"); - public final static TextAttributesKey DOC_COMMENT_TAG = - TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT_TAG"); - public final static TextAttributesKey DOC_COMMENT_TAG_VALUE = - TextAttributesKey.createTextAttributesKey("DEFAULT_DOC_COMMENT_TAG_VALUE"); - public final static TextAttributesKey VALID_STRING_ESCAPE = - TextAttributesKey.createTextAttributesKey("DEFAULT_VALID_STRING_ESCAPE"); - public final static TextAttributesKey INVALID_STRING_ESCAPE = - TextAttributesKey.createTextAttributesKey("DEFAULT_INVALID_STRING_ESCAPE"); - - public final static TextAttributesKey PREDEFINED_SYMBOL = - TextAttributesKey.createTextAttributesKey("DEFAULT_PREDEFINED_SYMBOL", IDENTIFIER); - - public final static TextAttributesKey METADATA = - TextAttributesKey.createTextAttributesKey("DEFAULT_METADATA", HighlighterColors.TEXT); - - public final static TextAttributesKey MARKUP_TAG = - TextAttributesKey.createTextAttributesKey("DEFAULT_TAG", HighlighterColors.TEXT); - public final static TextAttributesKey MARKUP_ATTRIBUTE = - TextAttributesKey.createTextAttributesKey("DEFAULT_ATTRIBUTE", IDENTIFIER); - public final static TextAttributesKey MARKUP_ENTITY = - TextAttributesKey.createTextAttributesKey("DEFAULT_ENTITY", IDENTIFIER); -} diff --git a/platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java b/platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java deleted file mode 100644 index fe4ee2a70a72..000000000000 --- a/platform/lang-api/src/com/intellij/openapi/editor/SyntaxHighlighterColors.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.intellij.openapi.editor; - -import com.intellij.openapi.editor.colors.TextAttributesKey; - -/** - * @author yole - * @deprecated Use DefaultLanguageHighlighterColors to inherit default attributes. - */ -public class SyntaxHighlighterColors { - public static final TextAttributesKey LINE_COMMENT = - TextAttributesKey.createTextAttributesKey("JAVA_LINE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); - public static final TextAttributesKey JAVA_BLOCK_COMMENT = - TextAttributesKey.createTextAttributesKey("JAVA_BLOCK_COMMENT", DefaultLanguageHighlighterColors.BLOCK_COMMENT); - public static final TextAttributesKey DOC_COMMENT = - TextAttributesKey.createTextAttributesKey("JAVA_DOC_COMMENT", DefaultLanguageHighlighterColors.DOC_COMMENT); - public static final TextAttributesKey KEYWORD = - TextAttributesKey.createTextAttributesKey("JAVA_KEYWORD", DefaultLanguageHighlighterColors.KEYWORD); - public static final TextAttributesKey NUMBER = - TextAttributesKey.createTextAttributesKey("JAVA_NUMBER", DefaultLanguageHighlighterColors.NUMBER); - public static final TextAttributesKey STRING = - TextAttributesKey.createTextAttributesKey("JAVA_STRING", DefaultLanguageHighlighterColors.STRING); - public static final TextAttributesKey OPERATION_SIGN = - TextAttributesKey.createTextAttributesKey("JAVA_OPERATION_SIGN", DefaultLanguageHighlighterColors.OPERATION_SIGN); - public static final TextAttributesKey PARENTHS = - TextAttributesKey.createTextAttributesKey("JAVA_PARENTH", DefaultLanguageHighlighterColors.PARENTHESES); - public static final TextAttributesKey BRACKETS = - TextAttributesKey.createTextAttributesKey("JAVA_BRACKETS", DefaultLanguageHighlighterColors.BRACKETS); - public static final TextAttributesKey BRACES = - TextAttributesKey.createTextAttributesKey("JAVA_BRACES", DefaultLanguageHighlighterColors.BRACES); - public static final TextAttributesKey COMMA = - TextAttributesKey.createTextAttributesKey("JAVA_COMMA", DefaultLanguageHighlighterColors.COMMA); - public static final TextAttributesKey DOT = TextAttributesKey.createTextAttributesKey("JAVA_DOT", DefaultLanguageHighlighterColors.DOT); - public static final TextAttributesKey JAVA_SEMICOLON = - TextAttributesKey.createTextAttributesKey("JAVA_SEMICOLON", DefaultLanguageHighlighterColors.SEMICOLON); - public static final TextAttributesKey DOC_COMMENT_TAG = - TextAttributesKey.createTextAttributesKey("JAVA_DOC_TAG", DefaultLanguageHighlighterColors.DOC_COMMENT_TAG); - public static final TextAttributesKey DOC_COMMENT_MARKUP = - TextAttributesKey.createTextAttributesKey("JAVA_DOC_MARKUP", DefaultLanguageHighlighterColors.DOC_COMMENT_MARKUP); - public static final TextAttributesKey VALID_STRING_ESCAPE = - TextAttributesKey.createTextAttributesKey("JAVA_VALID_STRING_ESCAPE", DefaultLanguageHighlighterColors.VALID_STRING_ESCAPE); - public static final TextAttributesKey INVALID_STRING_ESCAPE = - TextAttributesKey.createTextAttributesKey("JAVA_INVALID_STRING_ESCAPE", DefaultLanguageHighlighterColors.INVALID_STRING_ESCAPE); -} diff --git a/platform/lang-api/src/com/intellij/psi/search/TodoAttributesUtil.java b/platform/lang-api/src/com/intellij/psi/search/TodoAttributesUtil.java new file mode 100644 index 000000000000..e38b5d50b489 --- /dev/null +++ b/platform/lang-api/src/com/intellij/psi/search/TodoAttributesUtil.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.search; + +import com.intellij.icons.AllIcons; +import com.intellij.openapi.editor.colors.CodeInsightColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.TextAttributes; +import org.jetbrains.annotations.NotNull; + +public class TodoAttributesUtil { + @NotNull + public static TodoAttributes createDefault() { + final TextAttributes textAttributes = getDefaultColorSchemeTextAttributes().clone(); + return new TodoAttributes(AllIcons.General.TodoDefault, textAttributes); + } + + @NotNull + public static TextAttributes getDefaultColorSchemeTextAttributes() { + return EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.TODO_DEFAULT_ATTRIBUTES).clone(); + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java index 2b3368f831f0..d5353db96d8c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java @@ -22,6 +22,7 @@ import com.intellij.codeHighlighting.Pass; import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.daemon.*; import com.intellij.codeInsight.hint.HintManager; +import com.intellij.codeInsight.intention.impl.FileLevelIntentionComponent; import com.intellij.codeInsight.intention.impl.IntentionHintComponent; import com.intellij.concurrency.Job; import com.intellij.ide.PowerSaveMode; @@ -35,8 +36,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; -import com.intellij.openapi.editor.ex.EditorMarkupModel; -import com.intellij.openapi.editor.ex.MarkupModelEx; import com.intellij.openapi.editor.ex.RangeHighlighterEx; import com.intellij.openapi.editor.impl.DocumentMarkupModel; import com.intellij.openapi.editor.markup.MarkupModel; @@ -56,7 +55,6 @@ import com.intellij.packageDependencies.DependencyValidationManager; import com.intellij.psi.PsiCompiledElement; import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiFileSystemItem; import com.intellij.psi.impl.PsiDocumentManagerImpl; import com.intellij.psi.search.scope.packageSet.NamedScopeManager; import com.intellij.psi.util.PsiUtilCore; @@ -78,10 +76,11 @@ import java.util.*; /** * This class also controls the auto-reparse and auto-hints. */ -public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMExternalizable, NamedComponent { +public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements JDOMExternalizable, NamedComponent { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl"); private static final Key> MARKERS_IN_EDITOR_DOCUMENT_KEY = Key.create("MARKERS_IN_EDITOR_DOCUMENT"); + private static final Key> FILE_LEVEL_HIGHLIGHTS = Key.create("FILE_LEVEL_HIGHLIGHTS"); private final Project myProject; private final DaemonCodeAnalyzerSettings mySettings; @NotNull private final EditorTracker myEditorTracker; @@ -127,8 +126,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx final ProgressIndicator updateProgress) { if (fileEditor instanceof TextEditor) { log(updateProgress, pass, "Apply "); - Editor editor = ((TextEditor)fileEditor).getEditor(); - repaintErrorStripeRenderer(editor); } } @@ -161,11 +158,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx }); } - static boolean hasErrors(@NotNull Project project, @NotNull Document document) { - return !processHighlights(document, project, HighlightSeverity.ERROR, 0, document.getTextLength(), - CommonProcessors.alwaysFalse()); - } - @NotNull @TestOnly public static List getHighlights(@NotNull Document document, HighlightSeverity minSeverity, @NotNull Project project) { @@ -175,6 +167,66 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return infos; } + @Override + @NotNull + @TestOnly + public List getFileLevelHighlights(@NotNull Project project, @NotNull PsiFile file) { + VirtualFile vFile = file.getViewProvider().getVirtualFile(); + final FileEditorManager manager = FileEditorManager.getInstance(project); + List result = new ArrayList(); + for (FileEditor fileEditor : manager.getEditors(vFile)) { + final List infos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS); + if (infos == null) continue; + for (HighlightInfo info : infos) { + result.add(info); + } + } + return result; + } + + @Override + public void cleanFileLevelHighlights(@NotNull Project project, final int group, PsiFile psiFile) { + if (psiFile == null || !psiFile.getViewProvider().isPhysical()) return; + VirtualFile vFile = psiFile.getViewProvider().getVirtualFile(); + final FileEditorManager manager = FileEditorManager.getInstance(project); + for (FileEditor fileEditor : manager.getEditors(vFile)) { + final List infos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS); + if (infos == null) continue; + List infosToRemove = new ArrayList(); + for (HighlightInfo info : infos) { + if (info.getGroup() == group) { + manager.removeTopComponent(fileEditor, info.fileLevelComponent); + infosToRemove.add(info); + } + } + infos.removeAll(infosToRemove); + } + } + + @Override + public void addFileLevelHighlight(@NotNull final Project project, + final int group, + @NotNull final HighlightInfo info, + @NotNull final PsiFile psiFile) { + VirtualFile vFile = psiFile.getViewProvider().getVirtualFile(); + final FileEditorManager manager = FileEditorManager.getInstance(project); + for (FileEditor fileEditor : manager.getEditors(vFile)) { + if (fileEditor instanceof TextEditor) { + FileLevelIntentionComponent component = new FileLevelIntentionComponent(info.getDescription(), info.getSeverity(), info.quickFixActionRanges, + project, psiFile, ((TextEditor)fileEditor).getEditor()); + manager.addTopComponent(fileEditor, component); + List fileLevelInfos = fileEditor.getUserData(FILE_LEVEL_HIGHLIGHTS); + if (fileLevelInfos == null) { + fileLevelInfos = new ArrayList(); + fileEditor.putUserData(FILE_LEVEL_HIGHLIGHTS, fileLevelInfos); + } + info.fileLevelComponent = component; + info.setGroup(group); + fileLevelInfos.add(info); + } + } + } + @NotNull public List runMainPasses(@NotNull PsiFile psiFile, @NotNull Document document, @@ -297,17 +349,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return "DaemonCodeAnalyzer"; } - void repaintErrorStripeRenderer(@NotNull Editor editor) { - if (!myProject.isInitialized()) return; - final Document document = editor.getDocument(); - final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document); - final EditorMarkupModel markup = (EditorMarkupModel)editor.getMarkupModel(); - markup.setErrorPanelPopupHandler(new DaemonEditorPopup(psiFile)); - markup.setErrorStripTooltipRendererProvider(new DaemonTooltipRendererProvider(myProject)); - markup.setMinMarkHeight(DaemonCodeAnalyzerSettings.getInstance().ERROR_STRIPE_MARK_MIN_HEIGHT); - TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markup, myProject, document, psiFile); - } - @Override public void settingsChanged() { DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance(); @@ -437,6 +478,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx myFileStatusMap.allDirtyScopesAreNull(document); } + @Override public boolean isErrorAnalyzingFinished(@NotNull PsiFile file) { if (myDisposed) return false; Document document = PsiDocumentManager.getInstance(myProject).getCachedDocument(file); @@ -445,6 +487,7 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx myFileStatusMap.getFileDirtyScope(document, Pass.UPDATE_ALL) == null; } + @Override @NotNull public FileStatusMap getFileStatusMap() { return myFileStatusMap; @@ -480,52 +523,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx } } - public static boolean processHighlights(@NotNull Document document, - @NotNull Project project, - @Nullable("null means all") final HighlightSeverity minSeverity, - final int startOffset, - final int endOffset, - @NotNull final Processor processor) { - LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed()); - - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project); - MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); - return model.processRangeHighlightersOverlappingWith(startOffset, endOffset, new Processor() { - @Override - public boolean process(@NotNull RangeHighlighterEx marker) { - Object tt = marker.getErrorStripeTooltip(); - if (!(tt instanceof HighlightInfo)) return true; - HighlightInfo info = (HighlightInfo)tt; - return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0 - || info.highlighter == null - || processor.process(info); - } - }); - } - - static boolean processHighlightsOverlappingOutside(@NotNull Document document, - @NotNull Project project, - @Nullable("null means all") final HighlightSeverity minSeverity, - final int startOffset, - final int endOffset, - @NotNull final Processor processor) { - LOG.assertTrue(ApplicationManager.getApplication().isReadAccessAllowed()); - - final SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project); - MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true); - return model.processRangeHighlightersOutside(startOffset, endOffset, new Processor() { - @Override - public boolean process(@NotNull RangeHighlighterEx marker) { - Object tt = marker.getErrorStripeTooltip(); - if (!(tt instanceof HighlightInfo)) return true; - HighlightInfo info = (HighlightInfo)tt; - return minSeverity != null && severityRegistrar.compare(info.getSeverity(), minSeverity) < 0 - || info.highlighter == null - || processor.process(info); - } - }); - } - public static boolean processHighlightsNearOffset(@NotNull Document document, @NotNull Project project, @@ -758,11 +755,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return progress; } - public boolean canChangeFileSilently(@NotNull PsiFileSystemItem file) { - DaemonListeners listeners = DaemonListeners.getInstance(myProject); - return listeners == null || listeners.canChangeFileSilently(file); - } - @Override public void autoImportReferenceAtCursor(@NotNull Editor editor, @NotNull PsiFile file) { for (ReferenceImporter importer : Extensions.getExtensions(ReferenceImporter.EP_NAME)) { @@ -774,12 +766,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzer implements JDOMEx return myUpdateProgress; } - @NotNull - @TestOnly - public static List getFileLevelHighlights(@NotNull Project project, @NotNull PsiFile file) { - return UpdateHighlightersUtil.getFileLevelHighlights(project, file); - } - @TestOnly public void allowToInterrupt(boolean can) { allowToInterrupt = can; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java index dc0978560b42..c3b57a1ce115 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonListeners.java @@ -19,6 +19,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.ProjectTopics; import com.intellij.codeHighlighting.Pass; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings; import com.intellij.codeInsight.hint.TooltipController; import com.intellij.ide.PowerSaveMode; import com.intellij.ide.todo.TodoConfiguration; @@ -40,6 +41,8 @@ import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.event.*; import com.intellij.openapi.editor.ex.EditorEventMulticasterEx; +import com.intellij.openapi.editor.ex.EditorMarkupModel; +import com.intellij.openapi.editor.impl.EditorMarkupModelImpl; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.fileEditor.FileEditorManager; @@ -71,6 +74,8 @@ import com.intellij.psi.*; import com.intellij.psi.impl.PsiDocumentManagerImpl; import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.search.scope.packageSet.NamedScopeManager; +import com.intellij.psi.util.PsiUtilBase; +import com.intellij.util.Alarm; import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.ui.UIUtil; @@ -205,7 +210,7 @@ public class DaemonListeners implements Disposable { myDaemonCodeAnalyzer.setUpdateByTimerEnabled(true); } for (Editor editor : activeEditors) { - myDaemonCodeAnalyzer.repaintErrorStripeRenderer(editor); + repaintErrorStripeRenderer(editor); } } }; @@ -223,7 +228,7 @@ public class DaemonListeners implements Disposable { LOG.debug("Not worth: " + file); return; } - myDaemonCodeAnalyzer.repaintErrorStripeRenderer(editor); + repaintErrorStripeRenderer(editor); } @Override @@ -256,7 +261,7 @@ public class DaemonListeners implements Disposable { if (myProject.isDisposed()) return; for (FileEditor fileEditor : editors) { if (fileEditor instanceof TextEditor) { - myDaemonCodeAnalyzer.repaintErrorStripeRenderer(((TextEditor)fileEditor).getEditor()); + repaintErrorStripeRenderer(((TextEditor)fileEditor).getEditor()); } } } @@ -335,7 +340,51 @@ public class DaemonListeners implements Disposable { } }; LaterInvocator.addModalityStateListener(modalityStateListener,this); + + messageBus.connect().subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() { + @Override + public void daemonFinished() { + Editor editor = fileEditorManager.getSelectedTextEditor(); + if (editor != null) { + repaintErrorStripeRenderer(editor); + } + } + + @Override + public void passProgressHasAdvanced(@NotNull PsiFile file, double progress) { + repaintTrafficIcon(file, progress); + } + + @Override + public void visibleAreaHighlighted(@NotNull PsiFile file, Editor editor) { + // usability: show auto import popup as soon as possible + if (editor != null) { + new ShowAutoImportPass(myProject, file, editor).applyInformationToEditor(); + } + } + }); } + + + private final Alarm repaintIconAlarm = new Alarm(Alarm.ThreadToUse.SWING_THREAD); + private void repaintTrafficIcon(final PsiFile file, double progress) { + if (ApplicationManager.getApplication().isCommandLine()) return; + + if (repaintIconAlarm.isEmpty() || progress >= 1) { + repaintIconAlarm.addRequest(new Runnable() { + @Override + public void run() { + if (myProject.isDisposed()) return; + Editor editor = file == null ? null : PsiUtilBase.findEditor(file); + if (editor == null || editor.isDisposed()) return; + EditorMarkupModelImpl markup = (EditorMarkupModelImpl)editor.getMarkupModel(); + markup.repaintTrafficLightIcon(); + repaintErrorStripeRenderer(editor); + } + }, 50, null); + } + } + static boolean isUnderIgnoredAction(@Nullable Object action) { return action instanceof DocumentRunnable.IgnoreDocumentRunnable || @@ -357,17 +406,21 @@ public class DaemonListeners implements Disposable { LOG.assertTrue(replaced, "Daemon listeners already disposed for the project "+myProject); } - boolean canChangeFileSilently(@NotNull PsiFileSystemItem file) { - if (cutOperationJustHappened) return false; + public static boolean canChangeFileSilently(@NotNull PsiFileSystemItem file) { + Project project = file.getProject(); + DaemonListeners listeners = getInstance(project); + if (listeners == null) return true; + + if (listeners.cutOperationJustHappened) return false; VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) return false; if (file instanceof PsiCodeFragment) return true; - if (!ModuleUtilCore.projectContainsFile(myProject, virtualFile, false)) return false; - Result vcs = vcsThinksItChanged(virtualFile); + if (!ModuleUtilCore.projectContainsFile(project, virtualFile, false)) return false; + Result vcs = listeners.vcsThinksItChanged(virtualFile); if (vcs == Result.CHANGED) return true; if (vcs == Result.UNCHANGED) return false; - return canUndo(virtualFile); + return listeners.canUndo(virtualFile); } private boolean canUndo(@NotNull VirtualFile virtualFile) { @@ -377,7 +430,7 @@ public class DaemonListeners implements Disposable { return false; } - private static enum Result { + private enum Result { CHANGED, UNCHANGED, NOT_SURE } @@ -607,4 +660,15 @@ public class DaemonListeners implements Disposable { myDaemonEventPublisher.daemonCancelEventOccurred(); myDaemonCodeAnalyzer.restart(); } + + void repaintErrorStripeRenderer(@NotNull Editor editor) { + if (!myProject.isInitialized()) return; + final Document document = editor.getDocument(); + final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document); + final EditorMarkupModel markup = (EditorMarkupModel)editor.getMarkupModel(); + markup.setErrorPanelPopupHandler(new DaemonEditorPopup(psiFile)); + markup.setErrorStripTooltipRendererProvider(new DaemonTooltipRendererProvider(myProject)); + markup.setMinMarkHeight(DaemonCodeAnalyzerSettings.getInstance().ERROR_STRIPE_MARK_MIN_HEIGHT); + TrafficLightRenderer.setOrRefreshErrorStripeRenderer(markup, myProject, document, psiFile); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java index 8f2b3e43c9a1..cdd2148fe5ea 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ExternalToolPass.java @@ -17,8 +17,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.TextEditorHighlightingPass; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.lang.ExternalLanguageAnnotators; import com.intellij.lang.Language; import com.intellij.lang.annotation.Annotation; @@ -89,11 +88,12 @@ public class ExternalToolPass extends TextEditorHighlightingPass { final Set relevantLanguages = viewProvider.getLanguages(); for (Language language : relevantLanguages) { PsiFile psiRoot = viewProvider.getPsi(language); - if (!HighlightLevelUtil.shouldInspect(psiRoot)) continue; + if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(psiRoot)) continue; final List externalAnnotators = ExternalLanguageAnnotators.allForFile(language, psiRoot); if (!externalAnnotators.isEmpty()) { - boolean errorFound = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap().wasErrorFound(myDocument); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + boolean errorFound = daemonCodeAnalyzer.getFileStatusMap().wasErrorFound(myDocument); if (errorFound) return; for(ExternalAnnotator externalAnnotator: externalAnnotators) { @@ -110,8 +110,8 @@ public class ExternalToolPass extends TextEditorHighlightingPass { @Override public void doApplyInformationToEditor() { - DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject); - ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).getFileStatusMap().markFileUpToDate(myDocument, getId()); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + daemonCodeAnalyzer.getFileStatusMap().markFileUpToDate(myDocument, getId()); myDocumentListener = new DocumentListener() { @Override diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java index 1fecb3e31fee..c8d9e8f6090f 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/GotoNextErrorHandler.java @@ -71,7 +71,7 @@ public class GotoNextErrorHandler implements CodeInsightActionHandler { final HighlightInfo[][] infoToGo = new HighlightInfo[2][2]; //HighlightInfo[luck-noluck][skip-noskip] final int caretOffsetIfNoLuck = myGoForward ? -1 : document.getTextLength(); - DaemonCodeAnalyzerImpl.processHighlights(document, project, minSeverity, 0, document.getTextLength(), new Processor() { + DaemonCodeAnalyzerEx.processHighlights(document, project, minSeverity, 0, document.getTextLength(), new Processor() { @Override public boolean process(HighlightInfo info) { int startOffset = getNavigationPositionFor(info, document); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java index 2e6f6cf9ecd8..0483d5a05027 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HectorComponent.java @@ -19,6 +19,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.impl.analysis.FileHighlightingSetting; import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.lang.Language; import com.intellij.openapi.Disposable; import com.intellij.openapi.diagnostic.Logger; @@ -120,7 +121,8 @@ public class HectorComponent extends JPanel { final PsiFile psiRoot = viewProvider.getPsi(language); assert psiRoot != null : "No root in " + viewProvider + " for " + language; - slider.setValue(getValue(HighlightLevelUtil.shouldHighlight(psiRoot), HighlightLevelUtil.shouldInspect(psiRoot))); + slider.setValue(getValue(HighlightingLevelManager.getInstance(project).shouldHighlight(psiRoot), HighlightingLevelManager.getInstance(project).shouldInspect( + psiRoot))); mySliders.put(language, slider); } @@ -301,7 +303,8 @@ public class HectorComponent extends JPanel { for (Language language : mySliders.keySet()) { JSlider slider = mySliders.get(language); final PsiFile root = viewProvider.getPsi(language); - if (root != null && getValue(HighlightLevelUtil.shouldHighlight(root), HighlightLevelUtil.shouldInspect(root)) != slider.getValue()) { + HighlightingLevelManager highlightingLevelManager = HighlightingLevelManager.getInstance(myFile.getProject()); + if (root != null && getValue(highlightingLevelManager.shouldHighlight(root), highlightingLevelManager.shouldInspect(root)) != slider.getValue()) { return true; } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java new file mode 100644 index 000000000000..5a511d0c6b34 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPass.java @@ -0,0 +1,469 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.codeInsight.daemon.impl; + +import com.intellij.codeHighlighting.Pass; +import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightInfoHolder; +import com.intellij.concurrency.JobLauncher; +import com.intellij.injected.editor.DocumentWindow; +import com.intellij.lang.Language; +import com.intellij.lang.injection.InjectedLanguageManager; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.editor.HighlighterColors; +import com.intellij.openapi.editor.colors.EditorColors; +import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.TextAttributesKey; +import com.intellij.openapi.editor.ex.MarkupModelEx; +import com.intellij.openapi.editor.impl.DocumentMarkupModel; +import com.intellij.openapi.editor.markup.MarkupModel; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.fileTypes.SyntaxHighlighter; +import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; +import com.intellij.openapi.progress.ProcessCanceledException; +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.*; +import com.intellij.psi.*; +import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; +import com.intellij.psi.impl.source.tree.injected.Place; +import com.intellij.psi.tree.IElementType; +import com.intellij.util.Processor; +import com.intellij.util.ui.UIUtil; +import gnu.trove.THashSet; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.*; +import java.util.List; + +public class InjectedGeneralHighlightingPass extends GeneralHighlightingPass implements DumbAware { + private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.InjectedGeneralHighlightingPass"); + private static final String PRESENTABLE_NAME = "Injected fragments"; + + private volatile Runnable myApplyCommand; + + InjectedGeneralHighlightingPass(@NotNull Project project, + @NotNull PsiFile file, + @NotNull Document document, + int startOffset, + int endOffset, + boolean updateAll, + @NotNull ProperTextRange priorityRange, + @Nullable Editor editor) { + super(project, file, document, startOffset, endOffset, updateAll, priorityRange, editor); + + LOG.assertTrue(file.isValid()); + setId(Pass.UPDATE_ALL); + final DaemonCodeAnalyzerEx codeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(project); + myApplyCommand = new Runnable() { + @Override + public void run() { + ProperTextRange range = new ProperTextRange(myStartOffset, myEndOffset); + MarkupModel model = DocumentMarkupModel.forDocument(myDocument, myProject, true); + codeAnalyzer.cleanFileLevelHighlights(myProject, Pass.UPDATE_ALL, myFile); + final EditorColorsScheme colorsScheme = getColorsScheme(); + UpdateHighlightersUtil.setHighlightersInRange(myProject, myDocument, range, colorsScheme, myHighlights, (MarkupModelEx)model, getId()); + } + }; + + // initial guess to show correct progress in the traffic light icon + setProgressLimit(document.getTextLength()/2); // approx number of PSI elements = file length/2 + } + + @Override + protected String getPresentableName() { + return PRESENTABLE_NAME; + } + + @Override + protected void collectInformationWithProgress(@NotNull final ProgressIndicator progress) { + final Set gotHighlights = new THashSet(100); + + final List inside = new ArrayList(); + final List outside = new ArrayList(); + List insideRanges = new ArrayList(); + List outsideRanges = new ArrayList(); + Divider.divideInsideAndOutside(myFile, myStartOffset, myEndOffset, myPriorityRange, inside, insideRanges, outside, + outsideRanges, false, FILE_FILTER); + + setProgressLimit((long)(inside.size()+outside.size())); + + // all infos for the "injected fragment for the host which is inside" are indeed inside + // but some of the infos for the "injected fragment for the host which is outside" can be still inside + Set injectedResult = new THashSet(); + Set injected = getInjectedPsiFiles(inside, outside, progress); + if (!addInjectedPsiHighlights(injected, progress, Collections.synchronizedSet(injectedResult))) { + throw new ProcessCanceledException(); + } + final List injectionsOutside = new ArrayList(gotHighlights.size()); + + Set result; + synchronized (injectedResult) { + // sync here because all writes happened in another thread + result = injectedResult; + } + for (HighlightInfo info : result) { + if (myStartOffset <= info.getStartOffset() && info.getEndOffset() <= myEndOffset) { + gotHighlights.add(info); + } + else { + // nonconditionally apply injected results regardless whether they are in myStartOffset,myEndOffset + injectionsOutside.add(info); + } + } + + if (!injectionsOutside.isEmpty()) { + final ProperTextRange priorityIntersection = myPriorityRange.intersection(new TextRange(myStartOffset, myEndOffset)); + if ((!inside.isEmpty() || !gotHighlights.isEmpty()) && + priorityIntersection != null) { // do not apply when there were no elements to highlight + // clear infos found in visible area to avoid applying them twice + final List toApplyInside = new ArrayList(gotHighlights); + myHighlights.addAll(toApplyInside); + gotHighlights.clear(); + final long modificationStamp = myDocument.getModificationStamp(); + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + if (myProject.isDisposed() || modificationStamp != myDocument.getModificationStamp()) return; + MarkupModel markupModel = DocumentMarkupModel.forDocument(myDocument, myProject, true); + + UpdateHighlightersUtil + .setHighlightersInRange(myProject, myDocument, priorityIntersection, getColorsScheme(), toApplyInside, + (MarkupModelEx)markupModel, getId()); + if (myEditor != null) { + myProject.getMessageBus().syncPublisher(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC).visibleAreaHighlighted(myFile, myEditor); + } + } + }); + } + + myApplyCommand = new Runnable() { + @Override + public void run() { + ProperTextRange range = new ProperTextRange(myStartOffset, myEndOffset); + + List toApply = new ArrayList(); + for (HighlightInfo info : gotHighlights) { + if (!range.containsRange(info.getStartOffset(), info.getEndOffset())) continue; + if (!myPriorityRange.containsRange(info.getStartOffset(), info.getEndOffset())) { + toApply.add(info); + } + } + toApply.addAll(injectionsOutside); + + UpdateHighlightersUtil.setHighlightersOutsideRange(myProject, myDocument, toApply, getColorsScheme(), + 0, myDocument.getTextLength(), new ProperTextRange(myStartOffset, myEndOffset), getId()); + } + }; + } + // else apply only result (by default apply command) and only within inside + myHighlights.addAll(gotHighlights); + } + + @NotNull + private Set getInjectedPsiFiles(@NotNull final List elements1, + @NotNull final List elements2, + @NotNull final ProgressIndicator progress) { + final Set outInjected = new THashSet(); + + List injected = InjectedLanguageUtil.getCachedInjectedDocuments(myFile); + Collection hosts = new THashSet(elements1.size() + elements2.size() + injected.size()); + + //rehighlight all injected PSI regardless the range, + //since change in one place can lead to invalidation of injected PSI in (completely) other place. + for (DocumentWindow documentRange : injected) { + progress.checkCanceled(); + if (!documentRange.isValid()) continue; + PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(documentRange); + if (file == null) continue; + PsiElement context = InjectedLanguageManager.getInstance(file.getProject()).getInjectionHost(file); + if (context != null + && context.isValid() + && !file.getProject().isDisposed() + && (myUpdateAll || new ProperTextRange(myStartOffset, myEndOffset).intersects(context.getTextRange()))) { + hosts.add(context); + } + } + hosts.addAll(elements1); + hosts.addAll(elements2); + + final PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() { + @Override + public void visit(@NotNull PsiFile injectedPsi, @NotNull List places) { + synchronized (outInjected) { + outInjected.add(injectedPsi); + } + } + }; + if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(new ArrayList(hosts), progress, true, + new Processor() { + @Override + public boolean process(PsiElement element) { + progress.checkCanceled(); + InjectedLanguageUtil.enumerate(element, myFile, false, visitor); + return true; + } + })) { + throw new ProcessCanceledException(); + } + synchronized (outInjected) { + return outInjected; + } + } + + // returns false if canceled + private boolean addInjectedPsiHighlights(@NotNull final Set injectedFiles, + @NotNull final ProgressIndicator progress, + @NotNull final Collection outInfos) { + if (injectedFiles.isEmpty()) return true; + final InjectedLanguageManager injectedLanguageManager = InjectedLanguageManager.getInstance(myProject); + final TextAttributes injectedAttributes = myGlobalScheme.getAttributes(EditorColors.INJECTED_LANGUAGE_FRAGMENT); + + return JobLauncher.getInstance() + .invokeConcurrentlyUnderProgress(new ArrayList(injectedFiles), progress, isFailFastOnAcquireReadAction(), + new Processor() { + @Override + public boolean process(final PsiFile injectedPsi) { + return addInjectedPsiHighlights(injectedPsi, injectedAttributes, outInfos, progress, injectedLanguageManager); + } + }); + } + + private boolean addInjectedPsiHighlights(@NotNull PsiFile injectedPsi, + TextAttributes injectedAttributes, + @NotNull Collection outInfos, + @NotNull ProgressIndicator progress, + @NotNull InjectedLanguageManager injectedLanguageManager) { + DocumentWindow documentWindow = (DocumentWindow)PsiDocumentManager.getInstance(myProject).getCachedDocument(injectedPsi); + if (documentWindow == null) return true; + Place places = InjectedLanguageUtil.getShreds(injectedPsi); + for (PsiLanguageInjectionHost.Shred place : places) { + TextRange textRange = place.getRangeInsideHost().shiftRight(place.getHost().getTextRange().getStartOffset()); + if (textRange.isEmpty()) continue; + String desc = injectedPsi.getLanguage().getDisplayName() + ": " + injectedPsi.getText(); + HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_BACKGROUND).range(textRange); + if (injectedAttributes != null) { + builder.textAttributes(injectedAttributes); + } + builder.unescapedToolTip(desc); + HighlightInfo info = builder.createUnconditionally(); + info.setFromInjection(true); + outInfos.add(info); + } + + HighlightInfoHolder holder = createInfoHolder(injectedPsi); + runHighlightVisitorsForInjected(injectedPsi, holder, progress); + for (int i = 0; i < holder.size(); i++) { + HighlightInfo info = holder.get(i); + final int startOffset = documentWindow.injectedToHost(info.startOffset); + final TextRange fixedTextRange = getFixedTextRange(documentWindow, startOffset); + addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, fixedTextRange, outInfos); + } + int injectedStart = holder.size(); + highlightInjectedSyntax(injectedPsi, holder); + for (int i = injectedStart; i < holder.size(); i++) { + HighlightInfo info = holder.get(i); + final int startOffset = info.startOffset; + final TextRange fixedTextRange = getFixedTextRange(documentWindow, startOffset); + if (fixedTextRange == null) { + info.setFromInjection(true); + outInfos.add(info); + } + else { + HighlightInfo patched = + new HighlightInfo(info.forcedTextAttributes, info.forcedTextAttributesKey, + info.type, fixedTextRange.getStartOffset(), + fixedTextRange.getEndOffset(), + info.getDescription(), info.getToolTip(), info.type.getSeverity(null), + info.isAfterEndOfLine(), null, false, 0); + patched.setFromInjection(true); + outInfos.add(patched); + } + } + + if (!isDumbMode()) { + List todos = new ArrayList(); + highlightTodos(injectedPsi, injectedPsi.getText(), 0, injectedPsi.getTextLength(), progress, myPriorityRange, todos, todos); + for (HighlightInfo info : todos) { + addPatchedInfos(info, injectedPsi, documentWindow, injectedLanguageManager, null, outInfos); + } + } + return true; + } + + @Nullable("null means invalid") + private static TextRange getFixedTextRange(@NotNull DocumentWindow documentWindow, int startOffset) { + final TextRange fixedTextRange; + TextRange textRange = documentWindow.getHostRange(startOffset); + if (textRange == null) { + // todo[cdr] check this fix. prefix/suffix code annotation case + textRange = findNearestTextRange(documentWindow, startOffset); + if (textRange == null) return null; + final boolean isBefore = startOffset < textRange.getStartOffset(); + fixedTextRange = new ProperTextRange(isBefore ? textRange.getStartOffset() - 1 : textRange.getEndOffset(), + isBefore ? textRange.getStartOffset() : textRange.getEndOffset() + 1); + } + else { + fixedTextRange = null; + } + return fixedTextRange; + } + + private static void addPatchedInfos(@NotNull HighlightInfo info, + @NotNull PsiFile injectedPsi, + @NotNull DocumentWindow documentWindow, + @NotNull InjectedLanguageManager injectedLanguageManager, + @Nullable TextRange fixedTextRange, + @NotNull Collection out) { + ProperTextRange textRange = new ProperTextRange(info.startOffset, info.endOffset); + List editables = injectedLanguageManager.intersectWithAllEditableFragments(injectedPsi, textRange); + for (TextRange editable : editables) { + TextRange hostRange = fixedTextRange == null ? documentWindow.injectedToHost(editable) : fixedTextRange; + + boolean isAfterEndOfLine = info.isAfterEndOfLine(); + if (isAfterEndOfLine) { + // convert injected afterEndOfLine to either host' afterEndOfLine or not-afterEndOfLine highlight of the injected fragment boundary + int hostEndOffset = hostRange.getEndOffset(); + int lineNumber = documentWindow.getDelegate().getLineNumber(hostEndOffset); + int hostLineEndOffset = documentWindow.getDelegate().getLineEndOffset(lineNumber); + if (hostEndOffset < hostLineEndOffset) { + // convert to non-afterEndOfLine + isAfterEndOfLine = false; + hostRange = new ProperTextRange(hostRange.getStartOffset(), hostEndOffset+1); + } + } + + HighlightInfo patched = + new HighlightInfo(info.forcedTextAttributes, info.forcedTextAttributesKey, info.type, + hostRange.getStartOffset(), hostRange.getEndOffset(), + info.getDescription(), info.getToolTip(), info.type.getSeverity(null), isAfterEndOfLine, null, false, 0); + patched.setHint(info.hasHint()); + patched.setGutterIconRenderer(info.getGutterIconRenderer()); + + if (info.quickFixActionRanges != null) { + for (Pair pair : info.quickFixActionRanges) { + TextRange quickfixTextRange = pair.getSecond(); + List editableQF = injectedLanguageManager.intersectWithAllEditableFragments(injectedPsi, quickfixTextRange); + for (TextRange editableRange : editableQF) { + HighlightInfo.IntentionActionDescriptor descriptor = pair.getFirst(); + if (patched.quickFixActionRanges == null) patched.quickFixActionRanges = new ArrayList>(); + TextRange hostEditableRange = documentWindow.injectedToHost(editableRange); + patched.quickFixActionRanges.add(Pair.create(descriptor, hostEditableRange)); + } + } + } + patched.setFromInjection(true); + out.add(patched); + } + } + + // finds the first nearest text range + @Nullable("null means invalid") + private static TextRange findNearestTextRange(final DocumentWindow documentWindow, final int startOffset) { + TextRange textRange = null; + for (Segment marker : documentWindow.getHostRanges()) { + TextRange curRange = ProperTextRange.create(marker); + if (curRange.getStartOffset() > startOffset && textRange != null) break; + textRange = curRange; + } + return textRange; + } + + private void runHighlightVisitorsForInjected(@NotNull PsiFile injectedPsi, + @NotNull final HighlightInfoHolder holder, + @NotNull final ProgressIndicator progress) { + HighlightVisitor[] visitors = getHighlightVisitors(); + try { + HighlightVisitor[] filtered = filterVisitors(visitors, injectedPsi); + final List elements = CollectHighlightsUtil.getElementsInRange(injectedPsi, 0, injectedPsi.getTextLength()); + for (final HighlightVisitor visitor : filtered) { + visitor.analyze(injectedPsi, true, holder, new Runnable() { + @Override + public void run() { + for (PsiElement element : elements) { + progress.checkCanceled(); + visitor.visit(element); + } + } + }); + } + } + finally { + incVisitorUsageCount(-1); + } + } + + private void highlightInjectedSyntax(@NotNull PsiFile injectedPsi, @NotNull HighlightInfoHolder holder) { + List, TextRange>> tokens = InjectedLanguageUtil + .getHighlightTokens(injectedPsi); + if (tokens == null) return; + + final Language injectedLanguage = injectedPsi.getLanguage(); + Project project = injectedPsi.getProject(); + SyntaxHighlighter syntaxHighlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(injectedLanguage, project, injectedPsi.getVirtualFile()); + final TextAttributes defaultAttrs = myGlobalScheme.getAttributes(HighlighterColors.TEXT); + + for (Trinity, TextRange> token : tokens) { + ProgressManager.checkCanceled(); + IElementType tokenType = token.getFirst(); + PsiLanguageInjectionHost injectionHost = token.getSecond().getElement(); + if (injectionHost == null) continue; + TextRange textRange = token.getThird(); + TextAttributesKey[] keys = syntaxHighlighter.getTokenHighlights(tokenType); + if (textRange.getLength() == 0) continue; + + TextRange annRange = textRange.shiftRight(injectionHost.getTextRange().getStartOffset()); + // force attribute colors to override host' ones + TextAttributes attributes = null; + for(TextAttributesKey key:keys) { + TextAttributes attrs2 = myGlobalScheme.getAttributes(key); + if (attrs2 != null) { + attributes = attributes == null ? attrs2 : TextAttributes.merge(attributes, attrs2); + } + } + TextAttributes forcedAttributes; + if (attributes == null || attributes.isEmpty() || attributes.equals(defaultAttrs)) { + forcedAttributes = TextAttributes.ERASE_MARKER; + } + else { + HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT).range(annRange).textAttributes( + TextAttributes.ERASE_MARKER).createUnconditionally(); + holder.add(info); + + Color back = attributes.getBackgroundColor() == null ? myGlobalScheme.getDefaultBackground() : attributes.getBackgroundColor(); + Color fore = attributes.getForegroundColor() == null ? myGlobalScheme.getDefaultForeground() : attributes.getForegroundColor(); + forcedAttributes = new TextAttributes(fore, back, attributes.getEffectColor(), attributes.getEffectType(), attributes.getFontType()); + } + + HighlightInfo info = + HighlightInfo.newHighlightInfo(HighlightInfoType.INJECTED_LANGUAGE_FRAGMENT).range(annRange).textAttributes(forcedAttributes) + .createUnconditionally(); + holder.add(info); + } + } + + @Override + protected void applyInformationWithProgress() { + myApplyCommand.run(); + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPassFactory.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPassFactory.java new file mode 100644 index 000000000000..64806a040de8 --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/InjectedGeneralHighlightingPassFactory.java @@ -0,0 +1,63 @@ +/* + * Copyright 2000-2009 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.intellij.codeInsight.daemon.impl; + +import com.intellij.codeHighlighting.MainHighlightingPassFactory; +import com.intellij.codeHighlighting.Pass; +import com.intellij.codeHighlighting.TextEditorHighlightingPass; +import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar; +import com.intellij.openapi.components.AbstractProjectComponent; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.Editor; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.ProperTextRange; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiFile; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author cdr +*/ +public class InjectedGeneralHighlightingPassFactory extends AbstractProjectComponent implements MainHighlightingPassFactory { + public InjectedGeneralHighlightingPassFactory(Project project, TextEditorHighlightingPassRegistrar highlightingPassRegistrar) { + super(project); + highlightingPassRegistrar.registerTextEditorHighlightingPass(this, null, new int[]{Pass.UPDATE_ALL}, false, -1); + } + + @Override + @NonNls + @NotNull + public String getComponentName() { + return "InjectedGeneralHighlightingPassFactory"; + } + + @Override + @Nullable + public TextEditorHighlightingPass createHighlightingPass(@NotNull PsiFile file, @NotNull final Editor editor) { + TextRange textRange = FileStatusMap.getDirtyTextRange(editor, Pass.UPDATE_ALL); + if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(myProject, editor.getDocument()); + ProperTextRange visibleRange = VisibleHighlightingPassFactory.calculateVisibleRange(editor); + return new InjectedGeneralHighlightingPass(myProject, file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), true, visibleRange, editor); + } + + @Override + public TextEditorHighlightingPass createMainHighlightingPass(@NotNull PsiFile file, @NotNull Document document) { + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java index 07d4c0672e26..c59a02dd0fdc 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersPass.java @@ -24,7 +24,7 @@ import com.intellij.codeInsight.daemon.LineMarkerInfo; import com.intellij.codeInsight.daemon.LineMarkerProvider; import com.intellij.codeInsight.daemon.LineMarkerProviders; import com.intellij.codeInsight.daemon.MergeableLineMarkerInfo; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.injected.editor.DocumentWindow; import com.intellij.lang.Language; import com.intellij.lang.injection.InjectedLanguageManager; @@ -85,20 +85,20 @@ public class LineMarkersPass extends ProgressableTextEditorHighlightingPass impl @Override protected void applyInformationWithProgress() { try { - UpdateHighlightersUtil.setLineMarkersToEditor(myProject, myDocument, myStartOffset, myEndOffset, myMarkers, Pass.UPDATE_ALL); + LineMarkersUtil.setLineMarkersToEditor(myProject, myDocument, myStartOffset, myEndOffset, myMarkers, Pass.UPDATE_ALL); } catch (IndexNotReadyException ignored) { } } @Override - protected void collectInformationWithProgress(final ProgressIndicator progress) { + protected void collectInformationWithProgress(@NotNull final ProgressIndicator progress) { final List lineMarkers = new ArrayList(); final FileViewProvider viewProvider = myFile.getViewProvider(); final Set relevantLanguages = viewProvider.getLanguages(); for (Language language : relevantLanguages) { PsiElement psiRoot = viewProvider.getPsi(language); - if (!HighlightLevelUtil.shouldHighlight(psiRoot)) continue; + if (!HighlightingLevelManager.getInstance(myProject).shouldHighlight(psiRoot)) continue; //long time = System.currentTimeMillis(); int start = myStartOffset; int end = myEndOffset; diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java new file mode 100644 index 000000000000..d8226de2301b --- /dev/null +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LineMarkersUtil.java @@ -0,0 +1,104 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon.impl; + +import com.intellij.codeInsight.daemon.LineMarkerInfo; +import com.intellij.lang.injection.InjectedLanguageManager; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.editor.Document; +import com.intellij.openapi.editor.impl.DocumentMarkupModel; +import com.intellij.openapi.editor.markup.HighlighterLayer; +import com.intellij.openapi.editor.markup.HighlighterTargetArea; +import com.intellij.openapi.editor.markup.MarkupModel; +import com.intellij.openapi.editor.markup.RangeHighlighter; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class LineMarkersUtil { + static void setLineMarkersToEditor(@NotNull Project project, + @NotNull Document document, + int startOffset, + int endOffset, + @NotNull Collection markers, + int group) { + ApplicationManager.getApplication().assertIsDispatchThread(); + + List oldMarkers = DaemonCodeAnalyzerImpl.getLineMarkers(document, project); + List array = new ArrayList(oldMarkers == null ? markers.size() : oldMarkers.size()); + MarkupModel markupModel = DocumentMarkupModel.forDocument(document, project, true); + HighlightersRecycler toReuse = new HighlightersRecycler(); + if (oldMarkers != null) { + for (LineMarkerInfo info : oldMarkers) { + RangeHighlighter highlighter = info.highlighter; + boolean toRemove = !highlighter.isValid() || + info.updatePass == group && + startOffset <= highlighter.getStartOffset() && + (highlighter.getEndOffset() < endOffset || highlighter.getEndOffset() == document.getTextLength()); + + if (toRemove) { + toReuse.recycleHighlighter(highlighter); + } + else { + array.add(info); + } + } + } + + for (LineMarkerInfo info : markers) { + PsiElement element = info.getElement(); + if (element == null) { + continue; + } + + TextRange textRange = element.getTextRange(); + if (textRange == null) continue; + TextRange elementRange = InjectedLanguageManager.getInstance(project).injectedToHost(element, textRange); + if (startOffset > elementRange.getStartOffset() || elementRange.getEndOffset() > endOffset) { + continue; + } + RangeHighlighter marker = toReuse.pickupHighlighterFromGarbageBin(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX); + if (marker == null) { + marker = markupModel.addRangeHighlighter(info.startOffset, info.endOffset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.EXACT_RANGE); + } + LineMarkerInfo.LineMarkerGutterIconRenderer renderer = (LineMarkerInfo.LineMarkerGutterIconRenderer)info.createGutterRenderer(); + LineMarkerInfo.LineMarkerGutterIconRenderer oldRenderer = marker.getGutterIconRenderer() instanceof LineMarkerInfo.LineMarkerGutterIconRenderer ? (LineMarkerInfo.LineMarkerGutterIconRenderer)marker.getGutterIconRenderer() : null; + if (oldRenderer == null || renderer == null || !renderer.equals(oldRenderer)) { + marker.setGutterIconRenderer(renderer); + } + if (!Comparing.equal(marker.getLineSeparatorColor(), info.separatorColor)) { + marker.setLineSeparatorColor(info.separatorColor); + } + if (!Comparing.equal(marker.getLineSeparatorPlacement(), info.separatorPlacement)) { + marker.setLineSeparatorPlacement(info.separatorPlacement); + } + info.highlighter = marker; + array.add(info); + } + + for (RangeHighlighter highlighter : toReuse.forAllInGarbageBin()) { + highlighter.dispose(); + } + + DaemonCodeAnalyzerImpl.setLineMarkers(document, array, project); + } +} diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java index 2470e0dd0748..428b5bafa5b5 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/LocalInspectionsPass.java @@ -19,7 +19,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.Pass; import com.intellij.codeInsight.daemon.DaemonBundle; import com.intellij.codeInsight.daemon.HighlightDisplayKey; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.codeInsight.intention.EmptyIntentionAction; import com.intellij.codeInspection.*; @@ -80,7 +80,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass private static final Condition FILE_FILTER = new Condition() { @Override public boolean value(PsiFile file) { - return HighlightLevelUtil.shouldInspect(file); + return HighlightingLevelManager.getInstance(file.getProject()).shouldInspect(file); } }; private final int myStartOffset; @@ -134,7 +134,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @Override protected void collectInformationWithProgress(@NotNull ProgressIndicator progress) { try { - if (!HighlightLevelUtil.shouldInspect(myFile)) return; + if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(myFile)) return; final InspectionManagerEx iManager = (InspectionManagerEx)InspectionManager.getInstance(myProject); final InspectionProfileWrapper profile = myProfileWrapper; inspect(getInspectionTools(profile), iManager, true, true, DumbService.isDumb(myProject), progress); @@ -188,7 +188,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass PsiElement psiElement = descriptor.getPsiElement(); if (psiElement == null) continue; - if (InspectionManagerEx.inspectionResultSuppressed(psiElement, toolWrapper.getTool())) continue; + if (SuppressionUtil.inspectionResultSuppressed(psiElement, toolWrapper.getTool())) continue; List editables = ilManager.intersectWithAllEditableFragments(file, ((ProblemDescriptorBase)descriptor).getTextRange()); for (TextRange editable : editables) { TextRange hostRange = documentRange.injectedToHost(editable); @@ -482,7 +482,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass private void addDescriptorIncrementally(@NotNull final ProblemDescriptor descriptor, @NotNull final LocalInspectionToolWrapper tool, @NotNull final ProgressIndicator indicator) { - if (myIgnoreSuppressed && InspectionManagerEx.inspectionResultSuppressed(descriptor.getPsiElement(), tool.getTool())) { + if (myIgnoreSuppressed && SuppressionUtil.inspectionResultSuppressed(descriptor.getPsiElement(), tool.getTool())) { return; } myTransferToEDTQueue.offer(Trinity.create(descriptor, tool, indicator)); @@ -587,7 +587,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass @NotNull ProblemDescriptor descriptor, PsiElement element) { if (element == null) return; - if (myIgnoreSuppressed && InspectionManagerEx.inspectionResultSuppressed(element, tool.getTool())) return; + if (myIgnoreSuppressed && SuppressionUtil.inspectionResultSuppressed(element, tool.getTool())) return; HighlightInfoType level = highlightTypeFromDescriptor(descriptor, severity); HighlightInfo info = createHighlightInfo(descriptor, tool, level, emptyActionRegistered, element); if (info == null) return; @@ -711,7 +711,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass }; for (Language language : viewProvider.getLanguages()) { final PsiFile psiRoot = viewProvider.getPsi(language); - if (psiRoot == null || !HighlightLevelUtil.shouldInspect(psiRoot)) { + if (psiRoot == null || !HighlightingLevelManager.getInstance(file.getProject()).shouldInspect(psiRoot)) { continue; } psiRoot.accept(visitor); @@ -735,7 +735,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass } if (wrapper == null) continue; if (myIgnoreSuppressed) { - if (wrapper.isApplicable(language) && InspectionManagerEx.inspectionResultSuppressed(myFile, wrapper.getTool())) { + if (wrapper.isApplicable(language) && SuppressionUtil.inspectionResultSuppressed(myFile, wrapper.getTool())) { continue; } } @@ -768,7 +768,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass indicator.checkCanceled(); final LocalInspectionToolWrapper wrapper = pair.getKey(); final LocalInspectionTool tool = wrapper.getTool(); - if (host != null && myIgnoreSuppressed && InspectionManagerEx.inspectionResultSuppressed(host, tool)) { + if (host != null && myIgnoreSuppressed && SuppressionUtil.inspectionResultSuppressed(host, tool)) { continue; } ProblemsHolder holder = new ProblemsHolder(iManager, injectedPsi, isOnTheFly) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowAutoImportPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowAutoImportPass.java index 2dd47e6958d3..5dd6d21c5a16 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowAutoImportPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowAutoImportPass.java @@ -18,10 +18,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.CodeInsightSettings; -import com.intellij.codeInsight.daemon.DaemonBundle; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings; -import com.intellij.codeInsight.daemon.ReferenceImporter; +import com.intellij.codeInsight.daemon.*; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.HintAction; import com.intellij.lang.annotation.HighlightSeverity; @@ -97,7 +94,7 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass { Document document = getDocument(); final List infos = new ArrayList(); - DaemonCodeAnalyzerImpl.processHighlights(document, myProject, null, 0, document.getTextLength(), new Processor() { + DaemonCodeAnalyzerEx.processHighlights(document, myProject, null, 0, document.getTextLength(), new Processor() { @Override public boolean process(HighlightInfo info) { if (!info.hasHint() || info.getSeverity() != HighlightSeverity.ERROR) { @@ -121,7 +118,7 @@ public class ShowAutoImportPass extends TextEditorHighlightingPass { @NotNull private static List getVisibleHighlights(final int startOffset, final int endOffset, Project project, final Editor editor) { final List highlights = new ArrayList(); - DaemonCodeAnalyzerImpl.processHighlights(editor.getDocument(), project, null, startOffset, endOffset, new Processor() { + DaemonCodeAnalyzerEx.processHighlights(editor.getDocument(), project, null, startOffset, endOffset, new Processor() { @Override public boolean process(HighlightInfo info) { if (info.hasHint() && !editor.getFoldingModel().isOffsetCollapsed(info.startOffset)) { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java index 6484893c6dcb..9ada20e6af0b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/ShowIntentionsPass.java @@ -291,42 +291,43 @@ public class ShowIntentionsPass extends TextEditorHighlightingPass { } final int line = hostDocument.getLineNumber(offset); - DaemonCodeAnalyzerImpl.processHighlights(hostDocument, project, null, - hostDocument.getLineStartOffset(line), - hostDocument.getLineEndOffset(line), new Processor() { - @Override - public boolean process(HighlightInfo info) { - final GutterIconRenderer renderer = (GutterIconRenderer)info.getGutterIconRenderer(); - if (renderer == null) { - return true; - } - final AnAction action = renderer.getClickAction(); - if (action == null) { - return true; - } - final String text = renderer.getTooltipText(); - if (text == null) { - return true; - } - final IntentionAction actionAdapter = new AbstractIntentionAction() { - @Override - public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { - final RelativePoint relativePoint = JBPopupFactory.getInstance().guessBestPopupLocation(editor); - action.actionPerformed( - new AnActionEvent(relativePoint.toMouseEvent(), DataManager.getInstance().getDataContext(), text, new Presentation(), - ActionManager.getInstance(), 0)); - } - - @Override - @NotNull - public String getText() { - return text; - } - }; - intentions.guttersToShow.add(new HighlightInfo.IntentionActionDescriptor(actionAdapter, Collections.emptyList(), text, renderer.getIcon())); + DaemonCodeAnalyzerEx.processHighlights(hostDocument, project, null, + hostDocument.getLineStartOffset(line), + hostDocument.getLineEndOffset(line), new Processor() { + @Override + public boolean process(HighlightInfo info) { + final GutterIconRenderer renderer = (GutterIconRenderer)info.getGutterIconRenderer(); + if (renderer == null) { return true; } - }); + final AnAction action = renderer.getClickAction(); + if (action == null) { + return true; + } + final String text = renderer.getTooltipText(); + if (text == null) { + return true; + } + final IntentionAction actionAdapter = new AbstractIntentionAction() { + @Override + public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + final RelativePoint relativePoint = JBPopupFactory.getInstance().guessBestPopupLocation(editor); + action.actionPerformed( + new AnActionEvent(relativePoint.toMouseEvent(), DataManager.getInstance().getDataContext(), text, new Presentation(), + ActionManager.getInstance(), 0)); + } + + @Override + @NotNull + public String getText() { + return text; + } + }; + intentions.guttersToShow.add( + new HighlightInfo.IntentionActionDescriptor(actionAdapter, Collections.emptyList(), text, renderer.getIcon())); + return true; + } + }); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SlowLineMarkersPass.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SlowLineMarkersPass.java index e4cb967c8a2e..24ceab182546 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SlowLineMarkersPass.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/SlowLineMarkersPass.java @@ -17,10 +17,9 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.TextEditorHighlightingPass; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.LineMarkerInfo; import com.intellij.codeInsight.daemon.LineMarkerProvider; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.lang.Language; import com.intellij.openapi.editor.Document; import com.intellij.openapi.progress.ProcessCanceledException; @@ -59,7 +58,7 @@ public class SlowLineMarkersPass extends TextEditorHighlightingPass implements L List markers = new SmartList(); for (Language language : relevantLanguages) { PsiElement psiRoot = viewProvider.getPsi(language); - if (psiRoot == null || !HighlightLevelUtil.shouldHighlight(psiRoot)) continue; + if (psiRoot == null || !HighlightingLevelManager.getInstance(myProject).shouldHighlight(psiRoot)) continue; List elements = CollectHighlightsUtil.getElementsInRange(psiRoot, myStartOffset, myEndOffset); final List providers = LineMarkersPass.getMarkerProviders(language, myProject); addLineMarkers(elements, providers, markers, progress); @@ -81,10 +80,10 @@ public class SlowLineMarkersPass extends TextEditorHighlightingPass implements L @Override public void doApplyInformationToEditor() { - UpdateHighlightersUtil.setLineMarkersToEditor(myProject, myDocument, myStartOffset, myEndOffset, myMarkers, getId()); + LineMarkersUtil.setLineMarkersToEditor(myProject, myDocument, myStartOffset, myEndOffset, myMarkers, getId()); - DaemonCodeAnalyzer daemonCodeAnalyzer = DaemonCodeAnalyzer.getInstance(myProject); - ((DaemonCodeAnalyzerImpl)daemonCodeAnalyzer).getFileStatusMap().markFileUpToDate(myDocument, getId()); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + daemonCodeAnalyzer.getFileStatusMap().markFileUpToDate(myDocument, getId()); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/StatusBarUpdater.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/StatusBarUpdater.java index 1a644fb17afa..0437c18d3783 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/StatusBarUpdater.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/StatusBarUpdater.java @@ -58,15 +58,11 @@ public class StatusBarUpdater implements Disposable { } }); - project.getMessageBus().connect(this).subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListener() { + project.getMessageBus().connect(this).subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() { @Override public void daemonFinished() { updateLater(); } - - @Override - public void daemonCancelEventOccurred() { - } }); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java index c7920c9bb54c..7020cce65846 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TextEditorHighlightingPassRegistrarImpl.java @@ -17,7 +17,6 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.*; -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; @@ -151,7 +150,8 @@ public class TextEditorHighlightingPassRegistrarImpl extends TextEditorHighlight } }); - final FileStatusMap statusMap = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject)).getFileStatusMap(); + DaemonCodeAnalyzerEx daemonCodeAnalyzer = DaemonCodeAnalyzerEx.getInstanceEx(myProject); + final FileStatusMap statusMap = daemonCodeAnalyzer.getFileStatusMap(); passesRefusedToCreate.forEach(new TIntProcedure() { @Override public boolean execute(int passId) { @@ -223,6 +223,8 @@ public class TextEditorHighlightingPassRegistrarImpl extends TextEditorHighlight }); } + @NotNull + @Override public List getDirtyScopeTrackingFactories() { return myDirtyScopeTrackingFactories; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java index bdc05b5b5b19..d68504c9402c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/TrafficLightRenderer.java @@ -19,7 +19,7 @@ package com.intellij.codeInsight.daemon.impl; import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.icons.AllIcons; import com.intellij.lang.Language; import com.intellij.lang.annotation.HighlightSeverity; @@ -187,10 +187,10 @@ public class TrafficLightRenderer implements ErrorStripeRenderer, Disposable { Set languages = provider.getLanguages(); for (Language language : languages) { PsiFile root = provider.getPsi(language); - if (!HighlightLevelUtil.shouldHighlight(root)) { + if (!HighlightingLevelManager.getInstance(myProject).shouldHighlight(root)) { noHighlightingRoots.add(language.getID()); } - else if (!HighlightLevelUtil.shouldInspect(root)) { + else if (!HighlightingLevelManager.getInstance(myProject).shouldInspect(root)) { noInspectionRoots.add(language.getID()); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightLevelUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightLevelUtil.java index 990e9889cf68..74373e418f79 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightLevelUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightLevelUtil.java @@ -16,58 +16,12 @@ package com.intellij.codeInsight.daemon.impl.analysis; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectCoreUtil; -import com.intellij.openapi.roots.ProjectFileIndex; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.SingleRootFileViewProvider; -import com.intellij.psi.search.ProjectScope; import org.jetbrains.annotations.NotNull; public class HighlightLevelUtil { private HighlightLevelUtil() { } - public enum AnalysisLevel { - HIGHLIGHT, HIGHLIGHT_AND_INSPECT - } - public static boolean shouldAnalyse(@NotNull PsiFile root, @NotNull AnalysisLevel analysisLevel) { - return analysisLevel == AnalysisLevel.HIGHLIGHT_AND_INSPECT ? shouldInspect(root) : shouldHighlight(root); - } - - - public static boolean shouldHighlight(@NotNull PsiElement psiRoot) { - final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(psiRoot.getProject()); - if (component == null) return true; - - final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot); - return settingForRoot != FileHighlightingSetting.SKIP_HIGHLIGHTING; - } - - public static boolean shouldInspect(@NotNull PsiElement psiRoot) { - if (ApplicationManager.getApplication().isUnitTestMode()) return true; - - if (!shouldHighlight(psiRoot)) return false; - final Project project = psiRoot.getProject(); - final VirtualFile virtualFile = psiRoot.getContainingFile().getVirtualFile(); - if (virtualFile == null || !virtualFile.isValid()) return false; - - if (ProjectCoreUtil.isProjectOrWorkspaceFile(virtualFile)) return false; - - final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); - if (ProjectScope.getLibrariesScope(project).contains(virtualFile) && !fileIndex.isInContent(virtualFile)) return false; - - if (SingleRootFileViewProvider.isTooLargeForIntelligence(virtualFile)) return false; - - final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(project); - if (component == null) return true; - - final FileHighlightingSetting settingForRoot = component.getHighlightingSettingForRoot(psiRoot); - return settingForRoot != FileHighlightingSetting.SKIP_INSPECTION; - } public static void forceRootHighlighting(@NotNull PsiElement root, @NotNull FileHighlightingSetting level) { final HighlightingSettingsPerFile component = HighlightingSettingsPerFile.getInstance(root.getProject()); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java index f3cc7f39008e..49e91436e83e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightingSettingsPerFile.java @@ -16,18 +16,20 @@ package com.intellij.codeInsight.daemon.impl.analysis; -import com.intellij.codeInspection.InspectionProfile; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.*; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.project.ProjectManagerAdapter; +import com.intellij.openapi.project.ProjectCoreUtil; +import com.intellij.openapi.roots.ProjectFileIndex; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; +import com.intellij.psi.SingleRootFileViewProvider; +import com.intellij.psi.search.ProjectScope; import com.intellij.psi.util.PsiUtilBase; -import com.intellij.util.containers.WeakHashMap; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -35,27 +37,18 @@ import org.jetbrains.annotations.NotNull; import java.util.*; @State(name="HighlightingSettingsPerFile", storages = @Storage( file = StoragePathMacros.WORKSPACE_FILE)) -public class HighlightingSettingsPerFile implements PersistentStateComponent { +public class HighlightingSettingsPerFile extends HighlightingLevelManager implements PersistentStateComponent { @NonNls private static final String SETTING_TAG = "setting"; @NonNls private static final String ROOT_ATT_PREFIX = "root"; @NonNls private static final String FILE_ATT = "file"; public static HighlightingSettingsPerFile getInstance(Project project){ - return ServiceManager.getService(project, HighlightingSettingsPerFile.class); + return (HighlightingSettingsPerFile)ServiceManager.getService(project, HighlightingLevelManager.class); } private final Map myHighlightSettings = new HashMap(); - private final Map myProfileSettings = new WeakHashMap(); - - public HighlightingSettingsPerFile(Project project) { - project.getMessageBus().connect().subscribe(ProjectManager.TOPIC, new ProjectManagerAdapter() { - @Override - public void projectClosed(Project project) { - cleanProfileSettings(); - } - }); - } + @NotNull public FileHighlightingSetting getHighlightingSettingForRoot(@NotNull PsiElement root){ final PsiFile containingFile = root.getContainingFile(); final VirtualFile virtualFile = containingFile.getVirtualFile(); @@ -68,7 +61,8 @@ public class HighlightingSettingsPerFile implements PersistentStateComponent filtered = @@ -83,7 +77,8 @@ public class HighlightingSettingsPerFile implements PersistentStateComponent error = new AtomicReference(); + final AtomicBoolean hasErrorElement = new AtomicBoolean(); try { GeneralHighlightingPass pass = new GeneralHighlightingPass(myProject, psiFile, document, 0, document.getTextLength(), false) { @Override @@ -302,7 +300,9 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver { @Override public boolean add(@Nullable HighlightInfo info) { if (info != null && info.getSeverity() == HighlightSeverity.ERROR) { - throw new HaveGotErrorException(info, myHasErrorElement); + error.set(info); + hasErrorElement.set(myHasErrorElement); + throw new ProcessCanceledException(); } return super.add(info); } @@ -311,9 +311,11 @@ public class WolfTheProblemSolverImpl extends WolfTheProblemSolver { }; pass.collectInformation(progressIndicator); } - catch (HaveGotErrorException e) { - ProblemImpl problem = new ProblemImpl(file, e.myHighlightInfo, e.myHasErrorElement); - reportProblems(file, Collections.singleton(problem)); + catch (ProcessCanceledException e) { + if (error.get() != null) { + ProblemImpl problem = new ProblemImpl(file, error.get(), hasErrorElement.get()); + reportProblems(file, Collections.singleton(problem)); + } return false; } clearProblems(file); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java index 059343770500..17aaee57d8f5 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java @@ -22,16 +22,13 @@ package com.intellij.codeInspection.ex; -import com.intellij.codeInsight.daemon.impl.actions.AbstractBatchSuppressByNoInspectionCommentFix; import com.intellij.codeInspection.*; import com.intellij.icons.AllIcons; import com.intellij.ide.impl.ContentManagerWatcher; import com.intellij.ide.ui.search.SearchableOptionsRegistrar; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowAnchor; @@ -43,7 +40,6 @@ import com.intellij.ui.content.ContentFactory; import com.intellij.ui.content.ContentManager; import com.intellij.ui.content.TabbedPaneContentUI; import com.intellij.util.Function; -import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -89,53 +85,6 @@ public class InspectionManagerEx extends InspectionManagerBase { } } - @NotNull - public static SuppressIntentionAction convertBatchToSuppressIntentionAction(@NotNull final SuppressQuickFix fix) { - return new SuppressIntentionAction() { - @Override - public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { - PsiElement container = fix instanceof AbstractBatchSuppressByNoInspectionCommentFix - ? ((AbstractBatchSuppressByNoInspectionCommentFix )fix).getContainer(element) : null; - boolean caretWasBeforeStatement = editor != null && container != null && editor.getCaretModel().getOffset() == container.getTextRange().getStartOffset(); - try { - ProblemDescriptor descriptor = - new ProblemDescriptorImpl(element, element, "", null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null, false); - fix.applyFix(project, descriptor); - } - catch (IncorrectOperationException e) { - if (!ApplicationManager.getApplication().isUnitTestMode() && editor != null) { - Messages.showErrorDialog(editor.getComponent(), - InspectionsBundle.message("suppress.inspection.annotation.syntax.error", e.getMessage())); - } - else { - throw e; - } - } - - if (caretWasBeforeStatement) { - editor.getCaretModel().moveToOffset(container.getTextRange().getStartOffset()); - } - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { - return fix.isAvailable(project, element); - } - - @NotNull - @Override - public String getText() { - return fix.getName(); - } - - @NotNull - @Override - public String getFamilyName() { - return fix.getFamilyName(); - } - }; - } - @Nullable public static SuppressIntentionAction[] getSuppressActions(@NotNull InspectionProfileEntry tool) { if (tool instanceof CustomSuppressableInspectionTool) { @@ -146,7 +95,7 @@ public class InspectionManagerEx extends InspectionManagerBase { return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function() { @Override public SuppressIntentionAction fun(final LocalQuickFix fix) { - return convertBatchToSuppressIntentionAction((SuppressQuickFix)fix); + return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction((SuppressQuickFix)fix); } }); } @@ -164,6 +113,7 @@ public class InspectionManagerEx extends InspectionManagerBase { return new ProblemDescriptorImpl(psiElement, psiElement, descriptionTemplate, fixes, highlightType, false, null, hintAction, onTheFly); } + @Override @NotNull public GlobalInspectionContextImpl createNewGlobalContext(boolean reuse) { final GlobalInspectionContextImpl inspectionContext; @@ -194,22 +144,6 @@ public class InspectionManagerEx extends InspectionManagerBase { return myRunningContexts; } - public static boolean inspectionResultSuppressed(@NotNull PsiElement place, @NotNull LocalInspectionTool tool) { - if (tool instanceof CustomSuppressableInspectionTool) { - return ((CustomSuppressableInspectionTool)tool).isSuppressedFor(place); - } - if (tool instanceof BatchSuppressableTool) { - return ((BatchSuppressableTool)tool).isSuppressedFor(place); - } - String alternativeId; - String id; - - return SuppressionUtil.isSuppressed(place, id = tool.getID()) || - (alternativeId = tool.getAlternativeID()) != null && - !alternativeId.equals(id) && - SuppressionUtil.isSuppressed(place, alternativeId); - } - @NotNull @Deprecated public ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement, diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalDescriptorsUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalDescriptorsUtil.java index e85efb3df12a..f3595dc19351 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalDescriptorsUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/LocalDescriptorsUtil.java @@ -67,7 +67,7 @@ public class LocalDescriptorsUtil { context.isSuppressed(element, alternativeId))) { continue; } - if (InspectionManagerEx.inspectionResultSuppressed(element, tool)) continue; + if (SuppressionUtil.inspectionResultSuppressed(element, tool)) continue; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java index 91140d38ac78..f874b06fb14d 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java @@ -21,10 +21,9 @@ package com.intellij.codeInspection.offlineViewer; import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.*; -import com.intellij.codeInspection.ex.GlobalInspectionContextImpl; import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; import com.intellij.codeInspection.ex.QuickFixWrapper; import com.intellij.codeInspection.offline.OfflineProblemDescriptor; @@ -56,7 +55,7 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode { final Set result = new LinkedHashSet(); for (Language language : viewProvider.getLanguages()) { final PsiFile psiRoot = viewProvider.getPsi(language); - if (HighlightLevelUtil.shouldInspect(psiRoot)) { + if (HighlightingLevelManager.getInstance(file.getProject()).shouldInspect(psiRoot)) { result.addAll(CollectHighlightsUtil.getElementsInRange(psiRoot, startOffset, endOffset, true)); } } diff --git a/platform/lang-impl/src/com/intellij/ide/todo/TodoConfiguration.java b/platform/lang-impl/src/com/intellij/ide/todo/TodoConfiguration.java index 81862b29031d..5098875659d0 100644 --- a/platform/lang-impl/src/com/intellij/ide/todo/TodoConfiguration.java +++ b/platform/lang-impl/src/com/intellij/ide/todo/TodoConfiguration.java @@ -24,7 +24,7 @@ import com.intellij.openapi.util.JDOMExternalizable; import com.intellij.openapi.util.WriteExternalException; import com.intellij.psi.search.IndexPattern; import com.intellij.psi.search.IndexPatternProvider; -import com.intellij.psi.search.TodoAttributes; +import com.intellij.psi.search.TodoAttributesUtil; import com.intellij.psi.search.TodoPattern; import com.intellij.util.EventDispatcher; import com.intellij.util.messages.MessageBus; @@ -63,8 +63,8 @@ public class TodoConfiguration implements NamedComponent, JDOMExternalizable { public void resetToDefaultTodoPatterns() { myTodoPatterns = new TodoPattern[]{ - new TodoPattern("\\btodo\\b.*", TodoAttributes.createDefault(), false), - new TodoPattern("\\bfixme\\b.*", TodoAttributes.createDefault(), false), + new TodoPattern("\\btodo\\b.*", TodoAttributesUtil.createDefault(), false), + new TodoPattern("\\bfixme\\b.*", TodoAttributesUtil.createDefault(), false), }; myTodoFilters = new TodoFilter[]{}; buildIndexPatterns(); @@ -166,8 +166,8 @@ public class TodoConfiguration implements NamedComponent, JDOMExternalizable { for (Object o : element.getChildren()) { Element child = (Element)o; if (ELEMENT_PATTERN.equals(child.getName())) { - TodoPattern pattern = new TodoPattern(); - pattern.readExternal(child); + TodoPattern pattern = new TodoPattern(TodoAttributesUtil.createDefault()); + pattern.readExternal(child, TodoAttributesUtil.getDefaultColorSchemeTextAttributes()); patternsList.add(pattern); } else if (ELEMENT_FILTER.equals(child.getName())) { diff --git a/platform/lang-impl/src/com/intellij/ide/todo/configurable/PatternDialog.java b/platform/lang-impl/src/com/intellij/ide/todo/configurable/PatternDialog.java index 0421849ddfc7..9f46a7121956 100644 --- a/platform/lang-impl/src/com/intellij/ide/todo/configurable/PatternDialog.java +++ b/platform/lang-impl/src/com/intellij/ide/todo/configurable/PatternDialog.java @@ -26,6 +26,7 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.psi.search.TodoAttributes; +import com.intellij.psi.search.TodoAttributesUtil; import com.intellij.psi.search.TodoPattern; import javax.swing.*; @@ -118,7 +119,7 @@ class PatternDialog extends DialogWrapper{ final TodoAttributes attrs = myPattern.getAttributes(); attrs.setIcon((Icon)myIconComboBox.getSelectedItem()); - attrs.setUseCustomTodoColor(useCustomTodoColor()); + attrs.setUseCustomTodoColor(useCustomTodoColor(), TodoAttributesUtil.getDefaultColorSchemeTextAttributes()); if (useCustomTodoColor()) { myColorAndFontDescriptionPanel.apply(myColorAndFontDescription, null); diff --git a/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java b/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java index e27929a9de49..e29b797d5811 100644 --- a/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/todo/configurable/TodoConfigurable.java @@ -25,6 +25,7 @@ import com.intellij.openapi.options.Configurable; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.psi.search.TodoAttributesUtil; import com.intellij.psi.search.TodoPattern; import com.intellij.ui.*; import com.intellij.ui.table.JBTable; @@ -181,7 +182,7 @@ public class TodoConfigurable extends BaseConfigurable implements SearchableConf @Override public void run(AnActionButton button) { stopEditing(); - TodoPattern pattern = new TodoPattern(); + TodoPattern pattern = new TodoPattern(TodoAttributesUtil.createDefault()); PatternDialog dialog = new PatternDialog(myPanel, pattern); dialog.setTitle(IdeBundle.message("title.add.todo.pattern")); dialog.show(); diff --git a/platform/lang-impl/src/com/intellij/openapi/wm/impl/status/TogglePopupHintsPanel.java b/platform/lang-impl/src/com/intellij/openapi/wm/impl/status/TogglePopupHintsPanel.java index 5c2ed77a9f54..b30661e6e840 100644 --- a/platform/lang-impl/src/com/intellij/openapi/wm/impl/status/TogglePopupHintsPanel.java +++ b/platform/lang-impl/src/com/intellij/openapi/wm/impl/status/TogglePopupHintsPanel.java @@ -18,7 +18,7 @@ package com.intellij.openapi.wm.impl.status; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.impl.HectorComponent; -import com.intellij.codeInsight.daemon.impl.analysis.HighlightLevelUtil; +import com.intellij.codeInsight.daemon.impl.analysis.HighlightingLevelManager; import com.intellij.icons.AllIcons; import com.intellij.ide.PowerSaveMode; import com.intellij.openapi.application.ApplicationManager; @@ -127,13 +127,13 @@ public class TogglePopupHintsPanel extends EditorBasedWidget implements StatusBa myCurrentIcon = AllIcons.Ide.HectorNo; myToolTipText = "Code analysis is disabled in power save mode. "; } - else if (HighlightLevelUtil.shouldInspect(file)) { + else if (HighlightingLevelManager.getInstance(myProject).shouldInspect(file)) { myCurrentIcon = AllIcons.Ide.HectorOn; myToolTipText = "Current inspection profile: " + InspectionProjectProfileManager.getInstance(file.getProject()).getInspectionProfile().getName() + ". "; } - else if (HighlightLevelUtil.shouldHighlight(file)) { + else if (HighlightingLevelManager.getInstance(myProject).shouldHighlight(file)) { myCurrentIcon = AllIcons.Ide.HectorSyntax; myToolTipText = "Highlighting level is: Syntax. "; } diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java index 73fef640db29..65ad22d3fd2e 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/InspectionProfileManagerImpl.java @@ -49,7 +49,6 @@ import com.intellij.util.ui.UIUtil; import org.jdom.Document; import org.jdom.Element; import org.jdom.JDOMException; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.TestOnly; @@ -351,7 +350,8 @@ public class InspectionProfileManagerImpl extends InspectionProfileManager imple public static void onProfilesChanged() { //cleanup caches blindly for all projects in case ide profile was modified for (final Project project : ProjectManager.getInstance().getOpenProjects()) { - HighlightingSettingsPerFile.getInstance(project).cleanProfileSettings(); + synchronized (HighlightingSettingsPerFile.getInstance(project)) { + } UIUtil.invokeLaterIfNeeded(new Runnable() { @Override diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java index 66f6a65d8db1..ccdb32d31537 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/InjectedLanguageManagerImpl.java @@ -108,11 +108,7 @@ public class InjectedLanguageManagerImpl extends InjectedLanguageManager impleme final ExtensionPoint psiManagerPoint = Extensions.getRootArea().getExtensionPoint(LanguageInjector.EXTENSION_POINT_NAME); psiManagerPoint.addExtensionPointListener(myListener,this); myProgress = new DaemonProgressIndicator(); - project.getMessageBus().connect(this).subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListener() { - @Override - public void daemonFinished() { - } - + project.getMessageBus().connect(this).subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() { @Override public void daemonCancelEventOccurred() { myProgress.cancel(); diff --git a/platform/platform-api/platform-api.iml b/platform/platform-api/platform-api.iml index f9457ae5bbd6..e40a631f0c55 100644 --- a/platform/platform-api/platform-api.iml +++ b/platform/platform-api/platform-api.iml @@ -31,6 +31,7 @@ + diff --git a/platform/platform-api/src/com/intellij/openapi/actionSystem/PlatformDataKeys.java b/platform/platform-api/src/com/intellij/openapi/actionSystem/PlatformDataKeys.java index c492000388bb..9b3074069e2f 100644 --- a/platform/platform-api/src/com/intellij/openapi/actionSystem/PlatformDataKeys.java +++ b/platform/platform-api/src/com/intellij/openapi/actionSystem/PlatformDataKeys.java @@ -19,12 +19,10 @@ import com.intellij.ide.*; import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diff.DiffViewer; -import com.intellij.openapi.editor.Editor; import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; -import com.intellij.pom.Navigatable; import com.intellij.ui.content.ContentManager; import java.awt.*; @@ -33,18 +31,7 @@ import java.util.Comparator; /** * @author yole */ -public class PlatformDataKeys { - public static final DataKey PROJECT = DataKey.create("project"); - public static final DataKey EDITOR = DataKey.create("editor"); - - /** - * Returns com.intellij.openapi.editor.Editor even if focus currently is in find bar - */ - public static final DataKey EDITOR_EVEN_IF_INACTIVE = DataKey.create("editor.even.if.inactive"); - public static final DataKey NAVIGATABLE = DataKey.create("Navigatable"); - public static final DataKey NAVIGATABLE_ARRAY = DataKey.create("NavigatableArray"); - public static final DataKey VIRTUAL_FILE = DataKey.create("virtualFile"); - public static final DataKey VIRTUAL_FILE_ARRAY = DataKey.create("virtualFileArray"); +public class PlatformDataKeys extends CommonDataKeys { public static final DataKey FILE_EDITOR = DataKey.create("fileEditor"); /** diff --git a/platform/platform-api/src/com/intellij/util/PlatformUtils.java b/platform/platform-api/src/com/intellij/util/PlatformUtils.java index ddc25df03363..e71e70bbf1bd 100644 --- a/platform/platform-api/src/com/intellij/util/PlatformUtils.java +++ b/platform/platform-api/src/com/intellij/util/PlatformUtils.java @@ -23,16 +23,6 @@ import org.jetbrains.annotations.Nullable; * @author Konstantin Bulenkov */ public class PlatformUtils extends PlatformUtilsCore { - public static final String IDEA_PREFIX = "idea"; - public static final String COMMUNITY_PREFIX = "Idea"; - public static final String APPCODE_PREFIX = "AppCode"; - public static final String CPP_PREFIX = "CppIde"; - public static final String PYCHARM_PREFIX = "Python"; - public static final String RUBY_PREFIX = "Ruby"; - public static final String PHP_PREFIX = "PhpStorm"; - public static final String WEB_PREFIX = "WebStorm"; - public static final String FLEX_PREFIX = "Flex"; - private PlatformUtils() { } diff --git a/platform/platform-impl/platform-impl.iml b/platform/platform-impl/platform-impl.iml index c88e8c968df2..d47879947da2 100644 --- a/platform/platform-impl/platform-impl.iml +++ b/platform/platform-impl/platform-impl.iml @@ -36,8 +36,9 @@ - + + diff --git a/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java b/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java index 4a165e532ed0..0462398dec7c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java +++ b/platform/platform-impl/src/com/intellij/openapi/ui/playback/util/EditorPlaybackCall.java @@ -79,7 +79,7 @@ public class EditorPlaybackCall { @Override public void run(Project project) { final MessageBusConnection bus = project.getMessageBus().connect(connection); - bus.subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListener() { + bus.subscribe(DaemonCodeAnalyzer.DAEMON_EVENT_TOPIC, new DaemonCodeAnalyzer.DaemonListenerAdapter() { @Override public void daemonFinished() { context.flushAwtAndRunInEdt(result.createSetDoneRunnable()); diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index d2710f4a8f6b..c355a245cff6 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -205,7 +205,7 @@ - com.intellij.codeInsight.daemon.impl.GeneralHighlightingPassFactory + + com.intellij.codeInsight.daemon.impl.InjectedGeneralHighlightingPassFactory + + com.intellij.codeInsight.daemon.impl.LineMarkersPassFactory diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 3db5eb35163a..340990552030 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -26,10 +26,7 @@ import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings; import com.intellij.codeInsight.daemon.GutterMark; import com.intellij.codeInsight.daemon.HighlightDisplayKey; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; -import com.intellij.codeInsight.daemon.impl.HighlightInfo; -import com.intellij.codeInsight.daemon.impl.HighlightInfoType; -import com.intellij.codeInsight.daemon.impl.ShowIntentionsPass; +import com.intellij.codeInsight.daemon.impl.*; import com.intellij.codeInsight.folding.CodeFoldingManager; import com.intellij.codeInsight.highlighting.actions.HighlightUsagesAction; import com.intellij.codeInsight.intention.IntentionAction; @@ -1505,7 +1502,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig for (int i = 0; i < 100; i++) { try { List infos = codeAnalyzer.runPasses(file, editor.getDocument(), textEditor, toIgnore, canChangeDocument, null); - infos.addAll(DaemonCodeAnalyzerImpl.getFileLevelHighlights(project, file)); + infos.addAll(DaemonCodeAnalyzerEx.getInstanceEx(project).getFileLevelHighlights(project, file)); return infos; } catch (ProcessCanceledException e) { @@ -1574,7 +1571,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); List result = new ArrayList(); - List infos = DaemonCodeAnalyzerImpl.getFileLevelHighlights(file.getProject(), file); + List infos = DaemonCodeAnalyzerEx.getInstanceEx(file.getProject()).getFileLevelHighlights(file.getProject(), file); for (HighlightInfo info : infos) { for (Pair pair : info.quickFixActionRanges) { HighlightInfo.IntentionActionDescriptor actionInGroup = pair.first; diff --git a/plugins/devkit/src/actions/ToggleHighlightingMarkupAction.java b/plugins/devkit/src/actions/ToggleHighlightingMarkupAction.java index 18d3e49108a2..b3142ba1b1b1 100644 --- a/plugins/devkit/src/actions/ToggleHighlightingMarkupAction.java +++ b/plugins/devkit/src/actions/ToggleHighlightingMarkupAction.java @@ -15,7 +15,7 @@ */ package org.jetbrains.idea.devkit.actions; -import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl; +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.IndentsPass; import com.intellij.lang.annotation.HighlightSeverity; @@ -117,7 +117,7 @@ public class ToggleHighlightingMarkupAction extends AnAction { else { final int[] offset = new int[] {0}; final ArrayList infos = new ArrayList(); - DaemonCodeAnalyzerImpl.processHighlights( + DaemonCodeAnalyzerEx.processHighlights( document, project, HighlightSeverity.WARNING, 0, sequence.length(), new Processor() { @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java index 1f2b4d76ad5b..e7b0c945f33d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java @@ -20,6 +20,7 @@ import com.intellij.codeHighlighting.TextEditorHighlightingPass; import com.intellij.codeInsight.CodeInsightSettings; import com.intellij.codeInsight.FileModificationService; import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; +import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.impl.*; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; @@ -85,6 +86,7 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass { myEditor = editor; } + @Override public void doCollectInformation(@NotNull final ProgressIndicator progress) { ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); VirtualFile virtualFile = myFile.getViewProvider().getVirtualFile(); @@ -97,10 +99,12 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass { final boolean deadCodeEnabled = profile.isToolEnabled(unusedDefKey, myFile); final UnusedDeclarationInspection deadCodeInspection = (UnusedDeclarationInspection)profile.getUnwrappedTool(UnusedDeclarationInspection.SHORT_NAME, myFile); final GlobalUsageHelper usageHelper = new GlobalUsageHelper() { + @Override public boolean isCurrentFileAlreadyChecked() { return false; } + @Override public boolean isLocallyUsed(@NotNull PsiNamedElement member) { return false; } @@ -244,20 +248,24 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass { private static IntentionAction createUnusedImportIntention() { return new IntentionAction() { + @Override @NotNull public String getText() { return GroovyInspectionBundle.message("optimize.all.imports"); } + @Override @NotNull public String getFamilyName() { return GroovyInspectionBundle.message("optimize.imports"); } + @Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return true; } + @Override public void invoke(@NotNull final Project project, Editor editor, PsiFile file) { if (!FileModificationService.getInstance().prepareFileForWrite(file)) return; @@ -265,12 +273,14 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass { CommandProcessor.getInstance().executeCommand(project, runnable, "optimize imports", this); } + @Override public boolean startInWriteAction() { return true; } }; } + @Override public void doApplyInformationToEditor() { if (myUnusedDeclarations == null || myUnusedImports == null) { return; @@ -321,7 +331,7 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass { if (!codeAnalyzer.isErrorAnalyzingFinished(myFile)) return false; boolean errors = containsErrorsPreventingOptimize(); - return !errors && codeAnalyzer.canChangeFileSilently(myFile); + return !errors && DaemonListeners.canChangeFileSilently(myFile); } private boolean containsErrorsPreventingOptimize() { @@ -336,14 +346,16 @@ public class GroovyPostHighlightingPass extends TextEditorHighlightingPass { ignoreRange = TextRange.EMPTY_RANGE; } - return !DaemonCodeAnalyzerImpl.processHighlights(myDocument, myProject, HighlightSeverity.ERROR, 0, myDocument.getTextLength(), new Processor() { - public boolean process(HighlightInfo error) { - int infoStart = error.getActualStartOffset(); - int infoEnd = error.getActualEndOffset(); + return !DaemonCodeAnalyzerEx + .processHighlights(myDocument, myProject, HighlightSeverity.ERROR, 0, myDocument.getTextLength(), new Processor() { + @Override + public boolean process(HighlightInfo error) { + int infoStart = error.getActualStartOffset(); + int infoEnd = error.getActualEndOffset(); - return ignoreRange.containsRange(infoStart,infoEnd) && error.type.equals(HighlightInfoType.WRONG_REF); - } - }); + return ignoreRange.containsRange(infoStart, infoEnd) && error.type.equals(HighlightInfoType.WRONG_REF); + } + }); } diff --git a/plugins/java-i18n/src/com/intellij/lang/properties/psi/DefaultResourceBundleManager.java b/plugins/java-i18n/src/com/intellij/lang/properties/psi/DefaultResourceBundleManager.java index 121be5c77048..c3b6635d0ae4 100644 --- a/plugins/java-i18n/src/com/intellij/lang/properties/psi/DefaultResourceBundleManager.java +++ b/plugins/java-i18n/src/com/intellij/lang/properties/psi/DefaultResourceBundleManager.java @@ -1,4 +1,3 @@ - /* * Copyright 2000-2011 JetBrains s.r.o. * @@ -22,7 +21,7 @@ package com.intellij.lang.properties.psi; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.daemon.impl.quickfix.SetupJDKFix; +import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.ide.fileTemplates.JavaTemplateUtil; import com.intellij.openapi.project.Project; import com.intellij.psi.JavaPsiFacade; @@ -53,7 +52,7 @@ public class DefaultResourceBundleManager extends ResourceBundleManager { if (getResourceBundle() != null) { return true; } - throw new ResourceBundleNotFoundException(CodeInsightBundle.message("i18nize.dialog.error.jdk.message"), SetupJDKFix.getInstance()); + throw new ResourceBundleNotFoundException(CodeInsightBundle.message("i18nize.dialog.error.jdk.message"), QuickFixFactory.getInstance().createSetupJDKFix()); } public boolean canShowJavaCodeInfo() { diff --git a/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java b/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java index c41db743dab4..b19588cbcf2c 100644 --- a/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java +++ b/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java @@ -16,6 +16,7 @@ package com.intellij.uiDesigner.core; import com.intellij.compiler.instrumentation.InstrumentationClassFinder; +import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.PluginPathManager; @@ -73,6 +74,7 @@ public class AsmCodeGeneratorTest extends TestCase { appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/messages/UIBundle.properties")); appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/RuntimeBundle.properties")); appendPath(cp, GridLayoutManager.class); // forms_rt + appendPath(cp, DataProvider.class); myClassFinder = new MyClassFinder( new URL[] {new File(swingPath).toURI().toURL()}, cp.toArray(new URL[cp.size()]) diff --git a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java index 777c3acefef9..ffe32b39e9e7 100644 --- a/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java +++ b/xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlUnboundNsPrefixInspection.java @@ -128,7 +128,7 @@ public class XmlUnboundNsPrefixInspection extends XmlSuppressableInspectionTool PsiFile psiFile = context.getContainingFile(); if (!(psiFile instanceof XmlFile)) return; final XmlFile containingFile = (XmlFile)psiFile; - if (!HighlightLevelUtil.shouldInspect(containingFile)) return; + if (!HighlightingLevelManager.getInstance(containingFile.getProject()).shouldInspect(containingFile)) return; final XmlExtension extension = XmlExtension.getExtension(containingFile); if (extension.getPrefixDeclaration(context, namespacePrefix) != null) {