diff --git a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java index 5c1b585391d4..bc7915f62a47 100644 --- a/java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java +++ b/java/debugger/impl/src/com/intellij/debugger/DefaultDebugUIEnvironment.java @@ -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); diff --git a/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java b/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java index 7bf07bf64518..76e7175b87ff 100644 --- a/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java +++ b/java/execution/impl/src/com/intellij/execution/actions/JavaRerunFailedTestsAction.java @@ -37,7 +37,7 @@ public class JavaRerunFailedTestsAction extends AbstractRerunFailedTestsAction { @NotNull @Override protected Filter getFilter(Project project, GlobalSearchScope searchScope) { - return Filter.FAILED_OR_INTERRUPTED.and(JavaAwareFilter.METHOD(project, searchScope)); + return super.getFilter(project, searchScope).and(JavaAwareFilter.METHOD(project, searchScope)); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index 5354932c4201..55055c93b83c 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -1936,6 +1936,11 @@ public class HighlightUtil extends HighlightUtilBase { !thisOrSuperReference(((PsiReferenceExpression)expression).getQualifierExpression(), aClass)) { return null; } + + if (expression instanceof PsiJavaCodeReferenceElement && !aClass.equals(PsiTreeUtil.getParentOfType(expression, PsiClass.class))) { + return null; + } + final HighlightInfo highlightInfo = createMemberReferencedError(resolvedName, expression.getTextRange()); if (expression instanceof PsiReferenceExpression && PsiUtil.isInnerClass(aClass)) { final String referenceName = ((PsiReferenceExpression)expression).getReferenceName(); diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java index ba6b5f1dcf77..51ae457b4fc0 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreApplicationEnvironment.java @@ -51,8 +51,7 @@ public class JavaCoreApplicationEnvironment extends CoreApplicationEnvironment { registerFileType(JavaClassFileType.INSTANCE, "class"); registerFileType(JavaFileType.INSTANCE, "java"); - registerFileType(ArchiveFileType.INSTANCE, "jar"); - registerFileType(ArchiveFileType.INSTANCE, "zip"); + registerFileType(ArchiveFileType.INSTANCE, "jar;zip"); addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileViewProviderFactory()); addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder()); diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ReferenceMemberBeforeCtrCalled.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ReferenceMemberBeforeCtrCalled.java index fec91bc2dbb6..bafdc02117c7 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ReferenceMemberBeforeCtrCalled.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/ReferenceMemberBeforeCtrCalled.java @@ -1,5 +1,7 @@ // reference before ctr called import java.io.*; +import java.lang.Override; +import java.lang.String; import java.net.*; class A { @@ -171,4 +173,32 @@ class WithAnonymous { } } +} + +class InnerClassRefInsideAnonymous { + static class Foo {} + static class SuperClass { + SuperClass(Foo foo) { + } + + SuperClass(String s, Foo foo) { + } + } + + static class Child extends SuperClass { + Child(Foo foo) { + super(new Foo() { + public String toString() { + AFoo afoo = null; + return super.toString(); + } + }); + } + + Child(String s, Foo foo) { + super(s, new AFoo()); + } + + class AFoo extends Foo {} + } } \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/index/IndexTest.java b/java/java-tests/testSrc/com/intellij/index/IndexTest.java new file mode 100644 index 000000000000..6b84a760f4e1 --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/index/IndexTest.java @@ -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>>() { + @Override + public PersistentHashMap> 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> createMetaIndex(File metaIndexFile) throws IOException { + return new PersistentHashMap>(metaIndexFile, new EnumeratorIntegerDescriptor(), new DataExternalizer>() { + @Override + public void save(DataOutput out, Collection value) throws IOException { + DataInputOutputUtil.writeINT(out, value.size()); + for (String key : value) { + out.writeUTF(key); + } + } + + @Override + public Collection read(DataInput in) throws IOException { + final int size = DataInputOutputUtil.readINT(in); + final List list = new ArrayList(); + 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 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 data = stubUpdatingIndex.getData(fileId); + final List 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 void assertDataEquals(List actual, T... expected) { + assertTrue(new HashSet(Arrays.asList(expected)).equals(new HashSet(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(); + } + }); + } + +} diff --git a/java/java-tests/testSrc/com/intellij/index/StringIndex.java b/java/java-tests/testSrc/com/intellij/index/StringIndex.java new file mode 100644 index 000000000000..e48d5be0e0ca --- /dev/null +++ b/java/java-tests/testSrc/com/intellij/index/StringIndex.java @@ -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 myIndex; + + public StringIndex(final IndexStorage storage, final Factory>> factory) + throws IOException { + myIndex = new MapReduceIndex(null, new Indexer(), storage); + myIndex.setInputIdToDataKeysIndex(factory); + } + + public List 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 { + @Override + @NotNull + public Map map(final PathContentPair inputData) { + final Map _map = new HashMap(); + 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; + } + } + +} diff --git a/platform/bootstrap/src/com/intellij/ide/Bootstrap.java b/platform/bootstrap/src/com/intellij/ide/Bootstrap.java index 5853fcf99601..05280434f3d0 100644 --- a/platform/bootstrap/src/com/intellij/ide/Bootstrap.java +++ b/platform/bootstrap/src/com/intellij/ide/Bootstrap.java @@ -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()); } - public static void main(final String[] args, final String mainClass, final String methodName, final List 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 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); } } \ No newline at end of file diff --git a/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java b/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java index 84461aded7c9..6d6f715d026d 100644 --- a/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java +++ b/platform/bootstrap/src/com/intellij/ide/ClassloaderUtil.java @@ -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 classpathElements) { + public static UrlClassLoader initClassloader(final List 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; } diff --git a/platform/bootstrap/src/com/intellij/idea/Main.java b/platform/bootstrap/src/com/intellij/idea/Main.java index f67a902d8afc..182946c2c786 100644 --- a/platform/bootstrap/src/com/intellij/idea/Main.java +++ b/platform/bootstrap/src/com/intellij/idea/Main.java @@ -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 args = new ArrayList(); - if (SystemInfo.isWindows) { - args.add(Restarter.createTempExecutable(new File(PathManager.getBinPath(), "vistalauncher.exe")).getPath()); + int status = 0; + if (Restarter.isSupported()) { + List args = new ArrayList(); + + 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); + } } } diff --git a/platform/core-api/src/com/intellij/diagnostic/PluginException.java b/platform/core-api/src/com/intellij/diagnostic/PluginException.java index 1710d05cd34a..3a520ebc466c 100644 --- a/platform/core-api/src/com/intellij/diagnostic/PluginException.java +++ b/platform/core-api/src/com/intellij/diagnostic/PluginException.java @@ -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; diff --git a/platform/core-api/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java b/platform/core-api/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java index b695b651e51f..077fa0ffb2b9 100644 --- a/platform/core-api/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java +++ b/platform/core-api/src/com/intellij/openapi/vfs/impl/BulkVirtualFileListenerAdapter.java @@ -44,7 +44,7 @@ public class BulkVirtualFileListenerAdapter implements BulkFileListener { public void before(@NotNull final List events) { for (VFileEvent event : events) { if (myFileSystem == null || myFileSystem == event.getFileSystem()) { - fireBefore(event); + fireBefore(myAdapted, event); } } } @@ -53,16 +53,16 @@ public class BulkVirtualFileListenerAdapter implements BulkFileListener { public void after(@NotNull final List events) { for (VFileEvent event : events) { if (myFileSystem == null || myFileSystem == event.getFileSystem()) { - fireAfter(event); + fireAfter(myAdapted, event); } } } - private void fireAfter(final VFileEvent event) { + public static void fireAfter(VirtualFileListener adapted, final VFileEvent event) { if (event instanceof VFileContentChangeEvent) { final VFileContentChangeEvent ce = (VFileContentChangeEvent)event; final VirtualFile file = ce.getFile(); - myAdapted.contentsChanged( + adapted.contentsChanged( new VirtualFileEvent(event.getRequestor(), file, file.getParent(), ce.getOldModificationStamp(), ce.getModificationStamp())); } else if (event instanceof VFileCopyEvent) { @@ -70,49 +70,49 @@ public class BulkVirtualFileListenerAdapter implements BulkFileListener { final VirtualFile original = ce.getFile(); final VirtualFile copy = ce.getNewParent().findChild(ce.getNewChildName()); if (original != null && copy != null) { - myAdapted.fileCopied(new VirtualFileCopyEvent(event.getRequestor(), original, copy)); + adapted.fileCopied(new VirtualFileCopyEvent(event.getRequestor(), original, copy)); } } else if (event instanceof VFileCreateEvent) { final VFileCreateEvent ce = (VFileCreateEvent)event; final VirtualFile newChild = ce.getFile(); if (newChild != null) { - myAdapted.fileCreated(new VirtualFileEvent(event.getRequestor(), newChild, ce.getChildName(), ce.getParent())); + adapted.fileCreated(new VirtualFileEvent(event.getRequestor(), newChild, ce.getChildName(), ce.getParent())); } } else if (event instanceof VFileDeleteEvent) { final VFileDeleteEvent de = (VFileDeleteEvent)event; - myAdapted.fileDeleted(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0)); + adapted.fileDeleted(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0)); } else if (event instanceof VFileMoveEvent) { final VFileMoveEvent me = (VFileMoveEvent)event; - myAdapted.fileMoved(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent())); + adapted.fileMoved(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent())); } else if (event instanceof VFilePropertyChangeEvent) { final VFilePropertyChangeEvent pce = (VFilePropertyChangeEvent)event; - myAdapted.propertyChanged( + adapted.propertyChanged( new VirtualFilePropertyEvent(event.getRequestor(), pce.getFile(), pce.getPropertyName(), pce.getOldValue(), pce.getNewValue())); } } - private void fireBefore(final VFileEvent event) { + public static void fireBefore(VirtualFileListener adapted, final VFileEvent event) { if (event instanceof VFileContentChangeEvent) { final VFileContentChangeEvent ce = (VFileContentChangeEvent)event; final VirtualFile file = ce.getFile(); - myAdapted.beforeContentsChange( + adapted.beforeContentsChange( new VirtualFileEvent(event.getRequestor(), file, file.getParent(), ce.getOldModificationStamp(), ce.getModificationStamp())); } else if (event instanceof VFileDeleteEvent) { final VFileDeleteEvent de = (VFileDeleteEvent)event; - myAdapted.beforeFileDeletion(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0)); + adapted.beforeFileDeletion(new VirtualFileEvent(event.getRequestor(), de.getFile(), de.getFile().getParent(), 0, 0)); } else if (event instanceof VFileMoveEvent) { final VFileMoveEvent me = (VFileMoveEvent)event; - myAdapted.beforeFileMovement(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent())); + adapted.beforeFileMovement(new VirtualFileMoveEvent(event.getRequestor(), me.getFile(), me.getOldParent(), me.getNewParent())); } else if (event instanceof VFilePropertyChangeEvent) { final VFilePropertyChangeEvent pce = (VFilePropertyChangeEvent)event; - myAdapted.beforePropertyChange( + adapted.beforePropertyChange( new VirtualFilePropertyEvent(event.getRequestor(), pce.getFile(), pce.getPropertyName(), pce.getOldValue(), pce.getNewValue())); } } diff --git a/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java b/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java index 7efc8cca3b09..5427d88cc303 100644 --- a/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java +++ b/platform/core-impl/src/com/intellij/core/CoreFileTypeRegistry.java @@ -64,9 +64,11 @@ public class CoreFileTypeRegistry extends FileTypeRegistry { return result == null ? UnknownFileType.INSTANCE : result; } - public void registerFileType(FileType fileType, String extension) { + public void registerFileType(@NotNull FileType fileType, @NotNull @NonNls String extension) { myAllFileTypes.add(fileType); - myExtensionsMap.put(extension, fileType); + for (final String ext : extension.split(";")) { + myExtensionsMap.put(ext, fileType); + } } @NotNull diff --git a/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java b/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java index e231cb1e3ea6..a33f22150dae 100644 --- a/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/components/impl/ComponentManagerImpl.java @@ -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 myInterfaceToLockMap = new THashMap(); private final Map myInterfaceToClassMap = new THashMap(); - private final ArrayList myComponentInterfaces = new ArrayList(); // keeps order of component's registration + private final List myComponentInterfaces = new ArrayList(); // keeps order of component's registration private final Map myNameToComponent = new THashMap(); private final List myComponentConfigs = new ArrayList(); private final List myImplementations = new ArrayList(); @@ -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); } } } diff --git a/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java b/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java index 684fb56e7c0b..c3ac3b0c4e37 100644 --- a/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java +++ b/platform/core-impl/src/com/intellij/pom/tree/events/impl/TreeChangeImpl.java @@ -122,17 +122,17 @@ public class TreeChangeImpl implements TreeChange { } myChanges.put(child, info); } - - private static boolean ourDoAddChangeAtOffsetChecks = ourDoChecks; + + private static boolean ourEnableAddChangeAtOffsetOptimization = true; private void addChangeAtOffset(final ASTNode child, final int nodeOffset) { int optimizedIndex = haveNotCalculated; - if (mySortedChanges.size() > 0) { // check adding at end + if (ourEnableAddChangeAtOffsetOptimization && mySortedChanges.size() > 0) { // check adding at end Pair pair = mySortedChanges.get(mySortedChanges.size() - 1); if (pair.getFirst() == child.getTreePrev() && pair.getSecond() <= nodeOffset) { optimizedIndex = mySortedChanges.size(); - if (!ourDoAddChangeAtOffsetChecks) { + if (!ourDoChecks) { mySortedChanges.add(new Pair(child, Integer.valueOf(nodeOffset))); return; } @@ -157,7 +157,7 @@ public class TreeChangeImpl implements TreeChange { ChangeInfo changeInfo = myChanges.get(child); ASTNode prev = child.getTreePrev(); LOG.error("Failed to calculate optimized index for add change at offset:"+changeInfo + "," + prev + "," + myChanges.get(prev)); - ourDoAddChangeAtOffsetChecks = false; + ourEnableAddChangeAtOffsetOptimization = false; } } } @@ -330,9 +330,11 @@ public class TreeChangeImpl implements TreeChange { private static final int haveNotCalculated = -1; - private static boolean ourDoOptimizedNodeOldOffsetChecks = ourDoChecks; + private static boolean ourEnableOptimizedNodeOldOffset = true; private int getOptimizedNodeOldOffset(ASTNode child, ChangeInfo changeInfo) { + if (!ourEnableOptimizedNodeOldOffset) return haveNotCalculated; + // we usually add / remove ranges so old offset can be tried to calculate from change with previous sibling ASTNode prevSibling = child.getTreePrev(); if (prevSibling != null) { @@ -349,11 +351,11 @@ public class TreeChangeImpl implements TreeChange { ) ) { int optimizedResult = pair.getSecond() + prevSiblingChange.getOldLength(); - if (ourDoOptimizedNodeOldOffsetChecks) { + if (ourDoChecks) { int oldOffset = calculateOldOffsetLinearly(child); if (optimizedResult != oldOffset) { LOG.error("Failed optimized node old offset check:"+changeInfo + ", previous:" + prevSibling + "," + prevSiblingChange); - ourDoOptimizedNodeOldOffsetChecks = false; + ourEnableOptimizedNodeOldOffset = false; optimizedResult = oldOffset; } } @@ -412,27 +414,30 @@ public class TreeChangeImpl implements TreeChange { private int myLastOffsetInNewTree; private ASTNode myLastNode; - private static boolean ourDoGetNewOffsetChecks = ourDoChecks; + private static boolean ourEnableGetNewOffset = true; private int getNewOffset(ASTNode node){ int optimizedResult = haveNotCalculated; - ASTNode prev = node.getTreePrev(); - if (myLastNode == prev) { - ChangeInfo prevChangeInfo = myChanges.get(prev); - ChangeInfo changeInfo = myChanges.get(node); + ASTNode prev = null; + if (ourEnableGetNewOffset) { + prev = node.getTreePrev(); + if (myLastNode == prev) { + ChangeInfo prevChangeInfo = myChanges.get(prev); + ChangeInfo changeInfo = myChanges.get(node); - // newoffset of removed element is the same of removed previous sibling - if (prevChangeInfo != null && - changeInfo != null && - prevChangeInfo.getChangeType() == ChangeInfo.REMOVED && - changeInfo.getChangeType() == ChangeInfo.REMOVED - ) { - optimizedResult = myLastOffsetInNewTree; + // newoffset of removed element is the same of removed previous sibling + if (prevChangeInfo != null && + changeInfo != null && + prevChangeInfo.getChangeType() == ChangeInfo.REMOVED && + changeInfo.getChangeType() == ChangeInfo.REMOVED + ) { + optimizedResult = myLastOffsetInNewTree; - myLastNode = node; - myLastOffsetInNewTree = optimizedResult; - if (!ourDoGetNewOffsetChecks) return optimizedResult; + myLastNode = node; + myLastOffsetInNewTree = optimizedResult; + if (!ourDoChecks) return optimizedResult; + } } } @@ -475,11 +480,10 @@ public class TreeChangeImpl implements TreeChange { } } finally { - if (ourDoGetNewOffsetChecks && - optimizedResult != haveNotCalculated && + if (optimizedResult != haveNotCalculated && optimizedResult != currentOffsetInNewTree) { LOG.error("Failed to calculate optimized getNewOffset:"+myChanges.get(node) + "," + prev + "," + myChanges.get(prev)); - ourDoGetNewOffsetChecks = false; + ourEnableGetNewOffset = false; } } diff --git a/platform/core-impl/src/com/intellij/psi/PsiAnchor.java b/platform/core-impl/src/com/intellij/psi/PsiAnchor.java index be1442f06f6f..52c6c1bf986d 100644 --- a/platform/core-impl/src/com/intellij/psi/PsiAnchor.java +++ b/platform/core-impl/src/com/intellij/psi/PsiAnchor.java @@ -58,7 +58,7 @@ public abstract class PsiAnchor { if (element instanceof PsiFile) { VirtualFile virtualFile = ((PsiFile)element).getVirtualFile(); - if (virtualFile != null) return new PsiFileReference(virtualFile, element.getProject(), element.getLanguage()); + if (virtualFile != null) return new PsiFileReference(virtualFile, (PsiFile)element); return new HardReference(element); } if (element instanceof PsiDirectory) { @@ -262,12 +262,23 @@ public abstract class PsiAnchor { private static class PsiFileReference extends PsiAnchor { private final VirtualFile myFile; private final Project myProject; - @Nullable private final Language myLanguage; + @NotNull private final Language myLanguage; - private PsiFileReference(@NotNull VirtualFile file, @NotNull Project project, @NotNull Language language) { + private PsiFileReference(@NotNull VirtualFile file, @NotNull PsiFile psiFile) { myFile = file; - myProject = project; - myLanguage = language; + myProject = psiFile.getProject(); + myLanguage = findLanguage(psiFile); + } + + private static Language findLanguage(PsiFile file) { + FileViewProvider vp = file.getViewProvider(); + Set languages = vp.getLanguages(); + for (Language language : languages) { + if (file.equals(vp.getPsi(language))) { + return language; + } + } + throw new AssertionError("Non-retrievable file: " + file.getClass() + "; " + file.getLanguage() + "; " + languages); } @Override @@ -299,7 +310,7 @@ public abstract class PsiAnchor { PsiFileReference reference = (PsiFileReference)o; if (!myFile.equals(reference.myFile)) return false; - if (myLanguage != null ? !myLanguage.equals(reference.myLanguage) : reference.myLanguage != null) return false; + if (!myLanguage.equals(reference.myLanguage)) return false; if (!myProject.equals(reference.myProject)) return false; return true; @@ -307,9 +318,7 @@ public abstract class PsiAnchor { @Override public int hashCode() { - int result = myFile.hashCode(); - result = 31 * result + (myLanguage != null ? myLanguage.hashCode() : 0); - return result; + return 31 * myFile.hashCode() + (myLanguage.hashCode()); } } diff --git a/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java b/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java index f305321f15cd..c872f04a998b 100644 --- a/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java +++ b/platform/dvcs/src/com/intellij/dvcs/DvcsUtil.java @@ -15,13 +15,21 @@ */ package com.intellij.dvcs; +import com.intellij.dvcs.repo.Repository; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.StatusBar; import com.intellij.openapi.wm.StatusBarWidget; import com.intellij.openapi.wm.WindowManager; +import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; +import java.io.File; +import java.util.Collection; + /** * @author Kirill Likhodedov */ @@ -41,4 +49,43 @@ public class DvcsUtil { } } + @NotNull + public static String getShortRepositoryName(@NotNull Project project, @NotNull VirtualFile root) { + VirtualFile projectDir = project.getBaseDir(); + + String repositoryPath = root.getPresentableUrl(); + if (projectDir != null) { + String relativePath = VfsUtilCore.getRelativePath(root, projectDir, File.separatorChar); + if (relativePath != null) { + repositoryPath = relativePath; + } + } + + return repositoryPath.isEmpty() ? root.getName() : repositoryPath; + } + + @NotNull + public static String getShortRepositoryName(@NotNull Repository repository) { + return getShortRepositoryName(repository.getProject(), repository.getRoot()); + } + + @NotNull + public static String getShortNames(@NotNull Collection repositories) { + return StringUtil.join(repositories, new Function() { + @Override + public String fun(Repository repository) { + return getShortRepositoryName(repository); + } + }, ", "); + } + + @NotNull + public static String joinRootsPaths(@NotNull Collection roots) { + return StringUtil.join(roots, new Function() { + @Override + public String fun(VirtualFile virtualFile) { + return virtualFile.getPresentableUrl(); + } + }, ", "); + } } diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java b/platform/dvcs/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java new file mode 100644 index 000000000000..3edd0c0768f8 --- /dev/null +++ b/platform/dvcs/src/com/intellij/dvcs/ui/BranchActionGroupPopup.java @@ -0,0 +1,117 @@ +/* + * 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.dvcs.ui; + +import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.impl.SimpleDataContext; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.popup.PopupStep; +import com.intellij.openapi.util.Condition; +import com.intellij.ui.ErrorLabel; +import com.intellij.ui.JBColor; +import com.intellij.ui.components.panels.OpaquePanel; +import com.intellij.ui.popup.PopupFactoryImpl; +import com.intellij.ui.popup.WizardPopup; +import com.intellij.ui.popup.list.PopupListElementRenderer; +import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.*; + +/** + * @author Nadya Zabrodina + */ +public class BranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup { + public BranchActionGroupPopup(@NotNull String title, @NotNull Project project, + @NotNull Condition preselectActionCondition, @NotNull ActionGroup actions) { + super(title, actions, SimpleDataContext.getProjectContext(project), false, false, false, true, null, -1, + preselectActionCondition, null); + } + + @Override + protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) { + WizardPopup popup = super.createPopup(parent, step, parentValue); + RootAction rootAction = getRootAction(parentValue); + if (rootAction != null) { + popup.setAdText((rootAction).getCaption()); + } + return popup; + } + + @Nullable + private static RootAction getRootAction(Object value) { + if (value instanceof PopupFactoryImpl.ActionItem) { + AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction(); + if (action instanceof RootAction) { + return (RootAction)action; + } + } + return null; + } + + @Override + protected ListCellRenderer getListElementRenderer() { + return new PopupListElementRenderer(this) { + + private ErrorLabel myBranchLabel; + + @Override + protected void customizeComponent(JList list, Object value, boolean isSelected) { + super.customizeComponent(list, value, isSelected); + + RootAction rootAction = getRootAction(value); + if (rootAction != null) { + myBranchLabel.setVisible(true); + myBranchLabel.setText(String.format("[%s]", rootAction.getBranch())); + + if (isSelected) { + setSelected(myBranchLabel); + } + else { + myBranchLabel.setBackground(getBackground()); + myBranchLabel.setForeground(JBColor.GRAY); // different foreground than for other elements + } + + adjustOpacity(myBranchLabel, isSelected); + } + else { + myBranchLabel.setVisible(false); + } + } + + @Override + protected JComponent createItemComponent() { + myTextLabel = new ErrorLabel(); + myTextLabel.setOpaque(true); + myTextLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); + + myBranchLabel = new ErrorLabel(); + myBranchLabel.setOpaque(true); + myBranchLabel.setBorder(BorderFactory.createEmptyBorder(1, UIUtil.DEFAULT_HGAP, 1, 1)); + + JPanel compoundPanel = new OpaquePanel(new BorderLayout(), JBColor.WHITE); + compoundPanel.add(myTextLabel, BorderLayout.CENTER); + compoundPanel.add(myBranchLabel, BorderLayout.EAST); + + return layoutComponent(compoundPanel); + } + }; + } +} + diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java b/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java new file mode 100644 index 000000000000..19f1470c72d6 --- /dev/null +++ b/platform/dvcs/src/com/intellij/dvcs/ui/NewBranchAction.java @@ -0,0 +1,60 @@ +/* + * 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.dvcs.ui; + +import com.intellij.dvcs.repo.Repository; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.project.DumbAwareAction; +import com.intellij.openapi.project.Project; +import com.intellij.util.IconUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author Nadya Zabrodina + */ +public abstract class NewBranchAction extends DumbAwareAction { + protected final List myRepositories; + protected Project myProject; + + public NewBranchAction(@NotNull Project project, @NotNull List repositories) { + super("New Branch", "Create and checkout new branch", IconUtil.getAddIcon()); + myRepositories = repositories; + myProject = project; + } + + + @Override + public void update(AnActionEvent e) { + if (anyRepositoryIsFresh()) { + e.getPresentation().setEnabled(false); + e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit."); + } + } + + @Override + public abstract void actionPerformed(AnActionEvent e); + + private boolean anyRepositoryIsFresh() { + for (Repository repository : myRepositories) { + if (repository.isFresh()) { + return true; + } + } + return false; + } +} diff --git a/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java b/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java new file mode 100644 index 000000000000..a2a2f4961243 --- /dev/null +++ b/platform/dvcs/src/com/intellij/dvcs/ui/RootAction.java @@ -0,0 +1,85 @@ +/* + * 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.dvcs.ui; + +import com.intellij.dvcs.DvcsUtil; +import com.intellij.dvcs.repo.Repository; +import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.util.PlatformIcons; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * @author Nadya Zabrodina + */ +public class RootAction extends ActionGroup { + + @NotNull protected final T myRepository; + @NotNull private ActionGroup myGroup; + @NotNull private String myBranchText; + @NotNull private String myBranchOrRev; + + + /** + * @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then. + * @param actionsGroup + * @param branchText + * @param branchName + */ + public RootAction(@NotNull T repository, + @Nullable T currentRepository, + @NotNull ActionGroup actionsGroup, + @NotNull String branchText, + @NotNull String branchName) { + super(DvcsUtil.getShortRepositoryName(repository), true); + myRepository = repository; + myGroup = actionsGroup; + myBranchText = branchText; + myBranchOrRev = branchName; + if (repository.equals(currentRepository)) { + getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); + } + } + + + @NotNull + public String getCaption() { + return "Current branch in " + DvcsUtil.getShortRepositoryName(myRepository) + ": " + + getDisplayableBranchText(); + } + + @NotNull + private String getDisplayableBranchText() { + return myBranchText; + } + + @NotNull + public String getBranch() { + return myBranchOrRev; + } + + @NotNull + @Override + public AnAction[] getChildren(@Nullable AnActionEvent e) { + return myGroup.getChildren(e); + } +} + + + + diff --git a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java index 9c6f782cbcc1..746857e8eb49 100644 --- a/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java +++ b/platform/extensions/src/com/intellij/openapi/extensions/impl/ExtensionPointImpl.java @@ -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 implements ExtensionPoint { result = myExtensionsCache; if (result == null) { processAdapters(); - final Class extensionClass = getExtensionClass(); - //noinspection unchecked - result = myExtensions.toArray((T[])Array.newInstance(extensionClass, myExtensions.size())); + Class 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 implements ExtensionPoint { 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 implements ExtensionPoint { 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 implements ExtensionPoint { public synchronized void removeExtensionPointListener(@NotNull ExtensionPointListener 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 implements ExtensionPoint { if (extensionClass == null) { try { ClassLoader pluginClassLoader = myDescriptor.getPluginClassLoader(); - //noinspection unchecked - myExtensionClass = extensionClass = pluginClassLoader == null - ? (Class)Class.forName(myClassName) - : (Class)Class.forName(myClassName, true, pluginClassLoader); + @SuppressWarnings("unchecked") Class extClass = pluginClassLoader == null + ? (Class)Class.forName(myClassName) : (Class)Class.forName(myClassName, true, pluginClassLoader); + myExtensionClass = extensionClass = extClass; } catch (ClassNotFoundException e) { throw new RuntimeException(e); @@ -422,8 +420,8 @@ public class ExtensionPointImpl implements ExtensionPoint { 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; diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java index 75491a2c77be..48777a134daa 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java @@ -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 descriptorsToStop = new ArrayList(); 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) { diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java index 2d53816dd245..126aa490f172 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RestartAction.java @@ -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 diff --git a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java index 2600fa4f3268..ecea85eeff3d 100644 --- a/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java +++ b/platform/lang-impl/src/com/intellij/execution/runners/RunContentBuilder.java @@ -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() { diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java index 8ffe6acd5941..25bf410dc993 100644 --- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeTreeViewPanel.java @@ -685,7 +685,10 @@ public class ScopeTreeViewPanel extends JPanel implements Disposable { }, false); } else if (propertyName.equals(PsiTreeChangeEvent.PROP_DIRECTORY_NAME)) { - queueRefreshScope(scope, (PsiDirectory)element); + final PackageSet value = getCurrentScope().getValue(); + if (!(value instanceof PackageSetBase) || ((PackageSetBase)value).contains(((PsiDirectory)element).getVirtualFile(), myProject, myDependencyValidationManager)) { + queueRefreshScope(scope, (PsiDirectory)element); + } } } } diff --git a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java index c8401174733b..8d1ebb5bed3d 100644 --- a/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java +++ b/platform/lang-impl/src/com/intellij/ide/scopeView/ScopeViewPane.java @@ -114,14 +114,16 @@ public class ScopeViewPane extends AbstractProjectViewPane { @Override public JComponent createComponent() { - myViewPanel = new ScopeTreeViewPanel(myProject); - Disposer.register(this, myViewPanel); - myViewPanel.initListeners(); - myViewPanel.selectScope(NamedScopesHolder.getScope(myProject, getSubId())); - myTree = myViewPanel.getTree(); - PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_SCOPE_VIEW_POPUP, ActionPlaces.SCOPE_VIEW_POPUP); - enableDnD(); + if (myViewPanel == null) { + myViewPanel = new ScopeTreeViewPanel(myProject); + Disposer.register(this, myViewPanel); + myViewPanel.initListeners(); + myTree = myViewPanel.getTree(); + PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_SCOPE_VIEW_POPUP, ActionPlaces.SCOPE_VIEW_POPUP); + enableDnD(); + } + myViewPanel.selectScope(NamedScopesHolder.getScope(myProject, getSubId())); return myViewPanel.getPanel(); } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java index 4c439778edae..9e1fdb120992 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java @@ -38,8 +38,12 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; import com.intellij.openapi.vfs.impl.BulkVirtualFileListenerAdapter; +import com.intellij.openapi.vfs.newvfs.BulkFileListener; import com.intellij.openapi.vfs.newvfs.ManagingFS; import com.intellij.openapi.vfs.newvfs.NewVirtualFile; +import com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent; +import com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent; +import com.intellij.openapi.vfs.newvfs.events.VFileEvent; import com.intellij.openapi.vfs.newvfs.impl.FileNameCache; import com.intellij.util.*; import com.intellij.util.containers.ContainerUtil; @@ -143,7 +147,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { } }); - myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new MyVirtualFileListener())); + myConnection.subscribe(VirtualFileManager.VFS_CHANGES, new MyVirtualFileListener()); } private void markContentRootsForRefresh() { @@ -162,7 +166,10 @@ public class DirectoryIndexImpl extends DirectoryIndex { myConnection.deliverImmediately(); } - private class MyVirtualFileListener extends VirtualFileAdapter { + private class MyVirtualFileListener extends VirtualFileAdapter implements BulkFileListener { + private static final int MAX_DEPTH_TO_COUNT = 20; + private static final int DIRECTORIES_CHANGED_THRESHOLD = 50; + @Override public void fileCreated(VirtualFileEvent event) { VirtualFile file = event.getFile(); @@ -177,7 +184,6 @@ public class DirectoryIndexImpl extends DirectoryIndex { replaceState(newState); } - @NotNull private IndexState updateStateWithNewFile(@NotNull NewVirtualFile file, @NotNull NewVirtualFile parent) { final IndexState originalState = myState; @@ -224,22 +230,24 @@ public class DirectoryIndexImpl extends DirectoryIndex { state.fillMapWithModuleContent(file, module, (NewVirtualFile)parentContentRoot, null); String parentPackage = state.getPackageNameForDirectory(parent); + TObjectIntHashMap interned = new TObjectIntHashMap(); if (module != null) { if (parentInfo.isInModuleSource()) { String newDirPackageName = getPackageNameForSubdir(parentPackage, file.getName()); - state.fillMapWithModuleSource(module, (NewVirtualFile)parentContentRoot, file, newDirPackageName, (NewVirtualFile)parentInfo.getSourceRoot(), parentInfo.isTestSource(), null); + state.fillMapWithModuleSource(module, (NewVirtualFile)parentContentRoot, file, newDirPackageName, + (NewVirtualFile)parentInfo.getSourceRoot(), parentInfo.isTestSource(), null, interned); } } if (parentInfo.hasLibraryClassRoot()) { String newDirPackageName = getPackageNameForSubdir(parentPackage, file.getName()); - state.fillMapWithLibraryClasses(file, newDirPackageName, (NewVirtualFile)parentInfo.getLibraryClassRoot(), null); + state.fillMapWithLibraryClasses(file, newDirPackageName, (NewVirtualFile)parentInfo.getLibraryClassRoot(), null, interned); } if (parentInfo.isInLibrarySource()) { String newDirPackageName = getPackageNameForSubdir(parentPackage, file.getName()); - state.fillMapWithLibrarySources(file, newDirPackageName, (NewVirtualFile)parentInfo.getSourceRoot(), null); + state.fillMapWithLibrarySources(file, newDirPackageName, (NewVirtualFile)parentInfo.getSourceRoot(), null, interned); } OrderEntry[] entries = parentInfo.getOrderEntries(); @@ -303,11 +311,6 @@ public class DirectoryIndexImpl extends DirectoryIndex { myState.assertAncestorsConsistent(); } - @Override - public void beforeFileMovement(VirtualFileMoveEvent event) { - super.beforeFileMovement(event); - } - @Override public void fileMoved(VirtualFileMoveEvent event) { VirtualFile file = event.getFile(); @@ -327,6 +330,64 @@ public class DirectoryIndexImpl extends DirectoryIndex { } myState.assertAncestorsConsistent(); } + + private boolean myBatchChangePlanned; + private static final boolean ourCanHaveBatchUpdate = true; + + @Override + public void before(@NotNull List events) { + myBatchChangePlanned = false; + int directoriesRemoved = 0; + int directoriesCreated = 0; + + for(VFileEvent event:events) { + if (event instanceof VFileDeleteEvent) { + VirtualFile file = event.getFile(); + if (file != null && file.isDirectory()) { + directoriesRemoved += 1 + countDirectories(file, MAX_DEPTH_TO_COUNT); + } + } else if(event instanceof VFileCreateEvent) { + VirtualFile file = event.getFile(); + if (file != null && file.isDirectory()) directoriesCreated += 1 + countDirectories(file, MAX_DEPTH_TO_COUNT); + } + } + + final boolean willDoBatchUpdate = directoriesCreated + directoriesRemoved > DIRECTORIES_CHANGED_THRESHOLD; + + if (willDoBatchUpdate && ourCanHaveBatchUpdate) { + myBatchChangePlanned = true; + LOG.info("Too many directories created / deleted: " + directoriesCreated + "," + directoriesRemoved + ", will rebuild indexstate"); + } else { + for (VFileEvent event : events) { + BulkVirtualFileListenerAdapter.fireBefore(this, event); + } + } + } + + private int countDirectories(VirtualFile file, int depth) { + if (!(file instanceof NewVirtualFile)) return 0; + + int counter = 0; + for(VirtualFile child:((NewVirtualFile)file).iterInDbChildren()) { + if (child.isDirectory()) counter += 1 + (depth > 0 ? countDirectories(child, depth - 1):0); + } + return counter; + } + + @Override + public void after(@NotNull List events) { + if (myBatchChangePlanned) { + myBatchChangePlanned = false; + long started = System.currentTimeMillis(); + doInitialize(); + LOG.info("Rebuilt indexstate for " + (System.currentTimeMillis() - started)); + } + else { + for (VFileEvent event : events) { + BulkVirtualFileListenerAdapter.fireAfter(this, event); + } + } + } } private void replaceState(IndexState newState) { @@ -365,7 +426,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { dispatchPendingEvents(); IndexState state = myState; - int[] allDirs = state.getDirsForPackage(internPackageName(packageName)); + int[] allDirs = state.getDirsForPackage(internPackageName(packageName, null)); if (allDirs == null) allDirs = ArrayUtil.EMPTY_INT_ARRAY; List files = new ArrayList(allDirs.length); @@ -511,7 +572,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { return result.toString(); } - private static int[] internPackageName(@Nullable String packageName) { + private static int[] internPackageName(@Nullable String packageName, @Nullable TObjectIntHashMap alreadyEnumerated) { if (packageName == null) { return null; } @@ -531,7 +592,13 @@ public class DirectoryIndexImpl extends DirectoryIndex { if (tokenEnd < 0) { tokenEnd = packageName.length(); } - result[tokenIndex + 1] = FileNameCache.storeName(packageName.substring(tokenStart, tokenEnd)); + String nextName = packageName.substring(tokenStart, tokenEnd); + int internedId = alreadyEnumerated != null ? alreadyEnumerated.get(nextName) : 0; + if (internedId == 0) { + internedId = FileNameCache.storeName(nextName); + if (alreadyEnumerated != null) alreadyEnumerated.put(nextName, internedId); + } + result[tokenIndex + 1] = internedId; tokenStart = tokenEnd + 1; tokenIndex++; } @@ -788,7 +855,8 @@ public class DirectoryIndexImpl extends DirectoryIndex { } } - private void initModuleSources(@NotNull Module module, boolean reverseAllSets, @NotNull ProgressIndicator progress) { + private void initModuleSources(@NotNull Module module, boolean reverseAllSets, @NotNull ProgressIndicator progress, + @Nullable TObjectIntHashMap interned) { assertWritable(); progress.checkCanceled(); progress.setText2(ProjectBundle.message("project.index.processing.module.sources.progress", module.getName())); @@ -808,7 +876,8 @@ public class DirectoryIndexImpl extends DirectoryIndex { for (SourceFolder sourceFolder : sourceFolders) { VirtualFile dir = sourceFolder.getFile(); if (dir instanceof NewVirtualFile && contentRoot instanceof NewVirtualFile) { - fillMapWithModuleSource(module, (NewVirtualFile)contentRoot, (NewVirtualFile)dir, sourceFolder.getPackagePrefix(), (NewVirtualFile)dir, sourceFolder.isTestSource(), progress); + fillMapWithModuleSource(module, (NewVirtualFile)contentRoot, (NewVirtualFile)dir, sourceFolder.getPackagePrefix(), + (NewVirtualFile)dir, sourceFolder.isTestSource(), progress, interned); } } } @@ -820,7 +889,9 @@ public class DirectoryIndexImpl extends DirectoryIndex { @NotNull final String packageName, @NotNull final NewVirtualFile sourceRoot, final boolean isTestSource, - @Nullable final ProgressIndicator progress) { + @Nullable final ProgressIndicator progress, + final @Nullable TObjectIntHashMap interned + ) { assertWritable(); if (!isValid(dir)) return; assert VfsUtilCore.isAncestor(sourceRoot, dir, false) : "SourceRoot: "+sourceRoot+" ("+sourceRoot.getFileSystem()+"); dir: "+dir+" ("+dir.getFileSystem()+")"; @@ -850,7 +921,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { String currentPackage = myPackages.isEmpty() ? packageName : getPackageNameForSubdir(myPackages.peek(), file.getName()); myPackages.push(currentPackage); - setPackageName(id, internPackageName(currentPackage)); + setPackageName(id, internPackageName(currentPackage, interned)); return info; } @@ -866,7 +937,8 @@ public class DirectoryIndexImpl extends DirectoryIndex { return myDirToPackageName.get(id) == ArrayUtil.EMPTY_INT_ARRAY; } - private void initLibrarySources(@NotNull Module module, @NotNull ProgressIndicator progress) { + private void initLibrarySources(@NotNull Module module, @NotNull ProgressIndicator progress, + @Nullable TObjectIntHashMap interned) { assertWritable(); progress.checkCanceled(); progress.setText2(ProjectBundle.message("project.index.processing.library.sources.progress", module.getName())); @@ -876,7 +948,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { VirtualFile[] sourceRoots = ((LibraryOrSdkOrderEntry)orderEntry).getRootFiles(OrderRootType.SOURCES); for (final VirtualFile sourceRoot : sourceRoots) { if (sourceRoot instanceof NewVirtualFile) { - fillMapWithLibrarySources((NewVirtualFile)sourceRoot, "", (NewVirtualFile)sourceRoot, progress); + fillMapWithLibrarySources((NewVirtualFile)sourceRoot, "", (NewVirtualFile)sourceRoot, progress, interned); } } } @@ -884,9 +956,10 @@ public class DirectoryIndexImpl extends DirectoryIndex { } private void fillMapWithLibrarySources(@NotNull final NewVirtualFile dir, - @Nullable final String packageName, - @NotNull final NewVirtualFile sourceRoot, - @Nullable final ProgressIndicator progress) { + @Nullable final String packageName, + @NotNull final NewVirtualFile sourceRoot, + @Nullable final ProgressIndicator progress, + @Nullable final TObjectIntHashMap interned) { assertWritable(); if (!isValid(dir)) return; VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() { @@ -908,7 +981,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { final String packageName = getCurrentValue(); final String newPackageName = Comparing.equal(file, dir) ? packageName : getPackageNameForSubdir(packageName, file.getName()); - setPackageName(dirId, internPackageName(newPackageName)); + setPackageName(dirId, internPackageName(newPackageName, interned)); setValueForChildren(newPackageName); return true; @@ -916,7 +989,8 @@ public class DirectoryIndexImpl extends DirectoryIndex { }); } - private void initLibraryClasses(@NotNull Module module, @NotNull ProgressIndicator progress) { + private void initLibraryClasses(@NotNull Module module, @NotNull ProgressIndicator progress, + @Nullable TObjectIntHashMap interned) { assertWritable(); progress.checkCanceled(); progress.setText2(ProjectBundle.message("project.index.processing.library.classes.progress", module.getName())); @@ -926,7 +1000,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { VirtualFile[] classRoots = ((LibraryOrSdkOrderEntry)orderEntry).getRootFiles(OrderRootType.CLASSES); for (final VirtualFile classRoot : classRoots) { if (classRoot instanceof NewVirtualFile) { - fillMapWithLibraryClasses((NewVirtualFile)classRoot, "", (NewVirtualFile)classRoot, progress); + fillMapWithLibraryClasses((NewVirtualFile)classRoot, "", (NewVirtualFile)classRoot, progress, interned); } } } @@ -936,7 +1010,9 @@ public class DirectoryIndexImpl extends DirectoryIndex { private void fillMapWithLibraryClasses(@NotNull final NewVirtualFile dir, @NotNull final String packageName, @NotNull final NewVirtualFile classRoot, - @Nullable final ProgressIndicator progress) { + @Nullable final ProgressIndicator progress, + @Nullable final TObjectIntHashMap interned + ) { assertWritable(); if (!isValid(dir)) return; VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() { @@ -959,7 +1035,7 @@ public class DirectoryIndexImpl extends DirectoryIndex { final String packageName = getCurrentValue(); final String childPackageName = Comparing.equal(file, dir) ? packageName : getPackageNameForSubdir(packageName, file.getName()); if (!info.isInModuleSource() && !info.isInLibrarySource()) { - setPackageName(dirId, internPackageName(childPackageName)); + setPackageName(dirId, internPackageName(childPackageName, interned)); } setValueForChildren(childPackageName); @@ -1135,13 +1211,16 @@ public class DirectoryIndexImpl extends DirectoryIndex { for (Module module : modules) { initModuleContents(module, reverseAllSets, progress); } + + TObjectIntHashMap interned = new TObjectIntHashMap(100); + // Important! Because module's contents may overlap, // first modules should be marked and only after that sources markup // should be added. (src markup depends on module markup) for (Module module : modules) { - initModuleSources(module, reverseAllSets, progress); - initLibrarySources(module, progress); - initLibraryClasses(module, progress); + initModuleSources(module, reverseAllSets, progress, interned); + initLibrarySources(module, progress, interned); + initLibraryClasses(module, progress , interned); } progress.checkCanceled(); diff --git a/platform/platform-impl/src/com/intellij/diagnostic/DefaultIdeaErrorLogger.java b/platform/platform-impl/src/com/intellij/diagnostic/DefaultIdeaErrorLogger.java index f73bce667320..3488bce03487 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/DefaultIdeaErrorLogger.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/DefaultIdeaErrorLogger.java @@ -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 + - "
Possible cause: unable to allocate continuous memory chunk of necessary size.
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 + + "
Possible cause: unable to allocate continuous memory chunk of necessary size.
" + + "Reducing JVM maximum heap size (-Xmx) may help."; + Notifications.Bus.notify(new Notification("Memory", "Memory Mapping Failed", text, NotificationType.WARNING), null); } } - } diff --git a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java index fe8be3429f67..c21021478f06 100644 --- a/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java +++ b/platform/platform-impl/src/com/intellij/ide/IdeEventQueue.java @@ -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; } diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java b/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java index 29a113f9b3a7..212ade114677 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/ActionInstallPlugin.java @@ -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; diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java index 2ce3a3c4fe4f..5c9f61efba7d 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java @@ -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 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 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; } } } diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java index 6fa170bab32f..47558feddc74 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/IdeaLaf.java @@ -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 systemFont = UIUtil.getSystemFontData(); + if (systemFont != null) { + LafManagerImpl.initFontDefaults(defaults, systemFont.first, systemFont.second); + } + else { + LafManagerImpl.initFontDefaults(defaults, "Tahoma", 11); + } } @SuppressWarnings({"HardCodedStringLiteral"}) diff --git a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java index a3c34041752b..1e858edf612e 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/DarculaLaf.java @@ -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; diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 1641c8dd7838..4604d57a6777 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -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 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 willOpenProject = new Ref(Boolean.FALSE); + AppLifecycleListener lifecyclePublisher = app.getMessageBus().syncPublisher(AppLifecycleListener.TOPIC); + lifecyclePublisher.appFrameCreated(args, willOpenProject); - final Ref willOpenProject = new Ref(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() { diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java b/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java index 0c24c336acff..17de69c30b7c 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java @@ -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() { diff --git a/platform/platform-impl/src/com/intellij/idea/SocketLock.java b/platform/platform-impl/src/com/intellij/idea/SocketLock.java index ecdf70aed992..d2b0fbf09b7d 100644 --- a/platform/platform-impl/src/com/intellij/idea/SocketLock.java +++ b/platform/platform-impl/src/com/intellij/idea/SocketLock.java @@ -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); diff --git a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java index c05df8fdb349..28ee2fbfe8c2 100644 --- a/platform/platform-impl/src/com/intellij/idea/StartupUtil.java +++ b/platform/platform-impl/src/com/intellij/idea/StartupUtil.java @@ -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> 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 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 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> 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 arguments = RuntimemxBean.getInputArguments(); - - if (arguments != null) log.info("JVM Args: " + StringUtil.join(arguments, " ")); + List arguments = ManagementFactory.getRuntimeMXBean().getInputArguments(); + if (arguments != null) { + log.info("JVM Args: " + StringUtil.join(arguments, " ")); + } } } diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index 48d8b85b133d..f092d21e0e43 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -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 " + diff --git a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java index fd6e291e0b27..0ff8fe8b00fd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileTypes/impl/FileTypeManagerImpl.java @@ -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 diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java index d37e976dfc22..6e73479e6d5f 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/InternalDecorator.java @@ -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 diff --git a/platform/platform-main/src/com/intellij/idea/MainImpl.java b/platform/platform-main/src/com/intellij/idea/MainImpl.java index 0faeeb706a0a..32660d97733a 100644 --- a/platform/platform-main/src/com/intellij/idea/MainImpl.java +++ b/platform/platform-main/src/com/intellij/idea/MainImpl.java @@ -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); + } + } + }); } }); } -} \ No newline at end of file +} diff --git a/platform/platform-resources-en/src/messages/ExecutionBundle.properties b/platform/platform-resources-en/src/messages/ExecutionBundle.properties index 041c4ff04c0a..ae6a49ac3e4d 100644 --- a/platform/platform-resources-en/src/messages/ExecutionBundle.properties +++ b/platform/platform-resources-en/src/messages/ExecutionBundle.properties @@ -145,6 +145,7 @@ junit.runing.info.track.test.action.description=Select currently running test in junit.runing.info.collapse.test.action.name=Collapse all test suites junit.runing.info.expand.test.action.name=Expand all test suites junit.runing.info.select.first.failed.action.name=Select First Failed Test When Finished +junit.runing.info.include.non.started.in.rerun.failed.action.name=Include Non-Started Tests into Rerun Failed junit.runing.info.scroll.to.stacktrace.action.name=Scroll to Stacktrace junit.runing.info.scroll.to.stacktrace.action.description=Scroll console to beginning of assertion or exception stacktrace junit.runing.info.open.source.at.exception.action.name=Open Source at Exception diff --git a/platform/platform-resources/src/META-INF/XmlPlugin.xml b/platform/platform-resources/src/META-INF/XmlPlugin.xml index 4ecf05c4b7bd..85757e808bb5 100644 --- a/platform/platform-resources/src/META-INF/XmlPlugin.xml +++ b/platform/platform-resources/src/META-INF/XmlPlugin.xml @@ -13,7 +13,7 @@ + interface="com.intellij.psi.xml.StartTagEndTokenProvider"/> myTransferToEDTQueue = new TransferToEDTQueue("SM queue", new Processor() { @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 { diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDuration.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDuration.java index e0cad807eba2..ba3998eb463f 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDuration.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDuration.java @@ -59,14 +59,12 @@ public class ColumnDuration extends BaseColumn implements Comparator{ @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{ 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); } } } diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java index 6debd74209bf..13260684f5d9 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsPanel.java @@ -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); } } }; diff --git a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsTableModel.java b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsTableModel.java index 34413801840e..edab544952d5 100644 --- a/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsTableModel.java +++ b/platform/smRunner/src/com/intellij/execution/testframework/sm/runner/ui/statistics/StatisticsTableModel.java @@ -37,7 +37,7 @@ public class StatisticsTableModel extends ListTableModel { 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 { } final List list = new ArrayList(); - // suite's total statistics - list.add(suite); // chiled's statistics list.addAll(suite.getChildren()); diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java index 7cbe913e2973..8e554be5b303 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnDurationTest.java @@ -258,7 +258,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { public void testTotal_TotalSuite() { doRender(mySuite, 0); assertFragmentsSize(1); - assertEquals(SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0)); + assertEquals(SimpleTextAttributes.REGULAR_ATTRIBUTES, myFragmentsContainer.getAttribsAt(0)); assertEquals(myColumn.valueOf(mySuite), myFragmentsContainer.getTextAt(0)); } @@ -278,7 +278,7 @@ public class ColumnDurationTest extends BaseColumnRenderingTest { public MyRenderer(final SMTestProxy proxy, final UITestUtil.FragmentsContainer fragmentsContainer) { - super(proxy); + super(); myFragmentsContainer = fragmentsContainer; } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnTestTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnTestTest.java index 793bec3f3147..65a897b45cac 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnTestTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/ColumnTestTest.java @@ -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; } diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java index d2b8bf6c7d2b..586ac08e8bb3 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsPanelTest.java @@ -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 getItems() { diff --git a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsTableModelTest.java b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsTableModelTest.java index 547a2d45c8a8..2dce3dd9c097 100644 --- a/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsTableModelTest.java +++ b/platform/smRunner/testSrc/com/intellij/execution/testframework/sm/runner/ui/statistics/SMTRunnerStatisticsTableModelTest.java @@ -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() { diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index b14bdd7beb9e..2ed8cd76c785 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -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 list = ContainerUtil.newArrayList(); + for (int i = 0; i < 100; i++) { + list.add(new SoftReference(new byte[(int)Runtime.getRuntime().freeMemory() / 2])); + } + } } diff --git a/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java b/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java index 58f3bbecad53..5d7fe60d2288 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/TestConsoleProperties.java @@ -50,6 +50,7 @@ public abstract class TestConsoleProperties extends StoringPropertyContainer imp public static final BooleanProperty OPEN_FAILURE_LINE = new BooleanProperty("openFailureLine", true); public static final BooleanProperty TRACK_CODE_COVERAGE = new BooleanProperty("trackCodeCoverage", false); public static final BooleanProperty SHOW_STATISTICS = new BooleanProperty("showStatistics", false); + public static final BooleanProperty INCLUDE_NON_STARTED_IN_RERUN_FAILED = new BooleanProperty("includeNonStarted", true); private final Project myProject; private final Executor myExecutor; diff --git a/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java b/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java index dd61fbed941c..8b945eb9203a 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/actions/AbstractRerunFailedTestsAction.java @@ -150,6 +150,9 @@ public class AbstractRerunFailedTestsAction extends AnAction implements AnAction @NotNull protected Filter getFilter(Project project, GlobalSearchScope searchScope) { + if (TestConsoleProperties.INCLUDE_NON_STARTED_IN_RERUN_FAILED.value(myConsoleProperties)) { + return Filter.NOT_PASSED.or(Filter.FAILED_OR_INTERRUPTED); + } return Filter.FAILED_OR_INTERRUPTED; } diff --git a/platform/util/src/com/intellij/openapi/diagnostic/Logger.java b/platform/util/src/com/intellij/openapi/diagnostic/Logger.java index 6eea70f39aa9..bac5d8cab2cf 100644 --- a/platform/util/src/com/intellij/openapi/diagnostic/Logger.java +++ b/platform/util/src/com/intellij/openapi/diagnostic/Logger.java @@ -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); - } diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 6274fd0f3f23..240a8ca584aa 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -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); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java index 3fcadb528cba..68d56641c7a3 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/XDebugSessionTab.java @@ -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()); } diff --git a/plugins/ant/tests/src/com/intellij/lang/ant/AntParsingTest.java b/plugins/ant/tests/src/com/intellij/lang/ant/AntParsingTest.java index de266621e071..070b5611bb1b 100644 --- a/plugins/ant/tests/src/com/intellij/lang/ant/AntParsingTest.java +++ b/plugins/ant/tests/src/com/intellij/lang/ant/AntParsingTest.java @@ -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("com.intellij.xml.startTagEndToken"), - XmlChildRole.StartTagEndTokenProvider.class); + registerExtensionPoint(new ExtensionPointName("com.intellij.xml.startTagEndToken"), + StartTagEndTokenProvider.class); } @Override diff --git a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java index 306995b24135..fadba7dabc25 100644 --- a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java @@ -15,6 +15,7 @@ */ package git4idea.branch; +import com.intellij.dvcs.DvcsUtil; import com.intellij.notification.Notification; import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; @@ -35,7 +36,6 @@ import git4idea.merge.GitMergeCommittingConflictResolver; import git4idea.merge.GitMerger; import git4idea.repo.GitRepository; import git4idea.util.GitPreservingProcess; -import git4idea.util.GitUIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.event.HyperlinkEvent; @@ -275,9 +275,9 @@ class GitMergeOperation extends GitBranchOperation { } } - LOG.info("for smart rollback: " + GitUIUtil.getShortNames(repositoriesForSmartRollback) + - "; for simple rollback: " + GitUIUtil.getShortNames(repositoriesForSimpleRollback) + - "; for merge rollback: " + GitUIUtil.getShortNames(repositoriesForMergeRollback)); + LOG.info("for smart rollback: " + DvcsUtil.getShortNames(repositoriesForSmartRollback) + + "; for simple rollback: " + DvcsUtil.getShortNames(repositoriesForSimpleRollback) + + "; for merge rollback: " + DvcsUtil.getShortNames(repositoriesForMergeRollback)); GitCompoundResult result = smartRollback(repositoriesForSmartRollback); for (GitRepository repository : repositoriesForSimpleRollback) { diff --git a/plugins/git4idea/src/git4idea/push/GitPushLog.java b/plugins/git4idea/src/git4idea/push/GitPushLog.java index a471eb40d15a..d8da16b1315d 100644 --- a/plugins/git4idea/src/git4idea/push/GitPushLog.java +++ b/plugins/git4idea/src/git4idea/push/GitPushLog.java @@ -15,6 +15,7 @@ */ package git4idea.push; +import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.actionSystem.CommonShortcuts; import com.intellij.openapi.actionSystem.DataKey; import com.intellij.openapi.actionSystem.DataSink; @@ -34,7 +35,6 @@ import git4idea.GitBranch; import git4idea.GitCommit; import git4idea.GitUtil; import git4idea.repo.GitRepository; -import git4idea.util.GitUIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -362,7 +362,7 @@ class GitPushLog extends JPanel implements TypeSafeDataProvider { renderer.setToolTipText(getHashString(commit) + " " + getDateString(commit)); } else if (userObject instanceof GitRepository) { - String repositoryPath = GitUIUtil.getShortRepositoryName((GitRepository)userObject); + String repositoryPath = DvcsUtil.getShortRepositoryName((GitRepository)userObject); renderer.append(repositoryPath, SimpleTextAttributes.GRAY_ATTRIBUTES); } else if (userObject instanceof GitPushBranchInfo) { diff --git a/plugins/git4idea/src/git4idea/roots/GitIntegrationEnabler.java b/plugins/git4idea/src/git4idea/roots/GitIntegrationEnabler.java index 07da8828440f..32c3b686f578 100644 --- a/plugins/git4idea/src/git4idea/roots/GitIntegrationEnabler.java +++ b/plugins/git4idea/src/git4idea/roots/GitIntegrationEnabler.java @@ -31,8 +31,8 @@ import org.jetbrains.annotations.NotNull; import java.util.*; +import static com.intellij.dvcs.DvcsUtil.joinRootsPaths; import static com.intellij.openapi.util.text.StringUtil.pluralize; -import static git4idea.util.GitUIUtil.joinRootsPaths; /** * @author Kirill Likhodedov diff --git a/plugins/git4idea/src/git4idea/ui/GitRepositoryComboboxListCellRenderer.java b/plugins/git4idea/src/git4idea/ui/GitRepositoryComboboxListCellRenderer.java index 92532bfd78c1..822b90e58df4 100644 --- a/plugins/git4idea/src/git4idea/ui/GitRepositoryComboboxListCellRenderer.java +++ b/plugins/git4idea/src/git4idea/ui/GitRepositoryComboboxListCellRenderer.java @@ -15,9 +15,9 @@ */ package git4idea.ui; +import com.intellij.dvcs.DvcsUtil; import com.intellij.ui.ListCellRendererWrapper; import git4idea.repo.GitRepository; -import git4idea.util.GitUIUtil; import javax.swing.*; @@ -37,7 +37,7 @@ public class GitRepositoryComboboxListCellRenderer extends ListCellRendererWrapp @Override public void customize(JList list, GitRepository value, int index, boolean selected, boolean hasFocus) { - setText(GitUIUtil.getShortRepositoryName(value)); + setText(DvcsUtil.getShortRepositoryName(value)); } } diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java index d6c11a3f69eb..50e2e9622c36 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopup.java @@ -15,54 +15,44 @@ */ package git4idea.ui.branch; +import com.intellij.dvcs.DvcsUtil; +import com.intellij.dvcs.ui.BranchActionGroupPopup; +import com.intellij.dvcs.ui.RootAction; import com.intellij.notification.Notification; import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.actionSystem.impl.SimpleDataContext; import com.intellij.openapi.options.ShowSettingsUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.ListPopup; -import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.util.Condition; -import com.intellij.ui.ErrorLabel; -import com.intellij.ui.JBColor; -import com.intellij.ui.components.panels.OpaquePanel; -import com.intellij.ui.popup.PopupFactoryImpl; -import com.intellij.ui.popup.WizardPopup; import com.intellij.ui.popup.list.ListPopupImpl; -import com.intellij.ui.popup.list.PopupListElementRenderer; -import com.intellij.util.PlatformIcons; -import com.intellij.util.ui.UIUtil; import git4idea.GitUtil; import git4idea.GitVcs; import git4idea.branch.GitBranchUtil; import git4idea.config.GitVcsSettings; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryManager; -import git4idea.util.GitUIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.event.HyperlinkEvent; -import java.awt.*; import java.util.List; /** *

- * The popup which allows to quickly switch and control Git branches. + * The popup which allows to quickly switch and control Git branches. *

*

- * Use {@link #asListPopup()} to achieve the {@link ListPopup} itself. + * Use {@link #asListPopup()} to achieve the {@link ListPopup} itself. *

- * + * * @author Kirill Likhodedov */ -class GitBranchPopup { +class GitBranchPopup { private final Project myProject; private final GitRepositoryManager myRepositoryManager; @@ -121,7 +111,7 @@ class GitBranchPopup { } }; - myPopup = new GitBranchActionGroupPopup(title, project, preselectActionCondition); + myPopup = new BranchActionGroupPopup(title, project, preselectActionCondition, createActions()); initBranchSyncPolicyIfNotInitialized(); setCurrentBranchInfo(); @@ -145,7 +135,7 @@ class GitBranchPopup { String title = "Git Branches"; if (myRepositoryManager.moreThanOneRoot() && (myMultiRootBranchConfig.diverged() || myVcsSettings.getSyncSetting() == GitBranchSyncSetting.DONT)) { - title += " in " + GitUIUtil.getShortRepositoryName(currentRepository); + title += " in " + DvcsUtil.getShortRepositoryName(currentRepository); } return title; } @@ -154,7 +144,7 @@ class GitBranchPopup { String currentBranchText = "Current branch"; if (myRepositoryManager.moreThanOneRoot()) { if (myMultiRootBranchConfig.diverged()) { - currentBranchText += " in " + GitUIUtil.getShortRepositoryName(myCurrentRepository) + ": " + + currentBranchText += " in " + DvcsUtil.getShortRepositoryName(myCurrentRepository) + ": " + GitBranchUtil.getDisplayableBranchText(myCurrentRepository); } else { @@ -196,7 +186,7 @@ class GitBranchPopup { else { fillPopupWithCurrentRepositoryActions(popupGroup, createRepositoriesActions()); } - } + } else { fillPopupWithCurrentRepositoryActions(popupGroup, null); } @@ -213,7 +203,7 @@ class GitBranchPopup { List repositories = repositoryManager.getRepositories(); String currentBranch = myMultiRootBranchConfig.getCurrentBranch(); assert currentBranch != null : "Current branch can't be null if branches have not diverged"; - popupGroup.add(new GitBranchPopupActions.NewBranchAction(myProject, repositories)); + popupGroup.add(new GitBranchPopupActions.GitNewBranchAction(myProject, repositories)); popupGroup.addAll(createRepositoriesActions()); @@ -240,7 +230,10 @@ class GitBranchPopup { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); popupGroup.addSeparator("Repositories"); for (GitRepository repository : myRepositoryManager.getRepositories()) { - popupGroup.add(new RootAction(repository, highlightCurrentRepo() ? myCurrentRepository : null)); + popupGroup.add(new RootAction(repository, highlightCurrentRepo() ? myCurrentRepository : null, + new GitBranchPopupActions(repository.getProject(), repository).createActions(null), + GitBranchUtil.getDisplayableBranchText(repository), + GitBranchUtil.getBranchNameOrRev(repository))); } return popupGroup; } @@ -252,117 +245,4 @@ class GitBranchPopup { private void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) { popupGroup.addAll(new GitBranchPopupActions(myCurrentRepository.getProject(), myCurrentRepository).createActions(actions)); } - - private static class RootAction extends ActionGroup { - - private final GitRepository myRepository; - - /** - * @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then. - */ - RootAction(@NotNull GitRepository repository, @Nullable GitRepository currentRepository) { - super(GitUIUtil.getShortRepositoryName(repository), true); - myRepository = repository; - if (repository.equals(currentRepository)) { - getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); - } - } - - @NotNull - @Override - public AnAction[] getChildren(@Nullable AnActionEvent e) { - ActionGroup group = new GitBranchPopupActions(myRepository.getProject(), myRepository).createActions(null); - return group.getChildren(e); - } - - @NotNull - public String getCaption() { - return "Current branch in " + GitUIUtil.getShortRepositoryName(myRepository) + ": " + - GitBranchUtil.getDisplayableBranchText(myRepository); - } - - @NotNull - public String getBranch() { - return GitBranchUtil.getBranchNameOrRev(myRepository); - } - } - - private class GitBranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup { - public GitBranchActionGroupPopup(@NotNull String title, @NotNull Project project, - @NotNull Condition preselectActionCondition) { - super(title, GitBranchPopup.this.createActions(), SimpleDataContext.getProjectContext(project), false, false, false, true, null, -1, - preselectActionCondition, null); - } - - @Override - protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) { - WizardPopup popup = super.createPopup(parent, step, parentValue); - RootAction rootAction = getRootAction(parentValue); - if (rootAction != null) { - popup.setAdText((rootAction).getCaption()); - } - return popup; - } - - @Nullable - private RootAction getRootAction(Object value) { - if (value instanceof PopupFactoryImpl.ActionItem) { - AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction(); - if (action instanceof RootAction) { - return (RootAction)action; - } - } - return null; - } - - @Override - protected ListCellRenderer getListElementRenderer() { - return new PopupListElementRenderer(this) { - - private ErrorLabel myBranchLabel; - - @Override - protected void customizeComponent(JList list, Object value, boolean isSelected) { - super.customizeComponent(list, value, isSelected); - - RootAction rootAction = getRootAction(value); - if (rootAction != null) { - myBranchLabel.setVisible(true); - myBranchLabel.setText(String.format("[%s]", rootAction.getBranch())); - - if (isSelected) { - setSelected(myBranchLabel); - } - else { - myBranchLabel.setBackground(getBackground()); - myBranchLabel.setForeground(JBColor.GRAY); // different foreground than for other elements - } - - adjustOpacity(myBranchLabel, isSelected); - } - else { - myBranchLabel.setVisible(false); - } - } - - @Override - protected JComponent createItemComponent() { - myTextLabel = new ErrorLabel(); - myTextLabel.setOpaque(true); - myTextLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); - - myBranchLabel = new ErrorLabel(); - myBranchLabel.setOpaque(true); - myBranchLabel.setBorder(BorderFactory.createEmptyBorder(1, UIUtil.DEFAULT_HGAP, 1, 1)); - - JPanel compoundPanel = new OpaquePanel(new BorderLayout(), Color.white); - compoundPanel.add(myTextLabel, BorderLayout.CENTER); - compoundPanel.add(myBranchLabel, BorderLayout.EAST); - - return layoutComponent(compoundPanel); - } - - }; - } - } } diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java index 5d57ab1b4122..dbd3f8c902e5 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java @@ -15,16 +15,15 @@ */ package git4idea.ui.branch; +import com.intellij.dvcs.ui.NewBranchAction; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; -import com.intellij.util.IconUtil; import git4idea.GitBranch; import git4idea.branch.GitBranchUtil; import git4idea.branch.GitBrancher; @@ -43,7 +42,6 @@ import java.util.List; */ class GitBranchPopupActions { - private static final Logger LOG = Logger.getInstance(GitBranchPopupActions.class); private final Project myProject; private final GitRepository myRepository; @@ -55,7 +53,7 @@ class GitBranchPopupActions { ActionGroup createActions(@Nullable DefaultActionGroup toInsert) { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); - popupGroup.addAction(new NewBranchAction(myProject, Collections.singletonList(myRepository))); + popupGroup.addAction(new GitNewBranchAction(myProject,Collections.singletonList(myRepository))); popupGroup.addAction(new CheckoutRevisionActions(myProject, myRepository)); if (toInsert != null) { @@ -80,15 +78,11 @@ class GitBranchPopupActions { return popupGroup; } - - static class NewBranchAction extends DumbAwareAction { - private final Project myProject; - private final List myRepositories; - NewBranchAction(@NotNull Project project, @NotNull List repositories) { - super("New Branch", "Create and checkout new branch", IconUtil.getAddIcon()); - myProject = project; - myRepositories = repositories; + public static class GitNewBranchAction extends NewBranchAction { + + public GitNewBranchAction(@NotNull Project project, @NotNull List repositories) { + super(project, repositories); } @Override @@ -99,23 +93,6 @@ class GitBranchPopupActions { brancher.checkoutNewBranch(name, myRepositories); } } - - @Override - public void update(AnActionEvent e) { - if (anyRepositoryIsFresh()) { - e.getPresentation().setEnabled(false); - e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit."); - } - } - - private boolean anyRepositoryIsFresh() { - for (GitRepository repository : myRepositories) { - if (repository.isFresh()) { - return true; - } - } - return false; - } } /** diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitCompareBranchesDialog.java b/plugins/git4idea/src/git4idea/ui/branch/GitCompareBranchesDialog.java index 06d6a8358b0c..d9cbbd781f1c 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitCompareBranchesDialog.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitCompareBranchesDialog.java @@ -15,6 +15,7 @@ */ package git4idea.ui.branch; +import com.intellij.dvcs.DvcsUtil; import com.intellij.icons.AllIcons; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; @@ -22,7 +23,6 @@ import com.intellij.ui.TabbedPaneImpl; import git4idea.GitUtil; import git4idea.repo.GitRepository; import git4idea.util.GitCommitCompareInfo; -import git4idea.util.GitUIUtil; import icons.Git4ideaIcons; import org.jetbrains.annotations.NotNull; @@ -52,7 +52,7 @@ public class GitCompareBranchesDialog extends DialogWrapper { String rootString; if (compareInfo.getRepositories().size() == 1 && GitUtil.getRepositoryManager(myProject).moreThanOneRoot()) { - rootString = " in root " + GitUIUtil.getShortRepositoryName(initialRepo); + rootString = " in root " + DvcsUtil.getShortRepositoryName(initialRepo); } else { rootString = ""; diff --git a/plugins/git4idea/src/git4idea/update/GitFetcher.java b/plugins/git4idea/src/git4idea/update/GitFetcher.java index 7925ca720362..758797404008 100644 --- a/plugins/git4idea/src/git4idea/update/GitFetcher.java +++ b/plugins/git4idea/src/git4idea/update/GitFetcher.java @@ -15,6 +15,7 @@ */ package git4idea.update; +import com.intellij.dvcs.DvcsUtil; import com.intellij.notification.NotificationType; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; @@ -351,7 +352,7 @@ public class GitFetcher { StringBuilder info = new StringBuilder(); if (myRepositoryManager.moreThanOneRoot()) { for (Map.Entry entry : additionalInfo.entrySet()) { - info.append(entry.getValue()).append(" in ").append(GitUIUtil.getShortRepositoryName(myProject, entry.getKey())).append("
"); + info.append(entry.getValue()).append(" in ").append(DvcsUtil.getShortRepositoryName(myProject, entry.getKey())).append("
"); } } else { diff --git a/plugins/git4idea/src/git4idea/util/GitUIUtil.java b/plugins/git4idea/src/git4idea/util/GitUIUtil.java index 7ca621ae11c7..a9c88ee53ec5 100644 --- a/plugins/git4idea/src/git4idea/util/GitUIUtil.java +++ b/plugins/git4idea/src/git4idea/util/GitUIUtil.java @@ -23,10 +23,8 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.AbstractVcsHelper; import com.intellij.openapi.vcs.VcsException; -import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ListCellRendererWrapper; -import com.intellij.util.Function; import git4idea.GitBranch; import git4idea.GitUtil; import git4idea.GitVcs; @@ -39,7 +37,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.io.File; import java.util.Collection; import java.util.Collections; import java.util.HashSet; @@ -393,43 +390,4 @@ public class GitUIUtil { return String.format("<%2$s>%1$s", s, tag); } - @NotNull - public static String getShortRepositoryName(@NotNull Project project, @NotNull VirtualFile root) { - VirtualFile projectDir = project.getBaseDir(); - - String repositoryPath = root.getPresentableUrl(); - if (projectDir != null) { - String relativePath = VfsUtilCore.getRelativePath(root, projectDir, File.separatorChar); - if (relativePath != null) { - repositoryPath = relativePath; - } - } - - return repositoryPath.isEmpty() ? root.getName() : repositoryPath; - } - - @NotNull - public static String getShortRepositoryName(@NotNull GitRepository repository) { - return getShortRepositoryName(repository.getProject(), repository.getRoot()); - } - - @NotNull - public static String getShortNames(@NotNull Collection repositories) { - return StringUtil.join(repositories, new Function() { - @Override - public String fun(GitRepository repository) { - return getShortRepositoryName(repository); - } - }, ", "); - } - - @NotNull - public static String joinRootsPaths(@NotNull Collection roots) { - return StringUtil.join(roots, new Function() { - @Override - public String fun(VirtualFile virtualFile) { - return virtualFile.getPresentableUrl(); - } - }, ", "); - } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java index 5beb1daeed0c..b661a44a1658 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/settings/GradleExecutionSettings.java @@ -16,6 +16,7 @@ package org.jetbrains.plugins.gradle.settings; import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; +import com.intellij.openapi.util.SystemInfo; import com.intellij.util.SystemProperties; import com.intellij.util.containers.ContainerUtilRt; import org.jetbrains.annotations.NotNull; @@ -44,7 +45,7 @@ public class GradleExecutionSettings extends ExternalSystemExecutionSettings { @Nullable private String myJavaHome; public GradleExecutionSettings(@Nullable String gradleHome, @Nullable String serviceDirectory, boolean wrapper) { - this(gradleHome, serviceDirectory, wrapper, SystemProperties.getIntProperty("gradle.daemon.xmx.mb", 512)); + this(gradleHome, serviceDirectory, wrapper, SystemProperties.getIntProperty("gradle.daemon.xmx.mb", SystemInfo.is32Bit ? 512 : 1024)); } public GradleExecutionSettings(@Nullable String gradleHome, @Nullable String serviceDirectory, boolean wrapper, int daemonXmx) { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java index 7975847b8435..87ba6f4555b2 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopup.java @@ -15,25 +15,17 @@ */ package org.zmlx.hg4idea.action; +import com.intellij.dvcs.DvcsUtil; +import com.intellij.dvcs.ui.BranchActionGroupPopup; +import com.intellij.dvcs.ui.RootAction; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.actionSystem.impl.SimpleDataContext; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.ListPopup; -import com.intellij.openapi.ui.popup.PopupStep; import com.intellij.openapi.util.Condition; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.ErrorLabel; -import com.intellij.ui.JBColor; -import com.intellij.ui.components.panels.OpaquePanel; -import com.intellij.ui.popup.PopupFactoryImpl; -import com.intellij.ui.popup.WizardPopup; import com.intellij.ui.popup.list.ListPopupImpl; -import com.intellij.ui.popup.list.PopupListElementRenderer; -import com.intellij.util.PlatformIcons; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.repo.HgRepository; @@ -41,7 +33,6 @@ import org.zmlx.hg4idea.repo.HgRepositoryImpl; import org.zmlx.hg4idea.util.HgUtil; import javax.swing.*; -import java.awt.*; /** *

@@ -82,9 +73,7 @@ public class HgBranchPopup { return false; } }; - - myPopup = new HgBranchActionGroupPopup(title, project, preselectActionCondition); - + myPopup = new BranchActionGroupPopup(title, project, preselectActionCondition, createActions()); setCurrentBranchInfo(); } @@ -92,9 +81,7 @@ public class HgBranchPopup { @NotNull private static String createPopupTitle(@NotNull HgRepository currentRepository) { String title = "Hg Branches"; - - title += " in " + currentRepository.getRoot().getName(); - + title += " in " + DvcsUtil.getShortRepositoryName(currentRepository); return title; } @@ -119,126 +106,16 @@ public class HgBranchPopup { popupGroup.addSeparator("Repositories"); for (VirtualFile repository : HgUtil.getHgRepositories(myProject)) { HgRepository repo = HgRepositoryImpl.getFullInstance(repository, myProject, myProject); - popupGroup.add(new RootAction(repo, null)); + popupGroup.add(new RootAction(repo, null, + new HgBranchPopupActions(repo.getProject(), repo).createActions(null), + HgUtil.getDisplayableBranchText(repo), + repo.getCurrentBranch())); } return popupGroup; } - - private void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) { + protected void fillPopupWithCurrentRepositoryActions(@NotNull DefaultActionGroup popupGroup, @Nullable DefaultActionGroup actions) { popupGroup.addAll(new HgBranchPopupActions(myProject, myCurrentRepository).createActions(actions)); } - - private static class RootAction extends ActionGroup { - - private final HgRepository myRepository; - - /** - * @param currentRepository Pass null in the case of common repositories - none repository will be highlighted then. - */ - RootAction(@NotNull HgRepository repository, @Nullable HgRepository currentRepository) { - super(repository.getRoot().getName(), true); - myRepository = repository; - if (repository.equals(currentRepository)) { - getTemplatePresentation().setIcon(PlatformIcons.CHECK_ICON); - } - } - - @NotNull - @Override - public AnAction[] getChildren(@Nullable AnActionEvent e) { - ActionGroup group = new HgBranchPopupActions(myRepository.getProject(), myRepository).createActions(null); - return group.getChildren(e); - } - - @NotNull - public String getCaption() { - String captionText = "Current branch in " + myRepository.getRoot().getName() + ": "; - return captionText + HgUtil.getDisplayableBranchText(myRepository); - } - - @NotNull - public String getBranch() { - return myRepository.getCurrentBranch(); - } - } - - private class HgBranchActionGroupPopup extends PopupFactoryImpl.ActionGroupPopup { - public HgBranchActionGroupPopup(@NotNull String title, @NotNull Project project, - @NotNull Condition preselectActionCondition) { - super(title, HgBranchPopup.this.createActions(), SimpleDataContext.getProjectContext(project), false, false, false, true, null, -1, - preselectActionCondition, null); - } - - @Override - protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) { - WizardPopup popup = super.createPopup(parent, step, parentValue); - RootAction rootAction = getRootAction(parentValue); - if (rootAction != null) { - popup.setAdText((rootAction).getCaption()); - } - return popup; - } - - @Nullable - private RootAction getRootAction(Object value) { - if (value instanceof PopupFactoryImpl.ActionItem) { - AnAction action = ((PopupFactoryImpl.ActionItem)value).getAction(); - if (action instanceof RootAction) { - return (RootAction)action; - } - } - return null; - } - - @Override - protected ListCellRenderer getListElementRenderer() { - return new PopupListElementRenderer(this) { - - private ErrorLabel myBranchLabel; - - @Override - protected void customizeComponent(JList list, Object value, boolean isSelected) { - super.customizeComponent(list, value, isSelected); - - RootAction rootAction = getRootAction(value); - if (rootAction != null) { - myBranchLabel.setVisible(true); - myBranchLabel.setText(String.format("[%s]", rootAction.getBranch())); - - if (isSelected) { - setSelected(myBranchLabel); - } - else { - myBranchLabel.setBackground(getBackground()); - myBranchLabel.setForeground(JBColor.GRAY); // different foreground than for other elements - } - - adjustOpacity(myBranchLabel, isSelected); - } - else { - myBranchLabel.setVisible(false); - } - } - - @Override - protected JComponent createItemComponent() { - myTextLabel = new ErrorLabel(); - myTextLabel.setOpaque(true); - myTextLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); - - myBranchLabel = new ErrorLabel(); - myBranchLabel.setOpaque(true); - myBranchLabel.setBorder(BorderFactory.createEmptyBorder(1, UIUtil.DEFAULT_HGAP, 1, 1)); - - JPanel compoundPanel = new OpaquePanel(new BorderLayout(), Color.white); - compoundPanel.add(myTextLabel, BorderLayout.CENTER); - compoundPanel.add(myBranchLabel, BorderLayout.EAST); - - return layoutComponent(compoundPanel); - } - }; - } - } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java index 81eb20400cc8..79c3ca32bf3a 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/action/HgBranchPopupActions.java @@ -15,6 +15,7 @@ */ package org.zmlx.hg4idea.action; +import com.intellij.dvcs.ui.NewBranchAction; import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; @@ -23,7 +24,6 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.update.UpdatedFiles; -import com.intellij.util.IconUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.HgRevisionNumber; @@ -59,7 +59,7 @@ public class HgBranchPopupActions { ActionGroup createActions(@Nullable DefaultActionGroup toInsert) { DefaultActionGroup popupGroup = new DefaultActionGroup(null, false); - popupGroup.addAction(new NewBranchAction(myProject, Collections.singletonList(myRepository))); + popupGroup.addAction(new HgNewBranchAction(myProject, Collections.singletonList(myRepository))); if (toInsert != null) { popupGroup.addAll(toInsert); @@ -76,14 +76,10 @@ public class HgBranchPopupActions { return popupGroup; } - static class NewBranchAction extends DumbAwareAction { - private final Project myProject; - private final List myRepositories; + public static class HgNewBranchAction extends NewBranchAction { - NewBranchAction(@NotNull Project project, @NotNull List repositories) { - super("New Branch", "Create and checkout new branch", IconUtil.getAddIcon()); - myProject = project; - myRepositories = repositories; + HgNewBranchAction(@NotNull Project project, @NotNull List repositories) { + super(project, repositories); } @Override @@ -106,23 +102,6 @@ public class HgBranchPopupActions { HgAbstractGlobalAction.handleException(myProject, exception); } } - - @Override - public void update(AnActionEvent e) { - if (anyRepositoryIsFresh()) { - e.getPresentation().setEnabled(false); - e.getPresentation().setDescription("Checkout of a new branch is not possible before the first commit."); - } - } - - private boolean anyRepositoryIsFresh() { - for (HgRepository repository : myRepositories) { - if (repository.isFresh()) { - return true; - } - } - return false; - } } diff --git a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/JUnitToolbarPanel.java b/plugins/junit/src/com/intellij/execution/junit2/ui/actions/JUnitToolbarPanel.java index 492778fc35d3..03c223eac4f6 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/ui/actions/JUnitToolbarPanel.java +++ b/plugins/junit/src/com/intellij/execution/junit2/ui/actions/JUnitToolbarPanel.java @@ -16,6 +16,7 @@ package com.intellij.execution.junit2.ui.actions; +import com.intellij.execution.ExecutionBundle; import com.intellij.execution.Location; import com.intellij.execution.configurations.ConfigurationPerRunnerSettings; import com.intellij.execution.configurations.RunnerSettings; @@ -27,10 +28,12 @@ import com.intellij.execution.testframework.TestFrameworkRunningModel; import com.intellij.execution.testframework.TestsUIUtil; import com.intellij.execution.testframework.ToolbarPanel; import com.intellij.execution.testframework.actions.ScrollToTestSourceAction; +import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.project.Project; import com.intellij.pom.Navigatable; import com.intellij.psi.PsiClass; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.config.ToggleBooleanProperty; import org.jetbrains.annotations.NonNls; import javax.swing.*; @@ -45,6 +48,20 @@ public class JUnitToolbarPanel extends ToolbarPanel { super(properties, runnerSettings, configurationSettings, parentComponent); } + @Override + protected void appendAdditionalActions(DefaultActionGroup actionGroup, + TestConsoleProperties properties, + RunnerSettings runnerSettings, + ConfigurationPerRunnerSettings configurationSettings, + JComponent parent) { + super.appendAdditionalActions(actionGroup, properties, runnerSettings, configurationSettings, parent); + actionGroup.addAction(new ToggleBooleanProperty( + ExecutionBundle.message("junit.runing.info.include.non.started.in.rerun.failed.action.name"), + null, + null, + properties, TestConsoleProperties.INCLUDE_NON_STARTED_IN_RERUN_FAILED)).setAsSecondary(true); + } + public void setModel(final TestFrameworkRunningModel model) { super.setModel(model); diff --git a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java index afbd12cbd32d..617d403f915d 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java +++ b/plugins/testng/src/com/theoryinpractice/testng/ui/TestNGResults.java @@ -23,11 +23,13 @@ package com.theoryinpractice.testng.ui; import com.intellij.codeInsight.AnnotationUtil; +import com.intellij.execution.ExecutionBundle; import com.intellij.execution.configurations.ConfigurationPerRunnerSettings; import com.intellij.execution.configurations.RunnerSettings; import com.intellij.execution.testframework.*; import com.intellij.execution.testframework.actions.ScrollToTestSourceAction; import com.intellij.execution.testframework.ui.TestResultsPanel; +import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.util.ColorProgressBar; import com.intellij.openapi.project.Project; @@ -41,6 +43,7 @@ import com.intellij.ui.DoubleClickListener; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.table.TableView; import com.intellij.util.OpenSourceUtil; +import com.intellij.util.config.ToggleBooleanProperty; import com.theoryinpractice.testng.configuration.TestNGConfiguration; import com.theoryinpractice.testng.model.*; import com.theoryinpractice.testng.util.TestNGUtil; @@ -148,7 +151,21 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn @Override protected ToolbarPanel createToolbarPanel() { - final ToolbarPanel panel = new ToolbarPanel(getProperties(), myRunnerSettings, myConfigurationSettings, this); + final ToolbarPanel panel = new ToolbarPanel(getProperties(), myRunnerSettings, myConfigurationSettings, this){ + @Override + protected void appendAdditionalActions(DefaultActionGroup actionGroup, + TestConsoleProperties properties, + RunnerSettings runnerSettings, + ConfigurationPerRunnerSettings configurationSettings, + JComponent parent) { + super.appendAdditionalActions(actionGroup, properties, runnerSettings, configurationSettings, parent); + actionGroup.addAction(new ToggleBooleanProperty( + ExecutionBundle.message("junit.runing.info.include.non.started.in.rerun.failed.action.name"), + null, + null, + properties, TestConsoleProperties.INCLUDE_NON_STARTED_IN_RERUN_FAILED)).setAsSecondary(true); + } + }; panel.setModel(this); return panel; } diff --git a/xml/dom-impl/src/com/intellij/util/xml/impl/DomManagerImpl.java b/xml/dom-impl/src/com/intellij/util/xml/impl/DomManagerImpl.java index 574355c66859..ed67161b6773 100644 --- a/xml/dom-impl/src/com/intellij/util/xml/impl/DomManagerImpl.java +++ b/xml/dom-impl/src/com/intellij/util/xml/impl/DomManagerImpl.java @@ -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 MOCK = Key.create("MockElement"); + static final Key> CACHED_FILE_ELEMENT = Key.create("CACHED_FILE_ELEMENT"); static final Key MOCK_DESCRIPTION = Key.create("MockDescription"); - static final SemKey FILE_DESCRIPTION_KEY = SemKey.createKey("FILE_DESCRIPTION_KEY"); - public static final SemKey DOM_HANDLER_KEY = SemKey.createKey("DOM_HANDLER_KEY"); + static final SemKey DOM_HANDLER_KEY = SemKey.createKey("DOM_HANDLER_KEY"); static final SemKey DOM_INDEXED_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_INDEXED_HANDLER_KEY"); static final SemKey DOM_COLLECTION_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_COLLECTION_HANDLER_KEY"); static final SemKey DOM_CUSTOM_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_CUSTOM_HANDLER_KEY"); static final SemKey DOM_ATTRIBUTE_HANDLER_KEY = DOM_HANDLER_KEY.subKey("DOM_ATTRIBUTE_HANDLER_KEY"); private final EventDispatcher 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 myDeletionEvents = new SmartList(); @@ -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); } diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomAnnotationsTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomAnnotationsTest.java index f6d86922174a..49110e2c0f4a 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomAnnotationsTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomAnnotationsTest.java @@ -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 createElement(final String xml, final Class aClass) { diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java index 169c66b5aae0..89229bf889c5 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomChildrenTest.java @@ -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; diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java index e0aa679039e2..4a94d0e5ba26 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomConcurrencyStressTest.java @@ -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; diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java index 7977a8d103c9..5aa8c0b2255d 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomExtensionsTest.java @@ -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; diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java b/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java index 934bf2928ec6..c2f13f6368cb 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomHardCoreTestCase.java @@ -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 diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java index 2486c87e1b9b..623b11616f59 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomHighlightingLiteTest.java @@ -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; diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomModelMergingTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomModelMergingTest.java index 6dc47ed8a06a..9efc125bb83c 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomModelMergingTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomModelMergingTest.java @@ -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 diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomNamespacesTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomNamespacesTest.java index 9c24fa57557b..8d92c019129f 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomNamespacesTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomNamespacesTest.java @@ -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; diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomSimpleValuesTest.java b/xml/dom-tests/tests/com/intellij/util/xml/DomSimpleValuesTest.java index 4fcdcf0d91d1..8911df1c22ac 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomSimpleValuesTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/DomSimpleValuesTest.java @@ -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; diff --git a/xml/dom-tests/tests/com/intellij/util/xml/SimpleValuesIncrementalUpdateTest.java b/xml/dom-tests/tests/com/intellij/util/xml/SimpleValuesIncrementalUpdateTest.java index fe4038235825..2a2bf1a4e2f3 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/SimpleValuesIncrementalUpdateTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/SimpleValuesIncrementalUpdateTest.java @@ -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(""); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/DomTestCase.java b/xml/dom-tests/tests/com/intellij/util/xml/impl/DomTestCase.java similarity index 83% rename from xml/dom-tests/tests/com/intellij/util/xml/DomTestCase.java rename to xml/dom-tests/tests/com/intellij/util/xml/impl/DomTestCase.java index 7531e4838739..37682943b3eb 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/DomTestCase.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/impl/DomTestCase.java @@ -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 createElement(final DomManager domManager, final String xml, final Class aClass) + public static T createElement(final DomManager domManager, final String xml, final Class aClass) throws IncorrectOperationException { final String name = "a.xml"; final XmlFile file = (XmlFile)PsiFileFactory.getInstance(domManager.getProject()).createFileFromText(name, xml); diff --git a/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java b/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java index 9df3cceb1849..2f7f2fefcd90 100644 --- a/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java +++ b/xml/dom-tests/tests/com/intellij/util/xml/impl/IncrementalUpdateEventsTest.java @@ -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; diff --git a/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java b/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java index 34e2a2082ab5..fa2f1609c3b9 100644 --- a/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java +++ b/xml/impl/resources/com/intellij/codeInsight/completion/TagNameReferenceCompletionProvider.java @@ -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 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); } } } diff --git a/xml/impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java b/xml/impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java index cf6bee3dc81b..3aeb0ebf9fd0 100644 --- a/xml/impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java +++ b/xml/impl/src/com/intellij/codeInspection/htmlInspections/SwitchToHtml5Action.java @@ -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(); } } diff --git a/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java b/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java index 772dd1930d99..9ef5af47f311 100644 --- a/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java +++ b/xml/impl/src/com/intellij/javaee/DefaultHtmlDoctypeInitialConfigurator.java @@ -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()); } } } diff --git a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java index 56b9e70b4986..cd97d262957b 100644 --- a/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java +++ b/xml/impl/src/com/intellij/javaee/ExternalResourceManagerImpl.java @@ -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 { diff --git a/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java b/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java index ac828cbf5b88..5d4668a98ef2 100644 --- a/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java +++ b/xml/impl/src/com/intellij/javaee/HtmlLanguageLevelForm.java @@ -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); } diff --git a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java index 85f01c54b656..da3254a24815 100644 --- a/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java +++ b/xml/tests/src/com/intellij/codeInsight/XmlParsingTest.java @@ -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("com.intellij.xml.startTagEndToken"), - XmlChildRole.StartTagEndTokenProvider.class); + registerExtensionPoint(StartTagEndTokenProvider.EP_NAME, StartTagEndTokenProvider.class); } @Override diff --git a/xml/xml-psi-impl/src/messages/XmlErrorMessages.properties b/xml/xml-psi-impl/resources/messages/XmlErrorMessages.properties similarity index 100% rename from xml/xml-psi-impl/src/messages/XmlErrorMessages.properties rename to xml/xml-psi-impl/resources/messages/XmlErrorMessages.properties diff --git a/xml/impl/resources/standardSchemas/XMLSchema-instance.xsd b/xml/xml-psi-impl/resources/standardSchemas/XMLSchema-instance.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/XMLSchema-instance.xsd rename to xml/xml-psi-impl/resources/standardSchemas/XMLSchema-instance.xsd diff --git a/xml/impl/resources/standardSchemas/XMLSchema.dtd b/xml/xml-psi-impl/resources/standardSchemas/XMLSchema.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/XMLSchema.dtd rename to xml/xml-psi-impl/resources/standardSchemas/XMLSchema.dtd diff --git a/xml/impl/resources/standardSchemas/XMLSchema.xsd b/xml/xml-psi-impl/resources/standardSchemas/XMLSchema.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/XMLSchema.xsd rename to xml/xml-psi-impl/resources/standardSchemas/XMLSchema.xsd diff --git a/xml/impl/resources/standardSchemas/catalog.xsd b/xml/xml-psi-impl/resources/standardSchemas/catalog.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/catalog.xsd rename to xml/xml-psi-impl/resources/standardSchemas/catalog.xsd diff --git a/xml/impl/resources/standardSchemas/datatypes.dtd b/xml/xml-psi-impl/resources/standardSchemas/datatypes.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/datatypes.dtd rename to xml/xml-psi-impl/resources/standardSchemas/datatypes.dtd diff --git a/xml/impl/resources/standardSchemas/html5/xhtml5.xsd b/xml/xml-psi-impl/resources/standardSchemas/html5/xhtml5.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/html5/xhtml5.xsd rename to xml/xml-psi-impl/resources/standardSchemas/html5/xhtml5.xsd diff --git a/xml/impl/resources/standardSchemas/plugin-repository.dtd b/xml/xml-psi-impl/resources/standardSchemas/plugin-repository.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/plugin-repository.dtd rename to xml/xml-psi-impl/resources/standardSchemas/plugin-repository.dtd diff --git a/xml/impl/resources/standardSchemas/plugin.dtd b/xml/xml-psi-impl/resources/standardSchemas/plugin.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/plugin.dtd rename to xml/xml-psi-impl/resources/standardSchemas/plugin.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml-lat1.ent b/xml/xml-psi-impl/resources/standardSchemas/xhtml-lat1.ent similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-lat1.ent rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-lat1.ent diff --git a/xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-flat.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-flat.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-flat.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-flat.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-model-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-model-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-model-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10-model-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile10.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-form.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-form.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-form.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-form.mod diff --git a/xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-model-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-model-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-model-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12-model-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtml-mobile12.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml-mobile/xhtmlmp12-form-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtmlmp12-form-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-mobile/xhtmlmp12-form-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-mobile/xhtmlmp12-form-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml-special.ent b/xml/xml-psi-impl/resources/standardSchemas/xhtml-special.ent similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-special.ent rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-special.ent diff --git a/xml/impl/resources/standardSchemas/xhtml-symbol.ent b/xml/xml-psi-impl/resources/standardSchemas/xhtml-symbol.ent similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml-symbol.ent rename to xml/xml-psi-impl/resources/standardSchemas/xhtml-symbol.ent diff --git a/xml/impl/resources/standardSchemas/xhtml.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml1-frameset.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml1-frameset.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml1-frameset.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml1-frameset.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml1-frameset.xsd b/xml/xml-psi-impl/resources/standardSchemas/xhtml1-frameset.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml1-frameset.xsd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml1-frameset.xsd diff --git a/xml/impl/resources/standardSchemas/xhtml1-strict.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml1-strict.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml1-strict.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml1-strict.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml1-strict.xsd b/xml/xml-psi-impl/resources/standardSchemas/xhtml1-strict.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml1-strict.xsd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml1-strict.xsd diff --git a/xml/impl/resources/standardSchemas/xhtml1-transitional.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml1-transitional.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml1-transitional.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml1-transitional.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml1-transitional.xsd b/xml/xml-psi-impl/resources/standardSchemas/xhtml1-transitional.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml1-transitional.xsd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml1-transitional.xsd diff --git a/xml/impl/resources/standardSchemas/xhtml1.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml1.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml1.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml1.dtd diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-attribs-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-attribs-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-attribs-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-attribs-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-base-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-base-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-base-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-base-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-basic-form-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-basic-form-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-basic-form-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-basic-form-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-basic-table-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-basic-table-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-basic-table-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-basic-table-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-blkphras-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-blkphras-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-blkphras-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-blkphras-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-blkpres-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-blkpres-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-blkpres-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-blkpres-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-blkstruct-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-blkstruct-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-blkstruct-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-blkstruct-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-charent-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-charent-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-charent-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-charent-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-csismap-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-csismap-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-csismap-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-csismap-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-datatypes-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-datatypes-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-datatypes-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-datatypes-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-edit-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-edit-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-edit-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-edit-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-events-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-events-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-events-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-events-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-form-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-form-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-form-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-form-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-framework-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-framework-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-framework-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-framework-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-hypertext-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-hypertext-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-hypertext-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-hypertext-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-image-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-image-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-image-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-image-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-inlphras-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlphras-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-inlphras-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlphras-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-inlpres-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlpres-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-inlpres-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlpres-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-inlstruct-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlstruct-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-inlstruct-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlstruct-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-inlstyle-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlstyle-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-inlstyle-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-inlstyle-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-lat1.ent b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-lat1.ent similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-lat1.ent rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-lat1.ent diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-link-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-link-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-link-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-link-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-list-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-list-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-list-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-list-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-meta-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-meta-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-meta-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-meta-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-object-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-object-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-object-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-object-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-param-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-param-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-param-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-param-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-pres-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-pres-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-pres-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-pres-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-qname-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-qname-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-qname-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-qname-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-ruby-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-ruby-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-ruby-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-ruby-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-script-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-script-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-script-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-script-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-special.ent b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-special.ent similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-special.ent rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-special.ent diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-ssismap-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-ssismap-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-ssismap-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-ssismap-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-struct-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-struct-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-struct-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-struct-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-style-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-style-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-style-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-style-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-symbol.ent b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-symbol.ent similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-symbol.ent rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-symbol.ent diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-table-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-table-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-table-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-table-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-target-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-target-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-target-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-target-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml-text-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-text-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml-text-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml-text-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml11-model-1.mod b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml11-model-1.mod similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml11-model-1.mod rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml11-model-1.mod diff --git a/xml/impl/resources/standardSchemas/xhtml11/xhtml11.dtd b/xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml11.dtd similarity index 100% rename from xml/impl/resources/standardSchemas/xhtml11/xhtml11.dtd rename to xml/xml-psi-impl/resources/standardSchemas/xhtml11/xhtml11.dtd diff --git a/xml/impl/resources/standardSchemas/xinclude.xsd b/xml/xml-psi-impl/resources/standardSchemas/xinclude.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/xinclude.xsd rename to xml/xml-psi-impl/resources/standardSchemas/xinclude.xsd diff --git a/xml/impl/resources/standardSchemas/xml.xsd b/xml/xml-psi-impl/resources/standardSchemas/xml.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/xml.xsd rename to xml/xml-psi-impl/resources/standardSchemas/xml.xsd diff --git a/xml/impl/resources/standardSchemas/xslt-1_0.xsd b/xml/xml-psi-impl/resources/standardSchemas/xslt-1_0.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/xslt-1_0.xsd rename to xml/xml-psi-impl/resources/standardSchemas/xslt-1_0.xsd diff --git a/xml/impl/resources/standardSchemas/xslt-2_0.xsd b/xml/xml-psi-impl/resources/standardSchemas/xslt-2_0.xsd similarity index 100% rename from xml/impl/resources/standardSchemas/xslt-2_0.xsd rename to xml/xml-psi-impl/resources/standardSchemas/xslt-2_0.xsd diff --git a/xml-psi-impl/impl/src/com/intellij/lexer/_HtmlLexer.flex b/xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex similarity index 100% rename from xml-psi-impl/impl/src/com/intellij/lexer/_HtmlLexer.flex rename to xml/xml-psi-impl/src/com/intellij/lexer/_HtmlLexer.flex diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java index 3c4f2f4d8b2a..fea20095bc75 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java @@ -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); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/xml/StartTagEndTokenProvider.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/StartTagEndTokenProvider.java new file mode 100644 index 000000000000..e81ea4ad23d1 --- /dev/null +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/StartTagEndTokenProvider.java @@ -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 EP_NAME = new ExtensionPointName("com.intellij.xml.startTagEndToken"); + + IElementType[] getTypes(); +} diff --git a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java index 0e39ab22e2ab..02cb1fe03b5a 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/xml/XmlChildRole.java @@ -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 EP_NAME = new ExtensionPointName("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()); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java b/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java index b9ab906aa724..7d09b8780ab2 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/Html5SchemaProvider.java @@ -17,16 +17,25 @@ public abstract class Html5SchemaProvider { public static final ExtensionPointName 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 String getClassesListString(T[] a) { diff --git a/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java index 77852f097a34..d76dbb5bac35 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/XmlCoreEnvironment.java @@ -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; @@ -36,7 +36,7 @@ import com.intellij.xml.util.XmlApplicationComponent; * @author yole */ public class XmlCoreEnvironment { - public static void register(CoreApplicationEnvironment appEnvironment, CoreProjectEnvironment projectEnvironment) { + public static void registerApplication(CoreApplicationEnvironment appEnvironment) { appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml"); appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml"); appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt"); @@ -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); @@ -72,4 +72,7 @@ public class XmlCoreEnvironment { appEnvironment.registerApplicationService(ExternalResourceManager.class, new CoreExternalResourceManager()); } + + public static void registerProject(CoreProjectEnvironment projectEnvironment) { + } } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java index 62e66f46b247..efb006b587d9 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XmlNamespaceIndex.java @@ -73,7 +73,7 @@ public class XmlNamespaceIndex extends XmlIndex { return IndexedRelevantResource.getAllResources(NAME, module, project, chooser); } - private static final ID NAME = ID.create("XmlNamespaces"); + public static final ID NAME = ID.create("XmlNamespaces"); @Override @NotNull diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java index 9dc54b0025da..e502a5ed00df 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlUtil.java @@ -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())); } diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java index dc6e626ad78b..09fa8ade43bb 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/util/XmlUtil.java @@ -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; diff --git a/xml/xml-psi-impl/xml-psi-impl.iml b/xml/xml-psi-impl/xml-psi-impl.iml index 1aa39410f34e..b12b84d69dcf 100644 --- a/xml/xml-psi-impl/xml-psi-impl.iml +++ b/xml/xml-psi-impl/xml-psi-impl.iml @@ -4,6 +4,7 @@ +