diff --git a/.idea/libraries/TestNG.xml b/.idea/libraries/TestNG.xml index 5ab2412b1a6e..4249f2803a1b 100644 --- a/.idea/libraries/TestNG.xml +++ b/.idea/libraries/TestNG.xml @@ -1,7 +1,7 @@ - + diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant index 9f91ee9024ba..af6fdd1f86a6 100644 --- a/build/scripts/layouts.gant +++ b/build/scripts/layouts.gant @@ -292,7 +292,7 @@ public def layoutCommunityPlugins(String home) { pluginDir("testng") { dir("lib") { - jar("testng.jar") { + jar("testng-plugin.jar") { noResources("testng") noResources("testng_rt") } @@ -300,13 +300,7 @@ public def layoutCommunityPlugins(String home) { resources("testng") fileset(dir: "$home/plugins/testng/lib") { - include(name: "testng-jdk15.jar") - } - } - - dir("lib-jdk14") { - fileset(dir: "$home/plugins/testng/lib") { - include(name: "testng-jdk14.jar") + include(name: "testng.jar") } } } diff --git a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java index 0cc7055c6ae4..4ea275f38e0c 100644 --- a/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java +++ b/java/compiler/impl/src/com/intellij/compiler/server/BuildManager.java @@ -81,6 +81,7 @@ import java.net.InetSocketAddress; import java.util.*; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -301,14 +302,18 @@ public class BuildManager implements ApplicationComponent{ } } - public void cancelAutoMakeTasks(Project project) { + public Collection cancelAutoMakeTasks(Project project) { + final Collection futures = new ArrayList(); synchronized (myAutomakeFutures) { for (Map.Entry entry : myAutomakeFutures.entrySet()) { if (entry.getValue().equals(project)) { - entry.getKey().cancel(false); + final RequestFuture future = entry.getKey(); + future.cancel(false); + futures.add(future); } } } + return futures; } @Nullable @@ -746,8 +751,17 @@ public class BuildManager implements ApplicationComponent{ }); } + @Override + public boolean canCloseProject(Project project) { + cancelAutoMakeTasks(project); + return super.canCloseProject(project); + } + @Override public void projectClosing(Project project) { + for (RequestFuture future : cancelAutoMakeTasks(project)) { + future.waitFor(500, TimeUnit.MILLISECONDS); + } } @Override diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java index 30cef270105d..a11d37e8c0a8 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/options/ExcludedEntriesConfigurable.java @@ -149,7 +149,7 @@ public class ExcludedEntriesConfigurable implements UnnamedConfigurable { } private void addPath(FileChooserDescriptor descriptor) { - int selected = myExcludedTable.getSelectedRow() + 1; + int selected = -1 /*myExcludedTable.getSelectedRow() + 1*/; if(selected < 0) { selected = myExcludeEntryDescriptions.size(); } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java index dd994f87f514..47021b9899ad 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ConfigurationErrorsComponent.java @@ -20,7 +20,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.JBList; import com.intellij.ui.components.JBScrollPane; diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java index c74f1c7e59e8..ddf177c70cb2 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFieldFromUsageFix.java @@ -126,7 +126,7 @@ public class CreateFieldFromUsageFix extends CreateVarFromUsageFix { final Editor newEditor = positionCursor(project, targetFile, field); TextRange range = field.getTextRange(); newEditor.getDocument().deleteString(range.getStartOffset(), range.getEndOffset()); - template.setToShortenLongNames(false); + if (expectedTypes.length > 1) template.setToShortenLongNames(false); startTemplate(newEditor, template, project, new TemplateEditingAdapter() { @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java index d4d178428a33..d34a603216ff 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java @@ -195,7 +195,10 @@ public class CreateFromUsageUtils { if (end < start) { newEditor.getCaretModel().moveToOffset(end + 1); CodeStyleManager styleManager = CodeStyleManager.getInstance(method.getProject()); - final String lineIndent = styleManager.getLineIndent(method.getContainingFile(), Math.min(start, end)); + PsiFile containingFile = method.getContainingFile(); + final String lineIndent = styleManager.getLineIndent(containingFile, Math.min(start, end)); + PsiDocumentManager manager = PsiDocumentManager.getInstance(method.getProject()); + manager.doPostponedOperationsAndUnblockDocument(manager.getDocument(containingFile)); EditorModificationUtil.insertStringAtCaret(newEditor, lineIndent); } else { newEditor.getSelectionModel().setSelection(Math.min(start, end), Math.max(start, end)); diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java index 703de16a3ee8..ba22c9682e25 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddSingleMemberStaticImportAction.java @@ -156,9 +156,12 @@ public class AddSingleMemberStaticImportAction extends PsiElementBaseIntentionAc if (referent instanceof PsiMember && referent != reference.resolve()) { PsiElementFactory factory = JavaPsiFacade.getInstance(reference.getProject()).getElementFactory(); try { - PsiReferenceExpression copy = (PsiReferenceExpression)factory.createExpressionFromText("A." + reference.getReferenceName(), null); - reference = (PsiReferenceExpression)reference.replace(copy); - ((PsiReferenceExpression)reference.getQualifier()).bindToElement(((PsiMember)referent).getContainingClass()); + final PsiClass containingClass = ((PsiMember)referent).getContainingClass(); + if (containingClass != null) { + PsiReferenceExpression copy = (PsiReferenceExpression)factory.createExpressionFromText("A." + reference.getReferenceName(), null); + reference = (PsiReferenceExpression)reference.replace(copy); + ((PsiReferenceExpression)reference.getQualifier()).bindToElement(containingClass); + } } catch (IncorrectOperationException e) { LOG.error (e); diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java index 8f9ad7e76846..b0247a387e84 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/TypeExpression.java @@ -53,6 +53,11 @@ public class TypeExpression extends Expression { public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) { if (myItems.size() <= 1) super.handleRecalc(psiFile, document, segmentStart, segmentEnd); } + + @Override + public String toString() { + return myItems.size() == 1 ? type.getCanonicalText() : super.toString(); + } }; } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java index 86b946aa7b66..4260c0532dd2 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceparameterobject/IntroduceParameterObjectDialog.java @@ -107,6 +107,9 @@ public class IntroduceParameterObjectDialog extends RefactoringDialog { buttonGroup.add(createNewClassButton); buttonGroup.add(myCreateInnerClassRadioButton); createNewClassButton.setSelected(true); + if (containingClass != null && containingClass.getQualifiedName() == null) { + myCreateInnerClassRadioButton.setEnabled(false); + } init(); final ActionListener listener = new ActionListener() { diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/ImportSearcher.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/ImportSearcher.java new file mode 100644 index 000000000000..ad3ff198991b --- /dev/null +++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/ImportSearcher.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2012 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.refactoring.safeDelete; + +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.Nullable; + +/** + * @author Max Medvedev + */ +public abstract class ImportSearcher { + private static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.safeDelete.importSearcher"); + + /** + * @return found import or null + */ + @Nullable + public abstract PsiElement findImport(PsiElement element); + + @Nullable + public static PsiElement getImport(PsiElement element) { + for (ImportSearcher searcher : EP_NAME.getExtensions()) { + PsiElement anImport = searcher.findImport(element); + if (anImport != null) return anImport; + } + + return null; + } +} diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaImportSearcher.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaImportSearcher.java new file mode 100644 index 000000000000..a31285b6f49d --- /dev/null +++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaImportSearcher.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2012 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.refactoring.safeDelete; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.PsiImportList; +import com.intellij.psi.PsiJavaFile; +import com.intellij.psi.util.PsiTreeUtil; + +/** + * @author Max Medvedev + */ +public class JavaImportSearcher extends ImportSearcher { + @Override + public PsiElement findImport(PsiElement element) { + final PsiFile containingFile = element.getContainingFile(); + if (containingFile instanceof PsiJavaFile) { + return PsiTreeUtil.getParentOfType(element, PsiImportList.class, true); + } + return null; + } +} diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java index b60edb36e71f..eefad2425412 100644 --- a/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/JavaSafeDeleteProcessor.java @@ -329,13 +329,17 @@ public class JavaSafeDeleteProcessor extends SafeDeleteProcessorDelegateBase { } } LOG.assertTrue(element.getTextRange() != null); - usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(element, psiClass, parent instanceof PsiImportStatement)); + usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(element, psiClass, isInImport(element))); } return true; } }); } + private static boolean isInImport(PsiElement element) { + return ImportSearcher.getImport(element) != null; + } + private static boolean containsOnlyPrivates(final PsiClass aClass) { final PsiField[] fields = aClass.getFields(); for (PsiField field : fields) { diff --git a/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteReferenceJavaDeleteUsageInfo.java b/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteReferenceJavaDeleteUsageInfo.java index 8d1b485bcb6f..9a9b8edea969 100644 --- a/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteReferenceJavaDeleteUsageInfo.java +++ b/java/java-impl/src/com/intellij/refactoring/safeDelete/usageInfo/SafeDeleteReferenceJavaDeleteUsageInfo.java @@ -15,11 +15,10 @@ */ package com.intellij.refactoring.safeDelete.usageInfo; -import com.intellij.util.IncorrectOperationException; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiImportStatementBase; -import com.intellij.psi.util.PsiTreeUtil; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.psi.PsiElement; +import com.intellij.refactoring.safeDelete.ImportSearcher; +import com.intellij.util.IncorrectOperationException; /** * @author yole @@ -31,19 +30,26 @@ public class SafeDeleteReferenceJavaDeleteUsageInfo extends SafeDeleteReferenceS super(element, referencedElement, isSafeDelete); } - public SafeDeleteReferenceJavaDeleteUsageInfo(final PsiElement element, final PsiElement referencedElement, final int startOffset, final int endOffset, + public SafeDeleteReferenceJavaDeleteUsageInfo(final PsiElement element, + final PsiElement referencedElement, + final int startOffset, + final int endOffset, final boolean isNonCodeUsage, final boolean isSafeDelete) { super(element, referencedElement, startOffset, endOffset, isNonCodeUsage, isSafeDelete); } public void deleteElement() throws IncorrectOperationException { - if(isSafeDelete()) { + if (isSafeDelete()) { PsiElement element = getElement(); LOG.assertTrue(element != null); - PsiImportStatementBase importStatement = PsiTreeUtil.getParentOfType(element, PsiImportStatementBase.class); - if (importStatement != null) importStatement.delete(); - else element.delete(); + PsiElement importStatement = ImportSearcher.getImport(element); + if (importStatement != null) { + importStatement.delete(); + } + else { + element.delete(); + } } } } diff --git a/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java b/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java index 4c0bd5dd6479..0bde98391973 100644 --- a/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java +++ b/jps/jps-builders/testSrc/org/jetbrains/jps/incremental/artifacts/ArtifactBuilderTestCase.java @@ -130,7 +130,6 @@ public abstract class ArtifactBuilderTestCase extends UsefulTestCase { } } final Module module = myProject.createModule(moduleName, Closure.IDENTITY); - module.forceInit(); module.setSdk(myJdk); module.addDependency(myJdk, PredefinedDependencyScopes.getCOMPILE(), false); if (srcPaths.length > 0) { @@ -145,7 +144,6 @@ public abstract class ArtifactBuilderTestCase extends UsefulTestCase { protected Library addProjectLibrary(String name, String jarPath) { final Library library = myProject.createLibrary(name, Closure.IDENTITY); - library.forceInit(); library.getClasspath().add(jarPath); return library; } diff --git a/jps/model/src/org/jetbrains/jps/LazyInitializeableObject.groovy b/jps/model/src/org/jetbrains/jps/LazyInitializeableObject.groovy deleted file mode 100644 index a296030bd727..000000000000 --- a/jps/model/src/org/jetbrains/jps/LazyInitializeableObject.groovy +++ /dev/null @@ -1,50 +0,0 @@ -package org.jetbrains.jps - -/** - * @author max - */ -class LazyInitializeableObject { - private Intializing initializer - - def setInitializer(Closure init) { - def meta = ProxyMetaClass.getInstance(getClass()) - initializer = new Intializing(initializer: init) - meta.setInterceptor(initializer) - setMetaClass(meta) - } - - def forceInit () { - if (initializer != null) initializer.init() - } -} - -private class Intializing implements PropertyAccessInterceptor { - private Closure initializer - - Object beforeInvoke(Object object, String methodName, Object[] arguments) { - init() - } - - Object afterInvoke(Object object, String methodName, Object[] arguments, Object result) { - return result - } - - Object beforeGet(Object object, String property) { - init() - } - - void beforeSet(Object object, String property, Object newValue) { - init() - } - - boolean doInvoke() { - true - } - - def init() { - if (initializer == null) return - def i = initializer - initializer = null - i.call() - } -} diff --git a/jps/model/src/org/jetbrains/jps/Library.groovy b/jps/model/src/org/jetbrains/jps/Library.groovy index eb60360b6504..7ad2385c31e6 100644 --- a/jps/model/src/org/jetbrains/jps/Library.groovy +++ b/jps/model/src/org/jetbrains/jps/Library.groovy @@ -5,7 +5,7 @@ import com.intellij.openapi.util.io.FileUtil /** * @author max */ -class Library extends LazyInitializeableObject implements ClasspathItem { +class Library implements ClasspathItem { Project project; String name; @@ -14,42 +14,22 @@ class Library extends LazyInitializeableObject implements ClasspathItem { private Map props = [:] - def Library(project, name, initializer) { - this(project, name, false, initializer) - } - - def Library(project, name, forceInitialization, initializer) { + def Library(project, name) { this.project = project; this.name = name; + } - Closure lazyInit = { - def meta = new InitializingExpando() - meta.classpath = {Object[] arg -> - arg.each { classpath << FileUtil.toCanonicalPath(it.toString()) } - } + void addClasspath(String arg) { + classpath << FileUtil.toCanonicalPath(arg) + } - meta.src = {Object[] arg -> - arg.each { sourceRoots << FileUtil.toCanonicalPath(it.toString()) } - } + void addClasspath(GString arg) { + new Throwable().printStackTrace() + addClasspath(arg.toString()) + } - initializer.delegate = meta - initializer.setResolveStrategy Closure.DELEGATE_FIRST - initializer.call() - - def wrongProperties = ["classpath", "src"] as Set - meta.getProperties().each {String key, Object value -> - if (!wrongProperties.contains(key)) { - props[key] = value - } - } - } - - if (forceInitialization) { - lazyInit.call() - } - else { - setInitializer(lazyInit) - } + void src(Object[] arg) { + arg.each { sourceRoots << FileUtil.toCanonicalPath(it.toString()) } } def String toString() { @@ -57,7 +37,6 @@ class Library extends LazyInitializeableObject implements ClasspathItem { } def List getClasspathRoots(ClasspathKind kind) { - forceInit() classpath } diff --git a/jps/model/src/org/jetbrains/jps/Module.groovy b/jps/model/src/org/jetbrains/jps/Module.groovy index b3f06edf53f6..f5e47bd18708 100644 --- a/jps/model/src/org/jetbrains/jps/Module.groovy +++ b/jps/model/src/org/jetbrains/jps/Module.groovy @@ -7,7 +7,7 @@ import org.jetbrains.annotations.TestOnly /** * @author max */ -class Module extends LazyInitializeableObject implements ClasspathItem {//}, Comparable { +class Module implements ClasspathItem {//}, Comparable { Project project; String name; Sdk sdk; @@ -31,64 +31,37 @@ class Module extends LazyInitializeableObject implements ClasspathItem {//}, Com String languageLevel - /*int compareTo(Object o) { - if (o instanceof Module) { - ((Module) o).name.compareTo(name); - } - - return -1 - }*/ - def Module(project, name, initializer) { this.project = project; this.name = name; + } - setInitializer({ - def meta = new InitializingExpando() + void dependency(Object item, DependencyScope scope, boolean exported) { + dependencies << new ModuleDependency(project.resolve(item), scope, exported) + } - meta.dependency = {Object item, DependencyScope scope, boolean exported -> - dependencies << new ModuleDependency(project.resolve(item), scope, exported) - } + void classpath(Object[] arg) { + arg.each { dependencies << new ModuleDependency(project.resolve(it), PredefinedDependencyScopes.COMPILE, false) } + } - meta.classpath = {Object[] arg -> - arg.each { dependencies << new ModuleDependency(project.resolve(it), PredefinedDependencyScopes.COMPILE, false) } - } + void moduleSource() { + dependencies << new ModuleDependency(new ModuleSourceEntry(module: this), PredefinedDependencyScopes.COMPILE, true) + } - meta.testclasspath = {Object[] arg -> - arg.each { dependencies << new ModuleDependency(project.resolve(it), PredefinedDependencyScopes.TEST, false) } - } + void content(Object[] arg) { + arg.each { contentRoots << FileUtil.toCanonicalPath(it) } + } - meta.moduleSource = { - dependencies << new ModuleDependency(new ModuleSourceEntry(module: this), PredefinedDependencyScopes.COMPILE, true) - } + void src(Object[] arg) { + arg.each { sourceRoots << FileUtil.toCanonicalPath(it) } + } - meta.content = {Object[] arg -> - arg.each { contentRoots << FileUtil.toCanonicalPath(it) } - } + void testSrc(Object[] arg) { + arg.each { testRoots << FileUtil.toCanonicalPath(it) } + } - meta.src = {Object[] arg -> - arg.each { sourceRoots << FileUtil.toCanonicalPath(it) } - } - - meta.testSrc = {Object[] arg -> - arg.each { testRoots << FileUtil.toCanonicalPath(it) } - } - - meta.exclude = {Object[] arg -> - arg.each { addExcludedRoot(FileUtil.toCanonicalPath(it)) } - } - - initializer.delegate = meta - initializer.setResolveStrategy Closure.DELEGATE_FIRST - initializer.call() - - def wrongProperties = ["dependency", "classpath", "testclasspath", "src", "testSrc", "exclude"] as Set - meta.getProperties().each {String key, Object value -> - if (!wrongProperties.contains(key)) { - props[key] = value - } - } - }) + void exclude(Object[] arg) { + arg.each { addExcludedRoot(FileUtil.toCanonicalPath(it)) } } List getOwnExcludes() { @@ -100,8 +73,11 @@ class Module extends LazyInitializeableObject implements ClasspathItem {//}, Com excludes = new ArrayList(ownExcludes) Set allContentRoots = project.modules.values().collect { it.contentRoots }.flatten() as Set Set myRoots = contentRoots.collect { new File(it) } as Set - Collection newExcludes = (allContentRoots - contentRoots).findAll { PathUtil.isUnder(myRoots, new File(it)) }.collect { FileUtil.toCanonicalPath(it) } - excludes.addAll(newExcludes) + for (root in allContentRoots) { + if (!(root in contentRoots) && PathUtil.isUnder(myRoots, new File(root))) { + excludes << FileUtil.toCanonicalPath(root) + } + } } return excludes } @@ -133,7 +109,6 @@ class Module extends LazyInitializeableObject implements ClasspathItem {//}, Com } def List getClasspath(ClasspathKind kind, boolean exportedOnly) { - forceInit() return dependencies.findAll({it.scope.isIncludedIn(kind) && (!exportedOnly || it.exported)})*.item; } diff --git a/jps/model/src/org/jetbrains/jps/Project.groovy b/jps/model/src/org/jetbrains/jps/Project.groovy index 69898b12ccf1..d08da5c5ed64 100644 --- a/jps/model/src/org/jetbrains/jps/Project.groovy +++ b/jps/model/src/org/jetbrains/jps/Project.groovy @@ -41,7 +41,7 @@ class Project { } protected def Library createLibrary(String name, Closure initializer, Map libraries, String accessor) { - Library lib = new Library(this, name, initializer) + Library lib = new Library(this, name) libraries.put(name, lib) lib } diff --git a/jps/model/src/org/jetbrains/jps/Sdk.groovy b/jps/model/src/org/jetbrains/jps/Sdk.groovy index 93300f023248..bb41343ad91d 100644 --- a/jps/model/src/org/jetbrains/jps/Sdk.groovy +++ b/jps/model/src/org/jetbrains/jps/Sdk.groovy @@ -5,6 +5,6 @@ package org.jetbrains.jps */ class Sdk extends Library { Sdk(project, name, initializer) { - super(project, name, true, initializer); + super(project, name); } } diff --git a/jps/model/src/org/jetbrains/jps/idea/IdeaProjectLoader.groovy b/jps/model/src/org/jetbrains/jps/idea/IdeaProjectLoader.groovy index 1d70c83e807f..8522f64b43ae 100644 --- a/jps/model/src/org/jetbrains/jps/idea/IdeaProjectLoader.groovy +++ b/jps/model/src/org/jetbrains/jps/idea/IdeaProjectLoader.groovy @@ -17,6 +17,7 @@ public class IdeaProjectLoader { private ProjectMacroExpander projectMacroExpander private ProjectLoadingErrorReporter errorReporter private static final OwnServiceLoader rootsProviderLoader = OwnServiceLoader.load(AdditionalRootsProviderService.class) + private XmlParser xmlParser = new XmlParser(false, false) public static String guessHome(Script script) { File home = new File(script["gant.file"].substring("file:".length())) @@ -101,7 +102,7 @@ public class IdeaProjectLoader { project.locationHash = iprFile.absolutePath.hashCode() projectMacroExpander = new ProjectMacroExpander(pathVariables, iprFile.parentFile.absolutePath) - def root = new XmlParser(false, false).parse(iprFile) + def root = xmlParser.parse(iprFile) loadProjectJdkAndOutput(root) loadCompilerConfiguration(root) loadProjectFileEncodings(root) @@ -119,7 +120,7 @@ public class IdeaProjectLoader { projectMacroExpander = new ProjectMacroExpander(pathVariables, dir.parentFile.absolutePath) def miscXml = new File(dir, "misc.xml") if (miscXml.exists()) { - loadProjectJdkAndOutput(new XmlParser(false, false).parse(miscXml)) + loadProjectJdkAndOutput(xmlParser.parse(miscXml)) } else { errorReporter.error("Cannot find misc.xml in $dir") @@ -127,12 +128,12 @@ public class IdeaProjectLoader { def encodingsXml = new File(dir, "encodings.xml") if (encodingsXml.exists()) { - loadProjectFileEncodings(new XmlParser(false, false).parse(encodingsXml)) + loadProjectFileEncodings(xmlParser.parse(encodingsXml)) } def compilerXml = new File(dir, "compiler.xml") if (compilerXml.exists()) { - loadCompilerConfiguration(new XmlParser(false, false).parse(compilerXml)) + loadCompilerConfiguration(xmlParser.parse(compilerXml)) } loadWorkspaceConfiguration(new File(dir, "workspace.xml")) @@ -140,7 +141,7 @@ public class IdeaProjectLoader { if (librariesFolder.isDirectory()) { librariesFolder.eachFile {File file -> if (isXmlFile(file)) { - Node librariesComponent = new XmlParser(false, false).parse(file) + Node librariesComponent = xmlParser.parse(file) loadProjectLibraries(librariesComponent) } } @@ -148,7 +149,7 @@ public class IdeaProjectLoader { def modulesXml = new File(dir, "modules.xml") if (modulesXml.exists()) { - Node modulesXmlRoot = new XmlParser(false, false).parse(modulesXml) + Node modulesXmlRoot = xmlParser.parse(modulesXml) loadModules(modulesXmlRoot.component[0]) } else { @@ -157,14 +158,14 @@ public class IdeaProjectLoader { def uiDesignerXml = new File(dir, "uiDesigner.xml") if (uiDesignerXml.exists()) { - loadUiDesignerConfiguration(new XmlParser(false, false).parse(uiDesignerXml)) + loadUiDesignerConfiguration(xmlParser.parse(uiDesignerXml)) } def artifactsFolder = new File(dir, "artifacts") if (artifactsFolder.isDirectory()) { artifactsFolder.eachFile {File file -> if (isXmlFile(file)) { - def artifactsComponent = new XmlParser(false, false).parse(file) + def artifactsComponent = xmlParser.parse(file) loadArtifacts(artifactsComponent) } } @@ -174,7 +175,7 @@ public class IdeaProjectLoader { if (runConfFolder.isDirectory()) { runConfFolder.eachFile {File file -> if (isXmlFile(file)) { - def runConfManager = new XmlParser(false, false).parse(file); + def runConfManager = xmlParser.parse(file); loadRunConfigurations(runConfManager); } } @@ -196,7 +197,7 @@ public class IdeaProjectLoader { private def loadWorkspaceConfiguration(File workspaceFile) { if (!workspaceFile.exists()) return - def root = new XmlParser(false, false).parse(workspaceFile) + def root = xmlParser.parse(workspaceFile) def options = loadOptions(getComponent(root, "CompilerWorkspaceConfiguration")) // compatibility: in older projects this setting was stored in workspace if (project.compilerConfiguration.addNotNullAssertions == true) { // if is the same as default value @@ -328,8 +329,8 @@ public class IdeaProjectLoader { } private NodeList loadProjectLibraries(Node librariesComponent) { - return librariesComponent?.library?.each {Node libTag -> - project.createLibrary(libTag."@name", libraryInitializer(libTag, projectMacroExpander)) + return (NodeList)librariesComponent?.library?.each {Node libTag -> + initLibrary(libTag, projectMacroExpander, project.createLibrary(libTag."@name", Closure.IDENTITY)) } } @@ -357,23 +358,30 @@ public class IdeaProjectLoader { } private def loadModules(Node modulesComponent) { + List imlPaths = [] modulesComponent?.modules?.module?.each {Node moduleTag -> - loadModule(projectMacroExpander.expandMacros(moduleTag.@filepath)) + def imlPath = projectMacroExpander.expandMacros(moduleTag.@filepath) + project.createModule(moduleName(imlPath), {}) + imlPaths << imlPath } + imlPaths.each { loadModule(it) } Set allContentRoots = project.modules.values().collect { it.contentRoots }.flatten() as Set project.modules.values().each { module -> - Set myRoots = module.contentRoots.collect { new File(it) } as Set - Collection newExcludes = (allContentRoots - module.contentRoots).findAll { PathUtil.isUnder(myRoots, new File(it)) }.collect { FileUtil.toCanonicalPath(it) } - module.excludes.addAll(newExcludes) + def ownRootPaths = module.contentRoots + Set myRoots = ownRootPaths.collect { new File(it) } as Set + for (root in allContentRoots) { + if (!(root in ownRootPaths) && PathUtil.isUnder(myRoots, new File(root))) { + module.excludes << FileUtil.toCanonicalPath(root) + } + } } } private Library loadLibrary(Project project, String name, Node libraryTag, MacroExpander macroExpander) { - return new Library(project, name, true, libraryInitializer(libraryTag, macroExpander)) + return initLibrary(libraryTag, macroExpander, new Library(project, name)) } - private Closure libraryInitializer(Node libraryTag, MacroExpander macroExpander) { - return { + private Library initLibrary(Node libraryTag, MacroExpander macroExpander, Library library) { Map jarDirs = [:] libraryTag.jarDirectory.each {Node dirNode -> jarDirs[dirNode.@url] = Boolean.parseBoolean(dirNode.@recursive) @@ -386,18 +394,18 @@ public class IdeaProjectLoader { def paths = [] collectChildJars(path, jarDirs[url], paths) paths.each { - classpath it + library.addClasspath it.toString() } } else { - classpath path + library.addClasspath path } } libraryTag.SOURCES.root.each {Node rootTag -> - src macroExpander.expandMacros(rootTag.@url) + library.src macroExpander.expandMacros(rootTag.@url) } - } + return library } private def collectChildJars(String path, boolean recursively, List paths) { @@ -414,121 +422,29 @@ public class IdeaProjectLoader { } } - private def loadModule(String imlPath) { + private void loadModule(String imlPath) { def moduleFile = new File(imlPath) if (!moduleFile.exists()) { errorReporter.error("Module file $imlPath not found") return } - def moduleBasePath = FileUtil.toSystemIndependentName(moduleFile.getParentFile().getAbsolutePath()) MacroExpander moduleMacroExpander = new ModuleMacroExpander(projectMacroExpander, moduleBasePath) def currentModuleName = moduleName(imlPath) - project.createModule(currentModuleName) { Module currentModule = project.modules[currentModuleName] currentModule.basePath = moduleBasePath - def root = new XmlParser(false, false).parse(moduleFile) + def root = xmlParser.parse(moduleFile) def componentTag = getComponent(root, "NewModuleRootManager") if (componentTag != null) { - componentTag.orderEntry.each {Node entryTag -> - String type = entryTag.@type - DependencyScope scope = getScopeById(entryTag.@scope) - boolean exported = entryTag.@exported != null - switch (type) { - case "module": - def moduleName = entryTag.attribute("module-name") - def module = project.modules[moduleName] - if (module == null) { - errorReporter.warning("Cannot resolve module $moduleName in $currentModuleName") - } - else { - dependency(module, scope, exported) - } - break - - case "sourceFolder": - moduleSource() - break - - case "module-library": - def libraryTag = entryTag.library[0] - def libraryName = libraryTag."@name" - def moduleLibrary = loadLibrary(project, libraryName != null ? libraryName : "moduleLibrary#${libraryCount++}", - libraryTag, moduleMacroExpander) - dependency(moduleLibrary, scope, exported) - - if (libraryName != null) { - currentModule.libraries[libraryName] = moduleLibrary - } - break; - - case "library": - def name = entryTag.attribute("name") - def library = null - if (entryTag.@level == "project") { - library = project.libraries[name] - if (library == null) { - errorReporter.warning("Cannot resolve project library '$name' in module '$currentModuleName'") - } - } else { - library = project.globalLibraries[name] - if (library == null) { - errorReporter.warning("Cannot resolve global library '$name' in module '$currentModuleName'") - } - } - - if (library != null) { - dependency(library, scope, exported) - } - break - - case "jdk": - def name = entryTag.@jdkName - def sdk = project.sdks[name] - if (sdk == null) { - errorReporter.warning("Cannot resolve SDK '$name' in module '$currentModuleName'. Embedded javac will be used") - } - else { - currentModule.sdk = sdk - dependency(sdk, PredefinedDependencyScopes.COMPILE, false) - } - break - - case "inheritedJdk": - def sdk = project.projectSdk - if (sdk != null) { - currentModule.sdk = sdk - dependency(sdk, PredefinedDependencyScopes.COMPILE, false) - } - break - } - } + loadModuleOrderEntries(componentTag, currentModule, moduleMacroExpander, currentModuleName) def srcFolderExists = componentTag.content.sourceFolder[0] != null; - componentTag.content.each {Node contentTag -> - content moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(contentTag.@url)) - } - - componentTag.content.sourceFolder.each {Node folderTag -> - String path = moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(folderTag.@url)) - String prefix = folderTag.@packagePrefix - - if (folderTag.attribute("isTestSource") == "true") { - testSrc path - } - else { - src path - } - - if (prefix != null && prefix != "") { - currentModule.sourceRootPrefixes[path] = (prefix.replace('.', '/')) - } - } + loadSrcFolders(componentTag, moduleMacroExpander, currentModule) componentTag.content.excludeFolder.each {Node exTag -> String path = moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(exTag.@url)) - exclude path + currentModule.exclude path } def languageLevel = componentTag."@LANGUAGE_LEVEL" @@ -548,22 +464,7 @@ public class IdeaProjectLoader { } } if (srcFolderExists) { - if (componentTag."@inherit-compiler-output" == "true") { - if (projectOutputPath == null) { - errorReporter.error("Module '$currentModuleName' uses output path inherited from project but project output path is not specified") - } - else { - currentModule.outputPath = FileUtil.toSystemIndependentName(new File(new File(projectOutputPath, "production"), currentModuleName).absolutePath) - currentModule.testOutputPath = FileUtil.toSystemIndependentName(new File(new File(projectOutputPath, "test"), currentModuleName).absolutePath) - } - } - else { - currentModule.outputPath = FileUtil.toCanonicalPath(moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(componentTag.output[0]?.@url))) - currentModule.testOutputPath = FileUtil.toCanonicalPath(moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(componentTag."output-test"[0]?.'@url'))) - if (currentModule.testOutputPath == null) { - currentModule.testOutputPath = currentModule.outputPath - } - } + loadOutputPaths(componentTag, currentModuleName, currentModule, moduleMacroExpander) } } @@ -572,6 +473,123 @@ public class IdeaProjectLoader { def facetLoader = new FacetLoader(currentModule, moduleMacroExpander) facetLoader.loadFacets(facetManagerTag) } + } + + public void loadOutputPaths(Node componentTag, String currentModuleName, Module currentModule, ModuleMacroExpander moduleMacroExpander) { + if (componentTag."@inherit-compiler-output" == "true") { + if (projectOutputPath == null) { + errorReporter.error("Module '$currentModuleName' uses output path inherited from project but project output path is not specified") + } + else { + currentModule.outputPath = FileUtil.toSystemIndependentName(new File(new File(projectOutputPath, "production"), currentModuleName).absolutePath) + currentModule.testOutputPath = FileUtil.toSystemIndependentName(new File(new File(projectOutputPath, "test"), currentModuleName).absolutePath) + } + } + else { + currentModule.outputPath = FileUtil.toCanonicalPath(moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(componentTag.output[0]?.@url))) + currentModule.testOutputPath = FileUtil.toCanonicalPath(moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(componentTag."output-test"[0]?.'@url'))) + if (currentModule.testOutputPath == null) { + currentModule.testOutputPath = currentModule.outputPath + } + } + } + + public void loadSrcFolders(Node componentTag, moduleMacroExpander, currentModule) { + componentTag.content.each {Node contentTag -> + currentModule.content moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(contentTag.@url)) + } + + componentTag.content.sourceFolder.each {Node folderTag -> + String path = moduleMacroExpander.expandMacros(IdeaProjectLoadingUtil.pathFromUrl(folderTag.@url)) + String prefix = folderTag.@packagePrefix + + if (folderTag.attribute("isTestSource") == "true") { + currentModule.testSrc path + } + else { + currentModule.src path + } + + if (prefix != null && prefix != "") { + currentModule.sourceRootPrefixes[path] = (prefix.replace('.', '/')) + } + } + } + + public void loadModuleOrderEntries(Node componentTag, currentModule, MacroExpander moduleMacroExpander, currentModuleName) { + componentTag.orderEntry.each {Node entryTag -> + String type = entryTag.@type + DependencyScope scope = getScopeById(entryTag.@scope) + boolean exported = entryTag.@exported != null + switch (type) { + case "module": + def moduleName = entryTag.attribute("module-name") + def module = project.modules[moduleName] + if (module == null) { + errorReporter.warning("Cannot resolve module $moduleName in $currentModuleName") + } + else { + currentModule.dependency(module, scope, exported) + } + break + + case "sourceFolder": + currentModule.moduleSource() + break + + case "module-library": + def libraryTag = entryTag.library[0] + def libraryName = libraryTag."@name" + def moduleLibrary = loadLibrary(project, libraryName != null ? libraryName : "moduleLibrary#${libraryCount++}", + libraryTag, moduleMacroExpander) + currentModule.dependency(moduleLibrary, scope, exported) + + if (libraryName != null) { + currentModule.libraries[libraryName] = moduleLibrary + } + break; + + case "library": + def name = entryTag.attribute("name") + def library = null + if (entryTag.@level == "project") { + library = project.libraries[name] + if (library == null) { + errorReporter.warning("Cannot resolve project library '$name' in module '$currentModuleName'") + } + } + else { + library = project.globalLibraries[name] + if (library == null) { + errorReporter.warning("Cannot resolve global library '$name' in module '$currentModuleName'") + } + } + + if (library != null) { + currentModule.dependency(library, scope, exported) + } + break + + case "jdk": + def name = entryTag.@jdkName + def sdk = project.sdks[name] + if (sdk == null) { + errorReporter.warning("Cannot resolve SDK '$name' in module '$currentModuleName'. Embedded javac will be used") + } + else { + currentModule.sdk = sdk + currentModule.dependency(sdk, PredefinedDependencyScopes.COMPILE, false) + } + break + + case "inheritedJdk": + def sdk = project.projectSdk + if (sdk != null) { + currentModule.sdk = sdk + currentModule.dependency(sdk, PredefinedDependencyScopes.COMPILE, false) + } + break + } } } diff --git a/jps/src/org/jetbrains/jps/Jps.groovy b/jps/src/org/jetbrains/jps/Jps.groovy index e8eafd45700c..ee15668a1a58 100644 --- a/jps/src/org/jetbrains/jps/Jps.groovy +++ b/jps/src/org/jetbrains/jps/Jps.groovy @@ -20,10 +20,6 @@ final class Jps { return project.createLibrary(name, initializer) }) - binding.setVariable("globalLibrary", {String name, Closure initializer -> - return project.createGlobalLibrary(name, initializer) - }) - binding.setVariable("jdk", {Object[] args -> if (!(args.length in [2,3])) { projectBuilder.error("expected 2 to 3 parameters for jdk() but ${args.length} found") diff --git a/jps/testSrc/org/jetbrains/jps/BuildFromIdeaProjectTest.groovy b/jps/testSrc/org/jetbrains/jps/BuildFromIdeaProjectTest.groovy index ffbb656f81d5..7f3951df9b81 100644 --- a/jps/testSrc/org/jetbrains/jps/BuildFromIdeaProjectTest.groovy +++ b/jps/testSrc/org/jetbrains/jps/BuildFromIdeaProjectTest.groovy @@ -15,9 +15,7 @@ class BuildFromIdeaProjectTest extends JpsBuildTestCase { private Closure getGlobalLib() { return {Project project, ProjectBuilder projectBuilder -> - project.createGlobalLibrary("jdom") { - classpath "testData/iprProject/lib/jdom.jar" - } + project.createGlobalLibrary("jdom") { }.addClasspath("testData/iprProject/lib/jdom.jar") } } diff --git a/jps/testSrc/org/jetbrains/jps/ModuleClasspathTest.groovy b/jps/testSrc/org/jetbrains/jps/ModuleClasspathTest.groovy index 8e1591e67577..478842ca06dc 100644 --- a/jps/testSrc/org/jetbrains/jps/ModuleClasspathTest.groovy +++ b/jps/testSrc/org/jetbrains/jps/ModuleClasspathTest.groovy @@ -13,12 +13,8 @@ public class ModuleClasspathTest extends JpsBuildTestCase { protected void setUp() { super.setUp() project = loadProject(getProjectPath(), [:], {Project project -> - project.createJavaSdk("1.6", "jdk16") { - classpath "/jdk.jar" - } - project.createJavaSdk("1.5", "jdk15") { - classpath "/jdk15.jar" - } + project.createJavaSdk("1.6", "jdk16") { }.addClasspath("/jdk.jar") + project.createJavaSdk("1.5", "jdk15") { }.addClasspath("/jdk15.jar") }) builder = createBuilder(project) } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java index bdb13916bf55..4704342565d0 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionExtender.java @@ -19,6 +19,7 @@ import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.HintHint; import com.intellij.ui.LightweightHint; +import com.intellij.ui.ScreenUtil; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; @@ -79,6 +80,10 @@ public class CompletionExtender extends LightweightHint { hide(); return false; } + if (!checkComponentBounds()) { + hide(); + return false; + } final JList list = myLookup.getList(); if (getComponent().getWidth() > list.getWidth()) { final JComponent rootPane = myLookup.myLayeredPane; @@ -96,6 +101,15 @@ public class CompletionExtender extends LightweightHint { return false; } + private boolean checkComponentBounds() { + final Dimension size = getComponent().getPreferredSize(); + final JList list = myLookup.getList(); + final Point p = list.getLocationOnScreen(); + p.y += list.indexToLocation(list.getSelectedIndex()).y; + final Rectangle rectangle = new Rectangle(p, size); + return !ScreenUtil.isOutsideOnTheRightOFScreen(rectangle); + } + void recalculateLocation() { if (!isVisible()) return; final JList list = myLookup.getList(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java index 8c4b7ba40171..dd16959391b6 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/ToolsImpl.java @@ -31,6 +31,7 @@ import com.intellij.packageDependencies.DependencyValidationManager; import com.intellij.profile.ProfileManager; import com.intellij.profile.codeInspection.SeverityProvider; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; import com.intellij.psi.search.scope.packageSet.NamedScope; import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; import com.intellij.psi.search.scope.packageSet.PackageSet; @@ -88,8 +89,11 @@ public class ToolsImpl implements Tools { final NamedScope scope = state.getScope(project); if (scope != null) { final PackageSet packageSet = scope.getValue(); - if (packageSet != null && packageSet.contains(element.getContainingFile(), validationManager)) { - return state.getTool(); + if (packageSet != null) { + final PsiFile containingFile = element.getContainingFile(); + if (containingFile != null && packageSet.contains(containingFile, validationManager)) { + return state.getTool(); + } } } } diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java index 452f22b6a61b..e9fdd13f330d 100644 --- a/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java +++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/LogConsoleBase.java @@ -599,8 +599,9 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L int i = 0; while (i++ < 1000) { - if (myRunning && myReader != null && myReader.ready()) { - addMessage(myReader.readLine()); + final BufferedReader reader = myReader; + if (myRunning && reader != null && reader.ready()) { + addMessage(reader.readLine()); } else { break; diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 0d4c79a30a51..56023d8c7d0e 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -326,8 +326,12 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo // real document content will be cleared on next flush; myContentSize = 0; myBuffer.clear(); - myHyperlinks.clearHyperlinks(); myFolding.clear(); + + final EditorHyperlinkSupport hyperlinks = myHyperlinks; + if (hyperlinks != null) { + hyperlinks.clearHyperlinks(); + } } if (myFlushAlarm.isDisposed()) return; cancelAllFlushRequests(); diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java index 17a79f75ffb4..a86ca0670be5 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/LevelChooser.java @@ -39,6 +39,7 @@ public class LevelChooser extends ComboboxWithBrowseButton { final DefaultComboBoxModel model = new DefaultComboBoxModel(); comboBox.setModel(model); fillModel(model, severityRegistrar); + getButton().setToolTipText("Edit severities (" + getButton().getToolTipText(null) + ")"); comboBox.setRenderer(new ListCellRendererWrapper(comboBox.getRenderer()) { @Override diff --git a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java index b985f197e55d..8fc2c16335bb 100644 --- a/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java +++ b/platform/lang-impl/src/com/intellij/profile/codeInspection/ui/SingleInspectionProfilePanel.java @@ -21,8 +21,14 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.SeverityRegistrar; -import com.intellij.codeInspection.*; -import com.intellij.codeInspection.ex.*; +import com.intellij.codeInspection.InspectionProfile; +import com.intellij.codeInspection.InspectionProfileEntry; +import com.intellij.codeInspection.InspectionsBundle; +import com.intellij.codeInspection.ModifiableModel; +import com.intellij.codeInspection.ex.Descriptor; +import com.intellij.codeInspection.ex.InspectionProfileImpl; +import com.intellij.codeInspection.ex.InspectionToolRegistrar; +import com.intellij.codeInspection.ex.ScopeToolState; import com.intellij.ide.CommonActionsManager; import com.intellij.ide.DefaultTreeExpander; import com.intellij.ide.IdeTooltipManager; @@ -569,7 +575,7 @@ public class SingleInspectionProfilePanel extends JPanel { } static String renderSeverity(HighlightSeverity severity) { - return InspectionsBundle.message("inspection.as", severity.toString().toLowerCase()); + return severity.toString().toLowerCase(); } private void toggleToolNode(final InspectionConfigTreeNode toolNode) { @@ -865,6 +871,7 @@ public class SingleInspectionProfilePanel extends JPanel { myBrowser = new JEditorPane(UIUtil.HTML_MIME, EMPTY_HTML); myBrowser.setEditable(false); + myBrowser.setBorder(IdeBorderFactory.createEmptyBorder(5, 5, 5, 5)); myBrowser.addHyperlinkListener(new BrowserHyperlinkListener()); initDescriptors(); diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java index 88e3c85eaec0..9b8e43178130 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/InplaceRefactoring.java @@ -486,6 +486,7 @@ public abstract class InplaceRefactoring { } protected void revertState() { + if (myOldName == null) return; CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { public void run() { final Editor topLevelEditor = InjectedLanguageUtil.getTopLevelEditor(myEditor); diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java index 659eb6bad0ee..23976bfe7f0c 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DetailsComponent.java @@ -16,7 +16,6 @@ package com.intellij.openapi.ui; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.components.panels.Wrapper; import com.intellij.ui.treeStructure.Tree; diff --git a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java index bff6336086e2..6185510b4c4d 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/DialogWrapper.java @@ -33,7 +33,6 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.IdeGlassPaneUtil; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.UIBundle; import com.intellij.ui.components.JBOptionButton; @@ -1135,7 +1134,8 @@ public abstract class DialogWrapper { final ValidationInfo result = doValidate(); if (result == null) { clearProblems(); - } else { + } + else { reportProblem(result); } diff --git a/platform/platform-api/src/com/intellij/openapi/wm/impl/content/GraphicsConfig.java b/platform/platform-api/src/com/intellij/openapi/ui/GraphicsConfig.java similarity index 93% rename from platform/platform-api/src/com/intellij/openapi/wm/impl/content/GraphicsConfig.java rename to platform/platform-api/src/com/intellij/openapi/ui/GraphicsConfig.java index 8f03b42a0045..eef4d2d39042 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/impl/content/GraphicsConfig.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/GraphicsConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.intellij.openapi.wm.impl.content; +package com.intellij.openapi.ui; import java.awt.*; import java.util.Map; diff --git a/platform/platform-api/src/com/intellij/openapi/wm/WelcomeScreen.java b/platform/platform-api/src/com/intellij/openapi/wm/WelcomeScreen.java new file mode 100644 index 000000000000..63bb9092b19a --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/wm/WelcomeScreen.java @@ -0,0 +1,27 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.wm; + +import com.intellij.openapi.Disposable; + +import javax.swing.*; + +/** + * @author Konstantin Bulenkov + */ +public interface WelcomeScreen extends Disposable { + JComponent getWelcomePanel(); +} diff --git a/platform/platform-api/src/com/intellij/openapi/wm/WelcomeScreenProvider.java b/platform/platform-api/src/com/intellij/openapi/wm/WelcomeScreenProvider.java new file mode 100644 index 000000000000..62b912d44d43 --- /dev/null +++ b/platform/platform-api/src/com/intellij/openapi/wm/WelcomeScreenProvider.java @@ -0,0 +1,31 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.wm; + +import com.intellij.openapi.extensions.ExtensionPointName; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +/** + * @author Konstantin Bulenkov + */ +public interface WelcomeScreenProvider { + ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.welcomeScreen"); + + @Nullable + WelcomeScreen createWelcomeScreen(JRootPane rootPane); +} diff --git a/platform/platform-api/src/com/intellij/ui/switcher/SwitchingSession.java b/platform/platform-api/src/com/intellij/ui/switcher/SwitchingSession.java index 0f5045843532..b8a6801b2ef6 100644 --- a/platform/platform-api/src/com/intellij/ui/switcher/SwitchingSession.java +++ b/platform/platform-api/src/com/intellij/ui/switcher/SwitchingSession.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -22,7 +22,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.IdeGlassPane; import com.intellij.openapi.wm.IdeGlassPaneUtil; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.ColorUtil; import com.intellij.ui.awt.RelativeRectangle; import com.intellij.util.Alarm; diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index e48a903b9317..aed4055b1853 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -24,7 +24,7 @@ import com.intellij.openapi.ui.ShadowAction; import com.intellij.openapi.util.*; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.wm.*; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.CaptionPanel; import com.intellij.ui.ColorUtil; import com.intellij.ui.Gray; diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java index 08a504538651..10e982510430 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java @@ -20,7 +20,7 @@ import com.intellij.ide.util.treeView.*; import com.intellij.openapi.ui.Queryable; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.*; import com.intellij.util.ReflectionUtil; import com.intellij.util.ui.AsyncProcessIcon; diff --git a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java index 091162cb8a81..ceeec0f3c3e2 100644 --- a/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java +++ b/platform/platform-impl/src/com/intellij/ide/RecentProjectsManagerBase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -32,8 +32,9 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.IdeFrame; +import com.intellij.openapi.wm.WelcomeScreen; import com.intellij.openapi.wm.impl.IdeRootPane; -import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen; +import com.intellij.openapi.wm.impl.welcomeScreen.DefaultWelcomeScreen; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; @@ -214,9 +215,9 @@ public abstract class RecentProjectsManagerBase implements PersistentStateCompon IdeFrame frame = e.getData(IdeFrame.KEY); if (frame != null) { IdeRootPane rootPane = (IdeRootPane) frame.getComponent(); - WelcomeScreen welcomeScreen = rootPane.getWelcomeScreen(); - if (welcomeScreen != null) { - welcomeScreen.hideRecentProjectsPanel(); + final WelcomeScreen welcomeScreen = rootPane.getWelcomeScreen(); + if (welcomeScreen instanceof DefaultWelcomeScreen) { + ((DefaultWelcomeScreen)welcomeScreen).hideRecentProjectsPanel(); } } } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java index 1cdef03be13e..93c69f572abc 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/SwitcherToolWindowsListRenderer.java @@ -19,7 +19,7 @@ import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.wm.ToolWindow; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.SpeedSearchBase; diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java index 3cdc48f03a2a..5853849359ad 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffPanelImpl.java @@ -57,9 +57,11 @@ import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.pom.Navigatable; import com.intellij.ui.EditorNotificationPanel; import com.intellij.ui.PopupHandler; +import com.intellij.ui.border.CustomLineBorder; import com.intellij.util.containers.CacheOneStepIterator; import com.intellij.util.containers.Convertor; import com.intellij.util.diff.FilesTooBigForDiffException; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -115,8 +117,9 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid if (enableToolbar) myPanel.resetToolbar(); myOwnerWindow = owner; myIsSyncScroll = true; - myLeftSide = new DiffSideView("", this); - myRightSide = new DiffSideView("", this); + final boolean v = !horizontal; + myLeftSide = new DiffSideView("", this, new CustomLineBorder(UIUtil.getBorderColor(), 1, 0, v ? 0 : 1, v ? 0 : 1)); + myRightSide = new DiffSideView("", this, new CustomLineBorder(UIUtil.getBorderColor(), v ? 0 : 1, v ? 0 : 1, 1, 0)); myLeftSide.becomeMaster(); myDiffUpdater = new Rediffers(this); diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSideView.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSideView.java index 54944f3302a3..68c02c60e4d9 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSideView.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/DiffSideView.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -40,6 +40,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.Border; import java.awt.*; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; @@ -51,7 +52,7 @@ public class DiffSideView { } private static final DiffHighlighterFactory DUMMY_HIGHLIGHTER_FACTORY = new DiffHighlighterFactoryImpl(null, null, null); - private final LabeledEditor myPanel = new LabeledEditor(); + private final LabeledEditor myPanel; private final DiffSidesContainer myContainer; private final CurrentLineMarker myLineMarker = new CurrentLineMarker(); @@ -61,12 +62,17 @@ public class DiffSideView { private boolean myIsMaster = false; private String myTitle; - public DiffSideView(String title, DiffSidesContainer container) { + public DiffSideView(String title, DiffSidesContainer container, @Nullable Border editorBorder) { myTitle = title; myContainer = container; + myPanel = new LabeledEditor(editorBorder); insertComponent(MOCK_COMPONENT); } + public DiffSideView(String title, DiffSidesContainer container) { + this(title, container, null); + } + public JComponent getComponent() { return myPanel; } diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/splitter/DividerPolygon.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/splitter/DividerPolygon.java index 5b2b15bf1878..e5cf315e8e87 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/splitter/DividerPolygon.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/splitter/DividerPolygon.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -27,7 +27,8 @@ import com.intellij.util.ui.UIUtil; import java.awt.*; import java.util.ArrayList; -class DividerPolygon { +public class DividerPolygon { + public static final int OFFSET = 3; private final Color myColor; private final int myStart1; private final int myStart2; @@ -122,7 +123,7 @@ class DividerPolygon { int end1 = leftTransform.transform(base1.getEnd()); int start2 = rightTransform.transform(base2.getStart()); int end2 = rightTransform.transform(base2.getEnd()); - return new DividerPolygon(start1, start2, end1, end2, color); + return new DividerPolygon(start1 - OFFSET, start2 - OFFSET, end1 - OFFSET, end2 - OFFSET, color); } static Interval getVisibleInterval(Editor editor) { diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/LabeledEditor.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/LabeledEditor.java index 316bbe7f7152..4ac7a3f51e4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/LabeledEditor.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/util/LabeledEditor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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,18 +16,27 @@ package com.intellij.openapi.diff.impl.util; import com.intellij.openapi.diff.DiffBundle; +import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.Border; import java.awt.*; public class LabeledEditor extends JPanel { private final JLabel myLabel = new JLabel(); + private final Border myEditorBorder; - public LabeledEditor() { + public LabeledEditor(@Nullable Border editorBorder) { super(new BorderLayout()); myLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); + myEditorBorder = editorBorder; } + public LabeledEditor() { + this(null); + } + + private static String addReadOnly(String title, boolean readonly) { if (readonly) title += " " + DiffBundle.message("diff.content.read.only.content.title.suffix"); return title; @@ -35,7 +44,12 @@ public class LabeledEditor extends JPanel { public void setComponent(JComponent component, String title) { removeAll(); - add(component, BorderLayout.CENTER); + final JPanel p = new JPanel(new BorderLayout()); + if (myEditorBorder != null) { + p.setBorder(myEditorBorder); + } + p.add(component, BorderLayout.CENTER); + add(p, BorderLayout.CENTER); add(myLabel, BorderLayout.NORTH); setLabelTitle(title); revalidate(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java index 5f8e060e34d3..2f81eb10ecd2 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -41,7 +41,7 @@ import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.*; import com.intellij.openapi.wm.impl.status.IdeStatusBarImpl; import com.intellij.openapi.wm.impl.status.MemoryUsagePanel; -import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen; +import com.intellij.openapi.wm.impl.welcomeScreen.DefaultWelcomeScreen; import com.intellij.ui.PopupHandler; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBusConnection; @@ -81,7 +81,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { private final UISettings myUISettings; private WelcomeScreen myWelcomeScreen; - private Component myWelcomePane; + private JComponent myWelcomePane; private final boolean myGlassPaneInitialized; private final IdeGlassPaneImpl myGlassPane; @@ -129,7 +129,13 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { } void showWelcomeScreen() { - myWelcomeScreen = new WelcomeScreen(this); + for (WelcomeScreenProvider provider : WelcomeScreenProvider.EP_NAME.getExtensions()) { + myWelcomeScreen = provider.createWelcomeScreen(this); + if (myWelcomeScreen != null) break; + } + if (myWelcomeScreen == null) { + myWelcomeScreen = new DefaultWelcomeScreen(this); + } Disposer.register(myDisposable, myWelcomeScreen); myWelcomePane = myWelcomeScreen.getWelcomePanel(); myContentPane.add(myWelcomePane); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java index 6a5a54b7f160..683bda452eee 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/content/ComboContentLayout.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ package com.intellij.openapi.wm.impl.content; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.openapi.ui.popup.ListPopup; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.awt.RelativeRectangle; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java index 4e90cec9b9fd..44eaea9a677a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InlineProgressIndicator.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2012 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. @@ -23,7 +23,7 @@ import com.intellij.openapi.ui.popup.IconButton; import com.intellij.openapi.util.EmptyRunnable; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.ColorUtil; import com.intellij.ui.InplaceButton; import com.intellij.ui.components.panels.NonOpaquePanel; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java similarity index 99% rename from platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java rename to platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java index 70373166053a..c8e816ec880e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/DefaultWelcomeScreen.java @@ -22,7 +22,6 @@ import com.intellij.ide.ReopenProjectAction; import com.intellij.ide.dnd.FileCopyPasteUtil; import com.intellij.ide.highlighter.ProjectFileType; import com.intellij.ide.plugins.*; -import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.actionSystem.ex.ActionButtonLook; import com.intellij.openapi.actionSystem.impl.PresentationFactory; @@ -34,6 +33,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.wm.WelcomeScreen; import com.intellij.openapi.wm.impl.IdeRootPane; import com.intellij.ui.*; import com.intellij.util.containers.ContainerUtil; @@ -57,7 +57,7 @@ import static java.awt.GridBagConstraints.*; /** * @author pti */ -public class WelcomeScreen implements Disposable { +public class DefaultWelcomeScreen implements WelcomeScreen { private static final Insets ACTION_GROUP_CAPTION_INSETS = new Insets(20, 30, 5, 0); private static final Insets PLUGINS_CAPTION_INSETS = new Insets(20, 25, 0, 0); private static final Insets ACTION_ICON_INSETS = new Insets(5, 20, 15, 0); @@ -122,7 +122,7 @@ public class WelcomeScreen implements Disposable { return myWelcomePanel; } - public WelcomeScreen(IdeRootPane rootPane) { + public DefaultWelcomeScreen(IdeRootPane rootPane) { initApplicationSpecificImages(); myWelcomePanel = new JPanel(new GridBagLayout()); diff --git a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java index d765354c6743..5fc42bf8fd4d 100644 --- a/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/BalloonImpl.java @@ -34,7 +34,7 @@ import com.intellij.openapi.wm.FocusRequestor; import com.intellij.openapi.wm.IdeFocusManager; import com.intellij.openapi.wm.IdeGlassPaneUtil; import com.intellij.openapi.wm.impl.IdeGlassPaneEx; -import com.intellij.openapi.wm.impl.content.GraphicsConfig; +import com.intellij.openapi.ui.GraphicsConfig; import com.intellij.ui.awt.RelativePoint; import com.intellij.ui.components.panels.NonOpaquePanel; import com.intellij.ui.components.panels.Wrapper; diff --git a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml index 78db4f2f25d5..92cbadf77359 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensionPoints.xml @@ -98,6 +98,7 @@ + diff --git a/platform/util/src/com/intellij/openapi/util/SystemInfo.java b/platform/util/src/com/intellij/openapi/util/SystemInfo.java index 2d9f35d10cad..b2e0e9fb2c2e 100644 --- a/platform/util/src/com/intellij/openapi/util/SystemInfo.java +++ b/platform/util/src/com/intellij/openapi/util/SystemInfo.java @@ -148,6 +148,7 @@ public class SystemInfo extends SystemInfoRt { /** * Operating system is supposed to have middle mouse button click occupied by paste action. + * * @since 6.0 */ public static boolean X11PasteEnabledSystem = isUnix && !isMac; @@ -217,7 +218,7 @@ public class SystemInfo extends SystemInfoRt { return String.format("%02d%d%d", parts[0], normalize(parts[1]), 0); } - @NotNull + @NotNull public static String getMacOSMinorVersionCode(@NotNull String version) { int[] parts = getMacOSVersionParts(version); return String.format("%02d%02d", parts[1], parts[2]); @@ -225,7 +226,9 @@ public class SystemInfo extends SystemInfoRt { private static int[] getMacOSVersionParts(@NotNull String version) { List parts = StringUtil.split(version, "."); - if (parts.size() != 3) return new int[]{0, 0, 0}; + while (parts.size() < 3) { + parts.add("0"); + } return new int[]{toInt(parts.get(0)), toInt(parts.get(1)), toInt(parts.get(2))}; } diff --git a/platform/util/src/com/intellij/util/SystemProperties.java b/platform/util/src/com/intellij/util/SystemProperties.java index 6a0bbdfa5e8c..305ee73fc5fc 100644 --- a/platform/util/src/com/intellij/util/SystemProperties.java +++ b/platform/util/src/com/intellij/util/SystemProperties.java @@ -117,7 +117,7 @@ public class SystemProperties { * * @param key the property name * @param defaultValue default value - * @return the property value as integer, or default value. + * @return the property value as boolean, or default value. */ public static boolean getBooleanProperty(@NotNull final String key, final boolean defaultValue) { final String value = System.getProperty(key); diff --git a/platform/util/testSrc/com/intellij/util/SystemInfoTest.java b/platform/util/testSrc/com/intellij/util/SystemInfoTest.java index bdc8dd048549..140b54446ab7 100644 --- a/platform/util/testSrc/com/intellij/util/SystemInfoTest.java +++ b/platform/util/testSrc/com/intellij/util/SystemInfoTest.java @@ -19,12 +19,16 @@ import com.intellij.openapi.util.SystemInfo; import junit.framework.TestCase; public class SystemInfoTest extends TestCase { - public void testMacOsVersion() throws Exception { + public void testMacOsVersions() throws Exception { // see http://developer.apple.com/library/mac/#documentation/Carbon/Reference/Gestalt_Manager/Reference/reference.html#//apple_ref/doc/uid/TP30000036-CH1g-F01632 // System Version Selectors assertEquals("1.2", SystemInfo.getMacOSMajorVersion("1.2.3")); assertEquals("20.30", SystemInfo.getMacOSMajorVersion("20.30.40")); + + assertEquals("1.0", SystemInfo.getMacOSMajorVersion("1")); + assertEquals("1.2", SystemInfo.getMacOSMajorVersion("1.2")); + assertEquals("1.2", SystemInfo.getMacOSMajorVersion("1.2.3.4")); } public void testMacOsVersionCode() throws Exception { @@ -36,9 +40,9 @@ public class SystemInfoTest extends TestCase { assertVersions("10.15.15", "1099", "1090", "1515"); assertVersions("", "0000", "0000", "0000"); - assertVersions("1.1", "0000", "0000", "0000"); - assertVersions("1.1.1.1", "0000", "0000", "0000"); - assertVersions("a.b.c.", "0000", "0000", "0000"); + assertVersions("1.2", "0120", "0120", "0200"); + assertVersions("1.2.3.4", "0123", "0120", "0203"); + assertVersions("a.b.c", "0000", "0000", "0000"); } private void assertVersions(String version, String full, String major, String minor) { diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index 8556b790634b..f4be63494bea 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -608,6 +608,9 @@ public class GitUtil { } public static boolean justOneGitRepository(Project project) { + if (project.isDisposed()) { + return true; + } GitRepositoryManager manager = getRepositoryManager(project); if (manager == null) { return true; diff --git a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java index 139ac72b22aa..47169747ef0f 100644 --- a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java @@ -236,7 +236,9 @@ class GitCheckoutOperation extends GitBranchOperation { // See http://youtrack.jetbrains.com/issue/IDEA-80573 sleepABit(); refreshRoot(repository); - // repository state will be auto-updated with this VFS refresh => no need to call GitRepository#update(). + // repository state will be auto-updated with this VFS refresh => in general there is no need to call GitRepository#update() + // but to avoid problems of the asynchronous refresh, let's force update the repository info. + repository.update(GitRepository.TrackedTopic.CURRENT_BRANCH, GitRepository.TrackedTopic.CURRENT_REVISION); } } diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java index a2e21ae6f5ec..19c3319527da 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java @@ -476,9 +476,11 @@ public class GitCheckinEnvironment implements CheckinEnvironment { handler.addParameters(paths); handler.run(); } - GitRepositoryManager manager = GitUtil.getRepositoryManager(project); - if (manager != null) { - manager.updateRepository(root, GitRepository.TrackedTopic.CURRENT_REVISION, GitRepository.TrackedTopic.STATE); + if (!project.isDisposed()) { + GitRepositoryManager manager = GitUtil.getRepositoryManager(project); + if (manager != null) { + manager.updateRepository(root, GitRepository.TrackedTopic.CURRENT_REVISION, GitRepository.TrackedTopic.STATE); + } } } diff --git a/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java b/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java index a0ea8be656f2..cfc906f03bd6 100644 --- a/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java +++ b/plugins/git4idea/src/git4idea/commands/GitCompoundResult.java @@ -79,7 +79,7 @@ public final class GitCompoundResult { GitCommandResult result = entry.getValue(); if (!result.success()) { sb.append("

"); - if (!onlyOneRepositoryInTheProject()) { + if (!GitUtil.justOneGitRepository(myProject)) { sb.append("" + repository.getPresentableUrl() + ":
"); } sb.append(result.getErrorOutputAsHtmlString()); @@ -88,8 +88,4 @@ public final class GitCompoundResult { } return sb.toString(); } - - private boolean onlyOneRepositoryInTheProject() { - return !GitUtil.getRepositoryManager(myProject).moreThanOneRoot(); - } } diff --git a/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java b/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java index 66118a1f85e2..7ed54d9a1cfe 100644 --- a/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java +++ b/plugins/git4idea/src/git4idea/convert/GitFileSeparatorConverter.java @@ -50,6 +50,9 @@ public class GitFileSeparatorConverter { final GitVcsSettings settings, Map> sortedChanges, final List exceptions) { + if (project.isDisposed()) { + return true; + } final GitVcsSettings.ConversionPolicy conversionPolicy = settings.getLineSeparatorsConversion(); if (conversionPolicy != GitVcsSettings.ConversionPolicy.NONE) { LocalFileSystem lfs = LocalFileSystem.getInstance(); @@ -77,10 +80,10 @@ public class GitFileSeparatorConverter { } } // check crlf for real - for (Iterator>> i = files.entrySet().iterator(); i.hasNext();) { + for (Iterator>> i = files.entrySet().iterator(); i.hasNext(); ) { Map.Entry> e = i.next(); Set fs = e.getValue(); - for (Iterator j = fs.iterator(); j.hasNext();) { + for (Iterator j = fs.iterator(); j.hasNext(); ) { VirtualFile f = j.next(); String detectedLineSeparator = LoadTextUtil.detectLineSeparator(f, true); if (detectedLineSeparator == null || nl.equals(detectedLineSeparator)) { @@ -105,15 +108,18 @@ public class GitFileSeparatorConverter { settings.setLineSeparatorsConversion(GitVcsSettings.ConversionPolicy.CONVERT); } selectedFiles = d.getSelectedFiles(); - } else if (d.getExitCode() == GitConvertFilesDialog.DO_NOT_CONVERT) { + } + else if (d.getExitCode() == GitConvertFilesDialog.DO_NOT_CONVERT) { if (d.isDontShowAgainChosen()) { settings.setLineSeparatorsConversion(GitVcsSettings.ConversionPolicy.NONE); } - } else { + } + else { //noinspection ThrowableInstanceNeverThrown exceptions.add(new VcsException("Commit was cancelled in file conversion dialog")); } - } else { + } + else { ArrayList fileList = new ArrayList(); for (Set fileSet : files.values()) { fileList.addAll(fileSet); @@ -127,7 +133,8 @@ public class GitFileSeparatorConverter { } try { LoadTextUtil.changeLineSeparator(project, GitConvertFilesDialog.class.getName(), f, nl); - } catch (IOException e) { + } + catch (IOException e) { //noinspection ThrowableInstanceNeverThrown exceptions.add(new VcsException("Failed to change line separators for the file: " + f.getPresentableUrl(), e)); } diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java index 4a31f78873cf..5bf34489e979 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryUpdater.java @@ -16,6 +16,7 @@ package git4idea.repo; import com.intellij.openapi.Disposable; +import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -54,9 +55,15 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener { myHeadsDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsHeadsPath()); myRemotesDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsRemotesPath()); - myUpdateQueue = new QueueProcessor(new Updater(repository), repository.getProject().getDisposed()); - myMessageBusConnection = repository.getProject().getMessageBus().connect(); - myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, this); + Project project = repository.getProject(); + myUpdateQueue = new QueueProcessor(new Updater(repository), project.getDisposed()); + if (!project.isDisposed()) { + myMessageBusConnection = project.getMessageBus().connect(); + myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, this); + } + else { + myMessageBusConnection = null; + } } private static void visitGitDirVfs(@NotNull VirtualFile gitDir) { @@ -85,7 +92,9 @@ final class GitRepositoryUpdater implements Disposable, BulkFileListener { if (myWatchRequest != null) { LocalFileSystem.getInstance().removeWatchedRoot(myWatchRequest); } - myMessageBusConnection.disconnect(); + if (myMessageBusConnection != null) { + myMessageBusConnection.disconnect(); + } } @Override diff --git a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java index 356ba991486b..feabdb62c367 100644 --- a/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java +++ b/plugins/git4idea/src/git4idea/repo/GitUntrackedFilesHolder.java @@ -104,8 +104,10 @@ public class GitUntrackedFilesHolder implements Disposable, BulkFileListener { } void setupVfsListener(@NotNull Project project) { - MessageBusConnection connection = project.getMessageBus().connect(this); - connection.subscribe(VirtualFileManager.VFS_CHANGES, this); + if (!project.isDisposed()) { + MessageBusConnection connection = project.getMessageBus().connect(this); + connection.subscribe(VirtualFileManager.VFS_CHANGES, this); + } } @Override diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index d9734d6b6c8d..66ab96997fce 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -137,6 +137,7 @@ + diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java index b35ddb5939f7..ac0a3b8ced4b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java @@ -222,14 +222,29 @@ public class CodeBlockGenerator extends Generator { } @Override - public void visitAssertStatement(GrAssertStatement assertStatement) { + public void visitAssertStatement(final GrAssertStatement assertStatement) { final GrExpression assertion = assertStatement.getAssertion(); + final GrExpression message = assertStatement.getErrorMessage(); if (assertion != null) { GenerationUtil.writeStatement(builder, context, assertStatement, new StatementWriter() { @Override public void writeStatement(StringBuilder builder, ExpressionContext context) { builder.append("assert "); assertion.accept(new ExpressionGenerator(builder, context)); + if (message != null) { + builder.append(" : "); + message.accept(new ExpressionGenerator(builder, context)); + } + builder.append(';'); + } + }); + } + else if (message != null) { + GenerationUtil.writeStatement(builder, context, assertStatement, new StatementWriter() { + @Override + public void writeStatement(StringBuilder builder, ExpressionContext context) { + builder.append("assert : "); + message.accept(new ExpressionGenerator(builder, context)); builder.append(';'); } }); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java index 7cdf28a1ec6e..9882c18c253d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java @@ -1097,7 +1097,7 @@ public class ExpressionGenerator extends Generator { builder.append(" instanceof "); if (typeElement != null) { - typeElement.accept(this); + writeType(builder, typeElement.getType(), expression); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/safeDelete/GroovyImportSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/safeDelete/GroovyImportSearcher.java new file mode 100644 index 000000000000..b82f1d5bb446 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/safeDelete/GroovyImportSearcher.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2012 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 org.jetbrains.plugins.groovy.refactoring.safeDelete; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.refactoring.safeDelete.ImportSearcher; +import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; +import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; + +/** + * @author Max Medvedev + */ +public class GroovyImportSearcher extends ImportSearcher { + @Override + public PsiElement findImport(PsiElement element) { + PsiFile file = element.getContainingFile(); + if (file instanceof GroovyFile) { + return PsiTreeUtil.getParentOfType(element, GrImportStatement.class); + } + return null; + } +} diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java index 1bdd028d9d93..44a186947467 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandExecutor.java @@ -189,22 +189,31 @@ public final class HgCommandExecutor { final String cmdString = String.format("%s %s %s", executable, operation, arguments == null ? "" : StringUtils.join(arguments, " ")); // log command - LOG.info(cmdString); if (!myIsSilent) { + LOG.info(cmdString); myVcs.showMessageInConsole(cmdString, ConsoleViewContentType.NORMAL_OUTPUT.getAttributes()); } + else { + LOG.debug(cmdString); + } // log output if needed if (!myIsSilent && myShowOutput) { LOG.info(result.getRawOutput()); myVcs.showMessageInConsole(result.getRawOutput(), ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes()); } + else { + LOG.debug(result.getRawOutput()); + } // log error if (!myIsSilent) { LOG.info(result.getRawError()); myVcs.showMessageInConsole(result.getRawError(), ConsoleViewContentType.ERROR_OUTPUT.getAttributes()); } + else { + LOG.debug(result.getRawError()); + } } private void showError(Exception e) { diff --git a/plugins/testng/lib/testng-jdk15.jar b/plugins/testng/lib/testng.jar similarity index 100% rename from plugins/testng/lib/testng-jdk15.jar rename to plugins/testng/lib/testng.jar diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGVersionChecker.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGVersionChecker.java index 76c7e718bef7..8ad22b2bbe63 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGVersionChecker.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGVersionChecker.java @@ -52,7 +52,7 @@ public class TestNGVersionChecker { private static final Logger LOG = Logger.getInstance("#" + TestNGVersionChecker.class.getName()); private static final String TEST_NG_VERSIONS_INCOMPATIBILITY = "!!!TestNG protocol incompatibility!!!
"; - private static final String COPY_MESSAGE = "In order to use your project testng.jar, please, copy it in the plugin lib directory."; + private static final String COPY_MESSAGE = "In order to use your project testng.jar, please, copy it in the plugin lib directory."; @Nullable public static String getVersionIncompatibilityMessage(Project project, GlobalSearchScope scope, String pathToBundledJar) { @@ -85,7 +85,8 @@ public class TestNGVersionChecker { @Nullable private static String getIncompatibilityMessage(Project project, GlobalSearchScope scope, String pathToBundledJar) { final String protocolClassMessageClass = TestResultMessage.class.getName(); - final PsiClass psiProtocolClass = JavaPsiFacade.getInstance(project).findClass(protocolClassMessageClass, scope); + final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); + final PsiClass psiProtocolClass = psiFacade.findClass(protocolClassMessageClass, scope); if (psiProtocolClass != null) { final ZipFile workingLibrary = getZipLibrary(project, scope); if (workingLibrary != null) { @@ -101,11 +102,14 @@ public class TestNGVersionChecker { catch (IOException e) { return null; } + final boolean ableToStartWithUserJar = psiFacade.findClass("com.beust.jcommander.JCommander", scope) != null; return TEST_NG_VERSIONS_INCOMPATIBILITY + "Right now " + ApplicationNamesInfo.getInstance().getFullProductName() + " does not support testng version (v." + jarVersion + ") used in your project due to the protocol changes on the TestNG side.
" + "Bundled jar (v." + bundledVersion + ") was used instead to run your tests.
" + - COPY_MESSAGE; + (ableToStartWithUserJar ? COPY_MESSAGE + : "In order to use your project testng.jar, please, download & copy it in the plugin lib directory.") + + ""; } } } diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index d13db957a80c..0088a650067b 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -78,6 +78,9 @@ + + @@ -1017,6 +1020,7 @@ +