mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -41,7 +41,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.InputValidator;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
@@ -50,11 +53,15 @@ import com.intellij.packaging.artifacts.Artifact;
|
||||
import com.intellij.packaging.impl.artifacts.ArtifactBySourceFileFinder;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.xmlb.Accessor;
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.apache.oro.text.regex.*;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.java.compiler.JavaCompilers;
|
||||
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
|
||||
import org.jetbrains.jps.model.java.impl.compiler.ProcessorConfigProfileImpl;
|
||||
import org.jetbrains.jps.model.serialization.java.compiler.AnnotationProcessorProfileSerializer;
|
||||
@@ -74,8 +81,8 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.CompilerConfiguration");
|
||||
@NonNls public static final String TESTS_EXTERNAL_COMPILER_HOME_PROPERTY_NAME = "tests.external.compiler.home";
|
||||
|
||||
@SuppressWarnings({"WeakerAccess"}) public String DEFAULT_COMPILER;
|
||||
@NotNull private BackendCompiler myDefaultJavaCompiler;
|
||||
private BackendCompiler myDefaultJavaCompiler;
|
||||
private State myState = new State();
|
||||
|
||||
// extensions of the files considered as resource files
|
||||
private final List<Pattern> myRegexpResourcePatterns = new ArrayList<Pattern>();
|
||||
@@ -124,16 +131,24 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
});
|
||||
}
|
||||
|
||||
private static class State {
|
||||
public String DEFAULT_COMPILER = JavaCompilers.JAVAC_ID;
|
||||
|
||||
private boolean compilerWasSpecified;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
Element state = new Element("state");
|
||||
try {
|
||||
DefaultJDOMExternalizer.writeExternal(this, state);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
return null;
|
||||
}
|
||||
XmlSerializer.serializeInto(myState, state, new SkipDefaultValuesSerializationFilters() {
|
||||
@Override
|
||||
protected boolean accepts(@NotNull Accessor accessor, @NotNull Object bean, @Nullable Object beanValue) {
|
||||
if (myState.compilerWasSpecified && "DEFAULT_COMPILER".equals(accessor.getName())) {
|
||||
return true;
|
||||
}
|
||||
return super.accepts(accessor, bean, beanValue);
|
||||
}
|
||||
});
|
||||
|
||||
if (!myAddNotNullAssertions) {
|
||||
addChild(state, JpsJavaCompilerConfigurationSerializer.ADD_NOTNULL_ASSERTIONS).setAttribute(
|
||||
@@ -185,12 +200,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
|
||||
@Override
|
||||
public void loadState(Element state) {
|
||||
try {
|
||||
readExternal(state);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
readExternal(state);
|
||||
}
|
||||
|
||||
public void setProjectBytecodeTarget(@Nullable String level) {
|
||||
@@ -326,15 +336,15 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
for (FileType type : types) {
|
||||
compilerManager.addCompilableFileType(type);
|
||||
}
|
||||
|
||||
|
||||
myDefaultJavaCompiler = JAVAC_EXTERNAL_BACKEND;
|
||||
for (BackendCompiler compiler : myRegisteredCompilers) {
|
||||
if (compiler.getId().equals(DEFAULT_COMPILER)) {
|
||||
if (compiler.getId().equals(myState.DEFAULT_COMPILER)) {
|
||||
myDefaultJavaCompiler = compiler;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEFAULT_COMPILER = myDefaultJavaCompiler.getId();
|
||||
myState.DEFAULT_COMPILER = myDefaultJavaCompiler.getId();
|
||||
}
|
||||
|
||||
public Collection<BackendCompiler> getRegisteredJavaCompilers() {
|
||||
@@ -630,8 +640,12 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
|
||||
|
||||
public void readExternal(Element parentNode) throws InvalidDataException {
|
||||
DefaultJDOMExternalizer.readExternal(this, parentNode);
|
||||
public void readExternal(Element parentNode) {
|
||||
myState = XmlSerializer.deserialize(parentNode, State.class);
|
||||
Element option = parentNode.getChild("option");
|
||||
if (!myProject.isDefault()) {
|
||||
myState.compilerWasSpecified = option != null && "DEFAULT_COMPILER".equals(option.getAttributeValue("name"));
|
||||
}
|
||||
|
||||
final Element notNullAssertions = parentNode.getChild(JpsJavaCompilerConfigurationSerializer.ADD_NOTNULL_ASSERTIONS);
|
||||
if (notNullAssertions != null) {
|
||||
@@ -670,7 +684,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
}
|
||||
catch (MalformedPatternException e) {
|
||||
throw new InvalidDataException(e);
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
|
||||
@@ -822,7 +836,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
*/
|
||||
public void setDefaultCompiler(BackendCompiler defaultCompiler) {
|
||||
myDefaultJavaCompiler = defaultCompiler;
|
||||
DEFAULT_COMPILER = defaultCompiler.getId();
|
||||
myState.DEFAULT_COMPILER = defaultCompiler.getId();
|
||||
}
|
||||
|
||||
public void convertPatterns() {
|
||||
@@ -834,7 +848,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
try {
|
||||
ok = doConvertPatterns();
|
||||
}
|
||||
catch (MalformedPatternException e) {
|
||||
catch (MalformedPatternException ignored) {
|
||||
ok = false;
|
||||
}
|
||||
if (!ok) {
|
||||
|
||||
+25
-7
@@ -50,12 +50,12 @@ import java.util.*;
|
||||
* @author nik
|
||||
*/
|
||||
@State(
|
||||
name = ArtifactManagerImpl.COMPONENT_NAME,
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.PROJECT_FILE),
|
||||
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/artifacts/", scheme = StorageScheme.DIRECTORY_BASED,
|
||||
stateSplitter = ArtifactManagerStateSplitter.class)
|
||||
}
|
||||
name = ArtifactManagerImpl.COMPONENT_NAME,
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.PROJECT_FILE),
|
||||
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/artifacts/", scheme = StorageScheme.DIRECTORY_BASED,
|
||||
stateSplitter = ArtifactManagerStateSplitter.class)
|
||||
}
|
||||
)
|
||||
public class ArtifactManagerImpl extends ArtifactManager implements ProjectComponent, PersistentStateComponent<ArtifactManagerState> {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.packaging.impl.artifacts.ArtifactManagerImpl");
|
||||
@@ -77,25 +77,30 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
((ArtifactPointerManagerImpl)ArtifactPointerManager.getInstance(project)).setArtifactManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Artifact[] getArtifacts() {
|
||||
return myModel.getArtifacts();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Artifact findArtifact(@NotNull String name) {
|
||||
return myModel.findArtifact(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Artifact getArtifactByOriginal(@NotNull Artifact artifact) {
|
||||
return myModel.getArtifactByOriginal(artifact);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Artifact getOriginalArtifact(@NotNull Artifact artifact) {
|
||||
return myModel.getOriginalArtifact(artifact);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Collection<? extends Artifact> getArtifactsByType(@NotNull ArtifactType type) {
|
||||
return myModel.getArtifactsByType(type);
|
||||
@@ -106,6 +111,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
return myModel.getAllArtifactsIncludingInvalid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArtifactManagerState getState() {
|
||||
final ArtifactManagerState state = new ArtifactManagerState();
|
||||
for (Artifact artifact : getAllArtifactsIncludingInvalid()) {
|
||||
@@ -127,7 +133,8 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
}
|
||||
}
|
||||
Collections.sort(artifactState.getPropertiesList(), new Comparator<ArtifactPropertiesState>() {
|
||||
public int compare(ArtifactPropertiesState o1, ArtifactPropertiesState o2) {
|
||||
@Override
|
||||
public int compare(@NotNull ArtifactPropertiesState o1, @NotNull ArtifactPropertiesState o2) {
|
||||
return o1.getId().compareTo(o2.getId());
|
||||
}
|
||||
});
|
||||
@@ -184,6 +191,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
return packagingElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(ArtifactManagerState managerState) {
|
||||
final List<ArtifactImpl> artifacts = new ArrayList<ArtifactImpl>();
|
||||
for (ArtifactState state : managerState.getArtifacts()) {
|
||||
@@ -254,15 +262,18 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
LocalFileSystem.getInstance().removeWatchedRoots(myWatchedOutputs.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return COMPONENT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(new ArtifactVirtualFileListener(myProject, this), myProject);
|
||||
updateWatchedRoots();
|
||||
@@ -293,9 +304,11 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@@ -354,6 +367,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
final ArtifactListener publisher = myProject.getMessageBus().syncPublisher(TOPIC);
|
||||
hasChanges = !removed.isEmpty() || !added.isEmpty() || !changed.isEmpty();
|
||||
ProjectRootManagerEx.getInstanceEx(myProject).mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (ArtifactImpl artifact : removed) {
|
||||
publisher.artifactRemoved(artifact);
|
||||
@@ -381,9 +395,11 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Artifact addArtifact(@NotNull final String name, @NotNull final ArtifactType type, final CompositePackagingElement<?> root) {
|
||||
return new WriteAction<Artifact>() {
|
||||
@Override
|
||||
protected void run(@NotNull final Result<Artifact> result) {
|
||||
final ModifiableArtifactModel model = createModifiableModel();
|
||||
final ModifiableArtifact artifact = model.addArtifact(name, type);
|
||||
@@ -408,6 +424,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
final CompositePackagingElement<?> root = model.getOrCreateModifiableArtifact(artifact).getRootElement();
|
||||
PackagingElementFactory.getInstance().getOrCreateDirectory(root, relativePath).addOrFindChildren(elements);
|
||||
new WriteAction() {
|
||||
@Override
|
||||
protected void run(@NotNull final Result result) {
|
||||
model.commit();
|
||||
}
|
||||
@@ -434,6 +451,7 @@ public class ArtifactManagerImpl extends ArtifactManager implements ProjectCompo
|
||||
mySortedArtifacts = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends Artifact> getArtifactsList() {
|
||||
return myArtifactsList;
|
||||
}
|
||||
|
||||
+6
-23
@@ -15,37 +15,20 @@
|
||||
*/
|
||||
package com.intellij.packaging.impl.artifacts;
|
||||
|
||||
import com.intellij.openapi.components.StateSplitter;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.components.StateSplitterEx;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.serialization.artifact.ArtifactState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactManagerStateSplitter implements StateSplitter {
|
||||
public List<Pair<Element, String>> splitState(Element e) {
|
||||
final UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
|
||||
List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();
|
||||
|
||||
for (Element element : JDOMUtil.getElements(e)) {
|
||||
final String name = generator.generateUniqueName(FileUtil.sanitizeFileName(element.getAttributeValue(ArtifactState.NAME_ATTRIBUTE))) + ".xml";
|
||||
result.add(Pair.create(element, name));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void mergeStatesInto(Element target, Element[] elements) {
|
||||
for (Element e : elements) {
|
||||
target.addContent(e);
|
||||
}
|
||||
final class ArtifactManagerStateSplitter extends StateSplitterEx {
|
||||
@Override
|
||||
public List<Pair<Element, String>> splitState(@NotNull Element state) {
|
||||
return splitState(state, ArtifactState.NAME_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,10 @@ public class TransportServiceWrapper {
|
||||
return myTransport.startListening();
|
||||
}
|
||||
|
||||
public TransportService.ListenKey startListening(String address) throws IOException {
|
||||
return myTransport.startListening(address);
|
||||
}
|
||||
|
||||
public void stopListening(final TransportService.ListenKey address) throws IOException {
|
||||
myTransport.stopListening(address);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,20 @@ public class DebuggerUtilsImpl extends DebuggerUtilsEx{
|
||||
return address;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ExecutionException(DebugProcessImpl.processError(e));
|
||||
int tryNum = 0;
|
||||
while (true) {
|
||||
try {
|
||||
TransportService.ListenKey listenKey = transportService.startListening("javadebug_" + (int)(Math.random()*1000));
|
||||
final String address = listenKey.address();
|
||||
transportService.stopListening(listenKey);
|
||||
return address;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (tryNum++ > 10) {
|
||||
throw new ExecutionException(DebugProcessImpl.processError(ex));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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 com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.DefaultJDOMExternalizer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
@@ -47,11 +47,9 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigurationModule> implements SingleClassConfiguration, RefactoringListenerProvider {
|
||||
|
||||
public String MAIN_CLASS_NAME;
|
||||
public String HTML_FILE_NAME;
|
||||
public boolean HTML_USED;
|
||||
@@ -73,6 +71,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
super(new JavaRunConfigurationModule(project, false), factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainClass(final PsiClass psiClass) {
|
||||
final Module originalModule = getConfigurationModule().getModule();
|
||||
setMainClassName(JavaExecutionUtil.getRuntimeQualifiedName(psiClass));
|
||||
@@ -80,10 +79,12 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
restoreOriginalModule(originalModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
|
||||
return new JavaCommandLineState(env) {
|
||||
private AppletHtmlFile myHtmlURL = null;
|
||||
|
||||
@Override
|
||||
protected JavaParameters createJavaParameters() throws ExecutionException {
|
||||
final JavaParameters params = new JavaParameters();
|
||||
myHtmlURL = getHtmlURL();
|
||||
@@ -102,12 +103,14 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
protected OSProcessHandler startProcess() throws ExecutionException {
|
||||
final OSProcessHandler handler = super.startProcess();
|
||||
final AppletHtmlFile htmlUrl = myHtmlURL;
|
||||
if (htmlUrl != null) {
|
||||
handler.addProcessListener(new ProcessAdapter() {
|
||||
@Override
|
||||
public void processTerminated(ProcessEvent event) {
|
||||
htmlUrl.deleteFile();
|
||||
}
|
||||
@@ -118,6 +121,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SettingsEditor<? extends RunConfiguration> getConfigurationEditor() {
|
||||
return new AppletConfigurable(getProject());
|
||||
@@ -174,60 +178,64 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Module> getValidModules() {
|
||||
return JavaRunConfigurationModule.getModulesForClass(getProject(), MAIN_CLASS_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(final Element parentNode) throws InvalidDataException {
|
||||
DefaultJDOMExternalizer.readExternal(this, parentNode);
|
||||
readModule(parentNode);
|
||||
final ArrayList<AppletParameter> parameters = new ArrayList<AppletParameter>();
|
||||
for (
|
||||
Iterator iterator = parentNode.getChildren(PARAMETER_ELEMENT_NAME).iterator(); iterator.hasNext();) {
|
||||
final Element element = (Element)iterator.next();
|
||||
final String name = element.getAttributeValue(NAME_ATTR);
|
||||
final String value = element.getAttributeValue(VALUE_ATTR);
|
||||
parameters.add(new AppletParameter(name, value));
|
||||
for (final Element element : parentNode.getChildren(PARAMETER_ELEMENT_NAME)) {
|
||||
parameters.add(new AppletParameter(element.getAttributeValue(NAME_ATTR), element.getAttributeValue(VALUE_ATTR)));
|
||||
}
|
||||
myAppletParameters = parameters.toArray(new AppletParameter[parameters.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(final Element parentNode) throws WriteExternalException {
|
||||
writeModule(parentNode);
|
||||
DefaultJDOMExternalizer.writeExternal(this, parentNode);
|
||||
if (myAppletParameters != null) {
|
||||
for (int i = 0; i < myAppletParameters.length; i++) {
|
||||
for (AppletParameter myAppletParameter : myAppletParameters) {
|
||||
final Element element = new Element(PARAMETER_ELEMENT_NAME);
|
||||
parentNode.addContent(element);
|
||||
element.setAttribute(NAME_ATTR, myAppletParameters[i].getName());
|
||||
element.setAttribute(VALUE_ATTR, myAppletParameters[i].getValue());
|
||||
element.setAttribute(NAME_ATTR, myAppletParameter.getName());
|
||||
element.setAttribute(VALUE_ATTR, myAppletParameter.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RefactoringElementListener getRefactoringElementListener(final PsiElement element) {
|
||||
if (HTML_USED) return null;
|
||||
return RefactoringListeners.getClassOrPackageListener(element, new RefactoringListeners.SingleClassConfigurationAccessor(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClass getMainClass() {
|
||||
return getConfigurationModule().findClass(MAIN_CLASS_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String suggestedName() {
|
||||
if (MAIN_CLASS_NAME == null) return null;
|
||||
return ProgramRunnerUtil.shortenName(JavaExecutionUtil.getShortClassName(MAIN_CLASS_NAME), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMainClassName(final String qualifiedName) {
|
||||
MAIN_CLASS_NAME = qualifiedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConfiguration() throws RuntimeConfigurationException {
|
||||
if (ALTERNATIVE_JRE_PATH_ENABLED){
|
||||
if (ALTERNATIVE_JRE_PATH == null ||
|
||||
ALTERNATIVE_JRE_PATH.length() == 0 ||
|
||||
!JavaSdkImpl.checkForJre(ALTERNATIVE_JRE_PATH)){
|
||||
!JavaSdk.checkForJre(ALTERNATIVE_JRE_PATH)){
|
||||
throw new RuntimeConfigurationWarning(ExecutionBundle.message("jre.not.valid.error.message", ALTERNATIVE_JRE_PATH));
|
||||
}
|
||||
}
|
||||
@@ -283,7 +291,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
try {
|
||||
return generateAppletTempPage();
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (IOException ignored) {
|
||||
throw new CantRunException(ExecutionBundle.message("failed.to.generate.wrapper.error.message"));
|
||||
}
|
||||
}
|
||||
@@ -314,8 +322,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
finally {
|
||||
writer.close();
|
||||
}
|
||||
final String htmlFile = tempFile.getAbsolutePath();
|
||||
return new AppletHtmlFile(htmlFile, tempFile);
|
||||
return new AppletHtmlFile(tempFile.getAbsolutePath(), tempFile);
|
||||
}
|
||||
|
||||
private static class AppletHtmlFile {
|
||||
@@ -338,7 +345,7 @@ public class AppletConfiguration extends ModuleBasedConfiguration<JavaRunConfigu
|
||||
try {
|
||||
return new File(myHtmlFile).toURL().toString();
|
||||
}
|
||||
catch (MalformedURLException ex) {
|
||||
catch (MalformedURLException ignored) {
|
||||
}
|
||||
}
|
||||
return myHtmlFile;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,6 +30,7 @@ public class AppletConfigurationType implements ConfigurationType {
|
||||
/**reflection*/
|
||||
AppletConfigurationType() {
|
||||
myFactory = new ConfigurationFactoryEx(this) {
|
||||
@Override
|
||||
public RunConfiguration createTemplateConfiguration(Project project) {
|
||||
return new AppletConfiguration(project, this);
|
||||
}
|
||||
@@ -41,26 +42,27 @@ public class AppletConfigurationType implements ConfigurationType {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return ExecutionBundle.message("applet.configuration.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigurationTypeDescription() {
|
||||
return ExecutionBundle.message("applet.configuration.description");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return AllIcons.RunConfigurations.Applet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationFactory[] getConfigurationFactories() {
|
||||
return new ConfigurationFactory[]{myFactory};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getId() {
|
||||
return "Applet";
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<profiles>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
</profile>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="p1" />
|
||||
<option name="myLocal" value="false" />
|
||||
<inspection_tool class="ConstantConditions" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="true" />
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</profiles>
|
||||
<option name="PROJECT_PROFILE" value="p1" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
</config>
|
||||
<state>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default"/>
|
||||
<option name="myLocal" value="false"/>
|
||||
</profile>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="p1"/>
|
||||
<option name="myLocal" value="false"/>
|
||||
<inspection_tool class="ConstantConditions" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="true"/>
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="true"/>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
<option name="PROJECT_PROFILE" value="p1"/>
|
||||
<option name="USE_PROJECT_PROFILE" value="true"/>
|
||||
<version value="1.0"/>
|
||||
</state>
|
||||
@@ -59,7 +59,6 @@
|
||||
</component>
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<option name="PROJECT_PROFILE" value="p1" />
|
||||
<profiles>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
@@ -72,7 +71,6 @@
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</profiles>
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="TYPO" />
|
||||
<item index="1" class="java.lang.String" itemvalue="SERVER PROBLEM" />
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<profiles>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
</profile>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="p1" />
|
||||
<option name="myLocal" value="false" />
|
||||
<inspection_tool class="ConstantConditions" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<scope name="Production" level="WARNING" enabled="true">
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false" />
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="false" />
|
||||
</scope>
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="true" />
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</profiles>
|
||||
<option name="PROJECT_PROFILE" value="p1" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<version value="1.0" />
|
||||
</config>
|
||||
<state>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default"/>
|
||||
<option name="myLocal" value="false"/>
|
||||
</profile>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="p1"/>
|
||||
<option name="myLocal" value="false"/>
|
||||
<inspection_tool class="ConstantConditions" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<scope name="Production" level="WARNING" enabled="true">
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="false"/>
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="false"/>
|
||||
</scope>
|
||||
<option name="SUGGEST_NULLABLE_ANNOTATIONS" value="true"/>
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="true"/>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
<option name="PROJECT_PROFILE" value="p1"/>
|
||||
<option name="USE_PROJECT_PROFILE" value="true"/>
|
||||
<version value="1.0"/>
|
||||
</state>
|
||||
@@ -62,7 +62,6 @@
|
||||
<scopes>
|
||||
<scope profile="Project Default" name="Production" />
|
||||
</scopes>
|
||||
<profiles>
|
||||
<profile version="1.0" is_locked="false">
|
||||
<option name="myName" value="Project Default" />
|
||||
<option name="myLocal" value="false" />
|
||||
@@ -75,7 +74,6 @@
|
||||
<option name="DONT_REPORT_TRUE_ASSERT_STATEMENTS" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</profiles>
|
||||
<list size="5">
|
||||
<item index="0" class="java.lang.String" itemvalue="TYPO" />
|
||||
<item index="1" class="java.lang.String" itemvalue="SERVER PROBLEM" />
|
||||
|
||||
+4
-9
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2011 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,7 +25,6 @@ import com.intellij.testFramework.PlatformTestUtil;
|
||||
import org.jdom.Element;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
@@ -44,17 +43,13 @@ public class InspectionProfilesConverterTest extends LightIdeaTestCase {
|
||||
try {
|
||||
final String relativePath = "/inspection/converter/";
|
||||
final File projectFile = new File(JavaTestUtil.getJavaTestDataPath() + relativePath + dirName + "/options.ipr");
|
||||
final List children = JDOMUtil.loadDocument(projectFile).getRootElement().getChildren("component");
|
||||
|
||||
for (Object child : children) {
|
||||
final Element element = (Element)child;
|
||||
for (Element element : JDOMUtil.loadDocument(projectFile).getRootElement().getChildren("component")) {
|
||||
if (Comparing.strEqual(element.getAttributeValue("name"), "InspectionProjectProfileManager")) {
|
||||
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(getProject());
|
||||
InspectionProfileImpl.INIT_INSPECTIONS = true;
|
||||
profileManager.readExternal(element);
|
||||
profileManager.loadState(element);
|
||||
|
||||
final Element configElement = new Element("config");
|
||||
profileManager.writeExternal(configElement);
|
||||
Element configElement = profileManager.getState();
|
||||
final File file = new File(JavaTestUtil.getJavaTestDataPath() + relativePath + dirName + "/options.after.xml");
|
||||
PlatformTestUtil.assertElementsEqual(configElement, JDOMUtil.loadDocument(file).getRootElement());
|
||||
break;
|
||||
|
||||
+106
-124
@@ -16,50 +16,55 @@
|
||||
package com.intellij.profile;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.StateSplitter;
|
||||
import com.intellij.openapi.components.MainConfigurationStateSplitter;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import com.intellij.util.xmlb.XmlSerializer;
|
||||
import com.intellij.util.xmlb.annotations.OptionTag;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 30-Nov-2005
|
||||
*/
|
||||
public abstract class DefaultProjectProfileManager extends ProjectProfileManager implements JDOMExternalizable {
|
||||
public abstract class DefaultProjectProfileManager extends ProjectProfileManager implements PersistentStateComponent<Element> {
|
||||
protected static final Logger LOG = Logger.getInstance("#com.intellij.profile.DefaultProjectProfileManager");
|
||||
|
||||
@NonNls protected static final String PROFILES = "profiles";
|
||||
@NonNls public static final String SCOPES = "scopes";
|
||||
@NonNls protected static final String SCOPE = "scope";
|
||||
@NonNls public static final String PROFILE = "profile";
|
||||
@NonNls protected static final String NAME = "name";
|
||||
|
||||
|
||||
private static final String VERSION = "1.0";
|
||||
|
||||
@NotNull
|
||||
protected final Project myProject;
|
||||
|
||||
/** This field is used for serialization. Do not rename it or make access weaker */
|
||||
public String PROJECT_PROFILE;
|
||||
protected String myProjectProfile;
|
||||
/** This field is used for serialization. Do not rename it or make access weaker */
|
||||
public boolean USE_PROJECT_PROFILE = true;
|
||||
|
||||
private final ApplicationProfileManager myApplicationProfileManager;
|
||||
|
||||
private final Map<String, Profile> myProfiles = new HashMap<String, Profile>();
|
||||
private final Map<String, Profile> myProfiles = new THashMap<String, Profile>();
|
||||
protected final DependencyValidationManager myHolder;
|
||||
private final List<ProfileChangeAdapter> myProfilesListener = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
@NonNls private static final String PROJECT_DEFAULT_PROFILE_NAME = "Project Default";
|
||||
@@ -90,81 +95,85 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public synchronized void readExternal(Element element) throws InvalidDataException {
|
||||
myProfiles.clear();
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
final Element profilesElement = element.getChild(PROFILES);
|
||||
if (profilesElement != null) {
|
||||
for (Object o : profilesElement.getChildren(PROFILE)) {
|
||||
final Profile profile = myApplicationProfileManager.createProfile();
|
||||
profile.setProfileManager(this);
|
||||
profile.readExternal((Element)o);
|
||||
final String name = profile.getName();
|
||||
if (myApplicationProfileManager.getProfile(name) != null) { //override ide profile
|
||||
// myApplicationProfileManager.deleteProfile(name);
|
||||
}
|
||||
myProfiles.put(name, profile);
|
||||
}
|
||||
}
|
||||
if (element.getChild("version") == null || !Comparing.strEqual(element.getChild("version").getAttributeValue("value"), VERSION)) {
|
||||
boolean toConvert = true;
|
||||
for (Object o : element.getChildren("option")) {
|
||||
if (Comparing.strEqual(((Element)o).getAttributeValue("name"), "USE_PROJECT_LEVEL_SETTINGS")) {
|
||||
toConvert = Boolean.parseBoolean(((Element)o).getAttributeValue("value"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (toConvert) {
|
||||
convert(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
public synchronized Element getState() {
|
||||
Element state = new Element("settings");
|
||||
|
||||
protected void convert(Element element) throws InvalidDataException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void writeExternal(Element element) throws WriteExternalException {
|
||||
|
||||
final List<String> sortedProfiles = new ArrayList<String>(myProfiles.keySet());
|
||||
Collections.sort(sortedProfiles);
|
||||
Element profiles = null;
|
||||
String[] sortedProfiles = myProfiles.keySet().toArray(new String[myProfiles.size()]);
|
||||
Arrays.sort(sortedProfiles);
|
||||
for (String profile : sortedProfiles) {
|
||||
final Profile projectProfile = myProfiles.get(profile);
|
||||
if (projectProfile != null) {
|
||||
final Element profileElement = new Element(PROFILE);
|
||||
projectProfile.writeExternal(profileElement);
|
||||
boolean hasSmthToSave = sortedProfiles.size() > 1 || isDefaultProfileUsed();
|
||||
Element profileElement = new Element(PROFILE);
|
||||
try {
|
||||
projectProfile.writeExternal(profileElement);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
boolean hasSmthToSave = sortedProfiles.length > 1 || isDefaultProfileUsed();
|
||||
if (!hasSmthToSave) {
|
||||
for (Object child : profileElement.getChildren()) {
|
||||
if (!((Element)child).getName().equals("option")) {
|
||||
for (Element child : profileElement.getChildren()) {
|
||||
if (!child.getName().equals("option")) {
|
||||
hasSmthToSave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasSmthToSave) continue;
|
||||
|
||||
if (profiles == null) {
|
||||
profiles = new Element(PROFILES);
|
||||
element.addContent(profiles);
|
||||
if (!hasSmthToSave) {
|
||||
continue;
|
||||
}
|
||||
|
||||
profiles.addContent(profileElement);
|
||||
state.addContent(profileElement);
|
||||
}
|
||||
}
|
||||
|
||||
if (profiles != null || isDefaultProfileUsed()) {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
final Element version = new Element("version");
|
||||
version.setAttribute("value", VERSION);
|
||||
element.addContent(version);
|
||||
if (!state.getChildren().isEmpty() || isDefaultProfileUsed()) {
|
||||
XmlSerializer.serializeInto(this, state);
|
||||
state.addContent(new Element("version").setAttribute("value", VERSION));
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void loadState(Element state) {
|
||||
myProfiles.clear();
|
||||
XmlSerializer.deserializeInto(this, state);
|
||||
for (Element o : state.getChildren(PROFILE)) {
|
||||
final Profile profile = myApplicationProfileManager.createProfile();
|
||||
profile.setProfileManager(this);
|
||||
try {
|
||||
profile.readExternal(o);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
final String name = profile.getName();
|
||||
if (myApplicationProfileManager.getProfile(name) != null) { //override ide profile
|
||||
// myApplicationProfileManager.deleteProfile(name);
|
||||
}
|
||||
myProfiles.put(name, profile);
|
||||
}
|
||||
if (state.getChild("version") == null || !Comparing.strEqual(state.getChild("version").getAttributeValue("value"), VERSION)) {
|
||||
boolean toConvert = true;
|
||||
for (Element o : state.getChildren("option")) {
|
||||
if (Comparing.strEqual(o.getAttributeValue("name"), "USE_PROJECT_LEVEL_SETTINGS")) {
|
||||
toConvert = Boolean.parseBoolean(o.getAttributeValue("value"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (toConvert) {
|
||||
convert(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void convert(Element element) {
|
||||
}
|
||||
|
||||
private boolean isDefaultProfileUsed() {
|
||||
return PROJECT_PROFILE != null && !Comparing.strEqual(PROJECT_PROFILE, PROJECT_DEFAULT_PROFILE_NAME);
|
||||
return myProjectProfile != null && !Comparing.strEqual(myProjectProfile, PROJECT_DEFAULT_PROFILE_NAME);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -192,14 +201,19 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
}
|
||||
|
||||
@Override
|
||||
@OptionTag("PROJECT_PROFILE")
|
||||
public synchronized String getProjectProfile() {
|
||||
return PROJECT_PROFILE;
|
||||
return myProjectProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setProjectProfile(@Nullable final String newProfile) {
|
||||
final String oldProfile = PROJECT_PROFILE;
|
||||
PROJECT_PROFILE = newProfile;
|
||||
public synchronized void setProjectProfile(@Nullable String newProfile) {
|
||||
if (Comparing.strEqual(newProfile, myProjectProfile)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String oldProfile = myProjectProfile;
|
||||
myProjectProfile = newProfile;
|
||||
USE_PROJECT_PROFILE = newProfile != null;
|
||||
if (oldProfile != null) {
|
||||
for (ProfileChangeAdapter adapter : myProfilesListener) {
|
||||
@@ -210,8 +224,10 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
|
||||
@NotNull
|
||||
public synchronized Profile getProjectProfileImpl(){
|
||||
if (!USE_PROJECT_PROFILE) return myApplicationProfileManager.getRootProfile();
|
||||
if (PROJECT_PROFILE == null || myProfiles.isEmpty()){
|
||||
if (!USE_PROJECT_PROFILE) {
|
||||
return myApplicationProfileManager.getRootProfile();
|
||||
}
|
||||
if (myProjectProfile == null || myProfiles.isEmpty()){
|
||||
setProjectProfile(PROJECT_DEFAULT_PROFILE_NAME);
|
||||
final Profile projectProfile = myApplicationProfileManager.createProfile();
|
||||
projectProfile.copyFrom(myApplicationProfileManager.getRootProfile());
|
||||
@@ -219,11 +235,10 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
projectProfile.setName(PROJECT_DEFAULT_PROFILE_NAME);
|
||||
myProfiles.put(PROJECT_DEFAULT_PROFILE_NAME, projectProfile);
|
||||
}
|
||||
else if (!myProfiles.containsKey(PROJECT_PROFILE)){
|
||||
final String projectProfileAttempt = myProfiles.keySet().iterator().next();
|
||||
setProjectProfile(projectProfileAttempt);
|
||||
else if (!myProfiles.containsKey(myProjectProfile)){
|
||||
setProjectProfile(myProfiles.keySet().iterator().next());
|
||||
}
|
||||
final Profile profile = myProfiles.get(PROJECT_PROFILE);
|
||||
final Profile profile = myProfiles.get(myProjectProfile);
|
||||
profile.setProfileManager(this);
|
||||
return profile;
|
||||
}
|
||||
@@ -242,61 +257,28 @@ public abstract class DefaultProjectProfileManager extends ProjectProfileManager
|
||||
myProfilesListener.remove(profilesListener);
|
||||
}
|
||||
|
||||
public static class ProfileStateSplitter implements StateSplitter {
|
||||
|
||||
public static class ProfileStateSplitter extends MainConfigurationStateSplitter {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Pair<Element, String>> splitState(final Element e) {
|
||||
final UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();
|
||||
|
||||
final Element[] elements = JDOMUtil.getElements(e);
|
||||
for (Element element : elements) {
|
||||
if (element.getName().equals("profiles")) {
|
||||
element.detach();
|
||||
|
||||
final Element[] profiles = JDOMUtil.getElements(element);
|
||||
for (Element profile : profiles) {
|
||||
String profileName = null;
|
||||
|
||||
final Element[] options = JDOMUtil.getElements(profile);
|
||||
for (Element option : options) {
|
||||
if (option.getName().equals("option") && option.getAttributeValue("name").equals("myName")) {
|
||||
profileName = option.getAttributeValue("value");
|
||||
}
|
||||
}
|
||||
|
||||
assert profileName != null;
|
||||
|
||||
final String name = generator.generateUniqueName(FileUtil.sanitizeFileName(profileName)) + ".xml";
|
||||
result.add(Pair.create(profile, name));
|
||||
}
|
||||
protected String getSubStateFileName(@NotNull Element element) {
|
||||
for (Element option : element.getChildren("option")) {
|
||||
if (option.getAttributeValue("name").equals("myName")) {
|
||||
return option.getAttributeValue("value");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!e.getContent().isEmpty()) result.add(Pair.create(e, generator.generateUniqueName("profiles_settings") + ".xml"));
|
||||
|
||||
return result;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void mergeStatesInto(final Element target, final Element[] elements) {
|
||||
Element profiles = new Element("profiles");
|
||||
target.addContent(profiles);
|
||||
protected String getComponentStateFileName() {
|
||||
return "profiles_settings";
|
||||
}
|
||||
|
||||
for (Element element : elements) {
|
||||
if (element.getName().equals("profile")) {
|
||||
element.detach();
|
||||
profiles.addContent(element);
|
||||
}
|
||||
else {
|
||||
final Element[] states = JDOMUtil.getElements(element);
|
||||
for (Element state : states) {
|
||||
state.detach();
|
||||
target.addContent(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSubStateTagName() {
|
||||
return PROFILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,5 +25,6 @@ public abstract class ProjectProfileManager implements ProfileManager {
|
||||
public abstract String getProfileName();
|
||||
|
||||
public abstract String getProjectProfile();
|
||||
public abstract void setProjectProfile(@Nullable final String projectProfile);
|
||||
|
||||
public abstract void setProjectProfile(@Nullable String projectProfile);
|
||||
}
|
||||
|
||||
+49
-77
@@ -13,40 +13,40 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.packageDependencies;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.search.scope.packageSet.*;
|
||||
import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jdom.Attribute;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@State(
|
||||
name="DependencyValidationManager",
|
||||
storages= {
|
||||
name = "DependencyValidationManager",
|
||||
storages = {
|
||||
@Storage(file = StoragePathMacros.PROJECT_FILE),
|
||||
@Storage(file = StoragePathMacros.PROJECT_CONFIG_DIR + "/scopes/", scheme = StorageScheme.DIRECTORY_BASED,
|
||||
stateSplitter = DependencyValidationManagerImpl.ScopesStateSplitter.class)}
|
||||
stateSplitter = DependencyValidationManagerImpl.ScopesStateSplitter.class)}
|
||||
)
|
||||
public class DependencyValidationManagerImpl extends DependencyValidationManager {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.packageDependencies.DependencyValidationManagerImpl");
|
||||
private static final NotNullLazyValue<Icon> ourSharedScopeIcon = new NotNullLazyValue<Icon>() {
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -58,7 +58,8 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
private final List<DependencyRule> myRules = new ArrayList<DependencyRule>();
|
||||
private final NamedScopeManager myNamedScopeManager;
|
||||
|
||||
public boolean SKIP_IMPORT_STATEMENTS = false;
|
||||
private boolean mySkipImportStatements;
|
||||
private boolean mySkipImportStatementsWasSpecified;
|
||||
|
||||
@NonNls private static final String DENY_RULE_KEY = "deny_rule";
|
||||
@NonNls private static final String FROM_SCOPE_KEY = "from_scope";
|
||||
@@ -67,8 +68,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
@NonNls private static final String UNNAMED_SCOPE = "unnamed_scope";
|
||||
@NonNls private static final String VALUE = "value";
|
||||
|
||||
|
||||
private final Map<String, PackageSet> myUnnamedScopes = new HashMap<String, PackageSet>();
|
||||
private final Map<String, PackageSet> myUnnamedScopes = new THashMap<String, PackageSet>();
|
||||
|
||||
public DependencyValidationManagerImpl(final Project project, NamedScopeManager namedScopeManager) {
|
||||
super(project);
|
||||
@@ -147,12 +147,12 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
|
||||
@Override
|
||||
public boolean skipImportStatements() {
|
||||
return SKIP_IMPORT_STATEMENTS;
|
||||
return mySkipImportStatements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkipImportStatements(final boolean skip) {
|
||||
SKIP_IMPORT_STATEMENTS = skip;
|
||||
mySkipImportStatements = skip;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -206,12 +206,11 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(final Element element) {
|
||||
try {
|
||||
DefaultJDOMExternalizer.readExternal(this, element);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.info(e);
|
||||
public void loadState(Element element) {
|
||||
Element option = element.getChild("option");
|
||||
if (option != null && "SKIP_IMPORT_STATEMENTS".equals(option.getAttributeValue("name"))) {
|
||||
mySkipImportStatementsWasSpecified = !myProject.isDefault();
|
||||
mySkipImportStatements = Boolean.parseBoolean(option.getAttributeValue("value"));
|
||||
}
|
||||
|
||||
super.loadState(element);
|
||||
@@ -223,7 +222,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
final String packageSet = ((Element)unnamedScope).getAttributeValue(VALUE);
|
||||
myUnnamedScopes.put(packageSet, packageSetFactory.compile(packageSet));
|
||||
}
|
||||
catch (ParsingException e) {
|
||||
catch (ParsingException ignored) {
|
||||
//skip pattern
|
||||
}
|
||||
}
|
||||
@@ -234,9 +233,8 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
private void readRules(Element element) {
|
||||
removeAllRules();
|
||||
|
||||
List rules = element.getChildren(DENY_RULE_KEY);
|
||||
for (Object rule1 : rules) {
|
||||
DependencyRule rule = readRule((Element)rule1);
|
||||
for (Element rule1 : element.getChildren(DENY_RULE_KEY)) {
|
||||
DependencyRule rule = readRule(rule1);
|
||||
if (rule != null) {
|
||||
addRule(rule);
|
||||
}
|
||||
@@ -246,18 +244,17 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
@Override
|
||||
public Element getState() {
|
||||
Element element = super.getState();
|
||||
try {
|
||||
DefaultJDOMExternalizer.writeExternal(this, element);
|
||||
assert element != null;
|
||||
if (mySkipImportStatements || mySkipImportStatementsWasSpecified) {
|
||||
element.addContent(new Element("option").setAttribute("name", "SKIP_IMPORT_STATEMENTS").setAttribute("value", Boolean.toString(mySkipImportStatements)));
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
final List<String> unnamedScopes = new ArrayList<String>(myUnnamedScopes.keySet());
|
||||
Collections.sort(unnamedScopes);
|
||||
for (final String unnamedScope : unnamedScopes) {
|
||||
Element unnamedElement = new Element(UNNAMED_SCOPE);
|
||||
unnamedElement.setAttribute(VALUE, unnamedScope);
|
||||
element.addContent(unnamedElement);
|
||||
|
||||
if (!myUnnamedScopes.isEmpty()) {
|
||||
String[] unnamedScopes = myUnnamedScopes.keySet().toArray(new String[myUnnamedScopes.size()]);
|
||||
Arrays.sort(unnamedScopes);
|
||||
for (String unnamedScope : unnamedScopes) {
|
||||
element.addContent(new Element(UNNAMED_SCOPE).setAttribute(VALUE, unnamedScope));
|
||||
}
|
||||
}
|
||||
|
||||
writeRules(element);
|
||||
@@ -314,50 +311,26 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
return new DependencyRule(fromNamedScope, toNamedScope, Boolean.valueOf(denyRule).booleanValue());
|
||||
}
|
||||
|
||||
public static class ScopesStateSplitter implements StateSplitter {
|
||||
@Override
|
||||
public List<Pair<Element, String>> splitState(Element e) {
|
||||
final UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
final List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();
|
||||
|
||||
final Element[] elements = JDOMUtil.getElements(e);
|
||||
for (Element element : elements) {
|
||||
if (element.getName().equals("scope")) {
|
||||
element.detach();
|
||||
String scopeName = element.getAttributeValue("name");
|
||||
assert scopeName != null;
|
||||
final String name = generator.generateUniqueName(FileUtil.sanitizeFileName(scopeName)) + ".xml";
|
||||
result.add(Pair.create(element, name));
|
||||
}
|
||||
}
|
||||
if (!e.getChildren().isEmpty()) {
|
||||
result.add(Pair.create(e, generator.generateUniqueName("scope_settings") + ".xml"));
|
||||
}
|
||||
return result;
|
||||
static final class ScopesStateSplitter extends MainConfigurationStateSplitter {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSubStateFileName(@NotNull Element element) {
|
||||
return element.getAttributeValue("name");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void mergeStatesInto(Element target, Element[] elements) {
|
||||
for (Element element : elements) {
|
||||
if (element.getName().equals("scope")) {
|
||||
element.detach();
|
||||
target.addContent(element);
|
||||
}
|
||||
else {
|
||||
final Element[] states = JDOMUtil.getElements(element);
|
||||
for (Element state : states) {
|
||||
state.detach();
|
||||
target.addContent(state);
|
||||
}
|
||||
for (Object attr : element.getAttributes()) {
|
||||
target.setAttribute(((Attribute)attr).clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
protected String getComponentStateFileName() {
|
||||
return "scope_settings";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSubStateTagName() {
|
||||
return "scope";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final List<Pair<NamedScope, NamedScopesHolder>> myScopes = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
|
||||
private void reloadScopes() {
|
||||
@@ -377,8 +350,7 @@ public class DependencyValidationManagerImpl extends DependencyValidationManager
|
||||
|
||||
private static void addScopesToList(@NotNull final List<Pair<NamedScope, NamedScopesHolder>> scopeList,
|
||||
@NotNull final NamedScopesHolder holder) {
|
||||
NamedScope[] scopes = holder.getScopes();
|
||||
for (NamedScope scope : scopes) {
|
||||
for (NamedScope scope : holder.getScopes()) {
|
||||
scopeList.add(Pair.create(scope, holder));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-26
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,8 +19,6 @@ import com.intellij.codeInspection.InspectionProfile;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.ProjectComponent;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
import com.intellij.profile.DefaultProjectProfileManager;
|
||||
import com.intellij.profile.Profile;
|
||||
@@ -49,29 +47,6 @@ public abstract class InspectionProjectProfileManager extends DefaultProjectProf
|
||||
return getInspectionProfile().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
try {
|
||||
final Element e = new Element("settings");
|
||||
writeExternal(e);
|
||||
return e;
|
||||
}
|
||||
catch (WriteExternalException e1) {
|
||||
LOG.error(e1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element state) {
|
||||
try {
|
||||
readExternal(state);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public InspectionProfile getInspectionProfile(){
|
||||
return (InspectionProfile)getProjectProfileImpl();
|
||||
|
||||
+27
-34
@@ -21,7 +21,10 @@ import com.intellij.codeInspection.ex.InspectionProfileWrapper;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.*;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.StoragePathMacros;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.project.DumbAwareRunnable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
@@ -54,7 +57,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
stateSplitter = InspectionProjectProfileManagerImpl.ProfileStateSplitter.class)
|
||||
}
|
||||
)
|
||||
public class InspectionProjectProfileManagerImpl extends InspectionProjectProfileManager implements ProjectComponent, PersistentStateComponent<Element> {
|
||||
public class InspectionProjectProfileManagerImpl extends InspectionProjectProfileManager {
|
||||
private final Map<String, InspectionProfileWrapper> myName2Profile = new ConcurrentHashMap<String, InspectionProfileWrapper>();
|
||||
private final SeverityRegistrar mySeverityRegistrar;
|
||||
private final NamedScopeManager myLocalScopesHolder;
|
||||
@@ -73,29 +76,6 @@ public class InspectionProjectProfileManagerImpl extends InspectionProjectProfil
|
||||
return (InspectionProjectProfileManagerImpl)project.getComponent(InspectionProjectProfileManager.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element getState() {
|
||||
try {
|
||||
final Element e = new Element("settings");
|
||||
writeExternal(e);
|
||||
return e;
|
||||
}
|
||||
catch (WriteExternalException e1) {
|
||||
LOG.error(e1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadState(Element state) {
|
||||
try {
|
||||
readExternal(state);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProfileLoaded() {
|
||||
return myName2Profile.containsKey(getInspectionProfile().getName());
|
||||
@@ -133,7 +113,9 @@ public class InspectionProjectProfileManagerImpl extends InspectionProjectProfil
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
StartupManager startupManager = StartupManager.getInstance(myProject);
|
||||
if (startupManager == null) return; // upsource
|
||||
if (startupManager == null) {
|
||||
return; // upsource
|
||||
}
|
||||
startupManager.registerPostStartupActivity(new DumbAwareRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -219,15 +201,26 @@ public class InspectionProjectProfileManagerImpl extends InspectionProjectProfil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(final Element element) throws InvalidDataException {
|
||||
mySeverityRegistrar.readExternal(element);
|
||||
super.readExternal(element);
|
||||
public void loadState(Element state) {
|
||||
try {
|
||||
mySeverityRegistrar.readExternal(state);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
super.loadState(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(final Element element) throws WriteExternalException {
|
||||
super.writeExternal(element);
|
||||
mySeverityRegistrar.writeExternal(element);
|
||||
public Element getState() {
|
||||
Element state = super.getState();
|
||||
try {
|
||||
mySeverityRegistrar.writeExternal(state);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,9 +229,9 @@ public class InspectionProjectProfileManagerImpl extends InspectionProjectProfil
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(Element element) throws InvalidDataException {
|
||||
public void convert(Element element) {
|
||||
super.convert(element);
|
||||
if (PROJECT_PROFILE != null) {
|
||||
if (myProjectProfile != null) {
|
||||
((ProfileEx)getProjectProfileImpl()).convert(element, getProject());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -20,7 +20,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.ModuleUtil;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
@@ -37,7 +37,7 @@ import java.util.Set;
|
||||
* Base class for a configuration that is associated with a specific module. For example, Java run configurations use the selected module
|
||||
* to determine the run classpath.
|
||||
*/
|
||||
public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunConfigurationModule> extends RuntimeConfiguration {
|
||||
public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunConfigurationModule> extends LocatableConfigurationBase implements Cloneable, ModuleRunConfiguration {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.configurations.ModuleBasedConfiguration");
|
||||
private final ConfigurationModule myModule;
|
||||
@NonNls
|
||||
@@ -45,12 +45,12 @@ public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunCo
|
||||
|
||||
public ModuleBasedConfiguration(final String name,
|
||||
final ConfigurationModule configurationModule, final ConfigurationFactory factory) {
|
||||
super(name, configurationModule.getProject(), factory);
|
||||
super(configurationModule.getProject(), factory, name);
|
||||
myModule = configurationModule;
|
||||
}
|
||||
|
||||
public ModuleBasedConfiguration(final ConfigurationModule configurationModule, final ConfigurationFactory factory) {
|
||||
super("", configurationModule.getProject(), factory);
|
||||
super(configurationModule.getProject(), factory, "");
|
||||
myModule = configurationModule;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public abstract class ModuleBasedConfiguration<ConfigurationModule extends RunCo
|
||||
final Module[] classModules = getModules();
|
||||
final Set<Module> modules = new HashSet<Module>();
|
||||
for (Module classModule : classModules) {
|
||||
ModuleUtil.collectModulesDependsOn(classModule, modules);
|
||||
ModuleUtilCore.collectModulesDependsOn(classModule, modules);
|
||||
}
|
||||
if (modules.contains(originalModule)) setModule(originalModule);
|
||||
}
|
||||
|
||||
+31
-23
@@ -34,7 +34,10 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.application.ex.ApplicationEx;
|
||||
import com.intellij.openapi.application.ex.ApplicationManagerEx;
|
||||
import com.intellij.openapi.components.NamedComponent;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
import com.intellij.openapi.components.State;
|
||||
import com.intellij.openapi.components.Storage;
|
||||
import com.intellij.openapi.components.StoragePathMacros;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -54,7 +57,9 @@ import com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueueImpl;
|
||||
@@ -85,7 +90,11 @@ import java.util.*;
|
||||
/**
|
||||
* This class also controls the auto-reparse and auto-hints.
|
||||
*/
|
||||
public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements JDOMExternalizable, NamedComponent, Disposable {
|
||||
@State(
|
||||
name = "DaemonCodeAnalyzer",
|
||||
storages = @Storage(file = StoragePathMacros.WORKSPACE_FILE)
|
||||
)
|
||||
public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements PersistentStateComponent<Element>, Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl");
|
||||
|
||||
private static final Key<List<LineMarkerInfo>> MARKERS_IN_EDITOR_DOCUMENT_KEY = Key.create("MARKERS_IN_EDITOR_DOCUMENT");
|
||||
@@ -377,12 +386,6 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements JDOM
|
||||
myPassExecutorService.cancelAll(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return "DaemonCodeAnalyzer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingsChanged() {
|
||||
DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
|
||||
@@ -676,35 +679,40 @@ public class DaemonCodeAnalyzerImpl extends DaemonCodeAnalyzerEx implements JDOM
|
||||
return myLastIntentionHint;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void writeExternal(@NotNull Element parentNode) throws WriteExternalException {
|
||||
Element disableHintsElement = new Element(DISABLE_HINTS_TAG);
|
||||
parentNode.addContent(disableHintsElement);
|
||||
public Element getState() {
|
||||
Element state = new Element("state");
|
||||
if (myDisabledHintsFiles.isEmpty()) {
|
||||
return state;
|
||||
}
|
||||
|
||||
List<String> array = new ArrayList<String>();
|
||||
List<String> array = new SmartList<String>();
|
||||
for (VirtualFile file : myDisabledHintsFiles) {
|
||||
if (file.isValid()) {
|
||||
array.add(file.getUrl());
|
||||
}
|
||||
}
|
||||
Collections.sort(array);
|
||||
|
||||
for (String url : array) {
|
||||
Element fileElement = new Element(FILE_TAG);
|
||||
fileElement.setAttribute(URL_ATT, url);
|
||||
disableHintsElement.addContent(fileElement);
|
||||
if (!array.isEmpty()) {
|
||||
Collections.sort(array);
|
||||
|
||||
Element disableHintsElement = new Element(DISABLE_HINTS_TAG);
|
||||
state.addContent(disableHintsElement);
|
||||
for (String url : array) {
|
||||
disableHintsElement.addContent(new Element(FILE_TAG).setAttribute(URL_ATT, url));
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(@NotNull Element parentNode) throws InvalidDataException {
|
||||
public void loadState(Element state) {
|
||||
myDisabledHintsFiles.clear();
|
||||
|
||||
Element element = parentNode.getChild(DISABLE_HINTS_TAG);
|
||||
Element element = state.getChild(DISABLE_HINTS_TAG);
|
||||
if (element != null) {
|
||||
for (Object o : element.getChildren(FILE_TAG)) {
|
||||
Element e = (Element)o;
|
||||
|
||||
for (Element e : element.getChildren(FILE_TAG)) {
|
||||
String url = e.getAttributeValue(URL_ATT);
|
||||
if (url != null) {
|
||||
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url);
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.WeakHashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -528,10 +529,10 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
try {
|
||||
configuration.checkSettings(executor);
|
||||
}
|
||||
catch (RuntimeConfigurationError er) {
|
||||
catch (RuntimeConfigurationError ignored) {
|
||||
return false;
|
||||
}
|
||||
catch (RuntimeConfigurationException e) {
|
||||
catch (RuntimeConfigurationException ignored) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@@ -1082,7 +1083,7 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
settings.checkSettings();
|
||||
icon = ProgramRunnerUtil.getConfigurationIcon(settings, false);
|
||||
}
|
||||
catch (RuntimeConfigurationException e) {
|
||||
catch (RuntimeConfigurationException ignored) {
|
||||
icon = ProgramRunnerUtil.getConfigurationIcon(settings, true);
|
||||
}
|
||||
myIconCalcTime.put(uniqueID, System.currentTimeMillis() - startTime);
|
||||
@@ -1118,10 +1119,12 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
tasks = getBeforeRunTasks(settings);
|
||||
myConfigurationToBeforeTasksMap.put(settings, tasks);
|
||||
}
|
||||
List<T> result = new ArrayList<T>();
|
||||
List<T> result = new SmartList<T>();
|
||||
for (BeforeRunTask task : tasks) {
|
||||
if (task.getProviderId() == taskProviderID)
|
||||
if (task.getProviderId() == taskProviderID) {
|
||||
//noinspection unchecked
|
||||
result.add((T)task);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1187,10 +1190,10 @@ public class RunManagerImpl extends RunManagerEx implements PersistentStateCompo
|
||||
|
||||
@Override
|
||||
public final void setBeforeRunTasks(final RunConfiguration runConfiguration, @NotNull List<BeforeRunTask> tasks, boolean addEnabledTemplateTasksIfAbsent) {
|
||||
List<BeforeRunTask> result = new ArrayList<BeforeRunTask>(tasks);
|
||||
List<BeforeRunTask> result = new SmartList<BeforeRunTask>(tasks);
|
||||
if (addEnabledTemplateTasksIfAbsent) {
|
||||
List<BeforeRunTask> templates = getTemplateBeforeRunTasks(runConfiguration);
|
||||
Set<Key<BeforeRunTask>> idsToSet = new HashSet<Key<BeforeRunTask>>();
|
||||
Set<Key<BeforeRunTask>> idsToSet = new THashSet<Key<BeforeRunTask>>();
|
||||
for (BeforeRunTask task : tasks) {
|
||||
idsToSet.add(task.getProviderId());
|
||||
}
|
||||
|
||||
+4
-2
@@ -148,8 +148,10 @@ public class EncodingProjectManagerImpl extends EncodingProjectManager implement
|
||||
|
||||
myModificationTracker.incModificationCount();
|
||||
|
||||
myOldUTFGuessing = element.getAttributeValue("useUTFGuessing");
|
||||
myNative2AsciiForPropertiesFilesWasSpecified = native2AsciiForPropertiesFiles != null;
|
||||
if (!myProject.isDefault()) {
|
||||
myOldUTFGuessing = element.getAttributeValue("useUTFGuessing");
|
||||
myNative2AsciiForPropertiesFilesWasSpecified = native2AsciiForPropertiesFiles != null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -110,7 +110,6 @@
|
||||
<component>
|
||||
<interface-class>com.intellij.codeInsight.daemon.DaemonCodeAnalyzer</interface-class>
|
||||
<implementation-class>com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl</implementation-class>
|
||||
<option name="workspace" value="true"/>
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
<component>
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.components;
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MainConfigurationStateSplitter extends StateSplitterEx {
|
||||
@Override
|
||||
public final List<Pair<Element, String>> splitState(@NotNull Element state) {
|
||||
UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
List<Pair<Element, String>> result = new SmartList<Pair<Element, String>>();
|
||||
for (Iterator<Element> iterator = state.getChildren(getSubStateTagName()).iterator(); iterator.hasNext(); ) {
|
||||
Element element = iterator.next();
|
||||
iterator.remove();
|
||||
result.add(createItem(getSubStateFileName(element), generator, element));
|
||||
}
|
||||
if (!JDOMUtil.isEmpty(state)) {
|
||||
result.add(createItem(getComponentStateFileName(), generator, state));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void mergeStateInto(@NotNull Element target, @NotNull Element subState) {
|
||||
mergeStateInto(target, subState, getSubStateTagName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract String getSubStateFileName(@NotNull Element element);
|
||||
|
||||
@NotNull
|
||||
protected abstract String getComponentStateFileName();
|
||||
|
||||
@NotNull
|
||||
protected abstract String getSubStateTagName();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.openapi.components;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -22,9 +21,10 @@ import org.jdom.Element;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
* @deprecated Use {@link StateSplitterEx}
|
||||
*/
|
||||
public interface StateSplitter {
|
||||
List<Pair<Element, String>> splitState(Element e);
|
||||
|
||||
void mergeStatesInto(Element target, Element[] elements);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.components;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class StateSplitterEx implements StateSplitter {
|
||||
@Override
|
||||
public abstract List<Pair<Element, String>> splitState(@NotNull Element state);
|
||||
|
||||
public void mergeStateInto(@NotNull Element target, @NotNull Element subState) {
|
||||
target.addContent(subState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void mergeStatesInto(Element target, Element[] elements) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static List<Pair<Element, String>> splitState(@NotNull Element state, @NotNull String attributeName) {
|
||||
UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
List<Pair<Element, String>> result = new SmartList<Pair<Element, String>>();
|
||||
for (Element subState : state.getChildren()) {
|
||||
result.add(createItem(generator, subState, attributeName));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Pair<Element, String> createItem(@NotNull UniqueNameGenerator generator, @NotNull Element element, @NotNull String attributeName) {
|
||||
return createItem(element.getAttributeValue(attributeName), generator, element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Pair<Element, String> createItem(@NotNull String fileName, @NotNull UniqueNameGenerator generator, @NotNull Element element) {
|
||||
return Pair.create(element, generator.generateUniqueName(FileUtil.sanitizeFileName(fileName)) + ".xml");
|
||||
}
|
||||
|
||||
protected static void mergeStateInto(@NotNull Element target, @NotNull Element subState, @NotNull String subStateName) {
|
||||
if (subState.getName().equals(subStateName)) {
|
||||
target.addContent(subState);
|
||||
}
|
||||
else {
|
||||
for (Iterator<Element> iterator = subState.getChildren().iterator(); iterator.hasNext(); ) {
|
||||
Element configuration = iterator.next();
|
||||
iterator.remove();
|
||||
target.addContent(configuration);
|
||||
}
|
||||
for (Iterator<Attribute> iterator = subState.getAttributes().iterator(); iterator.hasNext(); ) {
|
||||
Attribute attribute = iterator.next();
|
||||
iterator.remove();
|
||||
target.setAttribute(attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-15
@@ -17,6 +17,7 @@ package com.intellij.openapi.components.impl.stores;
|
||||
|
||||
import com.intellij.application.options.PathMacrosCollector;
|
||||
import com.intellij.openapi.components.StateSplitter;
|
||||
import com.intellij.openapi.components.StateSplitterEx;
|
||||
import com.intellij.openapi.components.TrackingPathMacroSubstitutor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
@@ -243,24 +244,36 @@ public class DirectoryStorageData extends StorageDataBase {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Element getCompositeStateAndArchive(@NotNull String componentName, @NotNull StateSplitter splitter) {
|
||||
List<Element> subElements = new SmartList<Element>();
|
||||
public Element getCompositeStateAndArchive(@NotNull String componentName, @SuppressWarnings("deprecation") @NotNull StateSplitter splitter) {
|
||||
StateMap fileToState = myStates.get(componentName);
|
||||
if (fileToState != null) {
|
||||
for (String fileName : fileToState.keys()) {
|
||||
Element state = fileToState.getStateAndArchive(fileName);
|
||||
if (state == null) {
|
||||
subElements.clear();
|
||||
break;
|
||||
}
|
||||
|
||||
subElements.add(state);
|
||||
}
|
||||
Element state = new Element(StorageData.COMPONENT);
|
||||
if (fileToState == null || fileToState.isEmpty()) {
|
||||
return state;
|
||||
}
|
||||
|
||||
Element state = new Element(StorageData.COMPONENT);
|
||||
if (!subElements.isEmpty()) {
|
||||
splitter.mergeStatesInto(state, subElements.toArray(new Element[subElements.size()]));
|
||||
if (splitter instanceof StateSplitterEx) {
|
||||
StateSplitterEx splitterEx = (StateSplitterEx)splitter;
|
||||
for (String fileName : fileToState.keys()) {
|
||||
Element subState = fileToState.getStateAndArchive(fileName);
|
||||
if (subState == null) {
|
||||
return null;
|
||||
}
|
||||
splitterEx.mergeStateInto(state, subState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
List<Element> subElements = new SmartList<Element>();
|
||||
for (String fileName : fileToState.keys()) {
|
||||
Element subState = fileToState.getStateAndArchive(fileName);
|
||||
if (subState == null) {
|
||||
return null;
|
||||
}
|
||||
subElements.add(subState);
|
||||
}
|
||||
|
||||
if (!subElements.isEmpty()) {
|
||||
splitter.mergeStatesInto(state, subElements.toArray(new Element[subElements.size()]));
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
+5
-21
@@ -23,15 +23,13 @@ import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablePresentation;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author dsl
|
||||
* @author dsl
|
||||
*/
|
||||
@State(
|
||||
name = "libraryTable",
|
||||
@@ -77,24 +75,10 @@ public class ProjectLibraryTable extends LibraryTableBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class LibraryStateSplitter implements StateSplitter {
|
||||
public final static class LibraryStateSplitter extends StateSplitterEx {
|
||||
@Override
|
||||
public List<Pair<Element, String>> splitState(Element e) {
|
||||
final UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
|
||||
List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();
|
||||
for (Element library : e.getChildren()) {
|
||||
String name = generator.generateUniqueName(FileUtil.sanitizeFileName(library.getAttributeValue(LibraryImpl.LIBRARY_NAME_ATTR))) + ".xml";
|
||||
result.add(Pair.create(library, name));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeStatesInto(Element target, Element[] elements) {
|
||||
for (Element e : elements) {
|
||||
target.addContent(e);
|
||||
}
|
||||
public List<Pair<Element, String>> splitState(@NotNull Element state) {
|
||||
return splitState(state, LibraryImpl.LIBRARY_NAME_ATTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -19,6 +19,7 @@ import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.options.SettingsEditor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
@@ -31,9 +32,9 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author Roman Chernyatchik
|
||||
*/
|
||||
public class MockRuntimeConfiguration extends RuntimeConfiguration {
|
||||
public class MockRuntimeConfiguration extends LocatableConfigurationBase implements Cloneable, ModuleRunConfiguration {
|
||||
public MockRuntimeConfiguration(final Project project) {
|
||||
super("", project, new MockConfigurationFactory());
|
||||
super(project, new MockConfigurationFactory(), "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -57,6 +58,12 @@ public class MockRuntimeConfiguration extends RuntimeConfiguration {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Module[] getModules() {
|
||||
return Module.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
private static class MockConfigurationFactory extends ConfigurationFactory {
|
||||
public MockConfigurationFactory() {
|
||||
super(new MyConfigurationType());
|
||||
|
||||
+3
-1
@@ -172,7 +172,9 @@ public class SSBasedInspectionOptions {
|
||||
public void run(AnActionButton button) {
|
||||
performMoveUpDown(true);
|
||||
}
|
||||
}).createPanel()
|
||||
})
|
||||
.setPreferredSize(new Dimension(-1, 100))
|
||||
.createPanel()
|
||||
);
|
||||
new DoubleClickListener() {
|
||||
@Override
|
||||
|
||||
+1
-6
@@ -396,12 +396,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
|
||||
@Override
|
||||
public long checkHighlighting(final boolean checkWarnings, final boolean checkInfos, final boolean checkWeakWarnings) {
|
||||
try {
|
||||
return collectAndCheckHighlighting(checkWarnings, checkInfos, checkWeakWarnings);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return checkHighlighting(checkWarnings, checkInfos, checkWeakWarnings, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1053,21 +1053,40 @@ public class FileUtil extends FileUtilRt {
|
||||
*/
|
||||
@NotNull
|
||||
public static String sanitizeFileName(@NotNull String name) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < name.length(); i++) {
|
||||
final char ch = name.charAt(i);
|
||||
|
||||
if (ch > 0 && ch < 255) {
|
||||
if (Character.isLetterOrDigit(ch)) {
|
||||
result.append(ch);
|
||||
}
|
||||
else {
|
||||
result.append("_");
|
||||
StringBuilder result = null;
|
||||
int last = 0;
|
||||
int length = name.length();
|
||||
for (int i = 0; i < length; i++) {
|
||||
char c = name.charAt(i);
|
||||
boolean appendReplacement = true;
|
||||
if (c > 0 && c < 255) {
|
||||
if (Character.isLetterOrDigit(c) || c == '_') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
appendReplacement = false;
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
result = new StringBuilder();
|
||||
}
|
||||
if (last < i) {
|
||||
result.append(name, last, i);
|
||||
}
|
||||
if (appendReplacement) {
|
||||
result.append('_');
|
||||
}
|
||||
last = i + 1;
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
if (last < length) {
|
||||
result.append(name, last, length);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
@@ -32,6 +31,8 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.sameInstance;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class FileUtilLightTest {
|
||||
@@ -198,4 +199,18 @@ public class FileUtilLightTest {
|
||||
String expected = SystemInfo.isWindows ? "~\\relative" : "~/relative";
|
||||
assertEquals(expected, FileUtil.getLocationRelativeToUserHome(SystemProperties.getUserHome() + "/relative", false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sanitizeFileName() {
|
||||
String newS = "tmp";
|
||||
assertThat(FileUtil.sanitizeFileName(newS), sameInstance(newS));
|
||||
assertThat(FileUtil.sanitizeFileName("_test"), sameInstance("_test"));
|
||||
|
||||
assertThat(FileUtil.sanitizeFileName(" "), equalTo("_"));
|
||||
assertThat(FileUtil.sanitizeFileName("\u2026"), equalTo(""));
|
||||
assertThat(FileUtil.sanitizeFileName("q_test"), sameInstance("q_test"));
|
||||
assertThat(FileUtil.sanitizeFileName("12_"), sameInstance("12_"));
|
||||
assertThat(FileUtil.sanitizeFileName("12_ 123"), equalTo("12___123"));
|
||||
assertThat(FileUtil.sanitizeFileName(" 12\u2026123"), equalTo("_12123"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,10 @@ import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.packageDependencies.DependencyValidationManager;
|
||||
@@ -41,19 +43,20 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.PackageSet;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import com.maddyhome.idea.copyright.actions.UpdateCopyrightProcessor;
|
||||
import com.maddyhome.idea.copyright.options.LanguageOptions;
|
||||
import com.maddyhome.idea.copyright.options.Options;
|
||||
import com.maddyhome.idea.copyright.util.FileTypeUtil;
|
||||
import com.maddyhome.idea.copyright.util.NewFileTracker;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@State(name = "CopyrightManager",
|
||||
storages = {@Storage(file = StoragePathMacros.PROJECT_FILE),
|
||||
@@ -292,53 +295,28 @@ public class CopyrightManager extends AbstractProjectComponent implements Persis
|
||||
addCopyright(copyrightProfile);
|
||||
}
|
||||
|
||||
public static class CopyrightStateSplitter implements StateSplitter {
|
||||
static final class CopyrightStateSplitter extends MainConfigurationStateSplitter {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<Pair<Element, String>> splitState(Element e) {
|
||||
final UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
final List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();
|
||||
|
||||
final Element[] elements = JDOMUtil.getElements(e);
|
||||
for (Element element : elements) {
|
||||
if (element.getName().equals("copyright")) {
|
||||
element.detach();
|
||||
|
||||
String profileName = null;
|
||||
final Element[] options = JDOMUtil.getElements(element);
|
||||
for (Element option : options) {
|
||||
if (option.getName().equals("option") && option.getAttributeValue("name").equals("myName")) {
|
||||
profileName = option.getAttributeValue("value");
|
||||
}
|
||||
}
|
||||
|
||||
assert profileName != null;
|
||||
|
||||
final String name = generator.generateUniqueName(FileUtil.sanitizeFileName(profileName)) + ".xml";
|
||||
result.add(Pair.create(element, name));
|
||||
protected String getSubStateFileName(@NotNull Element element) {
|
||||
for (Element option : element.getChildren("option")) {
|
||||
if (option.getAttributeValue("name").equals("myName")) {
|
||||
return option.getAttributeValue("value");
|
||||
}
|
||||
}
|
||||
result.add(Pair.create(e, generator.generateUniqueName("profiles_settings") + ".xml"));
|
||||
return result;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void mergeStatesInto(Element target, Element[] elements) {
|
||||
for (Element element : elements) {
|
||||
if (element.getName().equals("copyright")) {
|
||||
element.detach();
|
||||
target.addContent(element);
|
||||
}
|
||||
else {
|
||||
final Element[] states = JDOMUtil.getElements(element);
|
||||
for (Element state : states) {
|
||||
state.detach();
|
||||
target.addContent(state);
|
||||
}
|
||||
for (Object attr : element.getAttributes()) {
|
||||
target.setAttribute(((Attribute)attr).clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
protected String getComponentStateFileName() {
|
||||
return "profiles_settings";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getSubStateTagName() {
|
||||
return "copyright";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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,35 +15,19 @@
|
||||
*/
|
||||
package com.intellij.spellchecker.state;
|
||||
|
||||
import com.intellij.openapi.components.StateSplitter;
|
||||
import com.intellij.openapi.components.StateSplitterEx;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
*
|
||||
* @author shkate@jetbrains.com
|
||||
*/
|
||||
public class ProjectDictionarySplitter implements StateSplitter {
|
||||
public class ProjectDictionarySplitter extends StateSplitterEx {
|
||||
@Override
|
||||
public List<Pair<Element, String>> splitState(Element e) {
|
||||
final UniqueNameGenerator generator = new UniqueNameGenerator();
|
||||
List<Pair<Element, String>> result = new ArrayList<Pair<Element, String>>();
|
||||
for (Element element : e.getChildren()) {
|
||||
result.add(Pair.create(element, generator.generateUniqueName(FileUtil.sanitizeFileName(element.getAttributeValue(DictionaryState.NAME_ATTRIBUTE))) + ".xml"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mergeStatesInto(Element target, Element[] elements) {
|
||||
for (Element e : elements) {
|
||||
target.addContent(e);
|
||||
}
|
||||
public List<Pair<Element, String>> splitState(@NotNull Element state) {
|
||||
return splitState(state, DictionaryState.NAME_ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user