mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
scopes: preserve invalid patterns (IDEA-72839)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2011 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.scope.packageSet;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
*/
|
||||
public class InvalidPackageSet extends AbstractPackageSet {
|
||||
|
||||
public InvalidPackageSet(@NotNull String text) {
|
||||
super(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(VirtualFile file, NamedScopesHolder holder) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -145,12 +145,13 @@ public abstract class NamedScopesHolder implements PersistentStateComponent<Elem
|
||||
|
||||
private static NamedScope readScope(Element setElement){
|
||||
String name = setElement.getAttributeValue(NAME_ATT);
|
||||
PackageSet set = null;
|
||||
PackageSet set;
|
||||
final String attributeValue = setElement.getAttributeValue(PATTERN_ATT);
|
||||
try {
|
||||
set = PackageSetFactory.getInstance().compile(setElement.getAttributeValue(PATTERN_ATT));
|
||||
set = PackageSetFactory.getInstance().compile(attributeValue);
|
||||
}
|
||||
catch (ParsingException e) {
|
||||
// Skip damaged set
|
||||
set = new InvalidPackageSet(attributeValue);
|
||||
}
|
||||
return new NamedScope(name, set);
|
||||
}
|
||||
|
||||
@@ -22,10 +22,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopeManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.psi.search.scope.packageSet.PackageSet;
|
||||
import com.intellij.psi.search.scope.packageSet.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -114,16 +111,16 @@ public class ScopeConfigurable extends NamedConfigurable<NamedScope> {
|
||||
|
||||
public boolean isModified() {
|
||||
if (mySharedCheckbox.isSelected() != myShareScope) return true;
|
||||
final PackageSet currentScope = myPanel.getCurrentScope();
|
||||
return !Comparing.strEqual(myPackageSet, currentScope != null ? currentScope.getText() : null);
|
||||
final String currentScope = myPanel.getPatternText();
|
||||
return !Comparing.strEqual(myPackageSet, currentScope);
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
try {
|
||||
myPanel.apply();
|
||||
final PackageSet packageSet = myPanel.getCurrentScope();
|
||||
myScope = new NamedScope(myScope.getName(), packageSet);
|
||||
myPackageSet = packageSet != null ? packageSet.getText() : null;
|
||||
myPackageSet = myPanel.getPatternText();
|
||||
myScope = new NamedScope(myScope.getName(), packageSet == null ? new InvalidPackageSet(myPackageSet) : packageSet);
|
||||
myShareScope = mySharedCheckbox.isSelected();
|
||||
}
|
||||
catch (ConfigurationException e) {
|
||||
|
||||
@@ -496,15 +496,16 @@ public class ScopeEditorPanel {
|
||||
}
|
||||
|
||||
public void apply() throws ConfigurationException {
|
||||
if (myCurrentScope == null) {
|
||||
throw new ConfigurationException(IdeBundle.message("error.correct.pattern.syntax.errors.first"));
|
||||
}
|
||||
}
|
||||
|
||||
public PackageSet getCurrentScope() {
|
||||
return myCurrentScope;
|
||||
}
|
||||
|
||||
public String getPatternText() {
|
||||
return myPatternField.getText();
|
||||
}
|
||||
|
||||
public void reset(PackageSet packageSet, @Nullable Runnable runnable) {
|
||||
myCurrentScope = packageSet;
|
||||
myPatternField.setText(myCurrentScope == null ? "" : myCurrentScope.getText());
|
||||
|
||||
Reference in New Issue
Block a user