mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
minimize LIP constructor count, simplify
This commit is contained in:
+5
-21
@@ -80,16 +80,10 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
static final Icon IN_PROGRESS_ICON = IconLoader.getIcon("/general/inspectionInProgress.png");
|
||||
private final String myShortcutText;
|
||||
private final SeverityRegistrar mySeverityRegistrar;
|
||||
private final InspectionProfileWrapperProvider myProfileWrapperProvider;
|
||||
private final InspectionProfileWrapper myProfileWrapper;
|
||||
private boolean myFailFastOnAcquireReadAction;
|
||||
|
||||
public LocalInspectionsPass(@NotNull PsiFile file, @Nullable Document document, int startOffset, int endOffset) {
|
||||
this(file, document, startOffset, endOffset, null);
|
||||
}
|
||||
|
||||
public LocalInspectionsPass(@NotNull PsiFile file, @Nullable Document document, int startOffset, int endOffset,
|
||||
@Nullable InspectionProfileWrapperProvider profileProvider)
|
||||
{
|
||||
super(file.getProject(), document, IN_PROGRESS_ICON, PRESENTABLE_NAME, file, true);
|
||||
myStartOffset = startOffset;
|
||||
myEndOffset = endOffset;
|
||||
@@ -104,18 +98,8 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
myShortcutText = "";
|
||||
}
|
||||
mySeverityRegistrar = SeverityRegistrar.getInstance(myProject);
|
||||
if (profileProvider == null) {
|
||||
myProfileWrapperProvider = new InspectionProfileWrapperProvider() {
|
||||
@NotNull
|
||||
@Override
|
||||
public InspectionProfileWrapper getWrapper() {
|
||||
return InspectionProjectProfileManager.getInstance(myProject).getProfileWrapper();
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
myProfileWrapperProvider = profileProvider;
|
||||
}
|
||||
InspectionProfileWrapper customProfile = file.getUserData(InspectionProfileWrapper.KEY);
|
||||
myProfileWrapper = customProfile == null ? InspectionProjectProfileManager.getInstance(myProject).getProfileWrapper() : customProfile;
|
||||
}
|
||||
|
||||
protected void collectInformationWithProgress(final ProgressIndicator progress) {
|
||||
@@ -124,7 +108,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
myTools = new ArrayList<LocalInspectionTool>();
|
||||
if (!HighlightLevelUtil.shouldInspect(myFile)) return;
|
||||
final InspectionManagerEx iManager = (InspectionManagerEx)InspectionManager.getInstance(myProject);
|
||||
final InspectionProfileWrapper profile = myProfileWrapperProvider.getWrapper();
|
||||
final InspectionProfileWrapper profile = myProfileWrapper;
|
||||
final List<LocalInspectionTool> tools = DumbService.getInstance(myProject).filterByDumbAwareness(getInspectionTools(profile));
|
||||
|
||||
inspect(tools, iManager, true, true, true);
|
||||
@@ -402,7 +386,7 @@ public class LocalInspectionsPass extends ProgressableTextEditorHighlightingPass
|
||||
@NonNls String message = ProblemDescriptionNode.renderDescriptionMessage(descriptor);
|
||||
|
||||
final HighlightDisplayKey key = HighlightDisplayKey.find(tool.getShortName());
|
||||
final InspectionProfile inspectionProfile = myProfileWrapperProvider.getWrapper().getInspectionProfile();
|
||||
final InspectionProfile inspectionProfile = myProfileWrapper.getInspectionProfile();
|
||||
if (!inspectionProfile.isToolEnabled(key, myFile)) return null;
|
||||
|
||||
HighlightInfoType type = new HighlightInfoType.HighlightInfoTypeImpl(level.getSeverity(psiElement), level.getAttributesKey());
|
||||
|
||||
+1
-3
@@ -22,7 +22,6 @@ import com.intellij.codeHighlighting.TextEditorHighlightingPassFactory;
|
||||
import com.intellij.codeHighlighting.TextEditorHighlightingPassRegistrar;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileWrapper;
|
||||
import com.intellij.codeInspection.ex.InspectionProfileWrapperProvider;
|
||||
import com.intellij.openapi.components.AbstractProjectComponent;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -55,8 +54,7 @@ public class LocalInspectionsPassFactory extends AbstractProjectComponent implem
|
||||
TextRange textRange = calculateRangeToProcess(editor);
|
||||
if (textRange == null) return new ProgressableTextEditorHighlightingPass.EmptyPass(myProject, editor.getDocument(), LocalInspectionsPass.IN_PROGRESS_ICON,
|
||||
LocalInspectionsPass.PRESENTABLE_NAME);
|
||||
InspectionProfileWrapperProvider provider = editor.getUserData(InspectionProfileWrapperProvider.KEY);
|
||||
return new LocalInspectionsPass(file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset(), provider) {
|
||||
return new LocalInspectionsPass(file, editor.getDocument(), textRange.getStartOffset(), textRange.getEndOffset()) {
|
||||
List<LocalInspectionTool> getInspectionTools(InspectionProfileWrapper profile) {
|
||||
List<LocalInspectionTool> tools = super.getInspectionTools(profile);
|
||||
List<LocalInspectionTool> result = new ArrayList<LocalInspectionTool>(tools.size());
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.InspectionProfile;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -30,6 +31,11 @@ import java.util.List;
|
||||
* Date: 15-Feb-2006
|
||||
*/
|
||||
public class InspectionProfileWrapper {
|
||||
/**
|
||||
* Generic-purpose key object that is intended to be used for customizing inspection profile wrapper retrieval
|
||||
* via {@link com.intellij.openapi.util.UserDataHolder} API.
|
||||
*/
|
||||
public static final Key<InspectionProfileWrapper> KEY = Key.create("Inspection Profile Wrapper");
|
||||
private final InspectionProfileImpl myProfile;
|
||||
|
||||
public InspectionProfileWrapper(final InspectionProfile profile) {
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.codeInspection.ex;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Defines contract for retrieving {@link InspectionProfileWrapper} objects.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since Aug 13, 2010 10:26:33 AM
|
||||
*/
|
||||
public interface InspectionProfileWrapperProvider {
|
||||
|
||||
/**
|
||||
* Generic-purpose key object that is intended to be used for customizing inspection profile wrapper retrieval
|
||||
* via {@link UserDataHolder} API.
|
||||
*/
|
||||
Key<InspectionProfileWrapperProvider> KEY = Key.create(InspectionProfileWrapperProvider.class.getName());
|
||||
|
||||
/**
|
||||
* @return managed inspection profile wrapper
|
||||
*/
|
||||
@NotNull
|
||||
InspectionProfileWrapper getWrapper();
|
||||
}
|
||||
+1
-1
@@ -38,7 +38,6 @@ import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -109,6 +108,7 @@ public class InspectionProjectProfileManager extends DefaultProjectProfileManage
|
||||
return getInspectionProfile();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public InspectionProfileWrapper getProfileWrapper(){
|
||||
final InspectionProfile profile = getInspectionProfile();
|
||||
final String profileName = profile.getName();
|
||||
|
||||
@@ -32,7 +32,9 @@ import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.VcsBundle;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.LanguageTextField;
|
||||
import com.intellij.ui.SeparatorFactory;
|
||||
@@ -89,11 +91,11 @@ public class CommitMessage extends JPanel implements Disposable {
|
||||
* Hence, we define custom profile that is used during highlighting of commit area editor.
|
||||
*/
|
||||
@Nullable
|
||||
private static final InspectionProfileWrapperProvider INSPECTION_PROFILE_WRAPPER_PROVIDER = initProvider();
|
||||
private static final InspectionProfileWrapper INSPECTION_PROFILE_WRAPPER_PROVIDER = initProvider();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
private static InspectionProfileWrapperProvider initProvider() {
|
||||
private static InspectionProfileWrapper initProvider() {
|
||||
// We don't want to add explicit dependency to 'spellchecker' module, hence, use reflection for instantiating
|
||||
// target inspection object. It's assumed that its default settings are just fine for processing commit dialog editor.
|
||||
// Please perform corresponding settings tuning if that assumption is broken at future.
|
||||
@@ -152,13 +154,7 @@ public class CommitMessage extends JPanel implements Disposable {
|
||||
}
|
||||
};
|
||||
|
||||
return new InspectionProfileWrapperProvider() {
|
||||
@NotNull
|
||||
@Override
|
||||
public InspectionProfileWrapper getWrapper() {
|
||||
return profileWrapper;
|
||||
}
|
||||
};
|
||||
return profileWrapper;
|
||||
}
|
||||
|
||||
private final EditorTextField myEditorField;
|
||||
@@ -197,7 +193,10 @@ public class CommitMessage extends JPanel implements Disposable {
|
||||
settings.setUseSoftWraps(true);
|
||||
settings.setAdditionalColumnsCount(0);
|
||||
if (INSPECTION_PROFILE_WRAPPER_PROVIDER != null) {
|
||||
ex.putUserData(InspectionProfileWrapperProvider.KEY, INSPECTION_PROFILE_WRAPPER_PROVIDER);
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(getDocument());
|
||||
if (file != null) {
|
||||
file.putUserData(InspectionProfileWrapper.KEY, INSPECTION_PROFILE_WRAPPER_PROVIDER);
|
||||
}
|
||||
}
|
||||
ex.putUserData(IntentionManager.SHOW_INTENTION_OPTIONS_KEY, false);
|
||||
return ex;
|
||||
|
||||
Reference in New Issue
Block a user