mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
retrieve project from context if possible; otherwise define tool scope by the "focused" project
This commit is contained in:
@@ -73,6 +73,16 @@ public class ScopeToolState {
|
||||
return myScope;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NamedScope getScope(Project project) {
|
||||
if (myScope == null) {
|
||||
if (project != null) {
|
||||
myScope = NamedScopesHolder.getScope(project, myScopeName);
|
||||
}
|
||||
}
|
||||
return myScope;
|
||||
}
|
||||
|
||||
public String getScopeName() {
|
||||
return myScopeName;
|
||||
}
|
||||
|
||||
+3
-3
@@ -155,10 +155,10 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext {
|
||||
final PsiFile file = refElement.getContainingFile();
|
||||
|
||||
if (file == null) return false;
|
||||
|
||||
final Project project = file.getProject();
|
||||
final Tools tools = myTools.get(tool.getShortName());
|
||||
for (ScopeToolState state : tools.getTools()) {
|
||||
final NamedScope namedScope = state.getScope();
|
||||
final NamedScope namedScope = state.getScope(project);
|
||||
if (namedScope == null || namedScope.getValue().contains(file, getCurrentProfile().getProfileManager().getScopesManager())) {
|
||||
return state.isEnabled() && ((GlobalInspectionToolWrapper)state.getTool()).getTool() == tool;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public class GlobalInspectionContextImpl implements GlobalInspectionContext {
|
||||
if (true) {
|
||||
final Tools tools = myTools.get(tool.getShortName());
|
||||
for (ScopeToolState state : tools.getTools()) {
|
||||
final NamedScope namedScope = state.getScope();
|
||||
final NamedScope namedScope = state.getScope(element.getProject());
|
||||
if (namedScope == null || namedScope.getValue().contains(element.getContainingFile(), getCurrentProfile().getProfileManager().getScopesManager())) {
|
||||
return state.isEnabled() && state.getTool() == tool;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel;
|
||||
import com.intellij.codeInspection.InspectionProfile;
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
@@ -85,8 +86,9 @@ public class ToolsImpl implements Tools {
|
||||
return state.getTool();
|
||||
}
|
||||
else {
|
||||
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(element.getProject());
|
||||
final NamedScope scope = state.getScope();
|
||||
final Project project = element.getProject();
|
||||
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project);
|
||||
final NamedScope scope = state.getScope(project);
|
||||
if (scope != null) {
|
||||
final PackageSet packageSet = scope.getValue();
|
||||
if (packageSet != null && packageSet.contains(element.getContainingFile(), validationManager)) {
|
||||
@@ -267,9 +269,10 @@ public class ToolsImpl implements Tools {
|
||||
|
||||
public HighlightDisplayLevel getLevel(PsiElement element) {
|
||||
if (myTools == null || element == null) return myDefaultState.getLevel();
|
||||
final DependencyValidationManager manager = DependencyValidationManager.getInstance(element.getProject());
|
||||
final Project project = element.getProject();
|
||||
final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
|
||||
for (ScopeToolState state : myTools) {
|
||||
final NamedScope scope = state.getScope();
|
||||
final NamedScope scope = state.getScope(project);
|
||||
final PackageSet set = scope != null ? scope.getValue() : null;
|
||||
if (set != null && set.contains(element.getContainingFile(), manager)) {
|
||||
return state.getLevel();
|
||||
@@ -292,9 +295,10 @@ public class ToolsImpl implements Tools {
|
||||
public boolean isEnabled(PsiElement element) {
|
||||
if (!myEnabled) return false;
|
||||
if (myTools == null || element == null) return myDefaultState.isEnabled();
|
||||
final DependencyValidationManager manager = DependencyValidationManager.getInstance(element.getProject());
|
||||
final Project project = element.getProject();
|
||||
final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
|
||||
for (ScopeToolState state : myTools) {
|
||||
final NamedScope scope = state.getScope();
|
||||
final NamedScope scope = state.getScope(project);
|
||||
if (scope != null) {
|
||||
final PackageSet set = scope.getValue();
|
||||
if (set != null && set.contains(element.getContainingFile(), manager)) {
|
||||
@@ -309,9 +313,10 @@ public class ToolsImpl implements Tools {
|
||||
public InspectionTool getEnabledTool(PsiElement element) {
|
||||
if (!myEnabled) return null;
|
||||
if (myTools == null || element == null) return myDefaultState.isEnabled() ? (InspectionTool)myDefaultState.getTool() : null;
|
||||
final DependencyValidationManager manager = DependencyValidationManager.getInstance(element.getProject());
|
||||
final Project project = element.getProject();
|
||||
final DependencyValidationManager manager = DependencyValidationManager.getInstance(project);
|
||||
for (ScopeToolState state : myTools) {
|
||||
final NamedScope scope = state.getScope();
|
||||
final NamedScope scope = state.getScope(project);
|
||||
if (scope != null) {
|
||||
final PackageSet set = scope.getValue();
|
||||
if (set != null && set.contains(element.getContainingFile(), manager)) {
|
||||
@@ -354,10 +359,11 @@ public class ToolsImpl implements Tools {
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(element.getProject());
|
||||
final Project project = element.getProject();
|
||||
final DependencyValidationManager validationManager = DependencyValidationManager.getInstance(project);
|
||||
if (myTools != null) {
|
||||
for (ScopeToolState state : myTools) {
|
||||
final NamedScope scope = state.getScope();
|
||||
final NamedScope scope = state.getScope(project);
|
||||
if (scope != null) {
|
||||
final PackageSet packageSet = scope.getValue();
|
||||
if (packageSet != null && packageSet.contains(element.getContainingFile(), validationManager)) {
|
||||
|
||||
@@ -484,7 +484,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren
|
||||
for (ScopeToolState state : currentTools.getTools()) {
|
||||
final InspectionTool tool = (InspectionTool)state.getTool();
|
||||
if (myProvider.checkReportedProblems(tool)) {
|
||||
addTool(tool, ((InspectionProfileImpl)profile).getErrorLevel(key, state.getScope()), isGroupedBySeverity);
|
||||
addTool(tool, ((InspectionProfileImpl)profile).getErrorLevel(key, state.getScope(myProject)), isGroupedBySeverity);
|
||||
resultsFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ public abstract class AddScopeAction extends AnAction {
|
||||
final List<ScopeToolState> nonDefaultTools = getSelectedProfile().getNonDefaultTools(descriptor.getKey().toString());
|
||||
if (nonDefaultTools != null) {
|
||||
for (ScopeToolState state : nonDefaultTools) {
|
||||
used.add(state.getScope());
|
||||
used.add(state.getScope(project));
|
||||
}
|
||||
}
|
||||
scopes.removeAll(used);
|
||||
|
||||
Reference in New Issue
Block a user