mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 15:15:45 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -114,10 +114,8 @@ public class DefaultDebugUIEnvironment implements DebugUIEnvironment {
|
||||
|
||||
@Override
|
||||
public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) {
|
||||
ProcessHandler processHandler = content.getProcessHandler();
|
||||
RestartAction restartAction = new RestartAction(myExecutor,
|
||||
myRunner,
|
||||
processHandler,
|
||||
content,
|
||||
myExecutionEnvironment);
|
||||
actionGroup.add(restartAction, Constraints.FIRST);
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
package com.intellij.index;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.PsiTestUtil;
|
||||
import com.intellij.util.indexing.MapIndexStorage;
|
||||
import com.intellij.util.indexing.StorageException;
|
||||
import com.intellij.util.io.*;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Dec 12, 2007
|
||||
*/
|
||||
public class IndexTest extends IdeaTestCase {
|
||||
|
||||
public void testUpdate() throws StorageException, IOException {
|
||||
final File storageFile = FileUtil.createTempFile("indextest", "storage");
|
||||
final File metaIndexFile = FileUtil.createTempFile("indextest_inputs", "storage");
|
||||
final MapIndexStorage indexStorage = new MapIndexStorage(storageFile, new EnumeratorStringDescriptor(), new EnumeratorStringDescriptor(), 16 * 1024);
|
||||
final StringIndex index = new StringIndex(indexStorage, new Factory<PersistentHashMap<Integer, Collection<String>>>() {
|
||||
@Override
|
||||
public PersistentHashMap<Integer, Collection<String>> create() {
|
||||
try {
|
||||
return createMetaIndex(metaIndexFile);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
// build index
|
||||
index.update("com/ppp/a.java", "a b c d", null);
|
||||
index.update("com/ppp/b.java", "a b g h", null);
|
||||
index.update("com/ppp/c.java", "a z f", null);
|
||||
index.update("com/ppp/d.java", "a a u y z", null);
|
||||
index.update("com/ppp/e.java", "a n chj e c d", null);
|
||||
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("b"), "com/ppp/a.java", "com/ppp/b.java");
|
||||
assertDataEquals(index.getFilesByWord("c"), "com/ppp/a.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("d"), "com/ppp/a.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("g"), "com/ppp/b.java");
|
||||
assertDataEquals(index.getFilesByWord("h"), "com/ppp/b.java");
|
||||
assertDataEquals(index.getFilesByWord("z"), "com/ppp/c.java", "com/ppp/d.java");
|
||||
assertDataEquals(index.getFilesByWord("f"), "com/ppp/c.java");
|
||||
assertDataEquals(index.getFilesByWord("u"), "com/ppp/d.java");
|
||||
assertDataEquals(index.getFilesByWord("y"), "com/ppp/d.java");
|
||||
assertDataEquals(index.getFilesByWord("n"), "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("chj"), "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("e"), "com/ppp/e.java");
|
||||
|
||||
// update index
|
||||
|
||||
index.update("com/ppp/d.java", "a u y z", "a a u y z");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
index.update("com/ppp/d.java", "u y z", "a u y z");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/e.java");
|
||||
index.update("com/ppp/d.java", "a a a u y z", "u y z");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/b.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
|
||||
index.update("com/ppp/e.java", "a n chj e c d z", "a n chj e c d");
|
||||
assertDataEquals(index.getFilesByWord("z"), "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
|
||||
index.update("com/ppp/b.java", null, "a b g h");
|
||||
assertDataEquals(index.getFilesByWord("a"), "com/ppp/a.java", "com/ppp/c.java", "com/ppp/d.java", "com/ppp/e.java");
|
||||
assertDataEquals(index.getFilesByWord("b"), "com/ppp/a.java");
|
||||
assertDataEquals(index.getFilesByWord("g"));
|
||||
assertDataEquals(index.getFilesByWord("h"));
|
||||
}
|
||||
finally {
|
||||
indexStorage.close();
|
||||
FileUtil.delete(storageFile);
|
||||
}
|
||||
}
|
||||
|
||||
private PersistentHashMap<Integer, Collection<String>> createMetaIndex(File metaIndexFile) throws IOException {
|
||||
return new PersistentHashMap<Integer, Collection<String>>(metaIndexFile, new EnumeratorIntegerDescriptor(), new DataExternalizer<Collection<String>>() {
|
||||
@Override
|
||||
public void save(DataOutput out, Collection<String> value) throws IOException {
|
||||
DataInputOutputUtil.writeINT(out, value.size());
|
||||
for (String key : value) {
|
||||
out.writeUTF(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> read(DataInput in) throws IOException {
|
||||
final int size = DataInputOutputUtil.readINT(in);
|
||||
final List<String> list = new ArrayList<String>();
|
||||
for (int idx = 0; idx < size; idx++) {
|
||||
list.add(in.readUTF());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
public void testStubIndexUnsavedDocumentsIndexing() throws IncorrectOperationException, IOException, StorageException {
|
||||
IdeaTestUtil.registerExtension(StubIndexExtension.EP_NAME, new TextStubIndexExtension(), getTestRootDisposable());
|
||||
IdeaTestUtil.registerExtension(StubIndexExtension.EP_NAME, new ClassNameStubIndexExtension(), getTestRootDisposable());
|
||||
FileTypeManager.getInstance().registerFileType(TestFileType.INSTANCE, "fff");
|
||||
final FFFLangParserDefinition parserDefinition = new FFFLangParserDefinition();
|
||||
LanguageParserDefinitions.INSTANCE.addExplicitExtension(FFFLanguage.INSTANCE, parserDefinition);
|
||||
|
||||
final TestStubElementType stubType = new TestStubElementType();
|
||||
SerializationManager.getInstance().registerSerializer(TestStubElement.class, stubType);
|
||||
|
||||
final File fffFile = new File(FileUtil.createTempDirectory("testing", "stubindex"), "MyClass.fff");
|
||||
fffFile.createNewFile();
|
||||
|
||||
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(fffFile);
|
||||
|
||||
assertNotNull(vFile);
|
||||
assertEquals(TestFileType.INSTANCE, vFile.getFileType());
|
||||
|
||||
try {
|
||||
final MockPsiFile psiFile = new MockPsiFile(vFile, MockPsiManager.getInstance(myProject));
|
||||
|
||||
final MockPsiClass cls = new MockPsiClass("com.company.MyClass");
|
||||
psiFile.add(cls);
|
||||
|
||||
final MockPsiMethod aaaMethod = new MockPsiMethod("aaa");
|
||||
cls.addMethod(aaaMethod);
|
||||
final MockPsiMethod bbbMethod = new MockPsiMethod("bbb");
|
||||
cls.addMethod(bbbMethod);
|
||||
|
||||
final PsiFileStubImpl fileStub = new PsiFileStubImpl(psiFile);
|
||||
final TestStubElement clsStub = stubType.createStub(cls, fileStub);
|
||||
stubType.createStub(aaaMethod, clsStub);
|
||||
stubType.createStub(bbbMethod, clsStub);
|
||||
|
||||
final ByteArrayOutputStream arrayStream = new ByteArrayOutputStream();
|
||||
SerializationManager.getInstance().serialize(fileStub, new DataOutputStream(arrayStream));
|
||||
|
||||
final FileBasedIndex fbi = FileBasedIndex.getInstance();
|
||||
final UpdatableIndex<Integer, SerializedStubTree, FileContent> stubUpdatingIndex = fbi.getIndex(StubUpdatingIndex.INDEX_ID);
|
||||
final MemoryIndexStorage storage = (MemoryIndexStorage)((MapReduceIndex)stubUpdatingIndex).getStorage();
|
||||
|
||||
// initial
|
||||
final int fileId = FileBasedIndex.getFileId(vFile);
|
||||
final byte[] bytes = arrayStream.toByteArray();
|
||||
stubUpdatingIndex.update(fileId, new FileContent(vFile, bytes), null);
|
||||
|
||||
final ValueContainer<SerializedStubTree> data = stubUpdatingIndex.getData(fileId);
|
||||
final List<SerializedStubTree> trees = data.toValueList();
|
||||
|
||||
final SerializedStubTree tree = assertOneElement(trees);
|
||||
|
||||
assertTrue(Comparing.equal(bytes, tree.getBytes()));
|
||||
|
||||
final StubElement deserialized = tree.getStub();
|
||||
}
|
||||
finally {
|
||||
LanguageParserDefinitions.INSTANCE.removeExplicitExtension(FFFLanguage.INSTANCE, parserDefinition);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
private static <T> void assertDataEquals(List<T> actual, T... expected) {
|
||||
assertTrue(new HashSet<T>(Arrays.asList(expected)).equals(new HashSet<T>(actual)));
|
||||
}
|
||||
|
||||
public void _testCollectedPsiWithChangedDocument() throws IOException {
|
||||
VirtualFile dir = getVirtualFile(createTempDirectory());
|
||||
PsiTestUtil.addSourceContentToRoots(myModule, dir);
|
||||
|
||||
final VirtualFile vFile = createChildData(dir, "Foo.java");
|
||||
VfsUtil.saveText(vFile, "class Foo {}");
|
||||
|
||||
final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
|
||||
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
|
||||
assertNotNull(facade.findClass("Foo", scope));
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PsiFile psiFile = PsiManager.getInstance(getProject()).findFile(vFile);
|
||||
assertNotNull(psiFile);
|
||||
|
||||
Document document = FileDocumentManager.getInstance().getDocument(vFile);
|
||||
document.deleteString(0, document.getTextLength());
|
||||
assertNotNull(facade.findClass("Foo", scope));
|
||||
|
||||
psiFile = null;
|
||||
PlatformTestUtil.tryGcSoftlyReachableObjects();
|
||||
assertNull(((PsiManagerEx)PsiManager.getInstance(getProject())).getFileManager().getCachedPsiFile(vFile));
|
||||
|
||||
// should be assertNull(facade.findClass("Foo", scope));
|
||||
// or the file should not be allowed to be gc'ed
|
||||
facade.findClass("Foo", scope).getText();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.intellij.index;
|
||||
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.util.indexing.DataIndexer;
|
||||
import com.intellij.util.indexing.IndexStorage;
|
||||
import com.intellij.util.indexing.MapReduceIndex;
|
||||
import com.intellij.util.indexing.StorageException;
|
||||
import com.intellij.util.io.PersistentHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: Dec 12, 2007
|
||||
*/
|
||||
public class StringIndex {
|
||||
private final MapReduceIndex<String, String, PathContentPair> myIndex;
|
||||
|
||||
public StringIndex(final IndexStorage<String, String> storage, final Factory<PersistentHashMap<Integer, Collection<String>>> factory)
|
||||
throws IOException {
|
||||
myIndex = new MapReduceIndex<String, String, PathContentPair>(null, new Indexer(), storage);
|
||||
myIndex.setInputIdToDataKeysIndex(factory);
|
||||
}
|
||||
|
||||
public List<String> getFilesByWord(String word) throws StorageException {
|
||||
return myIndex.getData(word).toValueList();
|
||||
}
|
||||
|
||||
public void update(final String path, @Nullable String content, @Nullable String oldContent) throws StorageException {
|
||||
myIndex.update(path.hashCode(), toInput(path, content));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PathContentPair toInput(@NotNull String path, @Nullable String content) {
|
||||
return content != null ? new PathContentPair(path, content) : null;
|
||||
}
|
||||
|
||||
private static class Indexer implements DataIndexer<String, String, PathContentPair> {
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String,String> map(final PathContentPair inputData) {
|
||||
final Map<String,String> _map = new HashMap<String, String>();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final String content = inputData.content;
|
||||
for (int idx = 0; idx < content.length(); idx++) {
|
||||
final char ch = content.charAt(idx);
|
||||
if (Character.isWhitespace(ch)) {
|
||||
if (builder.length() > 0) {
|
||||
_map.put(builder.toString(), inputData.path);
|
||||
builder.setLength(0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
builder.append(ch);
|
||||
}
|
||||
}
|
||||
// emit the last word
|
||||
if (builder.length() > 0) {
|
||||
_map.put(builder.toString(), inputData.path);
|
||||
builder.setLength(0);
|
||||
}
|
||||
return _map;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class PathContentPair {
|
||||
final String path;
|
||||
final String content;
|
||||
|
||||
public PathContentPair(final String path, final String content) {
|
||||
this.path = path;
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@ package com.intellij.ide;
|
||||
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -29,31 +28,19 @@ import java.util.List;
|
||||
public class Bootstrap {
|
||||
private static final String PLUGIN_MANAGER = "com.intellij.ide.plugins.PluginManager";
|
||||
|
||||
private Bootstrap() {}
|
||||
private Bootstrap() { }
|
||||
|
||||
public static void main(final String[] args, final String mainClass, final String methodName) {
|
||||
public static void main(String[] args, String mainClass, String methodName) throws Exception {
|
||||
main(args, mainClass, methodName, new ArrayList<URL>());
|
||||
}
|
||||
|
||||
public static void main(final String[] args, final String mainClass, final String methodName, final List<URL> classpathElements) {
|
||||
final UrlClassLoader newClassLoader = ClassloaderUtil.initClassloader(classpathElements);
|
||||
try {
|
||||
WindowsCommandLineProcessor.ourMirrorClass = Class.forName(WindowsCommandLineProcessor.class.getName(), true, newClassLoader);
|
||||
public static void main(String[] args, String mainClass, String methodName, List<URL> classpathElements) throws Exception {
|
||||
UrlClassLoader newClassLoader = ClassloaderUtil.initClassloader(classpathElements);
|
||||
WindowsCommandLineProcessor.ourMirrorClass = Class.forName(WindowsCommandLineProcessor.class.getName(), true, newClassLoader);
|
||||
|
||||
final Class<?> klass = Class.forName(PLUGIN_MANAGER, true, newClassLoader);
|
||||
|
||||
final Method startMethod = klass.getDeclaredMethod("start", String.class, String.class, String[].class);
|
||||
startMethod.setAccessible(true);
|
||||
startMethod.invoke(null, mainClass, methodName, args);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if ("true".equals(System.getProperty("java.awt.headless"))) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(null, e.getClass().getName() + ": " + e.getMessage(), "Error starting IntelliJ Platform", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
Class<?> klass = Class.forName(PLUGIN_MANAGER, true, newClassLoader);
|
||||
Method startMethod = klass.getDeclaredMethod("start", String.class, String.class, String[].class);
|
||||
startMethod.setAccessible(true);
|
||||
startMethod.invoke(null, mainClass, methodName, args);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,7 +30,6 @@ import com.intellij.util.lang.UrlClassLoader;
|
||||
import com.intellij.util.text.StringTokenizer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -44,76 +43,33 @@ import java.util.regex.Pattern;
|
||||
public class ClassloaderUtil extends ClassUtilCore {
|
||||
@NonNls public static final String PROPERTY_IGNORE_CLASSPATH = "ignore.classpath";
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
private static final String ERROR = "Error";
|
||||
|
||||
private ClassloaderUtil() {}
|
||||
|
||||
public static Logger getLogger() {
|
||||
return Logger.getInstance("ClassloaderUtil");
|
||||
}
|
||||
|
||||
public static UrlClassLoader initClassloader(final List<URL> classpathElements) {
|
||||
public static UrlClassLoader initClassloader(final List<URL> classpathElements) throws Exception {
|
||||
PathManager.loadProperties();
|
||||
|
||||
try {
|
||||
addParentClasspath(classpathElements);
|
||||
addIDEALibraries(classpathElements);
|
||||
addAdditionalClassPath(classpathElements);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
if (Main.isHeadless()) {
|
||||
getLogger().error(e);
|
||||
} else {
|
||||
JOptionPane
|
||||
.showMessageDialog(JOptionPane.getRootFrame(), e.getMessage(), ERROR, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
if (Main.isHeadless()) {
|
||||
getLogger().error(e.getMessage());
|
||||
} else {
|
||||
JOptionPane
|
||||
.showMessageDialog(JOptionPane.getRootFrame(), e.getMessage(), ERROR, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
System.exit(1);
|
||||
}
|
||||
addParentClasspath(classpathElements);
|
||||
addIDEALibraries(classpathElements);
|
||||
addAdditionalClassPath(classpathElements);
|
||||
|
||||
filterClassPath(classpathElements);
|
||||
UrlClassLoader newClassLoader = new UrlClassLoader(classpathElements, null, true, true);
|
||||
|
||||
UrlClassLoader newClassLoader = null;
|
||||
try {
|
||||
newClassLoader = new UrlClassLoader(classpathElements, null, true, true);
|
||||
|
||||
// prepare plugins
|
||||
if (!isLoadingOfExternalPluginsDisabled()) {
|
||||
try {
|
||||
StartupActionScriptManager.executeActionScript();
|
||||
}
|
||||
catch (IOException e) {
|
||||
final String errorMessage = "Error executing plugin installation script: " + e.getMessage();
|
||||
if (Main.isHeadless()) {
|
||||
System.out.println(errorMessage);
|
||||
} else {
|
||||
JOptionPane
|
||||
.showMessageDialog(JOptionPane.getRootFrame(), errorMessage, ERROR, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
// prepare plugins
|
||||
if (!isLoadingOfExternalPluginsDisabled()) {
|
||||
try {
|
||||
StartupActionScriptManager.executeActionScript();
|
||||
}
|
||||
|
||||
Thread.currentThread().setContextClassLoader(newClassLoader);
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
Logger logger = getLogger();
|
||||
if (logger == null) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
else {
|
||||
logger.error(e);
|
||||
catch (IOException e) {
|
||||
Main.showMessage("Plugin Installation Error", e);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.currentThread().setContextClassLoader(newClassLoader);
|
||||
return newClassLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.idea;
|
||||
|
||||
import com.intellij.ide.Bootstrap;
|
||||
@@ -21,102 +20,99 @@ import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.Restarter;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "MethodNamesDifferingOnlyByCase"})
|
||||
public class Main {
|
||||
public static final int UPDATE_FAILED = 1;
|
||||
public static final int STARTUP_EXCEPTION = 2;
|
||||
public static final int STARTUP_IMPOSSIBLE = 3;
|
||||
public static final int LICENSE_ERROR = 4;
|
||||
public static final int PLUGIN_ERROR = 5;
|
||||
|
||||
private static boolean isHeadless;
|
||||
private static boolean isCommandLine;
|
||||
|
||||
private Main() {
|
||||
}
|
||||
private Main() { }
|
||||
|
||||
@SuppressWarnings("MethodNamesDifferingOnlyByCase")
|
||||
public static void main(final String[] args) {
|
||||
isHeadless = isHeadless(args);
|
||||
if (isHeadless) {
|
||||
setFlags(args);
|
||||
|
||||
if (isHeadless()) {
|
||||
System.setProperty("java.awt.headless", Boolean.TRUE.toString());
|
||||
}
|
||||
else if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException("Unable to detect graphics environment");
|
||||
}
|
||||
else {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
throw new HeadlessException("Unable to detect graphics environment");
|
||||
}
|
||||
|
||||
if (!isHeadless) {
|
||||
try {
|
||||
installPatch();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
File log = null;
|
||||
try {
|
||||
log = FileUtilRt.createTempFile("patch", ".log", false);
|
||||
PrintWriter writer = new PrintWriter(log);
|
||||
try {
|
||||
e.printStackTrace(writer);
|
||||
}
|
||||
finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
}
|
||||
String message = e.getMessage()
|
||||
+ "\n" + (log == null ? "Log cannot be saved" : "Log is saved in " + log)
|
||||
+ "\n\nPlease download and install update manually" ;
|
||||
JOptionPane.showMessageDialog(null, message, "Cannot Apply Patch", JOptionPane.ERROR_MESSAGE);
|
||||
catch (Throwable t) {
|
||||
showMessage("Update Failed", t);
|
||||
System.exit(UPDATE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
Bootstrap.main(args, Main.class.getName() + "Impl", "start");
|
||||
}
|
||||
|
||||
public static boolean isHeadless(final String[] args) {
|
||||
final Boolean forceEnabledHeadlessMode = Boolean.valueOf(System.getProperty("java.awt.headless"));
|
||||
|
||||
@NonNls final String antAppCode = "ant";
|
||||
@NonNls final String duplocateCode = "duplocate";
|
||||
@NonNls final String traverseUI = "traverseUI";
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
try {
|
||||
Bootstrap.main(args, Main.class.getName() + "Impl", "start");
|
||||
}
|
||||
catch (Throwable t) {
|
||||
showMessage("Start Failed", t);
|
||||
System.exit(STARTUP_EXCEPTION);
|
||||
}
|
||||
final String firstArg = args[0];
|
||||
return forceEnabledHeadlessMode ||
|
||||
Comparing.strEqual(firstArg, antAppCode) ||
|
||||
Comparing.strEqual(firstArg, duplocateCode) ||
|
||||
Comparing.strEqual(firstArg, traverseUI) ||
|
||||
(firstArg.length() < 20 && firstArg.endsWith("inspect"));
|
||||
}
|
||||
|
||||
public static boolean isUITraverser(final String[] args) {
|
||||
return args.length > 0 && Comparing.strEqual(args[0], "traverseUI");
|
||||
}
|
||||
|
||||
public static boolean isCommandLine(final String[] args) {
|
||||
if (isHeadless(args)) return true;
|
||||
@NonNls final String diffAppCode = "diff";
|
||||
return args.length > 0 && Comparing.strEqual(args[0], diffAppCode);
|
||||
}
|
||||
|
||||
public static boolean isHeadless() {
|
||||
return isHeadless;
|
||||
}
|
||||
|
||||
public static boolean isCommandLine() {
|
||||
return isCommandLine;
|
||||
}
|
||||
|
||||
public static void setFlags(String[] args) {
|
||||
isHeadless = isHeadless(args);
|
||||
isCommandLine = isCommandLine(args);
|
||||
}
|
||||
|
||||
private static boolean isHeadless(String[] args) {
|
||||
if (GraphicsEnvironment.isHeadless()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String firstArg = args[0];
|
||||
return Comparing.strEqual(firstArg, "ant") ||
|
||||
Comparing.strEqual(firstArg, "duplocate") ||
|
||||
Comparing.strEqual(firstArg, "traverseUI") ||
|
||||
(firstArg.length() < 20 && firstArg.endsWith("inspect"));
|
||||
}
|
||||
|
||||
private static boolean isCommandLine(String[] args) {
|
||||
if (isHeadless()) return true;
|
||||
return args.length > 0 && Comparing.strEqual(args[0], "diff");
|
||||
}
|
||||
|
||||
public static boolean isUITraverser(final String[] args) {
|
||||
return args.length > 0 && Comparing.strEqual(args[0], "traverseUI");
|
||||
}
|
||||
|
||||
private static void installPatch() throws IOException {
|
||||
String platform = System.getProperty("idea.platform.prefix", "idea");
|
||||
String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase();
|
||||
@@ -124,28 +120,67 @@ public class Main {
|
||||
File copyPatchFile = new File(System.getProperty("java.io.tmpdir"), patchFileName + "_copy");
|
||||
|
||||
// always delete previous patch copy
|
||||
if (!FileUtilRt.delete(copyPatchFile)) throw new IOException("Cannot create temporary patch file");
|
||||
if (!FileUtilRt.delete(copyPatchFile)) {
|
||||
throw new IOException("Cannot create temporary patch file");
|
||||
}
|
||||
|
||||
if (!originalPatchFile.exists()) return;
|
||||
if (!originalPatchFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!originalPatchFile.renameTo(copyPatchFile) || !FileUtilRt.delete(originalPatchFile)) {
|
||||
throw new IOException("Cannot create temporary patch file");
|
||||
}
|
||||
|
||||
List<String> args = new ArrayList<String>();
|
||||
if (SystemInfo.isWindows) {
|
||||
args.add(Restarter.createTempExecutable(new File(PathManager.getBinPath(), "vistalauncher.exe")).getPath());
|
||||
int status = 0;
|
||||
if (Restarter.isSupported()) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
File launcher = new File(PathManager.getBinPath(), "VistaLauncher.exe");
|
||||
args.add(Restarter.createTempExecutable(launcher).getPath());
|
||||
}
|
||||
|
||||
Collections.addAll(args,
|
||||
System.getProperty("java.home") + "/bin/java",
|
||||
"-Xmx500m",
|
||||
"-classpath",
|
||||
copyPatchFile.getPath(),
|
||||
"com.intellij.updater.Runner",
|
||||
"install",
|
||||
PathManager.getHomePath());
|
||||
|
||||
status = Restarter.scheduleRestart(ArrayUtilRt.toStringArray(args));
|
||||
}
|
||||
else {
|
||||
String message = "Patch update is not supported - please do it manually";
|
||||
showMessage("Update Error", message, true);
|
||||
}
|
||||
|
||||
Collections.addAll(args,
|
||||
System.getProperty("java.home") + "/bin/java",
|
||||
"-Xmx500m",
|
||||
"-classpath",
|
||||
copyPatchFile.getPath(),
|
||||
"com.intellij.updater.Runner",
|
||||
"install",
|
||||
PathManager.getHomePath());
|
||||
System.exit(status);
|
||||
}
|
||||
|
||||
System.exit(Restarter.scheduleRestart(args.toArray(new String[args.size()])));
|
||||
public static void showMessage(String title, Throwable t) {
|
||||
String message = "Internal exception, please report to http://youtrack.jetbrains.com\n\n" + ExceptionUtil.getThrowableText(t);
|
||||
showMessage(title, message, true);
|
||||
}
|
||||
|
||||
public static void showMessage(String title, String message, boolean error) {
|
||||
if (isCommandLine()) {
|
||||
PrintStream stream = error ? System.err : System.out;
|
||||
stream.println(title + ": " + message);
|
||||
}
|
||||
else {
|
||||
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
|
||||
catch (Throwable ignore) { }
|
||||
|
||||
JTextPane textPane = new JTextPane();
|
||||
textPane.setEditable(false);
|
||||
textPane.setText(message.replaceAll("\t", " "));
|
||||
textPane.setBackground(UIManager.getColor("Panel.background"));
|
||||
|
||||
int type = error ? JOptionPane.ERROR_MESSAGE : JOptionPane.INFORMATION_MESSAGE;
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), textPane, title, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,11 +19,8 @@ import com.intellij.openapi.extensions.PluginId;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: stathik
|
||||
* Date: Jan 8, 2004
|
||||
* Time: 3:06:43 PM
|
||||
* To change this template use Options | File Templates.
|
||||
* @author stathik
|
||||
* @since Jan 8, 2004
|
||||
*/
|
||||
public class PluginException extends RuntimeException {
|
||||
private final PluginId myPluginId;
|
||||
|
||||
+72
-111
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -105,21 +105,10 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
try {
|
||||
myComponentsRegistry.loadClasses();
|
||||
|
||||
final Class[] componentInterfaces = myComponentsRegistry.getComponentInterfaces();
|
||||
Class[] componentInterfaces = myComponentsRegistry.getComponentInterfaces();
|
||||
for (Class componentInterface : componentInterfaces) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
try {
|
||||
createComponent(componentInterface);
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch(Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
createComponent(componentInterface);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
@@ -209,35 +198,12 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
return null;
|
||||
}
|
||||
|
||||
private void initComponent(Object component) {
|
||||
final ProgressIndicator indicator = getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
|
||||
try {
|
||||
initializeComponent(component, false);
|
||||
if (component instanceof BaseComponent) {
|
||||
((BaseComponent)component).initComponent();
|
||||
}
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
handleInitComponentError(ex, false, component.getClass().getName(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected static ProgressIndicator getProgressIndicator() {
|
||||
return ProgressIndicatorProvider.getGlobalProgressIndicator();
|
||||
}
|
||||
|
||||
protected double getPercentageOfComponentsLoaded() {
|
||||
protected float getPercentageOfComponentsLoaded() {
|
||||
return myComponentsRegistry.getPercentageOfComponentsLoaded();
|
||||
}
|
||||
|
||||
@@ -245,8 +211,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
public void initializeComponent(Object component, boolean service) {
|
||||
}
|
||||
|
||||
|
||||
protected void handleInitComponentError(final Throwable ex, final boolean fatal, final String componentClassName, ComponentConfig config) {
|
||||
protected void handleInitComponentError(Throwable ex, String componentClassName, ComponentConfig config) {
|
||||
LOG.error(ex);
|
||||
}
|
||||
|
||||
@@ -358,7 +323,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
getComponents();
|
||||
}
|
||||
|
||||
protected void loadComponentsConfiguration(ComponentConfig[] components, @Nullable final PluginDescriptor descriptor, final boolean defaultProject) {
|
||||
protected void loadComponentsConfiguration(ComponentConfig[] components, @Nullable PluginDescriptor descriptor, boolean defaultProject) {
|
||||
myConfigurator.loadComponentsConfiguration(components, descriptor, defaultProject);
|
||||
}
|
||||
|
||||
@@ -426,7 +391,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
protected class ComponentsRegistry {
|
||||
private final Map<Class, Object> myInterfaceToLockMap = new THashMap<Class, Object>();
|
||||
private final Map<Class, Class> myInterfaceToClassMap = new THashMap<Class, Class>();
|
||||
private final ArrayList<Class> myComponentInterfaces = new ArrayList<Class>(); // keeps order of component's registration
|
||||
private final List<Class> myComponentInterfaces = new ArrayList<Class>(); // keeps order of component's registration
|
||||
private final Map<String, BaseComponent> myNameToComponent = new THashMap<String, BaseComponent>();
|
||||
private final List<ComponentConfig> myComponentConfigs = new ArrayList<ComponentConfig>();
|
||||
private final List<Object> myImplementations = new ArrayList<Object>();
|
||||
@@ -452,7 +417,7 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
interfaceClass : Class.forName(config.getImplementationClass(), true, loader);
|
||||
|
||||
if (myInterfaceToClassMap.get(interfaceClass) != null) {
|
||||
throw new ComponentAlreadyRegisteredException(interfaceClass);
|
||||
throw new RuntimeException("Component already registered: " + interfaceClass.getName());
|
||||
}
|
||||
|
||||
getPicoContainer().registerComponent(new ComponentConfigComponentAdapter(config, implementationClass));
|
||||
@@ -460,17 +425,8 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
myComponentClassToConfig.put(implementationClass, config);
|
||||
myComponentInterfaces.add(interfaceClass);
|
||||
}
|
||||
catch (ComponentAlreadyRegisteredException ex) {
|
||||
throw new Error(ex);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
handleInitComponentError(e, false, null, config);
|
||||
}
|
||||
}
|
||||
|
||||
private class ComponentAlreadyRegisteredException extends Exception {
|
||||
private ComponentAlreadyRegisteredException(Class interfaceClass) {
|
||||
super(interfaceClass.getName() + " component already registered");
|
||||
catch (Throwable t) {
|
||||
handleInitComponentError(t, null, config);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,8 +448,8 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
return myInterfaceToClassMap.containsKey(interfaceClass);
|
||||
}
|
||||
|
||||
public double getPercentageOfComponentsLoaded() {
|
||||
return ((double)myImplementations.size()) / myComponentConfigs.size();
|
||||
public float getPercentageOfComponentsLoaded() {
|
||||
return ((float)myImplementations.size()) / myComponentConfigs.size();
|
||||
}
|
||||
|
||||
private void registerComponentInstance(final Object component) {
|
||||
@@ -565,57 +521,66 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
|
||||
public ComponentConfigComponentAdapter(final ComponentConfig config, Class<?> implementationClass) {
|
||||
myConfig = config;
|
||||
|
||||
final String componentKey = config.getInterfaceClass();
|
||||
myDelegate = new CachingComponentAdapter(new ConstructorInjectionComponentAdapter(componentKey, implementationClass, null, true)) {
|
||||
@Override
|
||||
public Object getComponentInstance(PicoContainer picoContainer) throws PicoInitializationException, PicoIntrospectionException {
|
||||
Object componentInstance = null;
|
||||
try {
|
||||
long startTime = myInitialized ? 0 : System.nanoTime();
|
||||
componentInstance = super.getComponentInstance(picoContainer);
|
||||
|
||||
if (!myInitialized) {
|
||||
if (myInitializing) {
|
||||
if (myConfig.pluginDescriptor != null) {
|
||||
LOG.error(new PluginException("Cyclic component initialization: " + componentKey, myConfig.pluginDescriptor.getPluginId()));
|
||||
}
|
||||
else {
|
||||
LOG.error(new Throwable("Cyclic component initialization: " + componentKey));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
myInitializing = true;
|
||||
myComponentsRegistry.registerComponentInstance(componentInstance);
|
||||
initComponent(componentInstance);
|
||||
long endTime = System.nanoTime();
|
||||
long ms = (endTime - startTime) / 1000000;
|
||||
if (ms > 10) {
|
||||
if (logSlowComponents()) {
|
||||
LOG.info(componentInstance.getClass().getName() + " initialized in " + ms + " ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myInitializing = false;
|
||||
}
|
||||
|
||||
myInitialized = true;
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
handleInitComponentError(t, componentInstance == null, componentKey, config);
|
||||
}
|
||||
return componentInstance;
|
||||
@Override
|
||||
public Object getComponentInstance(PicoContainer picoContainer) throws PicoInitializationException, PicoIntrospectionException {
|
||||
ProgressIndicator indicator = getProgressIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
};
|
||||
|
||||
Object componentInstance = null;
|
||||
try {
|
||||
long startTime = myInitialized ? 0 : System.nanoTime();
|
||||
|
||||
componentInstance = super.getComponentInstance(picoContainer);
|
||||
|
||||
if (!myInitialized) {
|
||||
if (myInitializing) {
|
||||
if (myConfig.pluginDescriptor != null) {
|
||||
LOG.error(new PluginException("Cyclic component initialization: " + componentKey, myConfig.pluginDescriptor.getPluginId()));
|
||||
}
|
||||
else {
|
||||
LOG.error(new Throwable("Cyclic component initialization: " + componentKey));
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
myInitializing = true;
|
||||
myComponentsRegistry.registerComponentInstance(componentInstance);
|
||||
|
||||
initializeComponent(componentInstance, false);
|
||||
if (componentInstance instanceof BaseComponent) {
|
||||
((BaseComponent)componentInstance).initComponent();
|
||||
}
|
||||
|
||||
long ms = (System.nanoTime() - startTime) / 1000000;
|
||||
if (ms > 10 && logSlowComponents()) {
|
||||
LOG.info(componentInstance.getClass().getName() + " initialized in " + ms + " ms");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
myInitializing = false;
|
||||
}
|
||||
|
||||
myInitialized = true;
|
||||
}
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
handleInitComponentError(t, componentKey, config);
|
||||
}
|
||||
|
||||
return componentInstance;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -625,27 +590,23 @@ public abstract class ComponentManagerImpl extends UserDataHolderBase implements
|
||||
|
||||
@Override
|
||||
public Class getComponentImplementation() {
|
||||
return getDelegate().getComponentImplementation();
|
||||
return myDelegate.getComponentImplementation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getComponentInstance(final PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
|
||||
return getDelegate().getComponentInstance(container);
|
||||
return myDelegate.getComponentInstance(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(final PicoContainer container) throws PicoIntrospectionException {
|
||||
getDelegate().verify(container);
|
||||
myDelegate.verify(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(final PicoVisitor visitor) {
|
||||
visitor.visitComponentAdapter(this);
|
||||
getDelegate().accept(visitor);
|
||||
}
|
||||
|
||||
private ComponentAdapter getDelegate() {
|
||||
return myDelegate;
|
||||
myDelegate.accept(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-16
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -183,9 +183,9 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
result = myExtensionsCache;
|
||||
if (result == null) {
|
||||
processAdapters();
|
||||
final Class<T> extensionClass = getExtensionClass();
|
||||
//noinspection unchecked
|
||||
result = myExtensions.toArray((T[])Array.newInstance(extensionClass, myExtensions.size()));
|
||||
Class<T> extensionClass = getExtensionClass();
|
||||
@SuppressWarnings("unchecked") T[] a = (T[])Array.newInstance(extensionClass, myExtensions.size());
|
||||
result = myExtensions.toArray(a);
|
||||
|
||||
for (int i = result.length - 1; i >= 0; i--) {
|
||||
T t = result[i];
|
||||
@@ -237,8 +237,7 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
ExtensionComponentAdapter[] adapters = allAdapters.toArray(new ExtensionComponentAdapter[myExtensionAdapters.size()]);
|
||||
LoadingOrder.sort(adapters);
|
||||
for (ExtensionComponentAdapter adapter : adapters) {
|
||||
//noinspection unchecked
|
||||
T extension = (T)adapter.getExtension();
|
||||
@SuppressWarnings("unchecked") T extension = (T)adapter.getExtension();
|
||||
assertClass(extension.getClass());
|
||||
|
||||
internalRegisterExtension(extension, adapter, myExtensions.size(), ArrayUtilRt.find(loadedAdapters, adapter) == -1);
|
||||
@@ -334,8 +333,8 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
if (myEPListeners.add(listener)) {
|
||||
for (ExtensionComponentAdapter componentAdapter : myLoadedAdapters.toArray(new ExtensionComponentAdapter[myLoadedAdapters.size()])) {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
listener.extensionAdded((T)componentAdapter.getExtension(), componentAdapter.getPluginDescriptor());
|
||||
@SuppressWarnings("unchecked") T extension = (T)componentAdapter.getExtension();
|
||||
listener.extensionAdded(extension, componentAdapter.getPluginDescriptor());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
@@ -348,8 +347,8 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
public synchronized void removeExtensionPointListener(@NotNull ExtensionPointListener<T> listener) {
|
||||
for (ExtensionComponentAdapter componentAdapter : myLoadedAdapters.toArray(new ExtensionComponentAdapter[myLoadedAdapters.size()])) {
|
||||
try {
|
||||
//noinspection unchecked
|
||||
listener.extensionRemoved((T)componentAdapter.getExtension(), componentAdapter.getPluginDescriptor());
|
||||
@SuppressWarnings("unchecked") T extension = (T)componentAdapter.getExtension();
|
||||
listener.extensionRemoved(extension, componentAdapter.getPluginDescriptor());
|
||||
}
|
||||
catch (Throwable e) {
|
||||
myLogger.error(e);
|
||||
@@ -379,10 +378,9 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
if (extensionClass == null) {
|
||||
try {
|
||||
ClassLoader pluginClassLoader = myDescriptor.getPluginClassLoader();
|
||||
//noinspection unchecked
|
||||
myExtensionClass = extensionClass = pluginClassLoader == null
|
||||
? (Class<T>)Class.forName(myClassName)
|
||||
: (Class<T>)Class.forName(myClassName, true, pluginClassLoader);
|
||||
@SuppressWarnings("unchecked") Class<T> extClass = pluginClassLoader == null
|
||||
? (Class<T>)Class.forName(myClassName) : (Class<T>)Class.forName(myClassName, true, pluginClassLoader);
|
||||
myExtensionClass = extensionClass = extClass;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -422,8 +420,8 @@ public class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
pluginContainer.unregisterComponent(componentKey);
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
internalUnregisterExtension((T)componentAdapter.getExtension(), componentAdapter.getPluginDescriptor());
|
||||
@SuppressWarnings("unchecked") T extension = (T)componentAdapter.getExtension();
|
||||
internalUnregisterExtension(extension, componentAdapter.getPluginDescriptor());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -132,7 +132,7 @@ public class LibraryDataService implements ProjectDataService<LibraryData, Libra
|
||||
String.format("Can't find %s of the library '%s' at path '%s'", entry.getKey(), libraryName, file.getAbsolutePath())
|
||||
);
|
||||
}
|
||||
String url = VfsUtilCore.pathToUrl(file.getAbsolutePath());
|
||||
String url = VfsUtil.getUrlForLibraryRoot(file);
|
||||
model.addRoot(url, entry.getKey());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.execution;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ExecutionEnvironment;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.ui.RunContentDescriptor;
|
||||
import com.intellij.execution.ui.RunContentManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -60,4 +61,10 @@ public abstract class ExecutionManager {
|
||||
@NotNull ExecutionTarget target,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@Nullable RunContentDescriptor currentDescriptor);
|
||||
|
||||
public abstract void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@Nullable ProgramRunner runner,
|
||||
@NotNull ExecutionEnvironment environment,
|
||||
@Nullable RunContentDescriptor currentDescriptor);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.intellij.execution.impl;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.execution.*;
|
||||
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
|
||||
import com.intellij.execution.configurations.RunConfiguration;
|
||||
import com.intellij.execution.configurations.RunProfile;
|
||||
import com.intellij.execution.configurations.RunProfileState;
|
||||
import com.intellij.execution.configurations.*;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
@@ -269,28 +266,55 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
for (RunContentDescriptor descriptor : getContentManager().getAllDescriptors()) {
|
||||
final ProcessHandler handler = descriptor.getProcessHandler();
|
||||
if (handler == processHandler) {
|
||||
restartRunProfile(project, executor, target, configuration, descriptor);
|
||||
restartRunProfile(project, null, null, null, null, executor, target, configuration, descriptor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
restartRunProfile(project, executor, target, configuration, (RunContentDescriptor)null);
|
||||
restartRunProfile(project, null, null, null, null, executor, target, configuration, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartRunProfile(@NotNull final Project project,
|
||||
public void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@NotNull ExecutionTarget target,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@Nullable RunContentDescriptor currentDescriptor) {
|
||||
restartRunProfile(project, null, null, null, null, executor, target, configuration, currentDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartRunProfile(@NotNull Project project,
|
||||
@NotNull Executor executor,
|
||||
@Nullable ProgramRunner runner,
|
||||
@NotNull ExecutionEnvironment environment,
|
||||
@Nullable RunContentDescriptor currentDescriptor) {
|
||||
restartRunProfile(project,
|
||||
runner,
|
||||
environment.getRunProfile(),
|
||||
environment.getRunnerSettings(),
|
||||
environment.getConfigurationSettings(),
|
||||
executor,
|
||||
environment.getExecutionTarget(),
|
||||
environment.getRunnerAndConfigurationSettings(), currentDescriptor);
|
||||
}
|
||||
|
||||
|
||||
private void restartRunProfile(@NotNull final Project project,
|
||||
@Nullable ProgramRunner r,
|
||||
@Nullable final RunProfile runProfile,
|
||||
@Nullable final RunnerSettings runnerSettings,
|
||||
@Nullable final ConfigurationPerRunnerSettings configurationPerRunnerSettings,
|
||||
@NotNull final Executor executor,
|
||||
@NotNull final ExecutionTarget target,
|
||||
@Nullable final RunnerAndConfigurationSettings configuration,
|
||||
@Nullable final RunContentDescriptor currentDescriptor) {
|
||||
if (configuration != null && ProgramRunnerUtil.getRunner(executor.getId(), configuration) == null) {
|
||||
final ProgramRunner runner = r != null ? r : ProgramRunnerUtil.getRunner(executor.getId(), configuration);
|
||||
if (configuration != null && runner == null) {
|
||||
LOG.error("Cannot find runner for " + configuration.getName());
|
||||
return;
|
||||
}
|
||||
if (configuration == null && (currentDescriptor == null || currentDescriptor.getRestarter() == null)) {
|
||||
LOG.error("Nothing to restart for descriptor ["+currentDescriptor+"]");
|
||||
return;
|
||||
}
|
||||
|
||||
final List<RunContentDescriptor> descriptorsToStop = new ArrayList<RunContentDescriptor>();
|
||||
if (configuration != null && configuration.isSingleton()) {
|
||||
descriptorsToStop.addAll(getRunningDescriptors(configuration));
|
||||
@@ -312,7 +336,6 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProgramRunner runner = ProgramRunnerUtil.getRunner(executor.getId(), configuration);
|
||||
if (runner != null && ExecutorRegistry.getInstance().isStarting(project, executor.getId(), runner.getRunnerId())) {
|
||||
awaitingTerminationAlarm.addRequest(this, 100);
|
||||
return;
|
||||
@@ -324,19 +347,39 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
return;
|
||||
}
|
||||
}
|
||||
start(project, configuration, executor, target, currentDescriptor);
|
||||
start(project, runner, runProfile, runnerSettings, configurationPerRunnerSettings, configuration, executor, target, currentDescriptor);
|
||||
}
|
||||
};
|
||||
awaitingTerminationAlarm.addRequest(runnable, 50);
|
||||
}
|
||||
|
||||
private static void start(@NotNull Project project,
|
||||
@Nullable ProgramRunner runner,
|
||||
@Nullable RunProfile runProfile,
|
||||
@Nullable RunnerSettings runnerSettings,
|
||||
@Nullable ConfigurationPerRunnerSettings configurationPerRunnerSettings,
|
||||
@Nullable RunnerAndConfigurationSettings configuration,
|
||||
@NotNull Executor executor,
|
||||
@NotNull ExecutionTarget target,
|
||||
@Nullable RunContentDescriptor descriptor) {
|
||||
Runnable restarter = descriptor != null ? descriptor.getRestarter() : null;
|
||||
if (configuration != null) {
|
||||
if (runner != null && runProfile != null) {
|
||||
try {
|
||||
runner.execute(executor, new ExecutionEnvironment(runProfile,
|
||||
target,
|
||||
project,
|
||||
runnerSettings,
|
||||
configurationPerRunnerSettings,
|
||||
descriptor,
|
||||
configuration));
|
||||
}
|
||||
catch (RunCanceledByUserException ignore) {
|
||||
}
|
||||
catch (ExecutionException e1) {
|
||||
Messages.showErrorDialog(project, e1.getMessage(), ExecutionBundle.message("restart.error.message.title"));
|
||||
}
|
||||
}
|
||||
else if (configuration != null) {
|
||||
ProgramRunnerUtil.executeConfiguration(project, configuration, executor, target, descriptor, true);
|
||||
}
|
||||
else if (restarter != null) {
|
||||
|
||||
@@ -43,7 +43,6 @@ import java.util.List;
|
||||
*/
|
||||
public class RestartAction extends FakeRerunAction implements DumbAware, AnAction.TransparentUpdate, Disposable {
|
||||
|
||||
private final ProcessHandler myProcessHandler;
|
||||
private final ProgramRunner myRunner;
|
||||
@NotNull private final RunContentDescriptor myDescriptor;
|
||||
@NotNull private final Executor myExecutor;
|
||||
@@ -51,7 +50,6 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
|
||||
|
||||
public RestartAction(@NotNull final Executor executor,
|
||||
final ProgramRunner runner,
|
||||
final ProcessHandler processHandler,//todo kill ProcessHandler here, use descriptor.getProcessHandler() is need
|
||||
@NotNull final RunContentDescriptor descriptor,
|
||||
@NotNull final ExecutionEnvironment env) {
|
||||
Disposer.register(descriptor, this);
|
||||
@@ -59,7 +57,6 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
|
||||
|
||||
myEnvironment = env;
|
||||
getTemplatePresentation().setEnabled(false);
|
||||
myProcessHandler = processHandler;
|
||||
myRunner = runner;
|
||||
myDescriptor = descriptor;
|
||||
myExecutor = executor;
|
||||
@@ -108,22 +105,8 @@ public class RestartAction extends FakeRerunAction implements DumbAware, AnActio
|
||||
|
||||
public void restart() {
|
||||
Project project = myEnvironment.getProject();
|
||||
if (project == null)
|
||||
return;
|
||||
if (myProcessHandler != null) {
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project,
|
||||
myExecutor,
|
||||
myEnvironment.getExecutionTarget(),
|
||||
myEnvironment.getRunnerAndConfigurationSettings(),
|
||||
myProcessHandler);
|
||||
}
|
||||
else {
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project,
|
||||
myExecutor,
|
||||
myEnvironment.getExecutionTarget(),
|
||||
myEnvironment.getRunnerAndConfigurationSettings(),
|
||||
myDescriptor);
|
||||
}
|
||||
if (project != null && !ExecutorRegistry.getInstance().isStarting(project, myExecutor.getId(), myRunner.getRunnerId()))
|
||||
ExecutionManager.getInstance(project).restartRunProfile(project, myExecutor, myRunner, myEnvironment, myDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -205,8 +205,7 @@ public class RunContentBuilder extends LogConsoleManagerBase {
|
||||
private ActionGroup createActionToolbar(final RunContentDescriptor contentDescriptor, final JComponent component) {
|
||||
final DefaultActionGroup actionGroup = new DefaultActionGroup();
|
||||
|
||||
final RestartAction restartAction = new RestartAction(myExecutor, myRunner, getProcessHandler(),
|
||||
contentDescriptor, getEnvironment());
|
||||
final RestartAction restartAction = new RestartAction(myExecutor, myRunner, contentDescriptor, getEnvironment());
|
||||
restartAction.registerShortcut(component);
|
||||
actionGroup.add(restartAction);
|
||||
contentDescriptor.setRestarter(new Runnable() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.diagnostic;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -35,13 +34,14 @@ import java.lang.reflect.InvocationTargetException;
|
||||
* @author kir
|
||||
*/
|
||||
public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
private static boolean ourOomOccured = false;
|
||||
private static boolean ourOomOccurred = false;
|
||||
private static boolean ourLoggerBroken = false;
|
||||
private static boolean mappingFailedNotificationPosted = false;
|
||||
private static boolean ourMappingFailedNotificationPosted = false;
|
||||
|
||||
@NonNls private static final String FATAL_ERROR_NOTIFICATION_PROPERTY = "idea.fatal.error.notification";
|
||||
@NonNls private static final String DISABLED_VALUE = "disabled";
|
||||
@NonNls private static final String ENABLED_VALUE = "enabled";
|
||||
@NonNls private static final String PARAM_PERMGEN = "PermGen";
|
||||
@NonNls private static final String PARAM_PERM_GEN = "PermGen";
|
||||
|
||||
public boolean canHandle(IdeaLoggingEvent event) {
|
||||
if (ourLoggerBroken) return false;
|
||||
@@ -56,7 +56,7 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
return notificationEnabled ||
|
||||
showPluginError ||
|
||||
ApplicationManagerEx.getApplicationEx().isInternal() ||
|
||||
isOOMError(event.getThrowable()) ||
|
||||
isOOMError(event.getThrowable()) ||
|
||||
event.getThrowable() instanceof MappingFailedException;
|
||||
}
|
||||
catch (LinkageError e) {
|
||||
@@ -68,13 +68,8 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection CallToPrintStackTrace
|
||||
*/
|
||||
public void handle(IdeaLoggingEvent event) {
|
||||
if (ourLoggerBroken) {
|
||||
return;
|
||||
}
|
||||
if (ourLoggerBroken) return;
|
||||
|
||||
try {
|
||||
Throwable throwable = event.getThrowable();
|
||||
@@ -84,11 +79,11 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
else if (throwable instanceof MappingFailedException) {
|
||||
processMappingFailed(event);
|
||||
}
|
||||
else if (!ourOomOccured) {
|
||||
else if (!ourOomOccurred) {
|
||||
MessagePool messagePool = MessagePool.getInstance();
|
||||
LogMessage message = messagePool.addIdeFatalMessage(event);
|
||||
if (message != null && ApplicationManager.getApplication() != null) {
|
||||
notifyUi(messagePool, message);
|
||||
ErrorNotifier.notifyUi(message, messagePool);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,14 +94,9 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
//noinspection AssignmentToStaticFieldFromInstanceMethod
|
||||
ourLoggerBroken = true;
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void notifyUi(MessagePool messagePool, LogMessage message) {
|
||||
ErrorNotifier.notifyUi(message, messagePool);
|
||||
}
|
||||
|
||||
private static boolean isOOMError(Throwable throwable) {
|
||||
return throwable instanceof OutOfMemoryError ||
|
||||
(throwable instanceof VirtualMachineError &&
|
||||
@@ -114,17 +104,13 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
throwable.getMessage().contains("CodeCache"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @noinspection CallToPrintStackTrace
|
||||
*/
|
||||
private static void processOOMError(final Throwable throwable) throws InterruptedException, InvocationTargetException {
|
||||
ourOomOccured = true;
|
||||
throwable.printStackTrace();
|
||||
ourOomOccurred = true;
|
||||
|
||||
SwingUtilities.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
String message = throwable.getMessage();
|
||||
OutOfMemoryDialog.MemoryKind k = message != null && message.contains(PARAM_PERMGEN)
|
||||
OutOfMemoryDialog.MemoryKind k = message != null && message.contains(PARAM_PERM_GEN)
|
||||
? OutOfMemoryDialog.MemoryKind.PERM_GEN
|
||||
: message != null && message.contains("CodeCache")
|
||||
? OutOfMemoryDialog.MemoryKind.CODE_CACHE
|
||||
@@ -135,13 +121,13 @@ public class DefaultIdeaErrorLogger implements ErrorLogger {
|
||||
}
|
||||
|
||||
private static void processMappingFailed(final IdeaLoggingEvent event) throws InterruptedException, InvocationTargetException {
|
||||
if (!mappingFailedNotificationPosted && SystemInfo.isWindows && SystemInfo.is32Bit) {
|
||||
mappingFailedNotificationPosted = true;
|
||||
final String exceptionMessage = event.getThrowable().getMessage();
|
||||
final String text = exceptionMessage +
|
||||
"<br>Possible cause: unable to allocate continuous memory chunk of necessary size.<br>Reducing JVM's maximum heap size (-Xmx) may help.";
|
||||
Notifications.Bus.notify(new Notification("Memory", "Memory Mapping Failed", text, NotificationType.WARNING), NotificationDisplayType.BALLOON, null);
|
||||
if (!ourMappingFailedNotificationPosted && SystemInfo.isWindows && SystemInfo.is32Bit) {
|
||||
ourMappingFailedNotificationPosted = true;
|
||||
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") String exceptionMessage = event.getThrowable().getMessage();
|
||||
String text = exceptionMessage +
|
||||
"<br>Possible cause: unable to allocate continuous memory chunk of necessary size.<br>" +
|
||||
"Reducing JVM maximum heap size (-Xmx) may help.";
|
||||
Notifications.Bus.notify(new Notification("Memory", "Memory Mapping Failed", text, NotificationType.WARNING), null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -903,11 +903,11 @@ public class IdeEventQueue extends EventQueue {
|
||||
myWaiterScheduled = false;
|
||||
}
|
||||
else {
|
||||
Application app = ApplicationManager.getApplication();
|
||||
if (app == null ||
|
||||
if (ApplicationManager.getApplication() == null ||
|
||||
UISettings.getInstance() == null ||
|
||||
!SystemInfo.isWindows ||
|
||||
!Registry.is("actionSystem.win.suppressAlt") ||
|
||||
(!UISettings.getInstance().HIDE_TOOL_STRIPES && !UISettings.getInstance().PRESENTATION_MODE)) {
|
||||
!(UISettings.getInstance().HIDE_TOOL_STRIPES || UISettings.getInstance().PRESENTATION_MODE)) {
|
||||
return !dispatch;
|
||||
}
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ public class ActionInstallPlugin extends AnAction implements DumbAware {
|
||||
installedPluginsToModel(list);
|
||||
if (!installed.isDisposed()) {
|
||||
getPluginTable().updateUI();
|
||||
installed.setRequireShutdown(true);
|
||||
}
|
||||
else {
|
||||
boolean needToRestart = false;
|
||||
|
||||
@@ -13,16 +13,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.ide.plugins;
|
||||
|
||||
import com.intellij.ide.ClassUtilCore;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.idea.Main;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.notification.Notifications;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.components.ComponentConfig;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -30,7 +32,7 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -39,12 +41,11 @@ import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author mike
|
||||
*/
|
||||
@SuppressWarnings({"UseOfSystemOutOrSystemErr", "CallToPrintStackTrace"}) // No logger is loaded at this time so we have to use these.
|
||||
public class PluginManager extends PluginManagerCore {
|
||||
@NonNls public static final String INSTALLED_TXT = "installed.txt";
|
||||
|
||||
@@ -55,93 +56,103 @@ public class PluginManager extends PluginManagerCore {
|
||||
/**
|
||||
* Called via reflection
|
||||
*/
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
@SuppressWarnings({"UnusedDeclaration", "HardCodedStringLiteral", "finally"})
|
||||
protected static void start(final String mainClass, final String methodName, final String[] args) {
|
||||
startupStart = System.nanoTime();
|
||||
try {
|
||||
//noinspection HardCodedStringLiteral
|
||||
ThreadGroup threadGroup = new ThreadGroup("Idea Thread Group") {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
if (!(e instanceof ProcessCanceledException)) {
|
||||
PluginManagerCore.getLogger().error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Main.setFlags(args);
|
||||
|
||||
if (!Main.isHeadless()) {
|
||||
UIUtil.initDefaultLAF();
|
||||
}
|
||||
|
||||
ThreadGroup threadGroup = new ThreadGroup("Idea Thread Group") {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
if (e instanceof StartupAbortedException) {
|
||||
StartupAbortedException se = (StartupAbortedException)e;
|
||||
try {
|
||||
ClassUtilCore.clearJarURLCache();
|
||||
|
||||
Class<?> aClass = Class.forName(mainClass);
|
||||
Method method = aClass.getDeclaredMethod(methodName, ArrayUtil.EMPTY_STRING_ARRAY.getClass());
|
||||
method.setAccessible(true);
|
||||
|
||||
//noinspection RedundantArrayCreation
|
||||
method.invoke(null, new Object[]{args});
|
||||
if (se.logError()) {
|
||||
if (Logger.isInitialized()) {
|
||||
getLogger().error(e);
|
||||
}
|
||||
Main.showMessage("Start Failed", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
String message = "Error while accessing " + mainClass + "." + methodName + " with arguments: " + Arrays.asList(args);
|
||||
if ("true".equals(System.getProperty("java.awt.headless"))) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.err.println(message);
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(null, message + ": " + e.getClass().getName() + ": " + e.getMessage() + "\n" + ExceptionUtil.getThrowableText(e), "Error starting IntelliJ Platform", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
finally {
|
||||
System.exit(se.exitCode());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//noinspection HardCodedStringLiteral
|
||||
new Thread(threadGroup, runnable, "Idea Main Thread").start();
|
||||
}
|
||||
catch (Exception e) {
|
||||
PluginManagerCore.getLogger().error(e);
|
||||
}
|
||||
if (!(e instanceof ProcessCanceledException)) {
|
||||
getLogger().error(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
ClassUtilCore.clearJarURLCache();
|
||||
|
||||
Class<?> aClass = Class.forName(mainClass);
|
||||
Method method = aClass.getDeclaredMethod(methodName, ArrayUtil.EMPTY_STRING_ARRAY.getClass());
|
||||
method.setAccessible(true);
|
||||
Object[] argsArray = {args};
|
||||
method.invoke(null, argsArray);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throw new StartupAbortedException(t);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
new Thread(threadGroup, runnable, "Idea Main Thread").start();
|
||||
}
|
||||
|
||||
public static void reportPluginError() {
|
||||
if (myPluginError != null) {
|
||||
Notifications.Bus.notify(new Notification(IdeBundle.message("title.plugin.error"), IdeBundle.message("title.plugin.error"),
|
||||
myPluginError, NotificationType.ERROR, new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
notification.expire();
|
||||
final String description = event.getDescription();
|
||||
if (EDIT.equals(description)) {
|
||||
final PluginManagerConfigurable configurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
|
||||
IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
|
||||
ShowSettingsUtil.getInstance().editConfigurable((JFrame)ideFrame, configurable);
|
||||
return;
|
||||
}
|
||||
final List<String> disabledPlugins = PluginManagerCore.getDisabledPlugins();
|
||||
if (myPlugins2Disable != null && DISABLE.equals(description)) {
|
||||
for (String pluginId : myPlugins2Disable) {
|
||||
if (!disabledPlugins.contains(pluginId)) {
|
||||
disabledPlugins.add(pluginId);
|
||||
}
|
||||
}
|
||||
} else if (myPlugins2Enable != null && ENABLE.equals(description)) {
|
||||
disabledPlugins.removeAll(myPlugins2Enable);
|
||||
}
|
||||
try {
|
||||
PluginManagerCore.saveDisabledPlugins(disabledPlugins, false);
|
||||
}
|
||||
catch (IOException ignore) {
|
||||
}
|
||||
myPlugins2Enable = null;
|
||||
myPlugins2Disable = null;
|
||||
String message = IdeBundle.message("title.plugin.error");
|
||||
Notifications.Bus.notify(new Notification(message, message, myPluginError, NotificationType.ERROR, new NotificationListener() {
|
||||
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
notification.expire();
|
||||
|
||||
String description = event.getDescription();
|
||||
if (EDIT.equals(description)) {
|
||||
PluginManagerConfigurable configurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
|
||||
IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
|
||||
ShowSettingsUtil.getInstance().editConfigurable((JFrame)ideFrame, configurable);
|
||||
return;
|
||||
}
|
||||
}));
|
||||
|
||||
List<String> disabledPlugins = getDisabledPlugins();
|
||||
if (myPlugins2Disable != null && DISABLE.equals(description)) {
|
||||
for (String pluginId : myPlugins2Disable) {
|
||||
if (!disabledPlugins.contains(pluginId)) {
|
||||
disabledPlugins.add(pluginId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (myPlugins2Enable != null && ENABLE.equals(description)) {
|
||||
disabledPlugins.removeAll(myPlugins2Enable);
|
||||
}
|
||||
|
||||
try {
|
||||
saveDisabledPlugins(disabledPlugins, false);
|
||||
}
|
||||
catch (IOException ignore) { }
|
||||
|
||||
myPlugins2Enable = null;
|
||||
myPlugins2Disable = null;
|
||||
}
|
||||
}));
|
||||
myPluginError = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPluginInstalled(PluginId id) {
|
||||
return getPlugin(id) != null;
|
||||
}
|
||||
@@ -157,24 +168,59 @@ public class PluginManager extends PluginManagerCore {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void disableIncompatiblePlugin(final Object cause, final Throwable ex) {
|
||||
final PluginId pluginId = getPluginByClassName(cause.getClass().getName());
|
||||
if (pluginId != null && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
final boolean success = PluginManagerCore.disablePlugin(pluginId.getIdString());
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
|
||||
"Incompatible plugin detected: " + pluginId.getIdString() +
|
||||
(success ? "\nThe plugin has been disabled" : ""),
|
||||
"Plugin Manager",
|
||||
JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
});
|
||||
public static void handleComponentError(Throwable t, String componentClassName, ComponentConfig config) {
|
||||
if (t instanceof StartupAbortedException) {
|
||||
throw (StartupAbortedException)t;
|
||||
}
|
||||
|
||||
PluginId pluginId = config != null ? config.getPluginId() : getPluginByClassName(componentClassName);
|
||||
|
||||
if (pluginId != null && !CORE_PLUGIN_ID.equals(pluginId.getIdString())) {
|
||||
getLogger().warn(t);
|
||||
|
||||
disablePlugin(pluginId.getIdString());
|
||||
|
||||
String message =
|
||||
"Plugin '" + pluginId.getIdString() + "' failed to initialize and will be disabled\n" +
|
||||
"(reason: " + t.getMessage() + ")\n\n" +
|
||||
ApplicationNamesInfo.getInstance().getFullProductName() + " will be restarted.";
|
||||
Main.showMessage("Plugin Error", message, false);
|
||||
|
||||
throw new StartupAbortedException(t).exitCode(Main.PLUGIN_ERROR).logError(false);
|
||||
}
|
||||
else {
|
||||
// should never happen
|
||||
throw new RuntimeException(ex);
|
||||
throw new StartupAbortedException("Fatal error initializing '" + componentClassName + "'", t);
|
||||
}
|
||||
}
|
||||
|
||||
public static class StartupAbortedException extends RuntimeException {
|
||||
private int exitCode = Main.STARTUP_EXCEPTION;
|
||||
private boolean logError = true;
|
||||
|
||||
public StartupAbortedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public StartupAbortedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public int exitCode() {
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
public StartupAbortedException exitCode(int exitCode) {
|
||||
this.exitCode = exitCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean logError() {
|
||||
return logError;
|
||||
}
|
||||
|
||||
public StartupAbortedException logError(boolean logError) {
|
||||
this.logError = logError;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,10 @@
|
||||
package com.intellij.ide.ui.laf;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.ColoredSideBorder;
|
||||
import com.intellij.ui.plaf.beg.*;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
|
||||
import com.sun.java.swing.plaf.windows.WindowsTreeUI;
|
||||
|
||||
@@ -38,7 +40,14 @@ public final class IdeaLaf extends MetalLookAndFeel {
|
||||
super.initComponentDefaults(defaults);
|
||||
LafManagerImpl.initInputMapDefaults(defaults);
|
||||
initIdeaDefaults(defaults);
|
||||
LafManagerImpl.initFontDefaults(defaults, "Tahoma", 11);
|
||||
|
||||
Pair<String, Integer> systemFont = UIUtil.getSystemFontData();
|
||||
if (systemFont != null) {
|
||||
LafManagerImpl.initFontDefaults(defaults, systemFont.first, systemFont.second);
|
||||
}
|
||||
else {
|
||||
LafManagerImpl.initFontDefaults(defaults, "Tahoma", 11);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral"})
|
||||
|
||||
@@ -23,13 +23,11 @@ import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.util.containers.hash.HashMap;
|
||||
import com.sun.jna.platform.unix.X11;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import javax.swing.plaf.FontUIResource;
|
||||
import javax.swing.plaf.IconUIResource;
|
||||
import javax.swing.plaf.InsetsUIResource;
|
||||
import javax.swing.plaf.basic.BasicLookAndFeel;
|
||||
@@ -49,6 +47,7 @@ import java.util.Properties;
|
||||
public final class DarculaLaf extends BasicLookAndFeel {
|
||||
public static final String NAME = "Darcula";
|
||||
BasicLookAndFeel base;
|
||||
|
||||
public DarculaLaf() {
|
||||
try {
|
||||
if (SystemInfo.isWindows || SystemInfo.isLinux) {
|
||||
@@ -58,8 +57,8 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
base = (BasicLookAndFeel)Class.forName(name).newInstance();
|
||||
}
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
log(ignore);
|
||||
catch (Exception e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,8 +68,8 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
superMethod.setAccessible(true);
|
||||
superMethod.invoke(base, defaults);
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
log(ignore);
|
||||
catch (Exception e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,19 +84,8 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
try {
|
||||
final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
|
||||
superMethod.setAccessible(true);
|
||||
final UIDefaults metalDefaults =
|
||||
(UIDefaults)superMethod.invoke(new MetalLookAndFeel());
|
||||
final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel());
|
||||
final UIDefaults defaults = (UIDefaults)superMethod.invoke(base);
|
||||
if (SystemInfo.isLinux) {
|
||||
Font font = findFont("Ubuntu");
|
||||
if (font != null) {
|
||||
for (Object key : defaults.keySet()) {
|
||||
if (key instanceof String && ((String)key).endsWith(".font")) {
|
||||
defaults.put(key, new FontUIResource(font.deriveFont(15f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LafManagerImpl.initInputMapDefaults(defaults);
|
||||
initIdeaDefaults(defaults);
|
||||
@@ -108,21 +96,12 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
MetalLookAndFeel.setCurrentTheme(new DarculaMetalTheme());
|
||||
return defaults;
|
||||
}
|
||||
catch (Exception ignore) {
|
||||
log(ignore);
|
||||
catch (Exception e) {
|
||||
log(e);
|
||||
}
|
||||
return super.getDefaults();
|
||||
}
|
||||
|
||||
private static Font findFont(String name) {
|
||||
for (Font font : GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()) {
|
||||
if (font.getName().equals(name)) {
|
||||
return font;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void patchComboBox(UIDefaults metalDefaults, UIDefaults defaults) {
|
||||
defaults.remove("ComboBox.ancestorInputMap");
|
||||
defaults.remove("ComboBox.actionMap");
|
||||
@@ -294,7 +273,6 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
@@ -355,7 +333,6 @@ public final class DarculaLaf extends BasicLookAndFeel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getSupportsWindowDecorations() {
|
||||
return true;
|
||||
|
||||
@@ -18,12 +18,12 @@ package com.intellij.idea;
|
||||
import com.intellij.ExtensionPoints;
|
||||
import com.intellij.Patches;
|
||||
import com.intellij.concurrency.JobScheduler;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.AppLifecycleListener;
|
||||
import com.intellij.ide.CommandLineProcessor;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.IdeRepaintManager;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.notification.NotificationDisplayType;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
@@ -36,10 +36,12 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateChecker;
|
||||
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.impl.SystemDock;
|
||||
@@ -54,7 +56,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -79,14 +80,15 @@ public class IdeaApplication {
|
||||
myArgs = args;
|
||||
boolean isInternal = Boolean.valueOf(System.getProperty(IDEA_IS_INTERNAL_PROPERTY)).booleanValue();
|
||||
|
||||
if (Main.isCommandLine(args)) {
|
||||
boolean headless = Main.isHeadless(args);
|
||||
if (!headless) patchSystem();
|
||||
boolean headless = Main.isHeadless();
|
||||
if (!headless) {
|
||||
patchSystem();
|
||||
}
|
||||
|
||||
if (Main.isCommandLine()) {
|
||||
new CommandLineApplication(isInternal, false, headless);
|
||||
}
|
||||
else {
|
||||
patchSystem();
|
||||
|
||||
Splash splash = null;
|
||||
if (myArgs.length == 0) {
|
||||
myStarter = getStarter();
|
||||
@@ -159,15 +161,16 @@ public class IdeaApplication {
|
||||
|
||||
protected ApplicationStarter getStarter() {
|
||||
if (myArgs.length > 0) {
|
||||
PluginManager.getPlugins();
|
||||
PluginManagerCore.getPlugins();
|
||||
|
||||
ExtensionPoint<ApplicationStarter> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.APPLICATION_STARTER);
|
||||
final ApplicationStarter[] starters = point.getExtensions();
|
||||
ApplicationStarter[] starters = point.getExtensions();
|
||||
String key = myArgs[0];
|
||||
for (ApplicationStarter o : starters) {
|
||||
if (Comparing.equal(o.getCommandName(), key)) return o;
|
||||
}
|
||||
}
|
||||
|
||||
return new IdeStarter();
|
||||
}
|
||||
|
||||
@@ -175,17 +178,9 @@ public class IdeaApplication {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
public void run() throws Exception {
|
||||
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||
try {
|
||||
app.load(PathManager.getOptionsPath());
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
app.load(PathManager.getOptionsPath());
|
||||
|
||||
myStarter.main(myArgs);
|
||||
myStarter = null; //GC it
|
||||
@@ -252,36 +247,28 @@ public class IdeaApplication {
|
||||
|
||||
@Override
|
||||
public void main(String[] args) {
|
||||
|
||||
SystemDock.updateMenu();
|
||||
|
||||
// Event queue should not be changed during initialization of application components.
|
||||
// It also cannot be changed before initialization of application components because IdeEventQueue uses other
|
||||
// application components. So it is proper to perform replacement only here.
|
||||
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
|
||||
// app.setupIdeQueue(IdeEventQueue.getInstance());
|
||||
WindowManagerImpl windowManager = (WindowManagerImpl)WindowManager.getInstance();
|
||||
IdeEventQueue.getInstance().setWindowManager(windowManager);
|
||||
|
||||
try {
|
||||
IdeEventQueue.getInstance().setWindowManager(windowManager);
|
||||
Ref<Boolean> willOpenProject = new Ref<Boolean>(Boolean.FALSE);
|
||||
AppLifecycleListener lifecyclePublisher = app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC);
|
||||
lifecyclePublisher.appFrameCreated(args, willOpenProject);
|
||||
|
||||
final Ref<Boolean> willOpenProject = new Ref<Boolean>(Boolean.FALSE);
|
||||
final AppLifecycleListener lifecyclePublisher = app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC);
|
||||
lifecyclePublisher.appFrameCreated(args, willOpenProject);
|
||||
LOG.info("App initialization took " + (System.nanoTime() - PluginManager.startupStart) / 1000000 + " ms");
|
||||
PluginManager.dumpPluginClassStatistics();
|
||||
if (!willOpenProject.get()) {
|
||||
WelcomeFrame.showNow();
|
||||
lifecyclePublisher.welcomeScreenDisplayed();
|
||||
}
|
||||
else {
|
||||
windowManager.showFrame();
|
||||
}
|
||||
LOG.info("App initialization took " + (System.nanoTime() - PluginManager.startupStart) / 1000000 + " ms");
|
||||
PluginManagerCore.dumpPluginClassStatistics();
|
||||
|
||||
if (!willOpenProject.get()) {
|
||||
WelcomeFrame.showNow();
|
||||
lifecyclePublisher.welcomeScreenDisplayed();
|
||||
}
|
||||
catch (PluginException e) {
|
||||
Messages.showErrorDialog("Plugin " + e.getPluginId() + " couldn't be loaded, the IDE will now exit.\n" +
|
||||
"See the full details in the log.\n" +
|
||||
e.getMessage(), "Plugin Error");
|
||||
System.exit(-1);
|
||||
else {
|
||||
windowManager.showFrame();
|
||||
}
|
||||
|
||||
app.invokeLater(new Runnable() {
|
||||
@@ -321,7 +308,6 @@ public class IdeaApplication {
|
||||
}
|
||||
}, ModalityState.NON_MODAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loadProject() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,6 @@ public class IdeaLogger extends Logger {
|
||||
|
||||
public static String ourLastActionId = "";
|
||||
|
||||
private final org.apache.log4j.Logger myLogger;
|
||||
/** If not null - it means that errors occurred and it is the first of them. */
|
||||
public static Exception ourErrorsOccurred;
|
||||
|
||||
@@ -59,25 +58,24 @@ public class IdeaLogger extends Logger {
|
||||
static {
|
||||
InputStream stream = Logger.class.getResourceAsStream(COMPILATION_TIMESTAMP_RESOURCE_NAME);
|
||||
if (stream != null) {
|
||||
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream));
|
||||
try {
|
||||
String s = reader.readLine();
|
||||
if (s != null) {
|
||||
ourCompilationTimestamp = s.trim();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
}
|
||||
finally {
|
||||
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream));
|
||||
try {
|
||||
stream.close();
|
||||
String s = reader.readLine();
|
||||
if (s != null) {
|
||||
ourCompilationTimestamp = s.trim();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ignored) { }
|
||||
}
|
||||
}
|
||||
|
||||
private final org.apache.log4j.Logger myLogger;
|
||||
|
||||
IdeaLogger(org.apache.log4j.Logger logger) {
|
||||
myLogger = logger;
|
||||
}
|
||||
@@ -134,9 +132,6 @@ public class IdeaLogger extends Logger {
|
||||
|
||||
myLogger.error(message + (!detailString.isEmpty() ? "\nDetails: " + detailString : ""), t);
|
||||
logErrorHeader();
|
||||
if (t != null && t.getCause() != null) {
|
||||
myLogger.error("Original exception: ", t.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
private void logErrorHeader() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,7 +88,7 @@ public class SocketLock {
|
||||
if (mySocket == null) {
|
||||
if (!myIsDialogShown) {
|
||||
final String productName = ApplicationNamesInfo.getInstance().getProductName();
|
||||
if (StartupUtil.isHeadless()) { //team server inspections
|
||||
if (Main.isHeadless()) { //team server inspections
|
||||
throw new RuntimeException("Only one instance of " + productName + " can be run at a time.");
|
||||
}
|
||||
@NonNls final String pathToLogFile = PathManager.getLogPath() + "/idea.log file".replace('/', File.separatorChar);
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
*/
|
||||
package com.intellij.idea;
|
||||
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.ide.startupWizard.StartupWizard;
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ConfigImportHelper;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.ApplicationInfoEx;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
@@ -28,6 +29,7 @@ import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.win32.IdeaWin32;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.EnvironmentUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
@@ -41,7 +43,6 @@ import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.RuntimeMXBean;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -54,8 +55,6 @@ public class StartupUtil {
|
||||
|
||||
public static final boolean NO_SNAPPY = SystemProperties.getBooleanProperty("idea.no.snappy", false);
|
||||
|
||||
static boolean isHeadless;
|
||||
|
||||
private static SocketLock ourLock;
|
||||
private static String myDefaultLAF;
|
||||
|
||||
@@ -73,17 +72,55 @@ public class StartupUtil {
|
||||
return !Arrays.asList(args).contains(NO_SPLASH);
|
||||
}
|
||||
|
||||
/** @deprecated use {@link Main#isHeadless()} (to remove in IDEA 14) */
|
||||
@SuppressWarnings("unused")
|
||||
public static boolean isHeadless() {
|
||||
return isHeadless;
|
||||
return Main.isHeadless();
|
||||
}
|
||||
|
||||
private static void showError(final String title, final String message) {
|
||||
if (isHeadless()) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.out.println(message);
|
||||
public synchronized static void addExternalInstanceListener(Consumer<List<String>> consumer) {
|
||||
ourLock.setActivateListener(consumer);
|
||||
}
|
||||
|
||||
interface AppStarter {
|
||||
void start(boolean newConfigFolder);
|
||||
}
|
||||
|
||||
static void prepareAndStart(String[] args, AppStarter appStarter) {
|
||||
boolean newConfigFolder = false;
|
||||
|
||||
if (!Main.isHeadless()) {
|
||||
AppUIUtil.updateFrameClass();
|
||||
AppUIUtil.updateWindowIcon(JOptionPane.getRootFrame());
|
||||
AppUIUtil.registerBundledFonts();
|
||||
|
||||
newConfigFolder = PathManager.ensureConfigFolderExists(true);
|
||||
if (newConfigFolder) {
|
||||
ConfigImportHelper.importConfigsTo(PathManager.getConfigPath());
|
||||
}
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), message, title, JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
boolean canStart = checkJdkVersion() && checkSystemFolders() && lockSystemFolders(args); // note: uses config folder!
|
||||
if (!canStart) {
|
||||
System.exit(Main.STARTUP_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
Logger.setFactory(LoggerFactory.getInstance());
|
||||
Logger log = Logger.getInstance(Main.class);
|
||||
startLogging(log);
|
||||
fixProcessEnvironment(log);
|
||||
loadSystemLibraries(log);
|
||||
|
||||
appStarter.start(newConfigFolder);
|
||||
}
|
||||
|
||||
static void runStartupWizard() {
|
||||
final List<ApplicationInfoEx.PluginChooserPage> pages = ApplicationInfoImpl.getShadowInstance().getPluginChooserPages();
|
||||
if (!pages.isEmpty()) {
|
||||
final StartupWizard startupWizard = new StartupWizard(pages);
|
||||
startupWizard.setCancelText("Skip");
|
||||
startupWizard.show();
|
||||
PluginManagerCore.invalidatePlugins();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,17 +134,9 @@ public class StartupUtil {
|
||||
Class.forName("com.sun.jdi.Field");
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
showError("Error", "'tools.jar' is not in " + ApplicationNamesInfo.getInstance().getProductName() + " classpath.\n" +
|
||||
"Please ensure JAVA_HOME points to JDK rather than JRE.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!"true".equals(System.getProperty("idea.no.jdk.check"))) {
|
||||
final String version = System.getProperty("java.version");
|
||||
if (!SystemInfo.isJavaVersionAtLeast("1.6")) {
|
||||
showError("Java Version Mismatch", "The JDK version is " + version + ".\n" +
|
||||
ApplicationNamesInfo.getInstance().getProductName() + " requires JDK 1.6 or higher.");
|
||||
String message = "'tools.jar' seems to be not in " + ApplicationNamesInfo.getInstance().getProductName() + " classpath.\n" +
|
||||
"Please ensure JAVA_HOME points to JDK rather than JRE.";
|
||||
Main.showMessage("JDK Required", message, true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -117,18 +146,20 @@ public class StartupUtil {
|
||||
|
||||
private synchronized static boolean checkSystemFolders() {
|
||||
final String configPath = PathManager.getConfigPath();
|
||||
if (configPath == null || !new File(configPath).isDirectory()) {
|
||||
showError("Invalid config path", "Config path '" + configPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.config.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.");
|
||||
if (!new File(configPath).isDirectory()) {
|
||||
String message = "Config path '" + configPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.config.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.";
|
||||
Main.showMessage("Invalid Config Path", message, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String systemPath = PathManager.getSystemPath();
|
||||
if (systemPath == null || !new File(systemPath).isDirectory()) {
|
||||
showError("Invalid system path", "System path '" + systemPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.system.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.");
|
||||
String message = "System path '" + systemPath + "' is invalid.\n" +
|
||||
"If you have modified the 'idea.system.path' property please make sure it is correct,\n" +
|
||||
"otherwise please re-install the IDE.";
|
||||
Main.showMessage("Invalid System Path", message, true);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,8 +177,9 @@ public class StartupUtil {
|
||||
}
|
||||
|
||||
if (activateStatus != SocketLock.ActivateStatus.NO_INSTANCE) {
|
||||
if (isHeadless() || activateStatus == SocketLock.ActivateStatus.CANNOT_ACTIVATE) {
|
||||
showError("Error", "Only one instance of " + ApplicationNamesInfo.getInstance().getFullProductName() + " can be run at a time.");
|
||||
if (Main.isHeadless() || activateStatus == SocketLock.ActivateStatus.CANNOT_ACTIVATE) {
|
||||
String message = "Only one instance of " + ApplicationNamesInfo.getInstance().getFullProductName() + " can be run at a time.";
|
||||
Main.showMessage("Too Many Instances", message, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -155,38 +187,16 @@ public class StartupUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean checkStartupPossible(String[] args) {
|
||||
return checkJdkVersion() &&
|
||||
checkSystemFolders() &&
|
||||
lockSystemFolders(args);
|
||||
}
|
||||
|
||||
static void runStartupWizard() {
|
||||
final List<ApplicationInfoEx.PluginChooserPage> pages = ApplicationInfoImpl.getShadowInstance().getPluginChooserPages();
|
||||
if (!pages.isEmpty()) {
|
||||
final StartupWizard startupWizard = new StartupWizard(pages);
|
||||
startupWizard.setCancelText("Skip");
|
||||
startupWizard.show();
|
||||
PluginManager.invalidatePlugins();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void addExternalInstanceListener(Consumer<List<String>> consumer) {
|
||||
ourLock.setActivateListener(consumer);
|
||||
}
|
||||
|
||||
|
||||
static void fixProcessEnvironment(Logger log) {
|
||||
private static void fixProcessEnvironment(Logger log) {
|
||||
boolean envReady = EnvironmentUtil.isEnvironmentReady(); // trigger environment loading
|
||||
if (!envReady) {
|
||||
log.info("initializing environment");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final String JAVA_IO_TEMP_DIR = "java.io.tmpdir";
|
||||
|
||||
static void loadSystemLibraries(final Logger log) {
|
||||
private static void loadSystemLibraries(final Logger log) {
|
||||
// load JNA and Snappy in own temp directory - to avoid collisions and work around no-exec /tmp
|
||||
final File ideaTempDir = new File(PathManager.getSystemPath(), "tmp");
|
||||
if (!(ideaTempDir.mkdirs() || ideaTempDir.exists())) {
|
||||
@@ -231,7 +241,7 @@ public class StartupUtil {
|
||||
IdeaWin32.isAvailable(); // logging is done there
|
||||
}
|
||||
|
||||
if (SystemInfo.isWin2kOrNewer && !isHeadless) {
|
||||
if (SystemInfo.isWin2kOrNewer && !Main.isHeadless()) {
|
||||
try {
|
||||
System.loadLibrary(SystemInfo.isAMD64 ? "focusKiller64" : "focusKiller");
|
||||
log.info("Using \"FocusKiller\" library to prevent focus stealing.");
|
||||
@@ -280,28 +290,25 @@ public class StartupUtil {
|
||||
loadNativeLibrary.invoke(null, loaderClass);
|
||||
}
|
||||
|
||||
public static void startLogging(final Logger log) {
|
||||
private static void startLogging(final Logger log) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook - logging") {
|
||||
public void run() {
|
||||
log.info(
|
||||
"------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------");
|
||||
log.info("------------------------------------------------------ IDE SHUTDOWN ------------------------------------------------------");
|
||||
}
|
||||
});
|
||||
log.info(
|
||||
"------------------------------------------------------ IDE STARTED ------------------------------------------------------");
|
||||
log.info("------------------------------------------------------ IDE STARTED ------------------------------------------------------");
|
||||
|
||||
final ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
final ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
|
||||
ApplicationInfo appInfo = ApplicationInfoImpl.getShadowInstance();
|
||||
ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
|
||||
log.info("IDE: " + namesInfo.getFullProductName() + " (build #" + appInfo.getBuild() + ", " +
|
||||
DateFormatUtilRt.formatBuildDate(appInfo.getBuildDate()) + ")");
|
||||
log.info("OS: " + SystemInfoRt.OS_NAME + " (" + SystemInfoRt.OS_VERSION + ")");
|
||||
|
||||
log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")");
|
||||
log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.vendor", "-") + ")");
|
||||
|
||||
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
|
||||
List<String> arguments = RuntimemxBean.getInputArguments();
|
||||
|
||||
if (arguments != null) log.info("JVM Args: " + StringUtil.join(arguments, " "));
|
||||
List<String> arguments = ManagementFactory.getRuntimeMXBean().getInputArguments();
|
||||
if (arguments != null) {
|
||||
log.info("JVM Args: " + StringUtil.join(arguments, " "));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-47
@@ -22,6 +22,7 @@ import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.*;
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.idea.StartupUtil;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.*;
|
||||
@@ -37,7 +38,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.EmptyProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -89,8 +89,8 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.application.impl.ApplicationImpl");
|
||||
private final ModalityState MODALITY_STATE_NONE = ModalityState.NON_MODAL;
|
||||
|
||||
// about writer preference: the way the java.util.concurrent.locks.ReentrantReadWriteLock.NonfairSync is implemented, the
|
||||
// writer thread will be always at the queue head and therefore, java.util.concurrent.locks.ReentrantReadWriteLock.NonfairSync.readerShouldBlock()
|
||||
// about writer preference: the way the j.u.c.l.ReentrantReadWriteLock.NonfairSync is implemented, the
|
||||
// writer thread will be always at the queue head and therefore, j.u.c.l.ReentrantReadWriteLock.NonfairSync.readerShouldBlock()
|
||||
// will return true if the write action is pending, exactly as we need
|
||||
private final ReentrantReadWriteLock myLock = new ReentrantReadWriteLock(false);
|
||||
|
||||
@@ -361,55 +361,25 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleInitComponentError(final Throwable ex, final boolean fatal, final String componentClassName, ComponentConfig config) {
|
||||
if (myHandlingInitComponentError) {
|
||||
return;
|
||||
}
|
||||
myHandlingInitComponentError = true;
|
||||
try {
|
||||
PluginId pluginId = config == null ? PluginManager.getPluginByClassName(componentClassName) : config.getPluginId();
|
||||
if (pluginId != null) {
|
||||
LOG.warn(ex);
|
||||
@NonNls final String errorMessage =
|
||||
"Plugin " + pluginId.getIdString() + " failed to initialize and will be disabled:\n" + ex.getMessage() +
|
||||
"\nPlease restart " + ApplicationNamesInfo.getInstance().getFullProductName() + ".";
|
||||
PluginManager.disablePlugin(pluginId.getIdString());
|
||||
if (!myHeadlessMode) {
|
||||
JOptionPane.showMessageDialog(null, errorMessage);
|
||||
}
|
||||
else if (!isUnitTestMode()) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.out.println(errorMessage);
|
||||
System.exit(1);
|
||||
}
|
||||
return; // do not call super
|
||||
protected void handleInitComponentError(Throwable t, String componentClassName, ComponentConfig config) {
|
||||
if (!myHandlingInitComponentError) {
|
||||
myHandlingInitComponentError = true;
|
||||
try {
|
||||
PluginManager.handleComponentError(t, componentClassName, config);
|
||||
}
|
||||
if (fatal) {
|
||||
LOG.error(ex);
|
||||
@NonNls final String errorMessage = "Fatal error initializing class " + componentClassName + ":\n" +
|
||||
StringUtil.trimLog(ex.toString(), 239) +
|
||||
"\nComplete error stacktrace was written to " + PathManager.getLogPath() + "/idea.log";
|
||||
if (!myHeadlessMode) {
|
||||
JOptionPane.showMessageDialog(null, errorMessage);
|
||||
}
|
||||
else {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.out.println(errorMessage);
|
||||
}
|
||||
finally {
|
||||
myHandlingInitComponentError = false;
|
||||
}
|
||||
super.handleInitComponentError(ex, fatal, componentClassName, config);
|
||||
}
|
||||
finally {
|
||||
myHandlingInitComponentError = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadApplicationComponents() {
|
||||
PluginManager.initPlugins(mySplash);
|
||||
final IdeaPluginDescriptor[] plugins = PluginManager.getPlugins();
|
||||
PluginManagerCore.initPlugins(mySplash);
|
||||
IdeaPluginDescriptor[] plugins = PluginManagerCore.getPlugins();
|
||||
for (IdeaPluginDescriptor plugin : plugins) {
|
||||
if (PluginManager.shouldSkipPlugin(plugin)) continue;
|
||||
loadComponentsConfiguration(plugin.getAppComponents(), plugin, false);
|
||||
if (!PluginManagerCore.shouldSkipPlugin(plugin)) {
|
||||
loadComponentsConfiguration(plugin.getAppComponents(), plugin, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,7 +387,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
protected synchronized Object createComponent(Class componentInterface) {
|
||||
Object component = super.createComponent(componentInterface);
|
||||
if (mySplash != null) {
|
||||
mySplash.showProgress("", (float)(0.65f + getPercentageOfComponentsLoaded() * 0.35f));
|
||||
mySplash.showProgress("", 0.65f + getPercentageOfComponentsLoaded() * 0.35f);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
@@ -1440,7 +1410,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
|
||||
public void run() {
|
||||
if (ex instanceof PluginException) {
|
||||
final PluginException pluginException = (PluginException)ex;
|
||||
PluginManager.disablePlugin(pluginException.getPluginId().getIdString());
|
||||
PluginManagerCore.disablePlugin(pluginException.getPluginId().getIdString());
|
||||
Messages.showMessageDialog("The plugin " +
|
||||
pluginException.getPluginId() +
|
||||
" failed to save settings and has been disabled. Please restart " +
|
||||
|
||||
+3
-5
@@ -149,12 +149,12 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
};
|
||||
|
||||
for (final FileTypeFactory factory : Extensions.getExtensions(FileTypeFactory.FILE_TYPE_FACTORY_EP)) {
|
||||
for (FileTypeFactory factory : Extensions.getExtensions(FileTypeFactory.FILE_TYPE_FACTORY_EP)) {
|
||||
try {
|
||||
factory.createFileTypes(consumer);
|
||||
}
|
||||
catch (final Error ex) {
|
||||
PluginManager.disableIncompatiblePlugin(factory, ex);
|
||||
catch (Throwable t) {
|
||||
PluginManager.handleComponentError(t, factory.getClass().getName(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,6 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,7 +217,6 @@ public class FileTypeManagerImpl extends FileTypeManagerEx implements NamedJDOME
|
||||
}
|
||||
|
||||
return new Document(root);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -319,7 +319,7 @@ public final class InternalDecorator extends JPanel implements Queryable, TypeSa
|
||||
add(contentPane, BorderLayout.CENTER);
|
||||
setBorder(new InnerPanelBorder(myToolWindow));
|
||||
if (SystemInfo.isMac) {
|
||||
setBackground(Gray._200);
|
||||
setBackground(new JBColor(Gray._200, Gray._90));
|
||||
}
|
||||
|
||||
// Add listeners
|
||||
|
||||
@@ -15,77 +15,42 @@
|
||||
*/
|
||||
package com.intellij.idea;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationInfo;
|
||||
import com.intellij.openapi.application.ApplicationNamesInfo;
|
||||
import com.intellij.openapi.application.ConfigImportHelper;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.impl.ApplicationInfoImpl;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.SystemInfoRt;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.util.PlatformUtils;
|
||||
import com.intellij.util.text.DateFormatUtilRt;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.PlatformUtilsCore;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@SuppressWarnings({"HardCodedStringLiteral", "UseOfSystemOutOrSystemErr", "UnusedDeclaration"})
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public class MainImpl {
|
||||
private static final String LOG_CATEGORY = "#com.intellij.idea.Main";
|
||||
|
||||
private MainImpl() { }
|
||||
|
||||
/**
|
||||
* Called from PluginManager via reflection.
|
||||
*/
|
||||
protected static void start(final String[] args) {
|
||||
System.setProperty(PlatformUtils.PLATFORM_PREFIX_KEY, PlatformUtils.getPlatformPrefix(PlatformUtils.COMMUNITY_PREFIX));
|
||||
System.setProperty(PlatformUtilsCore.PLATFORM_PREFIX_KEY, PlatformUtils.getPlatformPrefix(PlatformUtils.COMMUNITY_PREFIX));
|
||||
|
||||
StartupUtil.isHeadless = Main.isHeadless(args);
|
||||
if (!StartupUtil.isHeadless) {
|
||||
AppUIUtil.updateFrameClass();
|
||||
AppUIUtil.updateWindowIcon(JOptionPane.getRootFrame());
|
||||
AppUIUtil.registerBundledFonts();
|
||||
|
||||
UIUtil.initDefaultLAF();
|
||||
|
||||
final boolean isNewConfigFolder = PathManager.ensureConfigFolderExists(true);
|
||||
if (isNewConfigFolder) {
|
||||
ConfigImportHelper.importConfigsTo(PathManager.getConfigPath());
|
||||
}
|
||||
}
|
||||
|
||||
if (!StartupUtil.checkStartupPossible(args)) { // It uses config folder!
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
Logger.setFactory(LoggerFactory.getInstance());
|
||||
|
||||
final Logger LOG = Logger.getInstance(LOG_CATEGORY);
|
||||
|
||||
StartupUtil.startLogging(LOG);
|
||||
|
||||
_main(args);
|
||||
}
|
||||
|
||||
protected static void _main(final String[] args) {
|
||||
// http://weblogs.java.net/blog/shan_man/archive/2005/06/improved_drag_g.html
|
||||
System.setProperty("sun.swing.enableImprovedDragGesture", "");
|
||||
|
||||
Logger LOG = Logger.getInstance(LOG_CATEGORY);
|
||||
StartupUtil.fixProcessEnvironment(LOG);
|
||||
StartupUtil.loadSystemLibraries(LOG);
|
||||
|
||||
startApplication(args);
|
||||
}
|
||||
|
||||
private static void startApplication(final String[] args) {
|
||||
final IdeaApplication app = new IdeaApplication(args);
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
app.run();
|
||||
StartupUtil.prepareAndStart(args, new StartupUtil.AppStarter() {
|
||||
@Override
|
||||
public void start(boolean newConfigFolder) {
|
||||
final IdeaApplication app = new IdeaApplication(args);
|
||||
//noinspection SSBasedInspection
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
app.run();
|
||||
}
|
||||
catch (PluginManager.StartupAbortedException e) {
|
||||
throw e;
|
||||
}
|
||||
catch (Throwable t) {
|
||||
throw new PluginManager.StartupAbortedException(t);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<extensionPoints>
|
||||
|
||||
<extensionPoint name="xml.startTagEndToken"
|
||||
interface="com.intellij.psi.xml.XmlChildRole$StartTagEndTokenProvider"/>
|
||||
interface="com.intellij.psi.xml.StartTagEndTokenProvider"/>
|
||||
<extensionPoint name="xml.schemaProvider"
|
||||
interface="com.intellij.xml.XmlSchemaProvider"/>
|
||||
<extensionPoint name="xml.xmlExtension"
|
||||
|
||||
+14
-9
@@ -24,6 +24,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.testIntegration.TestLocationProvider;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.TransferToEDTQueue;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -38,7 +39,6 @@ import javax.swing.*;
|
||||
* and name of test method
|
||||
*/
|
||||
public abstract class GeneralTestEventsProcessor implements Disposable {
|
||||
private boolean myDisposed = false;
|
||||
private TransferToEDTQueue<Runnable> myTransferToEDTQueue =
|
||||
new TransferToEDTQueue<Runnable>("SM queue", new Processor<Runnable>() {
|
||||
@Override
|
||||
@@ -99,16 +99,18 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
myDisposed = true;
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myTransferToEDTQueue.drain();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public Condition getDisposedCondition() {
|
||||
return new Condition() {
|
||||
@Override
|
||||
public boolean value(Object o) {
|
||||
return myDisposed;
|
||||
}
|
||||
};
|
||||
return Condition.FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +121,10 @@ public abstract class GeneralTestEventsProcessor implements Disposable {
|
||||
*/
|
||||
public void addToInvokeLater(final Runnable runnable) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isHeadlessEnvironment() && !application.isUnitTestMode() || SwingUtilities.isEventDispatchThread()) {
|
||||
final boolean unitTestMode = application.isUnitTestMode();
|
||||
if (unitTestMode) {
|
||||
UIUtil.invokeLaterIfNeeded(runnable);
|
||||
} else if (application.isHeadlessEnvironment() || SwingUtilities.isEventDispatchThread()) {
|
||||
runnable.run();
|
||||
}
|
||||
else {
|
||||
|
||||
+3
-15
@@ -59,14 +59,12 @@ public class ColumnDuration extends BaseColumn implements Comparator<SMTestProxy
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getRenderer(final SMTestProxy proxy) {
|
||||
return new DurationCellRenderer(proxy);
|
||||
return new DurationCellRenderer();
|
||||
}
|
||||
|
||||
public static class DurationCellRenderer extends ColoredTableCellRenderer implements ColoredRenderer {
|
||||
private final SMTestProxy myProxy;
|
||||
|
||||
public DurationCellRenderer(final SMTestProxy proxy) {
|
||||
myProxy = proxy;
|
||||
public DurationCellRenderer() {
|
||||
}
|
||||
|
||||
public void customizeCellRenderer(final JTable table,
|
||||
@@ -77,17 +75,7 @@ public class ColumnDuration extends BaseColumn implements Comparator<SMTestProxy
|
||||
final int column) {
|
||||
assert value != null;
|
||||
|
||||
final String title = value.toString();
|
||||
|
||||
final SimpleTextAttributes attributes;
|
||||
if (myProxy.isSuite() && ColumnTest.TestsCellRenderer.isFirstLine(row)) {
|
||||
//Black bold for parent suite of items in statistics
|
||||
attributes = SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES;
|
||||
} else {
|
||||
//Black, regular for other suites and tests
|
||||
attributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
|
||||
}
|
||||
append(title, attributes);
|
||||
append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-28
@@ -51,19 +51,10 @@ public class ColumnTest extends BaseColumn implements Comparator<SMTestProxy>{
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getRenderer(final SMTestProxy proxy) {
|
||||
return new TestsCellRenderer(proxy);
|
||||
return new TestsCellRenderer();
|
||||
}
|
||||
|
||||
public static class TestsCellRenderer extends ColoredTableCellRenderer implements ColoredRenderer {
|
||||
@NonNls private static final String TOTAL_TITLE = SMTestsRunnerBundle.message("sm.test.runner.ui.tabs.statistics.columns.test.total.title");
|
||||
@NonNls private static final String PARENT_TITLE = "..";
|
||||
|
||||
private final SMTestProxy myProxy;
|
||||
|
||||
public TestsCellRenderer(final SMTestProxy proxy) {
|
||||
myProxy = proxy;
|
||||
}
|
||||
|
||||
public void customizeCellRenderer(final JTable table,
|
||||
final Object value,
|
||||
final boolean selected,
|
||||
@@ -72,24 +63,7 @@ public class ColumnTest extends BaseColumn implements Comparator<SMTestProxy>{
|
||||
final int column) {
|
||||
assert value != null;
|
||||
|
||||
final String title = value.toString();
|
||||
//Black bold for with caption "Total" for parent suite of items in statistics
|
||||
if (myProxy.isSuite() && isFirstLine(row)) {
|
||||
if (myProxy.getParent() == null) {
|
||||
append(TOTAL_TITLE, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
}
|
||||
else {
|
||||
append(PARENT_TITLE, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
append(" (" + myProxy.getName() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
return;
|
||||
}
|
||||
//Black, regular for other suites and tests
|
||||
append(title, SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
|
||||
public static boolean isFirstLine(final int row) {
|
||||
return row == 0;
|
||||
append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-13
@@ -219,19 +219,10 @@ public class StatisticsPanel implements DataProvider {
|
||||
final int i = myStatisticsTableView.getSelectedRow();
|
||||
assert i >= 0; //because something is selected
|
||||
|
||||
// If first line is selected we should go to parent suite
|
||||
if (ColumnTest.TestsCellRenderer.isFirstLine(i)) {
|
||||
final SMTestProxy parentSuite = selectedProxy.getParent();
|
||||
if (parentSuite != null) {
|
||||
// go to parent and current suit in it
|
||||
showInTableAndSelectRow(parentSuite, selectedProxy);
|
||||
}
|
||||
} else {
|
||||
// if selected element is suite - we should expand it
|
||||
if (selectedProxy.isSuite()) {
|
||||
// expand and select first (Total) row
|
||||
showInTableAndSelectRow(selectedProxy, selectedProxy);
|
||||
}
|
||||
// if selected element is suite - we should expand it
|
||||
if (selectedProxy.isSuite()) {
|
||||
// expand and select first (Total) row
|
||||
showInTableAndSelectRow(selectedProxy, selectedProxy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
+1
-3
@@ -37,7 +37,7 @@ public class StatisticsTableModel extends ListTableModel<SMTestProxy> {
|
||||
|
||||
public StatisticsTableModel() {
|
||||
super(new ColumnTest(), new ColumnDuration(), new ColumnResults());
|
||||
setSortable(false); // TODO: fix me
|
||||
setSortable(true);
|
||||
}
|
||||
|
||||
public void updateModelOnProxySelected(final SMTestProxy proxy) {
|
||||
@@ -95,8 +95,6 @@ public class StatisticsTableModel extends ListTableModel<SMTestProxy> {
|
||||
}
|
||||
|
||||
final List<SMTestProxy> list = new ArrayList<SMTestProxy>();
|
||||
// suite's total statistics
|
||||
list.add(suite);
|
||||
// chiled's statistics
|
||||
list.addAll(suite.getChildren());
|
||||
|
||||
|
||||
+1
-1
@@ -278,7 +278,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest {
|
||||
|
||||
public MyRenderer(final SMTestProxy proxy,
|
||||
final UITestUtil.FragmentsContainer fragmentsContainer) {
|
||||
super(proxy);
|
||||
super();
|
||||
myFragmentsContainer = fragmentsContainer;
|
||||
}
|
||||
|
||||
|
||||
+3
-8
@@ -90,18 +90,13 @@ public class ColumnTestTest extends BaseColumnRenderingTest {
|
||||
final SMTestProxy newRootSuite = createSuiteProxy("root_suite");
|
||||
mySuite.setParent(newRootSuite);
|
||||
doRender(mySuite, 0);
|
||||
assertFragmentsSize(2);
|
||||
assertEquals(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
assertEquals("..", myFragmentsContainer.getTextAt(0));
|
||||
assertEquals(SimpleTextAttributes.GRAYED_ATTRIBUTES, myFragmentsContainer.getAttribsAt(1));
|
||||
assertEquals(" (suite)", myFragmentsContainer.getTextAt(1));
|
||||
assertFragmentsSize(1);
|
||||
}
|
||||
|
||||
public void testTotal_TotalRootSuite() {
|
||||
doRender(mySuite, 0);
|
||||
assertFragmentsSize(1);
|
||||
assertEquals(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
assertEquals("Total:", myFragmentsContainer.getTextAt(0));
|
||||
assertEquals(SimpleTextAttributes.REGULAR_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,7 +115,7 @@ public class ColumnTestTest extends BaseColumnRenderingTest {
|
||||
|
||||
public MyRenderer(final SMTestProxy proxy,
|
||||
final UITestUtil.FragmentsContainer fragmentsContainer) {
|
||||
super(proxy);
|
||||
super();
|
||||
myFragmentsContainer = fragmentsContainer;
|
||||
}
|
||||
|
||||
|
||||
+32
-56
@@ -73,7 +73,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// show suite in table
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
// selects row that corresponds to test1
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(test1, myStatisticsPanel.getSelectedItem());
|
||||
@@ -84,7 +84,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// Check that current suite in table wasn't changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(test1, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testGotoSuite_OnSuite() {
|
||||
@@ -95,18 +95,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// show root suite in table
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
// selects row that corresponds to suite1
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
// Perform action on suite
|
||||
myStatisticsPanel.createGotoSuiteOrParentAction().run();
|
||||
|
||||
// Check that current suite in table was changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testGotoParentSuite_Total() {
|
||||
@@ -117,24 +110,14 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
// show suite in table
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
// selects Total row
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEmpty(myStatisticsPanel.getTableItems());
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
// Perform action on suite
|
||||
myStatisticsPanel.createGotoSuiteOrParentAction().run();
|
||||
|
||||
// Check that current suite in table was changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testGotoParentSuite_TotalRoot() {
|
||||
// create test sturcure
|
||||
final SMTestProxy rootSuite = createSuiteProxy("rootSuite");
|
||||
createSuiteProxy("suite1", rootSuite);
|
||||
final SMTestProxy suite1 = createSuiteProxy("suite1", rootSuite);
|
||||
|
||||
// show root suite in table
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
@@ -142,15 +125,8 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
myStatisticsPanel.selectRow(0);
|
||||
|
||||
// Check that necessary row is selected
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
// Perform action on suite
|
||||
myStatisticsPanel.createGotoSuiteOrParentAction().run();
|
||||
|
||||
// Check that current suite in table wasn't changed.
|
||||
// For it let's select Total row and check selected object
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testChangeSelectionListener() {
|
||||
@@ -165,7 +141,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//suite
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(null, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
public void testChangeSelectionAction() {
|
||||
@@ -190,7 +166,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
//on test
|
||||
myStatisticsPanel.selectProxy(suite1);
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(test1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
myStatisticsPanel.showSelectedProxyInTestsTree();
|
||||
@@ -205,7 +181,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
focusRequestedRef.set(null);
|
||||
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
myStatisticsPanel.selectRow(1);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
myStatisticsPanel.showSelectedProxyInTestsTree();
|
||||
@@ -221,11 +197,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
myStatisticsPanel.selectProxy(rootSuite);
|
||||
myStatisticsPanel.selectRow(0);
|
||||
assertEquals(rootSuite, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(suite1, myStatisticsPanel.getSelectedItem());
|
||||
|
||||
myStatisticsPanel.showSelectedProxyInTestsTree();
|
||||
assertTrue(onSelectedHappend.isSet());
|
||||
assertEquals(rootSuite, proxyRef.get());
|
||||
assertEquals(suite1, proxyRef.get());
|
||||
assertTrue(focusRequestedRef.get());
|
||||
}
|
||||
|
||||
@@ -244,24 +220,24 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteStarted(suite);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteStarted_Child() {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteStarted(test1);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteStarted_Other() {
|
||||
@@ -269,12 +245,12 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_suite = createSuiteProxy("other_suite", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
createTestProxy("test1", suite);
|
||||
createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteStarted(other_suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
}
|
||||
|
||||
public void testOnSuiteFinished_NoCurrent() {
|
||||
@@ -292,24 +268,24 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteFinished(suite);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteFinished_Child() {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
final SMTestProxy test1 = createTestProxy("test1", suite);
|
||||
final SMTestProxy test2 = createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteFinished(test1);
|
||||
assertSameElements(getItems(), suite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSuiteFinished_Other() {
|
||||
@@ -317,12 +293,12 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_suite = createSuiteProxy("other_suite", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
|
||||
createTestProxy("test1", suite);
|
||||
createTestProxy("test2", suite);
|
||||
myTestEventsListener.onSuiteFinished(other_suite);
|
||||
assertSameElements(getItems(), suite);
|
||||
assertSameElements(getItems());
|
||||
}
|
||||
|
||||
public void testOnTestStarted_NoCurrent() {
|
||||
@@ -340,11 +316,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy test1 = createTestProxy("test1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1);
|
||||
assertSameElements(getItems(),test1);
|
||||
|
||||
final SMTestProxy test2 = createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestStarted(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnTestStarted_Other() {
|
||||
@@ -354,11 +330,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_test = createTestProxy("other_test", suite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
|
||||
createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestStarted(other_test);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
}
|
||||
|
||||
public void testOnTestFinished_NoCurrent() {
|
||||
@@ -377,11 +353,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy test1 = createTestProxy("test1", myRootSuite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1);
|
||||
assertSameElements(getItems(), test1);
|
||||
|
||||
final SMTestProxy test2 = createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestFinished(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnTestFinished_Other() {
|
||||
@@ -391,11 +367,11 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy other_test = createTestProxy("other_test", suite);
|
||||
|
||||
myStatisticsPanel.selectProxy(test1);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
|
||||
createTestProxy("test2", myRootSuite);
|
||||
myTestEventsListener.onTestFinished(other_test);
|
||||
assertSameElements(getItems(), myRootSuite, test1, suite);
|
||||
assertSameElements(getItems(), test1, suite);
|
||||
}
|
||||
|
||||
public void testSelectionRestoring_ForTest() {
|
||||
@@ -417,7 +393,7 @@ public class SMTRunnerStatisticsPanelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite = createSuiteProxy("suite1", myRootSuite);
|
||||
myTestEventsListener.onSuiteStarted(suite);
|
||||
|
||||
assertEquals(myRootSuite, myStatisticsPanel.getSelectedItem());
|
||||
assertEquals(null, myStatisticsPanel.getSelectedItem());
|
||||
}
|
||||
|
||||
private List<SMTestProxy> getItems() {
|
||||
|
||||
+5
-4
@@ -18,6 +18,7 @@ package com.intellij.execution.testframework.sm.runner.ui.statistics;
|
||||
import com.intellij.execution.testframework.sm.runner.BaseSMTRunnerTestCase;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -47,7 +48,7 @@ public class SMTRunnerStatisticsTableModelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy test2 = createTestProxy("test2", myRootSuite);
|
||||
myStatisticsTableModel.updateModelOnProxySelected(test1);
|
||||
|
||||
assertSameElements(getItems(), myRootSuite, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
}
|
||||
|
||||
public void testOnSelected_Suite() {
|
||||
@@ -58,13 +59,13 @@ public class SMTRunnerStatisticsTableModelTest extends BaseSMTRunnerTestCase {
|
||||
final SMTestProxy suite2 = createSuiteProxy("suite2", myRootSuite);
|
||||
|
||||
myStatisticsTableModel.updateModelOnProxySelected(suite1);
|
||||
assertSameElements(getItems(), suite1, test1, test2);
|
||||
assertSameElements(getItems(), test1, test2);
|
||||
|
||||
myStatisticsTableModel.updateModelOnProxySelected(suite2);
|
||||
assertSameElements(getItems(), suite2);
|
||||
assertSameElements(getItems());
|
||||
|
||||
myStatisticsTableModel.updateModelOnProxySelected(myRootSuite);
|
||||
assertSameElements(getItems(), myRootSuite, suite1, suite2);
|
||||
assertSameElements(getItems(), suite1, suite2);
|
||||
}
|
||||
/*
|
||||
public void testSort_ColumnTest() {
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.io.ZipUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -66,6 +67,7 @@ import java.awt.event.InvocationEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.*;
|
||||
@@ -769,4 +771,11 @@ public class PlatformTestUtil {
|
||||
public static String loadFileText(@NotNull String fileName) throws IOException {
|
||||
return StringUtil.convertLineSeparators(FileUtil.loadFile(new File(fileName)));
|
||||
}
|
||||
|
||||
public static void tryGcSoftlyReachableObjects() {
|
||||
List<Object> list = ContainerUtil.newArrayList();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
list.add(new SoftReference<byte[]>(new byte[(int)Runtime.getRuntime().freeMemory() / 2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,17 +26,23 @@ public abstract class Logger {
|
||||
Logger getLoggerInstance(String category);
|
||||
}
|
||||
|
||||
public static Factory ourFactory = new Factory() {
|
||||
private static class DefaultFactory implements Factory {
|
||||
@Override
|
||||
public Logger getLoggerInstance(String category) {
|
||||
return new DefaultLogger(category);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Factory ourFactory = new DefaultFactory();
|
||||
|
||||
public static void setFactory(Factory factory) {
|
||||
ourFactory = factory;
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return !(ourFactory instanceof DefaultFactory);
|
||||
}
|
||||
|
||||
public static Logger getInstance(@NonNls String category) {
|
||||
return ourFactory.getLoggerInstance(category);
|
||||
}
|
||||
@@ -48,9 +54,29 @@ public abstract class Logger {
|
||||
public abstract boolean isDebugEnabled();
|
||||
|
||||
public abstract void debug(@NonNls String message);
|
||||
|
||||
public abstract void debug(@Nullable Throwable t);
|
||||
|
||||
public abstract void debug(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void info(@NotNull Throwable t) {
|
||||
info(t.getMessage(), t);
|
||||
}
|
||||
|
||||
public abstract void info(@NonNls String message);
|
||||
|
||||
public abstract void info(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void warn(@NonNls String message) {
|
||||
warn(message, null);
|
||||
}
|
||||
|
||||
public void warn(@NotNull Throwable t) {
|
||||
warn(t.getMessage(), t);
|
||||
}
|
||||
|
||||
public abstract void warn(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void error(@NonNls String message) {
|
||||
error(message, new Throwable(), ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
@@ -70,27 +96,8 @@ public abstract class Logger {
|
||||
error(t.getMessage(), t, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
|
||||
public void warn(@NonNls String message) {
|
||||
warn(message, null);
|
||||
}
|
||||
|
||||
public void warn(@NotNull Throwable t) {
|
||||
warn(t.getMessage(), t);
|
||||
}
|
||||
|
||||
|
||||
public abstract void error(@NonNls String message, @Nullable Throwable t, @NonNls @NotNull String... details);
|
||||
|
||||
public abstract void info(@NonNls String message);
|
||||
|
||||
public abstract void info(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public abstract void warn(@NonNls String message, @Nullable Throwable t);
|
||||
|
||||
public void info(@NotNull Throwable t) {
|
||||
info(t.getMessage(), t);
|
||||
}
|
||||
|
||||
public boolean assertTrue(boolean value, @NonNls Object message) {
|
||||
if (!value) {
|
||||
@NonNls StringBuilder resultMessage = new StringBuilder("Assertion failed");
|
||||
@@ -107,5 +114,4 @@ public abstract class Logger {
|
||||
}
|
||||
|
||||
public abstract void setLevel(Level level);
|
||||
|
||||
}
|
||||
|
||||
@@ -220,13 +220,12 @@ public class UIUtil {
|
||||
if (ourRetina.isNull()) {
|
||||
ourRetina.set(false); // in case HiDPIScaledImage.drawIntoImage is not called for some reason
|
||||
|
||||
String vendor = SystemProperties.getJavaVmVendor();
|
||||
if (SystemInfo.isJavaVersionAtLeast("1.6.0_33") && vendor != null && StringUtil.containsIgnoreCase(vendor, "Apple")) {
|
||||
if (SystemInfo.isJavaVersionAtLeast("1.6.0_33") && SystemInfo.isAppleJvm) {
|
||||
if (!"false".equals(System.getProperty("ide.mac.retina"))) {
|
||||
ourRetina.set(IsRetina.isRetina());
|
||||
return ourRetina.get();
|
||||
}
|
||||
} else if (SystemInfo.isJavaVersionAtLeast("1.7.0_40") && vendor != null && StringUtil.containsIgnoreCase(vendor, "Oracle")) {
|
||||
} else if (SystemInfo.isJavaVersionAtLeast("1.7.0_40") && SystemInfo.isOracleJvm) {
|
||||
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
final GraphicsDevice device = env.getDefaultScreenDevice();
|
||||
try {
|
||||
@@ -1496,11 +1495,7 @@ public class UIUtil {
|
||||
|
||||
public static BufferedImage createImage(int width, int height, int type) {
|
||||
if (isRetina()) {
|
||||
if (SystemInfo.isAppleJvm) {
|
||||
return RetinaImage.create(width, height, type);
|
||||
} else if (SystemInfo.isOracleJvm) {
|
||||
//todo[kb] provide some hidpi scaled image
|
||||
}
|
||||
return RetinaImage.create(width, height, type);
|
||||
}
|
||||
//noinspection UndesirableClassUsage
|
||||
return new BufferedImage(width, height, type);
|
||||
|
||||
@@ -160,8 +160,7 @@ public class XDebugSessionTab extends DebuggerSessionTabBase {
|
||||
DefaultActionGroup leftToolbar = new DefaultActionGroup();
|
||||
final Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
|
||||
if (runner != null && env != null) {
|
||||
RestartAction restartAction = new RestartAction(executor, runner, myRunContentDescriptor.getProcessHandler(),
|
||||
myRunContentDescriptor, env);
|
||||
RestartAction restartAction = new RestartAction(executor, runner, myRunContentDescriptor, env);
|
||||
leftToolbar.add(restartAction);
|
||||
restartAction.registerShortcut(myUi.getComponent());
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.intellij.lang.xml.XmlASTFactory;
|
||||
import com.intellij.openapi.application.PluginPathManager;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.psi.xml.XmlChildRole;
|
||||
import com.intellij.psi.xml.StartTagEndTokenProvider;
|
||||
import com.intellij.testFramework.ParsingTestCase;
|
||||
|
||||
public class AntParsingTest extends ParsingTestCase {
|
||||
@@ -36,8 +36,8 @@ public class AntParsingTest extends ParsingTestCase {
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, new XmlASTFactory());
|
||||
registerExtensionPoint(new ExtensionPointName<XmlChildRole.StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken"),
|
||||
XmlChildRole.StartTagEndTokenProvider.class);
|
||||
registerExtensionPoint(new ExtensionPointName<StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken"),
|
||||
StartTagEndTokenProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml.impl;
|
||||
|
||||
import com.intellij.ide.highlighter.DomSupportEnabled;
|
||||
import com.intellij.ide.startup.StartupManagerEx;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -57,36 +69,44 @@ import java.util.Set;
|
||||
*/
|
||||
public final class DomManagerImpl extends DomManager {
|
||||
private static final Key<Object> MOCK = Key.create("MockElement");
|
||||
|
||||
static final Key<WeakReference<DomFileElementImpl>> CACHED_FILE_ELEMENT = Key.create("CACHED_FILE_ELEMENT");
|
||||
static final Key<DomFileDescription> MOCK_DESCRIPTION = Key.create("MockDescription");
|
||||
|
||||
static final SemKey<FileDescriptionCachedValueProvider> FILE_DESCRIPTION_KEY = SemKey.createKey("FILE_DESCRIPTION_KEY");
|
||||
public static final SemKey<DomInvocationHandler> DOM_HANDLER_KEY = SemKey.createKey("DOM_HANDLER_KEY");
|
||||
static final SemKey<DomInvocationHandler> DOM_HANDLER_KEY = SemKey.createKey("DOM_HANDLER_KEY");
|
||||
static final SemKey<IndexedElementInvocationHandler> DOM_INDEXED_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_INDEXED_HANDLER_KEY");
|
||||
static final SemKey<CollectionElementInvocationHandler> DOM_COLLECTION_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_COLLECTION_HANDLER_KEY");
|
||||
static final SemKey<CollectionElementInvocationHandler> DOM_CUSTOM_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_CUSTOM_HANDLER_KEY");
|
||||
static final SemKey<AttributeChildInvocationHandler> DOM_ATTRIBUTE_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_ATTRIBUTE_HANDLER_KEY");
|
||||
|
||||
private final EventDispatcher<DomEventListener> myListeners = EventDispatcher.create(DomEventListener.class);
|
||||
private final ConverterManagerImpl myConverterManager;
|
||||
|
||||
private final GenericValueReferenceProvider myGenericValueReferenceProvider = new GenericValueReferenceProvider();
|
||||
|
||||
private final Project myProject;
|
||||
private final SemService mySemService;
|
||||
private final ConverterManager myConverterManager;
|
||||
private final DomApplicationComponent myApplicationComponent;
|
||||
private final PsiFileFactory myFileFactory;
|
||||
private final ProjectFileIndex myFileIndex;
|
||||
|
||||
private long myModificationCount;
|
||||
private boolean myChanging;
|
||||
private final ProjectFileIndex myFileIndex;
|
||||
private final SemService mySemService;
|
||||
|
||||
public DomManagerImpl(final Project project, final XmlAspect xmlAspect) {
|
||||
public DomManagerImpl(Project project,
|
||||
final XmlAspect xmlAspect,
|
||||
SemService semService,
|
||||
ConverterManager converterManager,
|
||||
DomApplicationComponent appComponent,
|
||||
PsiFileFactory fileFactory,
|
||||
ProjectFileIndex fileIndex) {
|
||||
myProject = project;
|
||||
mySemService = SemService.getSemService(project);
|
||||
myConverterManager = (ConverterManagerImpl)ServiceManager.getService(ConverterManager.class);
|
||||
myApplicationComponent = DomApplicationComponent.getInstance();
|
||||
final PomModel pomModel = PomManager.getModel(project);
|
||||
mySemService = semService;
|
||||
myConverterManager = converterManager;
|
||||
myApplicationComponent = appComponent;
|
||||
myFileFactory = fileFactory;
|
||||
myFileIndex = fileIndex;
|
||||
|
||||
PomModel pomModel = PomManager.getModel(project);
|
||||
pomModel.addModelListener(new PomModelListener() {
|
||||
public void modelChanged(PomModelEvent event) {
|
||||
final XmlChangeSet changeSet = (XmlChangeSet)event.getChangeSet(xmlAspect);
|
||||
@@ -105,11 +125,7 @@ public final class DomManagerImpl extends DomManager {
|
||||
}
|
||||
}, project);
|
||||
|
||||
myFileFactory = PsiFileFactory.getInstance(project);
|
||||
|
||||
final PsiManager psiManager = PsiManager.getInstance(project);
|
||||
|
||||
final Runnable setupVfsListeners = new Runnable() {
|
||||
Runnable setupVfsListeners = new Runnable() {
|
||||
public void run() {
|
||||
final VirtualFileAdapter listener = new VirtualFileAdapter() {
|
||||
private final List<DomEvent> myDeletionEvents = new SmartList<DomEvent>();
|
||||
@@ -125,7 +141,7 @@ public final class DomManagerImpl extends DomManager {
|
||||
}
|
||||
|
||||
public void beforeFileDeletion(final VirtualFileEvent event) {
|
||||
if (!project.isDisposed()) {
|
||||
if (!myProject.isDisposed()) {
|
||||
beforeFileDeletion(event.getFile());
|
||||
}
|
||||
}
|
||||
@@ -148,7 +164,7 @@ public final class DomManagerImpl extends DomManager {
|
||||
|
||||
public void fileDeleted(VirtualFileEvent event) {
|
||||
if (!myDeletionEvents.isEmpty()) {
|
||||
if (!project.isDisposed()) {
|
||||
if (!myProject.isDisposed()) {
|
||||
for (DomEvent domEvent : myDeletionEvents) {
|
||||
fireEvent(domEvent);
|
||||
}
|
||||
@@ -164,18 +180,17 @@ public final class DomManagerImpl extends DomManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(listener, project);
|
||||
VirtualFileManager.getInstance().addVirtualFileListener(listener, myProject);
|
||||
}
|
||||
};
|
||||
|
||||
final StartupManager startupManager = StartupManager.getInstance(project);
|
||||
StartupManager startupManager = StartupManager.getInstance(project);
|
||||
if (!((StartupManagerEx)startupManager).startupActivityPassed()) {
|
||||
startupManager.registerStartupActivity(setupVfsListeners);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
setupVfsListeners.run();
|
||||
}
|
||||
|
||||
myFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
}
|
||||
|
||||
private void processVfsChange(final VirtualFile file) {
|
||||
@@ -507,7 +522,4 @@ public final class DomManagerImpl extends DomManager {
|
||||
public SemService getSemService() {
|
||||
return mySemService;
|
||||
}
|
||||
|
||||
|
||||
private final static Logger LOG = Logger.getInstance(DomManagerImpl.class);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
@@ -11,13 +23,14 @@ import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.xml.highlighting.*;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class DomAnnotationsTest extends DomTestCase{
|
||||
public class DomAnnotationsTest extends DomTestCase {
|
||||
|
||||
@Override
|
||||
protected <T extends DomElement> T createElement(final String xml, final Class<T> aClass) {
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -11,6 +26,7 @@ import com.intellij.util.Function;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
@@ -16,6 +28,7 @@ import com.intellij.semantic.SemService;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.Timings;
|
||||
import com.intellij.util.xml.impl.DomFileElementImpl;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.reflect.DomExtender;
|
||||
import com.intellij.util.xml.reflect.DomExtenderEP;
|
||||
import com.intellij.util.xml.reflect.DomExtensionsRegistrar;
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
@@ -9,6 +21,7 @@ import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ParameterizedTypeImpl;
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.reflect.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
@@ -14,8 +26,8 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.psi.xml.XmlTagValue;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomApplicationComponent;
|
||||
import com.intellij.util.xml.impl.DomManagerImpl;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
@@ -22,6 +34,7 @@ import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.testFramework.MockSchemesManagerFactory;
|
||||
import com.intellij.util.xml.highlighting.*;
|
||||
import com.intellij.util.xml.impl.DefaultDomAnnotator;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
@@ -1,16 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2006 JetBrains s.r.o. All Rights Reserved.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class DomModelMergingTest extends DomTestCase{
|
||||
public class DomModelMergingTest extends DomTestCase {
|
||||
private ModelMerger myMerger;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
@@ -9,6 +20,7 @@ import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.xml.impl.DomFileElementImpl;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.reflect.DomGenericInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
@@ -7,6 +22,7 @@ import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
import com.intellij.util.xml.ui.DomUIFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml;
|
||||
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomTestCase;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public class SimpleValuesIncrementalUpdateTest extends DomTestCase{
|
||||
public class SimpleValuesIncrementalUpdateTest extends DomTestCase {
|
||||
|
||||
public void testAttributeChange() throws Throwable {
|
||||
final MyElement element = createElement("<a/>");
|
||||
|
||||
+18
-6
@@ -1,4 +1,19 @@
|
||||
package com.intellij.util.xml;
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml.impl;
|
||||
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
@@ -10,11 +25,8 @@ import com.intellij.psi.xml.XmlFile;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.*;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
import com.intellij.util.xml.impl.DomApplicationComponent;
|
||||
import com.intellij.util.xml.impl.DomFileElementImpl;
|
||||
import com.intellij.util.xml.impl.DomInvocationHandler;
|
||||
import com.intellij.util.xml.impl.DomManagerImpl;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -72,7 +84,7 @@ public abstract class DomTestCase extends LightIdeaTestCase {
|
||||
return element;
|
||||
}
|
||||
|
||||
protected static <T extends DomElement> T createElement(final DomManager domManager, final String xml, final Class<T> aClass)
|
||||
public static <T extends DomElement> T createElement(final DomManager domManager, final String xml, final Class<T> aClass)
|
||||
throws IncorrectOperationException {
|
||||
final String name = "a.xml";
|
||||
final XmlFile file = (XmlFile)PsiFileFactory.getInstance(domManager.getProject()).createFileFromText(name, xml);
|
||||
@@ -1,10 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.util.xml.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.xml.DomElement;
|
||||
import com.intellij.util.xml.DomTestCase;
|
||||
import com.intellij.util.xml.SubTag;
|
||||
import com.intellij.util.xml.events.DomEvent;
|
||||
|
||||
|
||||
+16
-10
@@ -25,12 +25,12 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.impl.source.xml.TagNameReference;
|
||||
import com.intellij.psi.xml.XmlTag;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.xml.XmlTagNameProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -52,15 +52,21 @@ public class TagNameReferenceCompletionProvider extends CompletionProvider<Compl
|
||||
PsiReference reference = parameters.getPosition().getContainingFile().findReferenceAt(parameters.getOffset());
|
||||
if (reference instanceof TagNameReference) {
|
||||
TagNameReference tagNameReference = (TagNameReference)reference;
|
||||
PsiElement element = tagNameReference.getElement();
|
||||
if (element instanceof XmlTag) {
|
||||
if (!tagNameReference.isStartTagFlag()) {
|
||||
result.addElement(createClosingTagLookupElement((XmlTag)element, false, tagNameReference.getNameElement()));
|
||||
}
|
||||
else {
|
||||
XmlTag tag = (XmlTag) element;
|
||||
LookupElement[] variants = getTagNameVariants(tag, tag.getNamespacePrefix());
|
||||
result.addAllElements(Arrays.asList(variants));
|
||||
collectCompletionVariants(tagNameReference, result);
|
||||
}
|
||||
}
|
||||
|
||||
public static void collectCompletionVariants(TagNameReference tagNameReference,
|
||||
Consumer<LookupElement> consumer) {
|
||||
PsiElement element = tagNameReference.getElement();
|
||||
if (element instanceof XmlTag) {
|
||||
if (!tagNameReference.isStartTagFlag()) {
|
||||
consumer.consume(createClosingTagLookupElement((XmlTag)element, false, tagNameReference.getNameElement()));
|
||||
}
|
||||
else {
|
||||
XmlTag tag = (XmlTag) element;
|
||||
for(LookupElement variant: getTagNameVariants(tag, tag.getNamespacePrefix())) {
|
||||
consumer.consume(variant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class SwitchToHtml5Action implements LocalQuickFix, IntentionAction {
|
||||
}
|
||||
|
||||
private static void applyFix(Project project) {
|
||||
ExternalResourceManagerEx.getInstanceEx().setDefaultHtmlDoctype(Html5SchemaProvider.HTML5_SCHEMA_LOCATION, project);
|
||||
ExternalResourceManagerEx.getInstanceEx().setDefaultHtmlDoctype(Html5SchemaProvider.getHtml5SchemaLocation(), project);
|
||||
DaemonCodeAnalyzer.getInstance(project).restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class DefaultHtmlDoctypeInitialConfigurator {
|
||||
if (!propertiesComponent.getBoolean("DefaultHtmlDoctype.MigrateToHtml5", false)) {
|
||||
propertiesComponent.setValue("DefaultHtmlDoctype.MigrateToHtml5", Boolean.TRUE.toString());
|
||||
ExternalResourceManagerEx.getInstanceEx()
|
||||
.setDefaultHtmlDoctype(Html5SchemaProvider.HTML5_SCHEMA_LOCATION, projectManager.getDefaultProject());
|
||||
.setDefaultHtmlDoctype(Html5SchemaProvider.getHtml5SchemaLocation(), projectManager.getDefaultProject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +461,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
return XmlUtil.XHTML4_SCHEMA_LOCATION;
|
||||
}
|
||||
else if (HTML5_DOCTYPE_ELEMENT.equals(doctype)) {
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
return Html5SchemaProvider.getHtml5SchemaLocation();
|
||||
}
|
||||
else {
|
||||
return doctype;
|
||||
@@ -496,7 +496,7 @@ public class ExternalResourceManagerImpl extends ExternalResourceManagerEx imple
|
||||
private void setDefaultHtmlDoctype(String defaultHtmlDoctype) {
|
||||
myModificationCount++;
|
||||
|
||||
if (Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(defaultHtmlDoctype)) {
|
||||
if (Html5SchemaProvider.getHtml5SchemaLocation().equals(defaultHtmlDoctype)) {
|
||||
myDefaultHtmlDoctype = HTML5_DOCTYPE_ELEMENT;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class HtmlLanguageLevelForm {
|
||||
return XmlUtil.XHTML_URI;
|
||||
}
|
||||
if (myHtml5RadioButton.isSelected()) {
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
return Html5SchemaProvider.getHtml5SchemaLocation();
|
||||
}
|
||||
return myDoctypeTextField.getText();
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class HtmlLanguageLevelForm {
|
||||
myHtml4RadioButton.setSelected(true);
|
||||
myDoctypeTextField.setEnabled(false);
|
||||
}
|
||||
else if (doctype.equals(Html5SchemaProvider.HTML5_SCHEMA_LOCATION)) {
|
||||
else if (doctype.equals(Html5SchemaProvider.getHtml5SchemaLocation())) {
|
||||
myHtml5RadioButton.setSelected(true);
|
||||
myDoctypeTextField.setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ public class XmlParsingTest extends ParsingTestCase {
|
||||
addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, XMLLanguage.INSTANCE, new XmlASTFactory());
|
||||
addExplicitExtension(LanguageASTFactory.INSTANCE, DTDLanguage.INSTANCE, new XmlASTFactory());
|
||||
registerExtensionPoint(new ExtensionPointName<XmlChildRole.StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken"),
|
||||
XmlChildRole.StartTagEndTokenProvider.class);
|
||||
registerExtensionPoint(StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -218,7 +218,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument {
|
||||
if (nsDescriptor == null) {
|
||||
String htmlns = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(getProject());
|
||||
if (htmlns.length() == 0) {
|
||||
htmlns = Html5SchemaProvider.HTML5_SCHEMA_LOCATION;
|
||||
htmlns = Html5SchemaProvider.getHtml5SchemaLocation();
|
||||
}
|
||||
nsDescriptor = getDefaultNSDescriptor(htmlns, false);
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument {
|
||||
else if (XmlUtil.XHTML_URI.equals(namespace)) {
|
||||
String xhtmlNamespace = XmlUtil.getDefaultXhtmlNamespace(getProject());
|
||||
if (xhtmlNamespace == null || xhtmlNamespace.length() == 0) {
|
||||
xhtmlNamespace = Html5SchemaProvider.XHTML5_SCHEMA_LOCATION;
|
||||
xhtmlNamespace = Html5SchemaProvider.getXhtml5SchemaLocation();
|
||||
}
|
||||
return getDefaultNSDescriptor(xhtmlNamespace, false);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.intellij.psi.xml;
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
public interface StartTagEndTokenProvider {
|
||||
ExtensionPointName<StartTagEndTokenProvider> EP_NAME = new ExtensionPointName<StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken");
|
||||
|
||||
IElementType[] getTypes();
|
||||
}
|
||||
@@ -16,11 +16,9 @@
|
||||
package com.intellij.psi.xml;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.tree.DefaultRoleFinder;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.RoleFinder;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.xml.util.XmlTagUtil;
|
||||
@@ -29,12 +27,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface XmlChildRole {
|
||||
|
||||
interface StartTagEndTokenProvider {
|
||||
IElementType[] getTypes();
|
||||
}
|
||||
|
||||
ExtensionPointName<StartTagEndTokenProvider> EP_NAME = new ExtensionPointName<StartTagEndTokenProvider>("com.intellij.xml.startTagEndToken");
|
||||
|
||||
RoleFinder START_TAG_NAME_FINDER = new RoleFinder() {
|
||||
public ASTNode findChild(@NotNull ASTNode parent) {
|
||||
final PsiElement element = XmlTagUtil.getStartTagNameElement((XmlTag)parent.getPsi());
|
||||
@@ -65,7 +57,7 @@ public interface XmlChildRole {
|
||||
RoleFinder ATTRIBUTE_VALUE_VALUE_FINDER = new DefaultRoleFinder(XmlTokenType.XML_ATTRIBUTE_VALUE_TOKEN);
|
||||
RoleFinder START_TAG_END_FINDER = new DefaultRoleFinder(XmlTokenType.XML_TAG_END) {
|
||||
{
|
||||
final StartTagEndTokenProvider[] tokenProviders = Extensions.getExtensions(EP_NAME);
|
||||
final StartTagEndTokenProvider[] tokenProviders = Extensions.getExtensions(StartTagEndTokenProvider.EP_NAME);
|
||||
for (StartTagEndTokenProvider tokenProvider : tokenProviders) {
|
||||
myElementTypes = ArrayUtil.mergeArrays(myElementTypes, tokenProvider.getTypes());
|
||||
}
|
||||
|
||||
@@ -17,16 +17,25 @@ public abstract class Html5SchemaProvider {
|
||||
|
||||
public static final ExtensionPointName<Html5SchemaProvider> EP_NAME = ExtensionPointName.create("com.intellij.xml.html5SchemaProvider");
|
||||
|
||||
public static final String HTML5_SCHEMA_LOCATION;
|
||||
public static final String XHTML5_SCHEMA_LOCATION;
|
||||
private static String HTML5_SCHEMA_LOCATION;
|
||||
private static String XHTML5_SCHEMA_LOCATION;
|
||||
|
||||
@NotNull
|
||||
public abstract URL getHtmlSchemaLocation();
|
||||
private static boolean ourInitialized;
|
||||
|
||||
@NotNull
|
||||
public abstract URL getXhtmlSchemaLocation();
|
||||
public static String getHtml5SchemaLocation() {
|
||||
ensureInitialized();
|
||||
return HTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
|
||||
public static String getXhtml5SchemaLocation() {
|
||||
ensureInitialized();
|
||||
return XHTML5_SCHEMA_LOCATION;
|
||||
}
|
||||
|
||||
private synchronized static void ensureInitialized() {
|
||||
if (ourInitialized) return;
|
||||
ourInitialized = true;
|
||||
|
||||
static {
|
||||
final Html5SchemaProvider[] providers = EP_NAME.getExtensions();
|
||||
final URL htmlSchemaLocationURL;
|
||||
final URL xhtmlSchemaLocationURL;
|
||||
@@ -48,11 +57,20 @@ public abstract class Html5SchemaProvider {
|
||||
|
||||
HTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
|
||||
URLUtil.unescapePercentSequences(htmlSchemaLocationURL.toExternalForm())));
|
||||
LOG.info("HTML5_SCHEMA_LOCATION = " + HTML5_SCHEMA_LOCATION);
|
||||
LOG.info("HTML5_SCHEMA_LOCATION = " + getHtml5SchemaLocation());
|
||||
|
||||
XHTML5_SCHEMA_LOCATION = VfsUtilCore.urlToPath(VfsUtilCore.fixURLforIDEA(
|
||||
URLUtil.unescapePercentSequences(xhtmlSchemaLocationURL.toExternalForm())));
|
||||
LOG.info("XHTML5_SCHEMA_LOCATION = " + XHTML5_SCHEMA_LOCATION);
|
||||
LOG.info("XHTML5_SCHEMA_LOCATION = " + getXhtml5SchemaLocation());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract URL getHtmlSchemaLocation();
|
||||
|
||||
@NotNull
|
||||
public abstract URL getXhtmlSchemaLocation();
|
||||
|
||||
static {
|
||||
}
|
||||
|
||||
private static <T> String getClassesListString(T[] a) {
|
||||
|
||||
@@ -26,7 +26,7 @@ import com.intellij.psi.impl.cache.impl.id.IdIndexers;
|
||||
import com.intellij.psi.impl.cache.impl.idCache.XmlIdIndexer;
|
||||
import com.intellij.psi.impl.source.xml.XmlElementDescriptorProvider;
|
||||
import com.intellij.psi.meta.MetaDataContributor;
|
||||
import com.intellij.psi.xml.XmlChildRole;
|
||||
import com.intellij.psi.xml.StartTagEndTokenProvider;
|
||||
import com.intellij.psi.xml.XmlFileNSInfoProvider;
|
||||
import com.intellij.util.indexing.FileBasedIndexExtension;
|
||||
import com.intellij.xml.index.XmlNamespaceIndex;
|
||||
@@ -57,7 +57,7 @@ public class XmlCoreEnvironment {
|
||||
appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer());
|
||||
appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer());
|
||||
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlChildRole.EP_NAME, XmlChildRole.StartTagEndTokenProvider.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSuppressionProvider.EP_NAME, XmlSuppressionProvider.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlFileNSInfoProvider.EP_NAME, XmlFileNSInfoProvider.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(Extensions.getRootArea(), XmlSchemaProvider.EP_NAME, XmlSchemaProvider.class);
|
||||
|
||||
@@ -374,7 +374,7 @@ public class HtmlUtil {
|
||||
|
||||
if (doctype == null) {
|
||||
LOG.debug("DOCTYPE for " + htmlFileFullName + " is null");
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION
|
||||
return Html5SchemaProvider.getHtml5SchemaLocation()
|
||||
.equals(ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(doc.getProject()));
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ public class XmlUtil {
|
||||
@NonNls public static final String NO_NAMESPACE_SCHEMA_LOCATION_ATT = "noNamespaceSchemaLocation";
|
||||
@NonNls public static final String SCHEMA_LOCATION_ATT = "schemaLocation";
|
||||
@NonNls public static final String[] WEB_XML_URIS =
|
||||
{"http://java.sun.com/xml/ns/j2ee", "http://java.sun.com/xml/ns/javaee", "http://java.sun.com/dtd/web-app_2_3.dtd",
|
||||
{"http://java.sun.com/xml/ns/j2ee", "http://java.sun.com/xml/ns/javaee", "http://xmlns.jcp.org/xml/ns/javaee", "http://java.sun.com/dtd/web-app_2_3.dtd",
|
||||
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"};
|
||||
|
||||
@NonNls public static final String FACELETS_URI = "http://java.sun.com/jsf/facelets";
|
||||
@@ -613,8 +613,8 @@ public class XmlUtil {
|
||||
|
||||
public static String getDefaultXhtmlNamespace(Project project) {
|
||||
final String doctype = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(project);
|
||||
return Html5SchemaProvider.HTML5_SCHEMA_LOCATION.equals(doctype)
|
||||
? Html5SchemaProvider.XHTML5_SCHEMA_LOCATION
|
||||
return Html5SchemaProvider.getHtml5SchemaLocation().equals(doctype)
|
||||
? Html5SchemaProvider.getXhtml5SchemaLocation()
|
||||
: doctype;
|
||||
}
|
||||
|
||||
@@ -782,8 +782,8 @@ public class XmlUtil {
|
||||
}
|
||||
else if (HtmlUtil.isHtml5Doctype(doctype)) {
|
||||
docType = doctype.getLanguage() instanceof HTMLLanguage
|
||||
? Html5SchemaProvider.HTML5_SCHEMA_LOCATION
|
||||
: Html5SchemaProvider.XHTML5_SCHEMA_LOCATION;
|
||||
? Html5SchemaProvider.getHtml5SchemaLocation()
|
||||
: Html5SchemaProvider.getXhtml5SchemaLocation();
|
||||
}
|
||||
}
|
||||
return docType;
|
||||
|
||||
Reference in New Issue
Block a user