diff --git a/build/scripts/libLicenses.gant b/build/scripts/libLicenses.gant index adaaf1868fa5..b54f6d7370d2 100644 --- a/build/scripts/libLicenses.gant +++ b/build/scripts/libLicenses.gant @@ -236,7 +236,8 @@ libraryLicense(name: "protobuf", version: "2.3.0", license: "New BSD", url: "htt libraryLicense(name: "Netty", libraryName: "Netty", version: "3.5.8", license: "Apache 2.0", url: "http://netty.io", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0") libraryLicense(name: "Kryo", libraryName: "Kryo", version: "1.04", license: "New BSD License", url: "http://code.google.com/p/kryo/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php") libraryLicense(name: "Snappy-Java", libraryName: "Snappy-Java", version: "1.0.4.1", license: "Apache 2.0", url: "http://code.google.com/p/snappy-java/", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0") -libraryLicense(name: "Cucumber-JVM", libraryName: "cucumber-jvm", version: "1.0.11", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") +libraryLicense(name: "Cucumber-Java", libraryName: "cucumber-java", version: "1.0.14", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") +libraryLicense(name: "Cucumber-JVM", libraryName: "cucumber-jvm", version: "1.0.14", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") libraryLicense(name: "Cucumber-Groovy", libraryName: "cucumber-groovy", version: "1.0.14", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html") libraryLicense(name: "proxy-vole", libraryName: "proxy-vole", version: "20120920", license: "New BSD License", url: "http://code.google.com/p/proxy-vole/", licenseUrl: "http://opensource.org/licenses/BSD-3-Clause") libraryLicense(name: "Rhino JavaScript Engine", libraryName: "rhino-js-1_7R4", version: "1.7R4", license: "MPL 1.1", url: "http://www.mozilla.org/rhino/", licenseUrl: "http://www.mozilla.org/MPL/MPL-1.1.html") diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java index da10c4200294..21081fdb823f 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompileDriver.java @@ -626,6 +626,8 @@ public class CompileDriver { LOG.error(e); // todo } finally { + CompilerCacheManager.getInstance(myProject).flushCaches(); + final long duration = notifyCompilationCompleted(compileContext, callback, COMPILE_SERVER_BUILD_STATUS.get(compileContext)); CompilerUtil.logDuration( "\tCOMPILATION FINISHED (BUILD PROCESS); Errors: " + @@ -635,8 +637,6 @@ public class CompileDriver { duration ); - CompilerCacheManager.getInstance(myProject).flushCaches(); - // refresh on output roots is required in order for the order enumerator to see all roots via VFS final Set outputs = new HashSet(); for (final String path : CompilerPathsEx.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) { @@ -668,7 +668,6 @@ public class CompileDriver { doCompile(compileContext, isRebuild, forceCompile, callback, checkCachesVersion); } finally { - CompilerCacheManager.getInstance(myProject).flushCaches(); FileUtil.delete(CompilerPaths.getRebuildMarkerFile(myProject)); } } @@ -737,6 +736,7 @@ public class CompileDriver { } finally { dropDependencyCache(compileContext); + CompilerCacheManager.getInstance(myProject).flushCaches(); if (compileContext.isRebuildRequested()) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { diff --git a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java index 86d4e0299348..f02820fa0f93 100644 --- a/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java +++ b/java/compiler/openapi/src/com/intellij/openapi/compiler/CompilerPaths.java @@ -24,7 +24,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.CompilerModuleExtension; -import com.intellij.openapi.roots.CompilerProjectExtension; import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.io.FileUtil; @@ -228,15 +227,12 @@ public class CompilerPaths { return StringUtil.isEmpty(sourceDirName)? VirtualFileManager.extractPath(roots[0]): VirtualFileManager.extractPath(roots[0]) + "/" + sourceDirName; } - final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(module.getProject()); - if (extension == null) { + + final String path = getModuleOutputPath(module, false); + if (path == null) { return null; } - final String url = extension.getCompilerOutputUrl(); - if (url == null) { - return null; - } - return StringUtil.isEmpty(sourceDirName)? VirtualFileManager.extractPath(url) : VirtualFileManager.extractPath(url) + "/" + sourceDirName; + return StringUtil.isEmpty(sourceDirName)? path : path + "/" + sourceDirName; } @NonNls diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java index 738663e7ad9a..04e2017cb64f 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddModuleWizard.java @@ -79,7 +79,7 @@ public class AddModuleWizard extends AbstractWizard { initModuleWizard(project, null); } - private void initModuleWizard(final Project project, @Nullable final String defaultPath) { + private void initModuleWizard(@Nullable final Project project, @Nullable final String defaultPath) { myWizardContext = new WizardContext(project); if (defaultPath != null) { myWizardContext.setProjectFileDirectory(defaultPath); diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateSettings.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateSettings.java index 4bc065fc4f81..f0677f6f6e4b 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateSettings.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/SelectTemplateSettings.java @@ -22,7 +22,7 @@ import com.intellij.openapi.util.WriteExternalException; import com.intellij.util.xmlb.annotations.Tag; import com.intellij.util.xmlb.annotations.Transient; import org.jdom.Element; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** * @author Dmitry Avdeev @@ -31,7 +31,9 @@ import org.jetbrains.annotations.Nullable; @State(name = "SelectProjectTemplateSettings", storages = {@Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml")}) public class SelectTemplateSettings implements PersistentStateComponent { - static SelectTemplateSettings getInstance() { + private static final String STATE_ELEMENT_NAME = "treeState"; + + public static SelectTemplateSettings getInstance() { return ServiceManager.getService(SelectTemplateSettings.class); } @@ -45,11 +47,11 @@ public class SelectTemplateSettings implements PersistentStateComponent builders) { sequence.addCommonStep(new ProjectNameWithTypeStep(context, sequence, mode)); for (ModuleBuilder builder : builders) { - addModuleBuilder(builder, context, modulesProvider, sequence); + context.setTemplateMode(mode instanceof CreateFromTemplateMode); + addStepsForBuilder(builder, context, modulesProvider, sequence); } return sequence; } - private static void addModuleBuilder(ModuleBuilder builder, - WizardContext context, - ModulesProvider modulesProvider, - StepSequence myStepSequence) { + private static void addStepsForBuilder(ModuleBuilder builder, + WizardContext context, + ModulesProvider modulesProvider, + StepSequence sequence) { final String id = builder.getBuilderId(); for (ModuleWizardStep step : builder.createWizardSteps(context, modulesProvider)) { - myStepSequence.addSpecificStep(id, step); + sequence.addSpecificStep(id, step); } } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java index 221400e9a58c..8850bb7105f4 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromTemplateMode.java @@ -47,7 +47,7 @@ public class CreateFromTemplateMode extends WizardMode { @Override public boolean isAvailable(WizardContext context) { - return true; + return context.isCreatingNewProject(); } @Nullable diff --git a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java index d7ea3164ffce..63d7a8932ef1 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExpectedTypeInfoImpl.java @@ -82,6 +82,9 @@ public class ExpectedTypeInfoImpl implements ExpectedTypeInfo { } this.defaultType = defaultType; + + assert type.isValid(); + assert defaultType.isValid(); } @Override diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java index edd11ed4728b..99d3cfea274f 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassNameCompletionContributor.java @@ -60,12 +60,7 @@ public class JavaClassNameCompletionContributor extends CompletionContributor { static void addAllClasses(CompletionParameters parameters, final CompletionResultSet _result) { CompletionResultSet result = _result.withPrefixMatcher(CompletionUtil.findReferenceOrAlphanumericPrefix(parameters)); - addAllClasses(parameters, parameters.getInvocationCount() <= 1, result.getPrefixMatcher(), new Consumer() { - @Override - public void consume(LookupElement element) { - _result.addElement(element); - } - }); + addAllClasses(parameters, parameters.getInvocationCount() <= 1, result.getPrefixMatcher(), _result); } private static boolean mayContainClassName(CompletionParameters parameters) { diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java index e7ad8966c1f3..be4867cc9c05 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaClassReferenceCompletionContributor.java @@ -62,6 +62,10 @@ public class JavaClassReferenceCompletionContributor extends CompletionContribut StringUtil.join(extendClassNames, ", ")); } + if (parameters.getCompletionType() == CompletionType.SMART) { + return; + } + if (parameters.getCompletionType() == CompletionType.CLASS_NAME) { JavaClassNameCompletionContributor.addAllClasses(parameters, result); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java index 2bb455223430..cf4a331e058e 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionContributor.java @@ -237,12 +237,7 @@ public class JavaCompletionContributor extends CompletionContributor { !((PsiReferenceExpression)parent).isQualified() && parameters.isExtendedCompletion() && StringUtil.isNotEmpty(matcher.getPrefix())) { - new JavaStaticMemberProcessor(parameters).processStaticMethodsGlobally(matcher, new Consumer() { - @Override - public void consume(LookupElement element) { - result.addElement(element); - } - }); + new JavaStaticMemberProcessor(parameters).processStaticMethodsGlobally(matcher, result); } result.stopHere(); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java index ce09e552c4c0..e143706d6eed 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionData.java @@ -554,12 +554,7 @@ public class JavaCompletionData extends JavaAwareCompletionData { static void addExpectedTypeMembers(CompletionParameters parameters, final CompletionResultSet result, PsiElement position) { for (final ExpectedTypeInfo info : JavaSmartCompletionContributor.getExpectedTypes(parameters)) { - new JavaMembersGetter(info.getDefaultType(), parameters).addMembers(parameters.getInvocationCount() > 1, new Consumer() { - @Override - public void consume(LookupElement element) { - result.addElement(element); - } - }); + new JavaMembersGetter(info.getDefaultType(), parameters).addMembers(parameters.getInvocationCount() > 1, result); } } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java index e113fa2159d9..9f281aa51cf8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java @@ -177,6 +177,9 @@ public class JavaCompletionSorting { final PsiType defaultType = expectedInfo.getDefaultType(); final PsiType expectedType = expectedInfo.getType(); + assert expectedType.isValid(); + assert defaultType.isValid(); + if (defaultType != expectedType && defaultType.isAssignableFrom(itemType)) { return ExpectedTypeMatching.ofDefaultType; } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java index af6dc31c8482..8e604a247d33 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaNoVariantsDelegator.java @@ -90,12 +90,7 @@ public class JavaNoVariantsDelegator extends CompletionContributor { private static void suggestCollectionUtilities(CompletionParameters parameters, final CompletionResultSet result, PsiElement position) { if (StringUtil.isNotEmpty(result.getPrefixMatcher().getPrefix())) { for (ExpectedTypeInfo info : JavaSmartCompletionContributor.getExpectedTypes(parameters)) { - new CollectionsUtilityMethodsProvider(position, info.getType(), info.getDefaultType(), new Consumer() { - @Override - public void consume(LookupElement element) { - result.addElement(element); - } - }).addCompletions(true); + new CollectionsUtilityMethodsProvider(position, info.getType(), info.getDefaultType(), result).addCompletions(true); } } } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index f4ec240b7f2d..d1a44922714a 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -973,7 +973,7 @@ public class HighlightMethodUtil { PsiClass[] interfaces = aClass.getInterfaces(); for (PsiClass aInterfaces : interfaces) { superClass = aInterfaces; - superMethod = MethodSignatureUtil.findMethodBySignature(superClass, method, true); + superMethod = MethodSignatureUtil.findMethodInSuperClassBySignatureInDerived(aClass, superClass, method.getSignature(PsiSubstitutor.EMPTY), true); highlightInfo = checkStaticMethodOverride(aClass, method, true, superClass, superMethod); if (highlightInfo != null) return highlightInfo; } diff --git a/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java b/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java index b1a1844a17b4..4b1de571c01d 100644 --- a/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java +++ b/java/java-impl/src/com/intellij/packageDependencies/ui/TreeModelBuilder.java @@ -36,7 +36,6 @@ import com.intellij.openapi.vfs.VirtualFileVisitor; import com.intellij.psi.JavaPsiFacade; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiPackage; -import com.intellij.util.PlatformIcons; import com.intellij.util.ui.tree.TreeUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -104,8 +103,8 @@ public class TreeModelBuilder { createMaps(ScopeType.TEST); if (myGroupByScopeType) { - mySourceRoot = new GeneralGroupNode(PRODUCTION_NAME, PlatformIcons.PACKAGE_ICON, project); - myTestRoot = new GeneralGroupNode(TEST_NAME, AllIcons.Nodes.TestSourceFolder, project); + mySourceRoot = new GeneralGroupNode(PRODUCTION_NAME, AllIcons.Modules.SourceFolder, project); + myTestRoot = new GeneralGroupNode(TEST_NAME, AllIcons.Modules.TestSourceFolder, project); myLibsRoot = new GeneralGroupNode(LIBRARY_NAME, AllIcons.Nodes.PpLibFolder, project); myRoot.add(mySourceRoot); myRoot.add(myTestRoot); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java index b91cfc74191a..04dd71c7970d 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReference.java @@ -15,7 +15,6 @@ */ package com.intellij.psi.impl.source.resolve.reference.impl.providers; -import com.intellij.codeInsight.completion.CompletionResultSet; import com.intellij.codeInsight.completion.JavaLookupElementBuilder; import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor; import com.intellij.codeInsight.daemon.QuickFixProvider; @@ -24,6 +23,7 @@ import com.intellij.codeInsight.daemon.impl.quickfix.OrderEntryFix; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl; import com.intellij.codeInsight.daemon.quickFix.CreateClassOrPackageFix; +import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.LocalQuickFixProvider; @@ -51,6 +51,7 @@ import com.intellij.psi.util.ClassKind; import com.intellij.psi.util.ClassUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.util.ArrayUtil; +import com.intellij.util.Consumer; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.CharArrayUtil; @@ -255,7 +256,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer return ArrayUtil.EMPTY_OBJECT_ARRAY; } - @NotNull + @Nullable public PsiElement getCompletionContext() { PsiElement context = getContext(); return context == null ? JavaPsiFacade.getInstance(getElement().getProject()).findPackage("") : context; @@ -512,7 +513,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer } @NotNull - public void processSubclassVariants(@NotNull PsiPackage context, @NotNull String[] extendClasses, CompletionResultSet result) { + public void processSubclassVariants(@NotNull PsiPackage context, @NotNull String[] extendClasses, Consumer result) { GlobalSearchScope packageScope = PackageScope.packageScope(context, true); GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope(getElement().getProject()); if (scope != null) { @@ -532,13 +533,13 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer // add itself if (packageScope.contains(extendClass.getContainingFile().getVirtualFile())) { if (isClassAccepted(extendClass, classKind, instantiatable, concrete, notInterface, notEnum)) { - result.addElement(createSubclassLookupValue(extendClass, extendClassName)); + result.consume(createSubclassLookupValue(extendClass, extendClassName)); } } for (final PsiClass clazz : ClassInheritorsSearch.search(extendClass, packageScope, true)) { String qname = clazz.getQualifiedName(); if (qname != null && isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) { - result.addElement(createSubclassLookupValue(clazz, qname)); + result.consume(createSubclassLookupValue(clazz, qname)); } } } diff --git a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java index 50c6a6b7be06..a1f4ce122e1a 100644 --- a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java @@ -226,7 +226,7 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor { for (final PsiElement element : myRenameProcessor.getElements()) { try { - RenameUtil.doRename(element, myNewName, extractUsagesForElement(element, usages), myProject, new RefactoringElementListener() { + RenameUtil.doRename(element, myRenameProcessor.getNewName(element), extractUsagesForElement(element, usages), myProject, new RefactoringElementListener() { public void elementMoved(@NotNull PsiElement newElement) { } diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java index e1119d06e11a..2aad61325e56 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/ConstructorReferencesSearchHelper.java @@ -84,7 +84,7 @@ public class ConstructorReferencesSearchHelper { if (parent instanceof PsiMethodReferenceExpression && ((PsiMethodReferenceExpression)parent).getReferenceNameElement() instanceof PsiKeyword) { if (((PsiMethodReferenceExpression)parent).isReferenceTo(constructor)) { - processor.process(reference); + processor.process((PsiReference)parent); } } } diff --git a/java/java-indexing-impl/src/com/intellij/psi/impl/search/MethodUsagesSearcher.java b/java/java-indexing-impl/src/com/intellij/psi/impl/search/MethodUsagesSearcher.java index 64e25dda9870..49bd3f3c2ca3 100644 --- a/java/java-indexing-impl/src/com/intellij/psi/impl/search/MethodUsagesSearcher.java +++ b/java/java-indexing-impl/src/com/intellij/psi/impl/search/MethodUsagesSearcher.java @@ -59,8 +59,7 @@ public class MethodUsagesSearcher extends QueryExecutorBase { + + public static int compare(String a, String b) { + return 42; + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java index 5ce67a32dfc7..3ebc98e69a9c 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -150,6 +150,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testInconvertibleTypes() throws Exception { doTest(false); } public void testIncompatibleReturnType() throws Exception { doTest(false); } public void testContinueInferenceAfterFirstRawResult() throws Exception { doTest(false); } + public void testStaticOverride() throws Exception { doTest(false); } public void testJavaUtilCollections_NoVerify() throws Exception { PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule())); diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/BuildRootIndex.java b/jps/jps-builders/src/org/jetbrains/jps/builders/BuildRootIndex.java index ab9f6b390173..adec314e5b51 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/builders/BuildRootIndex.java +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/BuildRootIndex.java @@ -43,7 +43,7 @@ public interface BuildRootIndex { Collection findAllParentDescriptors(@NotNull File file, @Nullable CompileContext context); @Nullable - JavaSourceRootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file); + JavaSourceRootDescriptor findJavaRootDescriptor(@Nullable CompileContext context, File file); @NotNull FileFilter getRootFilter(@NotNull BuildRootDescriptor descriptor); diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootIndexImpl.java b/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootIndexImpl.java index 9ceaf2fd307e..19a18b0d81d3 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootIndexImpl.java +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/impl/BuildRootIndexImpl.java @@ -8,15 +8,22 @@ import com.intellij.util.containers.ConcurrentHashMap; import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.ProjectPaths; import org.jetbrains.jps.builders.*; import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType; import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor; +import org.jetbrains.jps.builders.java.ResourcesOnlyRootDescriptor; import org.jetbrains.jps.builders.storage.BuildDataPaths; import org.jetbrains.jps.incremental.BuilderRegistry; import org.jetbrains.jps.incremental.CompileContext; +import org.jetbrains.jps.incremental.ModuleBuildTarget; import org.jetbrains.jps.indices.IgnoredFileIndex; import org.jetbrains.jps.indices.ModuleExcludeIndex; import org.jetbrains.jps.model.JpsModel; +import org.jetbrains.jps.model.JpsProject; +import org.jetbrains.jps.model.java.JpsJavaExtensionService; +import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration; +import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile; import org.jetbrains.jps.service.JpsServiceManager; import java.io.File; @@ -31,30 +38,65 @@ public class BuildRootIndexImpl implements BuildRootIndex { private static final Key> ROOT_DESCRIPTOR_MAP = Key.create("_root_to_descriptor_map"); private static final Key, List>> TEMP_TARGET_ROOTS_MAP = Key.create("_module_to_root_map"); private HashMap, List> myRootsByTarget; - private THashMap> myRootToDescriptor; + private THashMap> myRootToDescriptors; private ConcurrentMap myFileFilters; public BuildRootIndexImpl(BuildTargetIndex targetIndex, JpsModel model, ModuleExcludeIndex index, BuildDataPaths dataPaths, final IgnoredFileIndex ignoredFileIndex) { myRootsByTarget = new HashMap, List>(); - myRootToDescriptor = new THashMap>(FileUtil.FILE_HASHING_STRATEGY); + myRootToDescriptors = new THashMap>(FileUtil.FILE_HASHING_STRATEGY); myFileFilters = new ConcurrentHashMap(); final Iterable rootsProviders = JpsServiceManager.getInstance().getExtensions(AdditionalRootsProviderService.class); for (BuildTargetType targetType : BuilderRegistry.getInstance().getTargetTypes()) { for (BuildTarget target : targetIndex.getAllTargets(targetType)) { - addRoots(dataPaths, rootsProviders, targetType, target, model, index, ignoredFileIndex); + addRoots(dataPaths, rootsProviders, target, model, index, ignoredFileIndex); } } + + // registering resource-only roots for annotation processor's generated classes + Map> moduleNameToTargetsMap = null; + + final JpsProject project = model.getProject(); + final ProjectPaths paths = new ProjectPaths(project); + final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project); + for (ProcessorConfigProfile profile : compilerConfig.getAnnotationProcessingConfigurations()) { + if (!profile.isEnabled()) { + continue; + } + for (String moduleName : profile.getModuleNames()) { + if (moduleNameToTargetsMap == null) { + moduleNameToTargetsMap = buildModuleNameToTargetsMap(targetIndex); // lazy init + } + final List targets = moduleNameToTargetsMap.get(moduleName); + if (targets != null) { + for (ModuleBuildTarget target : targets) { + final File annotationOut = paths.getAnnotationProcessorGeneratedSourcesOutputDir(target.getModule(), target.isTests(), profile); + if (annotationOut != null) { + if (findJavaRootDescriptor(null, annotationOut) == null && !FileUtil.filesEqual(annotationOut, target.getOutputDir())) { + // register only if the root is not under already existing roots and not is the same as target's output root + final ResourcesOnlyRootDescriptor descriptor = new ResourcesOnlyRootDescriptor(annotationOut, target, true, false, ""); + registerDescriptor(descriptor); + //noinspection unchecked + final List descriptors = (List)myRootsByTarget.get(target); + assert descriptors != null; + descriptors.add(descriptor); + } + } + } + } + } + } + } private void addRoots(BuildDataPaths dataPaths, Iterable rootsProviders, - BuildTargetType targetType, BuildTarget target, + BuildTarget target, JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex) { List descriptors = target.computeRootDescriptors(model, index, ignoredFileIndex, dataPaths); for (AdditionalRootsProviderService provider : rootsProviders) { - if (provider.getTargetTypes().contains(targetType)) { + if (provider.getTargetTypes().contains(target.getTargetType())) { //noinspection unchecked AdditionalRootsProviderService providerService = (AdditionalRootsProviderService)provider; final List additionalRoots = providerService.getAdditionalRoots(target, dataPaths); @@ -65,22 +107,42 @@ public class BuildRootIndexImpl implements BuildRootIndex { } } for (BuildRootDescriptor descriptor : descriptors) { - List list = myRootToDescriptor.get(descriptor.getRootFile()); - if (list == null) { - list = new SmartList(); - myRootToDescriptor.put(descriptor.getRootFile(), list); - } - list.add(descriptor); + registerDescriptor(descriptor); } myRootsByTarget.put(target, descriptors); } + private void registerDescriptor(BuildRootDescriptor descriptor) { + List list = myRootToDescriptors.get(descriptor.getRootFile()); + if (list == null) { + list = new SmartList(); + myRootToDescriptors.put(descriptor.getRootFile(), list); + } + list.add(descriptor); + } + + private static Map> buildModuleNameToTargetsMap(BuildTargetIndex targetIndex) { + final Map> moduleNameToTargetsMap = new HashMap>(); + for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) { + for (ModuleBuildTarget target : targetIndex.getAllTargets(type)) { + final String moduleName = target.getModule().getName(); + List targets = moduleNameToTargetsMap.get(moduleName); + if (targets == null) { + targets = new ArrayList(); + moduleNameToTargetsMap.put(moduleName, targets); + } + targets.add(target); + } + } + return moduleNameToTargetsMap; + } + @NotNull @Override public List getRootDescriptors(@NotNull File root, @Nullable Collection>> types, @Nullable CompileContext context) { - List descriptors = myRootToDescriptor.get(root); + List descriptors = myRootToDescriptors.get(root); List result = new SmartList(); if (descriptors != null) { for (BuildRootDescriptor descriptor : descriptors) { @@ -132,9 +194,7 @@ public class BuildRootIndexImpl implements BuildRootIndex { } @Override - public void associateTempRoot(@NotNull CompileContext context, - @NotNull BuildTarget target, - @NotNull R root) { + public void associateTempRoot(@NotNull CompileContext context, @NotNull BuildTarget target, @NotNull R root) { Map rootToDescriptorMap = ROOT_DESCRIPTOR_MAP.get(context); if (rootToDescriptorMap == null) { rootToDescriptorMap = new THashMap(FileUtil.FILE_HASHING_STRATEGY); @@ -223,7 +283,7 @@ public class BuildRootIndexImpl implements BuildRootIndex { @Override @Nullable - public JavaSourceRootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file) { + public JavaSourceRootDescriptor findJavaRootDescriptor(@Nullable CompileContext context, File file) { return findParentDescriptor(file, JavaModuleBuildTargetType.ALL_TYPES, context); } diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java index e0872828eddf..309fab56987c 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaBuilderUtil.java @@ -164,7 +164,8 @@ public class JavaBuilderUtil { final List> result = new ArrayList>(); for (File file : affected) { if (!moduleBasedFilter.accept(file)) { - final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file); + final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, + file); result.add(Pair.create(file, moduleAndRoot != null ? moduleAndRoot.target.getModule() : null)); } } @@ -176,7 +177,8 @@ public class JavaBuilderUtil { final Set chunkModules = chunk.getModules(); if (!chunkModules.isEmpty()) { for (File file : affected) { - final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file); + final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, + file); if (moduleAndRoot != null && chunkModules.contains(moduleAndRoot.target.getModule())) { return true; } @@ -250,7 +252,7 @@ public class JavaBuilderUtil { @Override public boolean accept(File file) { - final JavaSourceRootDescriptor rd = myContext.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(myContext, file); + final JavaSourceRootDescriptor rd = myContext.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(myContext, file); if (rd == null) { return true; } diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaSourceRootDescriptor.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaSourceRootDescriptor.java index 519a2382fbe2..a31e82a44537 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaSourceRootDescriptor.java +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/JavaSourceRootDescriptor.java @@ -3,7 +3,6 @@ package org.jetbrains.jps.builders.java; import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.builders.BuildRootDescriptor; -import org.jetbrains.jps.builders.BuildTarget; import org.jetbrains.jps.incremental.ModuleBuildTarget; import org.jetbrains.jps.model.java.JpsJavaExtensionService; import org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes; @@ -15,7 +14,7 @@ import java.io.FileFilter; * @author Eugene Zhuravlev * Date: 1/3/12 */ -public final class JavaSourceRootDescriptor extends BuildRootDescriptor { +public class JavaSourceRootDescriptor extends BuildRootDescriptor { @NotNull public final File root; @NotNull @@ -57,7 +56,7 @@ public final class JavaSourceRootDescriptor extends BuildRootDescriptor { } @Override - public BuildTarget getTarget() { + public ModuleBuildTarget getTarget() { return target; } diff --git a/jps/jps-builders/src/org/jetbrains/jps/builders/java/ResourcesOnlyRootDescriptor.java b/jps/jps-builders/src/org/jetbrains/jps/builders/java/ResourcesOnlyRootDescriptor.java new file mode 100644 index 000000000000..23f427b26eae --- /dev/null +++ b/jps/jps-builders/src/org/jetbrains/jps/builders/java/ResourcesOnlyRootDescriptor.java @@ -0,0 +1,30 @@ +package org.jetbrains.jps.builders.java; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jps.incremental.ModuleBuildTarget; + +import java.io.File; + +/** +* @author Eugene Zhuravlev +* Date: 1/3/12 +*/ +public final class ResourcesOnlyRootDescriptor extends JavaSourceRootDescriptor { + + public ResourcesOnlyRootDescriptor(@NotNull File root, + @NotNull ModuleBuildTarget target, + boolean isGenerated, + boolean isTemp, + @NotNull String packagePrefix) { + super(root, target, isGenerated, isTemp, packagePrefix); + } + + @Override + public String toString() { + return "ResourceRootDescriptor{" + + "target='" + target + '\'' + + ", root=" + root + + ", generated=" + isGeneratedSources + + '}'; + } +} diff --git a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java index 73995ab4d56b..685c9ce1dc3c 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java +++ b/jps/jps-builders/src/org/jetbrains/jps/cmdline/BuildSession.java @@ -282,7 +282,9 @@ final class BuildSession implements Runnable, CanceledStatus { LOG.info("Applying dirty path from fs event: " + file.getPath()); } for (BuildRootDescriptor descriptor : descriptors) { - pd.fsState.markDirty(null, file, descriptor, timestamps); + if (!descriptor.isGenerated()) { // ignore generates sources as they are processed at the time of generation + pd.fsState.markDirty(null, file, descriptor, timestamps); + } } } else if (Utils.IS_TEST_MODE) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/CompilerEncodingConfiguration.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/CompilerEncodingConfiguration.java index ac6ac34006a7..d9142cb1b6e0 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/CompilerEncodingConfiguration.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/CompilerEncodingConfiguration.java @@ -6,7 +6,6 @@ import com.intellij.util.containers.ContainerUtil; import gnu.trove.THashMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jps.util.JpsPathUtil; import org.jetbrains.jps.ModuleChunk; import org.jetbrains.jps.builders.BuildRootIndex; import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor; @@ -14,6 +13,7 @@ import org.jetbrains.jps.model.JpsEncodingConfigurationService; import org.jetbrains.jps.model.JpsEncodingProjectConfiguration; import org.jetbrains.jps.model.JpsModel; import org.jetbrains.jps.model.module.JpsModule; +import org.jetbrains.jps.util.JpsPathUtil; import java.io.File; import java.util.*; @@ -50,7 +50,7 @@ public class CompilerEncodingConfiguration { File file = JpsPathUtil.urlToFile(fileUrl); if (charset == null || (!file.isDirectory() && !shouldHonorEncodingForCompilation(builders, file))) continue; - final JavaSourceRootDescriptor rootDescriptor = myRootsIndex.getModuleAndRoot(null, file); + final JavaSourceRootDescriptor rootDescriptor = myRootsIndex.findJavaRootDescriptor(null, file); if (rootDescriptor == null) continue; final JpsModule module = rootDescriptor.target.getModule(); diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/FSOperations.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/FSOperations.java index e475f68a00c3..093289dba9f6 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/FSOperations.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/FSOperations.java @@ -31,7 +31,7 @@ import java.util.Set; */ public class FSOperations { public static void markDirty(CompileContext context, final File file) throws IOException { - final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file); + final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file); if (rd != null) { final ProjectDescriptor pd = context.getProjectDescriptor(); pd.fsState.markDirty(context, file, rd, pd.timestamps.getStorage()); @@ -39,7 +39,7 @@ public class FSOperations { } public static void markDirtyIfNotDeleted(CompileContext context, final File file) throws IOException { - final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file); + final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file); if (rd != null) { final ProjectDescriptor pd = context.getProjectDescriptor(); pd.fsState.markDirtyIfNotDeleted(context, file, rd, pd.timestamps.getStorage()); @@ -47,7 +47,7 @@ public class FSOperations { } public static void markDeleted(CompileContext context, File file) throws IOException { - final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file); + final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file); if (rd != null) { final ProjectDescriptor pd = context.getProjectDescriptor(); pd.fsState.registerDeleted(rd.target, file, pd.timestamps.getStorage()); diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java index 40570401a85a..816eaed509a2 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/ModuleBuildTarget.java @@ -93,19 +93,16 @@ public class ModuleBuildTarget extends BuildTarget { @NotNull @Override - public List computeRootDescriptors(JpsModel model, - ModuleExcludeIndex index, - IgnoredFileIndex ignoredFileIndex, - BuildDataPaths dataPaths) { + public List computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) { List roots = new ArrayList(); JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE; Iterable excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class); - roots: + roots_loop: for (JpsTypedModuleSourceRoot> sourceRoot : myModule.getSourceRoots(type)) { for (ExcludedJavaSourceRootProvider provider : excludedRootProviders) { if (provider.isExcludedFromCompilation(myModule, sourceRoot)) { - continue roots; + continue roots_loop; } } String packagePrefix = sourceRoot.getProperties().getData().getPackagePrefix(); diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java index 3d4b4f2ee275..a224ba271caa 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/java/JavaBuilder.java @@ -36,6 +36,7 @@ import org.jetbrains.jps.builders.DirtyFilesHolder; import org.jetbrains.jps.builders.FileProcessor; import org.jetbrains.jps.builders.java.JavaBuilderUtil; import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor; +import org.jetbrains.jps.builders.java.ResourcesOnlyRootDescriptor; import org.jetbrains.jps.builders.java.dependencyView.Callbacks; import org.jetbrains.jps.builders.java.dependencyView.Mappings; import org.jetbrains.jps.builders.logging.ProjectBuilderLogger; @@ -122,12 +123,13 @@ public class JavaBuilder extends ModuleLevelBuilder { public void process(CompileContext context, OutputFileObject out) { final OutputFileObject.Content content = out.getContent(); final File srcFile = out.getSourceFile(); + boolean isTemp = false; + final JavaFileObject.Kind outKind = out.getKind(); if (srcFile != null && content != null) { final String outputPath = FileUtil.toSystemIndependentName(out.getFile().getPath()); final String sourcePath = FileUtil.toSystemIndependentName(srcFile.getPath()); - final JavaSourceRootDescriptor rootDescriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, srcFile); + final JavaSourceRootDescriptor rootDescriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, srcFile); final BuildDataManager dataManager = context.getProjectDescriptor().dataManager; - boolean isTemp = false; if (rootDescriptor != null) { isTemp = rootDescriptor.isTemp; if (!isTemp) { @@ -140,7 +142,7 @@ public class JavaBuilder extends ModuleLevelBuilder { } } out.setTemp(isTemp); - if (!isTemp && out.getKind() == JavaFileObject.Kind.CLASS && !Utils.errorsDetected(context)) { + if (!isTemp && outKind == JavaFileObject.Kind.CLASS && !Utils.errorsDetected(context)) { final Callbacks.Backend callback = DELTA_MAPPINGS_CALLBACK_KEY.get(context); if (callback != null) { final ClassReader reader = new ClassReader(content.getBuffer(), content.getOffset(), content.getLength()); @@ -148,6 +150,14 @@ public class JavaBuilder extends ModuleLevelBuilder { } } } + if (!isTemp && outKind != JavaFileObject.Kind.CLASS && outKind != JavaFileObject.Kind.SOURCE) { // this should be a generated resource + try { + FSOperations.markDirty(context, out.getFile()); + } + catch (IOException e) { + LOG.info(e); + } + } } }); } @@ -179,7 +189,10 @@ public class JavaBuilder extends ModuleLevelBuilder { final Set formsToCompile = new THashSet(FileUtil.FILE_HASHING_STRATEGY); dirtyFilesHolder.processDirtyFiles(new FileProcessor() { - public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor sourceRoot) throws IOException { + public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor descriptor) throws IOException { + if (descriptor instanceof ResourcesOnlyRootDescriptor) { + return true; + } if (JAVA_SOURCES_FILTER.accept(file)) { filesToCompile.add(file); } @@ -196,7 +209,7 @@ public class JavaBuilder extends ModuleLevelBuilder { if (!context.isProjectRebuild()) { for (Iterator formsIterator = formsToCompile.iterator(); formsIterator.hasNext(); ) { final File form = formsIterator.next(); - final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, form); + final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, form); if (descriptor == null) { continue; } @@ -315,11 +328,11 @@ public class JavaBuilder extends ModuleLevelBuilder { try { if (hasSourcesToCompile) { exitCode = ExitCode.OK; - final Set tempRootsSourcePath = new HashSet(); + final Set srcPath = new HashSet(); final BuildRootIndex index = pd.getBuildRootIndex(); for (ModuleBuildTarget target : chunk.getTargets()) { for (JavaSourceRootDescriptor rd : index.getTempTargetRoots(target, context)) { - tempRootsSourcePath.add(rd.root); + srcPath.add(rd.root); } } @@ -340,7 +353,7 @@ public class JavaBuilder extends ModuleLevelBuilder { LOG.debug(" " + file.getAbsolutePath()); } } - compiledOk = compileJava(context, chunk, files, classpath, platformCp, tempRootsSourcePath, diagnosticSink, outputSink); + compiledOk = compileJava(context, chunk, files, classpath, platformCp, srcPath, diagnosticSink, outputSink); } context.checkCanceled(); diff --git a/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java b/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java index 5bcc12583567..5d616e277359 100644 --- a/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java +++ b/platform/lang-api/src/com/intellij/codeInsight/completion/CompletionResultSet.java @@ -22,7 +22,7 @@ import java.util.LinkedHashSet; * * @author peter */ -public abstract class CompletionResultSet { +public abstract class CompletionResultSet implements Consumer { private final PrefixMatcher myPrefixMatcher; private final Consumer myConsumer; protected final CompletionService myCompletionService = CompletionService.getCompletionService(); @@ -39,6 +39,11 @@ public abstract class CompletionResultSet { return myConsumer; } + @Override + public void consume(LookupElement element) { + addElement(element); + } + /** * If a given element matches the prefix, give it for further processing (which may eventually result in its appearing in the completion list) * @param element diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java index 8cb3e36021f7..e8fc24b1dac7 100644 --- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java +++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java @@ -59,7 +59,7 @@ public class WizardContext { void nextStepRequested(); } - public WizardContext(Project project) { + public WizardContext(@Nullable Project project) { myProject = project; if (myProject != null){ myProjectJdk = ProjectRootManager.getInstance(myProject).getProjectSdk(); @@ -172,4 +172,16 @@ public class WizardContext { public StorageScheme getProjectStorageFormat() { return myProjectStorageFormat; } + + private boolean myTemplateMode; + + /** This will be removed shortly */ + @Deprecated + public boolean isTemplateMode() { + return myTemplateMode; + } + + public void setTemplateMode(boolean templateMode) { + myTemplateMode = templateMode; + } } diff --git a/platform/lang-api/src/com/intellij/lang/refactoring/InlineHandler.java b/platform/lang-api/src/com/intellij/lang/refactoring/InlineHandler.java index 4b8e7a65b927..773e9e9d2235 100644 --- a/platform/lang-api/src/com/intellij/lang/refactoring/InlineHandler.java +++ b/platform/lang-api/src/com/intellij/lang/refactoring/InlineHandler.java @@ -22,10 +22,9 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.intellij.usageView.UsageInfo; import com.intellij.util.containers.MultiMap; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; - /** * Interface that should be implemented by the language in order to provide inline functionality and possibly * participate in inline of elements in other languages this language may reference. @@ -60,19 +59,19 @@ public interface InlineHandler { * @return Settings object in case refactoring should be performed or null otherwise */ - @Nullable Settings prepareInlineElement(PsiElement element, Editor editor, boolean invokedOnReference); + @Nullable Settings prepareInlineElement(@NotNull PsiElement element, @Nullable Editor editor, boolean invokedOnReference); /** * @param element inlined element */ - void removeDefinition(PsiElement element, Settings settings); + void removeDefinition(@NotNull PsiElement element, @NotNull Settings settings); /** * @param element inlined element * @param settings * @return Inliner instance to be used for inlining references in this language */ - @Nullable Inliner createInliner(PsiElement element, Settings settings); + @Nullable Inliner createInliner(@NotNull PsiElement element, @NotNull Settings settings); interface Inliner { /** @@ -82,13 +81,13 @@ public interface InlineHandler { * or null if no conflicts detected. */ @Nullable - MultiMap getConflicts(PsiReference reference, PsiElement referenced); + MultiMap getConflicts(@NotNull PsiReference reference, @NotNull PsiElement referenced); /** * Perform actual inline of element to the point where it is referenced * @param usage usage of inlined element * @param referenced inlined element */ - void inlineUsage(UsageInfo usage, PsiElement referenced); + void inlineUsage(@NotNull UsageInfo usage, @NotNull PsiElement referenced); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/module/WebModuleType.java b/platform/lang-impl/src/com/intellij/openapi/module/WebModuleType.java index cd048d659cf2..4b317ffcfac1 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/WebModuleType.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/WebModuleType.java @@ -18,6 +18,7 @@ public class WebModuleType extends WebModuleTypeBase { @Override public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModuleBuilder moduleBuilder, ModulesProvider modulesProvider) { + if (wizardContext.isTemplateMode()) return ModuleWizardStep.EMPTY_ARRAY; WebModuleGenerationStep generationStep = new WebModuleGenerationStep( moduleBuilder, wizardContext.getStepIcon(), diff --git a/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java b/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java index dcf1c7db77cd..79c2b3f1c479 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/inline/GenericInlineHandler.java @@ -22,10 +22,12 @@ import com.intellij.lang.refactoring.InlineHandler; import com.intellij.lang.refactoring.InlineHandlers; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; import com.intellij.psi.PsiReference; @@ -48,6 +50,8 @@ import java.util.*; @SuppressWarnings({"UtilityClassWithoutPrivateConstructor"}) public class GenericInlineHandler { + private static final Logger LOG = Logger.getInstance(GenericInlineHandler.class); + public static boolean invoke(final PsiElement element, @Nullable Editor editor, final InlineHandler languageSpecific) { final PsiReference invocationReference = editor != null ? TargetElementUtilBase.findReference(editor) : null; final InlineHandler.Settings settings = languageSpecific.prepareInlineElement(element, editor, invocationReference != null); @@ -128,7 +132,7 @@ public class GenericInlineHandler { languageSpecific.removeDefinition(element, settings); } } - }, RefactoringBundle.message("inline.command", subj), null); + }, RefactoringBundle.message("inline.command", StringUtil.notNullize(subj, "")), null); } }); return true; @@ -139,7 +143,10 @@ public class GenericInlineHandler { Collection allReferences) { final Map inliners = new HashMap(); for (PsiReference ref : allReferences) { - final Language language = ref.getElement().getLanguage(); + PsiElement refElement = ref.getElement(); + LOG.assertTrue(refElement != null, ref.getClass().getName()); + + final Language language = refElement.getLanguage(); if (inliners.containsKey(language)) continue; final List handlers = InlineHandlers.getInlineHandlers(language); diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java index 6f2e687b8a76..8eb9835bf35b 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/RenameProcessor.java @@ -100,6 +100,10 @@ public class RenameProcessor extends BaseRefactoringProcessor { public Set getElements() { return Collections.unmodifiableSet(myAllRenames.keySet()); } + + public String getNewName(PsiElement element) { + return myAllRenames.get(element); + } public void addRenamerFactory(AutomaticRenamerFactory factory) { if (!myRenamerFactories.contains(factory)) { diff --git a/platform/platform-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java b/platform/platform-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java index 6816f1442adc..6d94b41c9d2b 100644 --- a/platform/platform-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java +++ b/platform/platform-api/src/com/intellij/ide/util/treeView/PresentableNodeDescriptor.java @@ -30,7 +30,7 @@ public abstract class PresentableNodeDescriptor extends NodeDescriptor { private PresentationData myTemplatePresentation; private PresentationData myUpdatedPresentation; - protected PresentableNodeDescriptor(Project project, NodeDescriptor parentDescriptor) { + protected PresentableNodeDescriptor(Project project, @Nullable NodeDescriptor parentDescriptor) { super(project, parentDescriptor); } diff --git a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java index 7781f61f598c..8d5a4f367422 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java @@ -71,7 +71,7 @@ public abstract class AbstractWizard extends DialogWrapper { initWizard(title); } - public AbstractWizard(final String title, final Project project) { + public AbstractWizard(final String title, @Nullable final Project project) { super(project, true); mySteps = new ArrayList(); initWizard(title); diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/CachingSimpleNode.java b/platform/platform-api/src/com/intellij/ui/treeStructure/CachingSimpleNode.java index ae27e3496dde..af26c5985eee 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/CachingSimpleNode.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/CachingSimpleNode.java @@ -27,7 +27,7 @@ public abstract class CachingSimpleNode extends SimpleNode { super(aParent); } - protected CachingSimpleNode(Project aProject, NodeDescriptor aParentDescriptor) { + protected CachingSimpleNode(Project aProject, @Nullable NodeDescriptor aParentDescriptor) { super(aProject, aParentDescriptor); } diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java index 19e127fc3efc..8b93e2637966 100644 --- a/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java +++ b/platform/platform-api/src/com/intellij/ui/treeStructure/SimpleNode.java @@ -42,7 +42,7 @@ public abstract class SimpleNode extends PresentableNodeDescriptor implements Co this(project, null); } - protected SimpleNode(Project project, NodeDescriptor parentDescriptor) { + protected SimpleNode(Project project, @Nullable NodeDescriptor parentDescriptor) { super(project, parentDescriptor); myName = ""; } diff --git a/platform/platform-impl/src/com/intellij/ui/AppIcon.java b/platform/platform-impl/src/com/intellij/ui/AppIcon.java index b37e212ba812..881ca6bf68c6 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AppIcon.java @@ -298,15 +298,18 @@ public abstract class AppIcon { Shape rect = new RoundRectangle2D.Double(xInset, y, width, progressHeight, progressHeight, progressHeight); Shape border = new RoundRectangle2D.Double(xInset - 1, y - 1, width + 2, progressHeight + 2, (progressHeight + 2), (progressHeight + 2)); - Shape progress = new RoundRectangle2D.Double(xInset + 1, y + 1, (width - 2) * value, progressHeight - 2, (progressHeight - 2), - (progressHeight - 2)); + Shape progress = new RoundRectangle2D.Double(xInset + 1, y + 1, (width - 2) * value, progressHeight - 1, (progressHeight - 2), + (progressHeight - 1)); AppImage appImg = createAppImage(); final Color brighter = Color.GRAY.brighter().brighter(); final Color backGround = new Color(brighter.getRed(), brighter.getGreen(), brighter.getBlue(), 85); appImg.myG2d.setColor(backGround); appImg.myG2d.fill(rect); - appImg.myG2d.setColor(isOk ? scheme.getOkColor() : scheme.getErrorColor()); + final Color color = isOk ? scheme.getOkColor() : scheme.getErrorColor(); + final GradientPaint paint = new GradientPaint(xInset + 1, y + 1, color.brighter(), + xInset + 1, y + progressHeight - 1, color.darker().darker()); + appImg.myG2d.setPaint(paint); appImg.myG2d.fill(progress); appImg.myG2d.setColor(Color.GRAY.darker().darker()); appImg.myG2d.draw(rect); diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index b516a727efc1..ac42dd7a1de7 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -931,7 +931,7 @@ add.scope.popup.title=Add scope add.scope.name.label=Name add.scope.dialog.title=Add New Scope scope.banner.text=Scope ''{0}'' -prompt.please.select.module.jdk=Please select {0} to be set for this module +prompt.please.select.module.jdk=Please select the {0} to be set for this module scopes.save.dialog.title.shared=Save as shared scope scopes.save.dialog.title.local=Save as local scope plugin.version.label=Version @@ -943,7 +943,7 @@ scope.unable.to.save.scope.message=Do you want to save scope as shared? scope.unable.to.save.scope.title=Unable to use local scope predefined.scope.production.name=Production plugin.manager.dependencies.detected.title=Plugin Dependencies Detected -plugin.manager.dependencies.detected.message=The plugin you want to install requires other plugin{0, choice, 1#|2#s} ({1}) which have to be installed as well. +plugin.manager.dependencies.detected.message=The plugin you want to install requires other plugin{0, choice, 1#|2#s} ({1}) which have to be installed as well. Proceed? plugin.manager.optional.dependencies.detected.message=The plugin you want to install optionally requires other plugin{0, choice, 1#|2#s} ({1}). Should those be installed as well? message.server.no.licenses=No suitable licenses left on the license server title.server.no.licenses=No Licenses on Server diff --git a/platform/platform-resources/src/idea/Keymap_Default.xml b/platform/platform-resources/src/idea/Keymap_Default.xml index 0df3265f28b1..240f951f2e6c 100644 --- a/platform/platform-resources/src/idea/Keymap_Default.xml +++ b/platform/platform-resources/src/idea/Keymap_Default.xml @@ -922,6 +922,7 @@ + @@ -931,15 +932,12 @@ - - - - - + + diff --git a/platform/projectModel-impl/src/com/intellij/core/CoreModule.java b/platform/projectModel-impl/src/com/intellij/core/CoreModule.java index 7c5544c7e511..adc0f3ef0c52 100644 --- a/platform/projectModel-impl/src/com/intellij/core/CoreModule.java +++ b/platform/projectModel-impl/src/com/intellij/core/CoreModule.java @@ -61,10 +61,16 @@ public class CoreModule extends MockComponentManager implements ModuleEx { } }); - ModuleRootManagerImpl moduleRootManager = new ModuleRootManagerImpl(this, + final ModuleRootManagerImpl moduleRootManager = new ModuleRootManagerImpl(this, DirectoryIndex.getInstance(project), ProjectRootManagerImpl.getInstanceImpl(project), VirtualFilePointerManager.getInstance()); + Disposer.register(parentDisposable, new Disposable() { + @Override + public void dispose() { + moduleRootManager.disposeComponent(); + } + }); getPicoContainer().registerComponentInstance(ModuleRootManager.class, moduleRootManager); getPicoContainer().registerComponentInstance(PathMacroManager.class, new ModulePathMacroManager(PathMacros.getInstance(), this)); myModuleScopeProvider = createModuleScopeProvider(); diff --git a/platform/projectModel-impl/src/messages/ProjectBundle.properties b/platform/projectModel-impl/src/messages/ProjectBundle.properties index a009a97741db..d04d18e7b436 100644 --- a/platform/projectModel-impl/src/messages/ProjectBundle.properties +++ b/platform/projectModel-impl/src/messages/ProjectBundle.properties @@ -53,7 +53,7 @@ message.text.stop.searching.for.frameworks={0} is currently searching for framew label.text.the.following.frameworks.are.detected=Several frameworks are detected in the project. Please review the following items and exclude mistakenly detected. label.text.no.frameworks.detected=No frameworks detected. -sdk.java.name=JSDK +sdk.java.name=JDK sdk.java.unknown.name=Unknown sdk.java.corrupt.error=Probably SDK installed in ''{0}'' is corrupt sdk.java.corrupt.title=Cannot Detect SDK Version diff --git a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java index f1f2ee2751db..cf6db68d2dab 100644 --- a/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/AbstractCollectionBinding.java @@ -29,18 +29,14 @@ abstract class AbstractCollectionBinding implements Binding { private final Class myElementType; private final String myTagName; - @Nullable protected Accessor myAccessor; - private AbstractCollection myAnnotation = null; - private boolean myUsingOptionBinding = false; + @Nullable protected final Accessor myAccessor; + private final AbstractCollection myAnnotation; public AbstractCollectionBinding(Class elementType, String tagName, @Nullable Accessor accessor) { myElementType = elementType; myTagName = tagName; myAccessor = accessor; - - if (accessor != null) { - myAnnotation = XmlSerializerImpl.findAnnotation(accessor.getAnnotations(), AbstractCollection.class); - } + myAnnotation = accessor == null ? null : XmlSerializerImpl.findAnnotation(accessor.getAnnotations(), AbstractCollection.class); } public void init() { @@ -51,10 +47,10 @@ abstract class AbstractCollectionBinding implements Binding { } if (myAnnotation.elementTag().equals(Constants.OPTION)) { - getElementBindings(); - - if (myUsingOptionBinding) { - throw new XmlSerializationException("If surround with tag is turned off, element tag must be specified for: " + myAccessor); + for (Binding binding : getElementBindings().values()) { + if (binding instanceof TagBindingWrapper) { + throw new XmlSerializationException("If surround with tag is turned off, element tag must be specified for: " + myAccessor); + } } } } @@ -66,7 +62,7 @@ abstract class AbstractCollectionBinding implements Binding { return binding == null ? XmlSerializerImpl.getBinding(elementClass) : binding; } - private Map getElementBindings() { + private synchronized Map getElementBindings() { if (myElementBindings == null) { myElementBindings = new HashMap(); @@ -91,15 +87,8 @@ abstract class AbstractCollectionBinding implements Binding { } private Binding getBinding(final Class type) { - Binding binding; - binding = XmlSerializerImpl.getBinding(type); - - if (!binding.getBoundNodeType().isAssignableFrom(Element.class)) { - binding = createElementTagWrapper(binding); - myUsingOptionBinding = true; - } - - return binding; + Binding binding = XmlSerializerImpl.getBinding(type); + return binding.getBoundNodeType().isAssignableFrom(Element.class) ? binding : createElementTagWrapper(binding); } private Binding createElementTagWrapper(final Binding elementBinding) { diff --git a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java index 562380c8a2fc..a40a40ed6e3e 100644 --- a/platform/util/src/com/intellij/util/xmlb/BeanBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/BeanBinding.java @@ -64,7 +64,7 @@ class BeanBinding implements Binding { initPropertyBindings(myBeanClass); } - private void initPropertyBindings(Class beanClass) { + private synchronized void initPropertyBindings(Class beanClass) { for (Accessor accessor : getAccessors(beanClass)) { final Binding binding = createBindingByAccessor(accessor); myPropertyBindingsList.add(binding); diff --git a/platform/util/src/com/intellij/util/xmlb/TextBinding.java b/platform/util/src/com/intellij/util/xmlb/TextBinding.java index 781b023ac7b2..ff6bed258705 100644 --- a/platform/util/src/com/intellij/util/xmlb/TextBinding.java +++ b/platform/util/src/com/intellij/util/xmlb/TextBinding.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; public class TextBinding implements Binding { private final Accessor myAccessor; - private Binding myBinding; + private volatile Binding myBinding; public TextBinding(final Accessor accessor) { myAccessor = accessor; diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java index 0a873ced0d6a..436f2a8b7e12 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/AbstractVcs.java @@ -44,6 +44,7 @@ import com.intellij.util.ThrowableRunnable; import com.intellij.util.containers.Convertor; import com.intellij.util.ui.VcsSynchronousProgressWrapper; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Arrays; @@ -559,6 +560,10 @@ public abstract class AbstractVcs extends S return true; } + public boolean allowsRemoteCalls(@NotNull final VirtualFile file) { + return true; + } + public void setCheckinEnvironment(CheckinEnvironment checkinEnvironment) { if (myCheckinEnvironment != null) throw new IllegalStateException("Attempt to redefine checkin environment"); myCheckinEnvironment = checkinEnvironment; diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java b/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java index 139ab20a392d..844d1d1330af 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/CommittedChangesProvider.java @@ -26,6 +26,7 @@ import com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditor; import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.AsynchConsumer; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -34,6 +35,7 @@ import java.util.List; * @author yole */ public interface CommittedChangesProvider extends VcsProviderMarker { + @NotNull U createDefaultSettings(); ChangesBrowserSettingsEditor createFilterUI(final boolean showDateFilter); diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/Change.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/Change.java index c62db4ccd872..8e300bd2a291 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/Change.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/Change.java @@ -60,11 +60,11 @@ public class Change { // if null, vcs's is used. intended: for property conflict case private Getter myMergeProvider; - public Change(final ContentRevision beforeRevision, final ContentRevision afterRevision) { + public Change(@Nullable final ContentRevision beforeRevision, @Nullable final ContentRevision afterRevision) { this(beforeRevision, afterRevision, convertStatus(beforeRevision, afterRevision)); } - public Change(final ContentRevision beforeRevision, final ContentRevision afterRevision, FileStatus fileStatus) { + public Change(@Nullable final ContentRevision beforeRevision, @Nullable final ContentRevision afterRevision, @Nullable FileStatus fileStatus) { assert beforeRevision != null || afterRevision != null; myBeforeRevision = beforeRevision; myAfterRevision = afterRevision; @@ -73,7 +73,7 @@ public class Change { myOtherLayers = new HashMap(0); } - private static FileStatus convertStatus(ContentRevision beforeRevision, ContentRevision afterRevision) { + private static FileStatus convertStatus(@Nullable ContentRevision beforeRevision, @Nullable ContentRevision afterRevision) { if (beforeRevision == null) return FileStatus.ADDED; if (afterRevision == null) return FileStatus.DELETED; return FileStatus.MODIFIED; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java index efb49b2029ee..22aa60ac6d21 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/FilePathImpl.java @@ -292,6 +292,10 @@ public class FilePathImpl implements FilePath { return myVirtualFile != null ? myVirtualFile.getFileType() : FileTypeManager.getInstance().getFileTypeByFileName(myFile.getName()); } + public static FilePathImpl create(VirtualFile file) { + return create(VfsUtilCore.virtualToIoFile(file), file.isDirectory()); + } + public static FilePathImpl create(File selectedFile) { return create(selectedFile, false); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BrowseChangesAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BrowseChangesAction.java index c8937a38a86a..aabb82a5e7f6 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BrowseChangesAction.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/BrowseChangesAction.java @@ -74,7 +74,7 @@ public class BrowseChangesAction extends AnAction implements DumbAware { VirtualFile vFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); if (vFile == null) return false; AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(vFile); - if (vcs == null || vcs.getCommittedChangesProvider() == null) { + if (vcs == null || vcs.getCommittedChangesProvider() == null || !vcs.allowsRemoteCalls(vFile)) { return false; } FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(vFile); diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java index 3aabe0499d17..40f6d209e903 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/committed/CompositeCommittedChangesProvider.java @@ -31,6 +31,7 @@ import com.intellij.ui.components.JBTabbedPane; import com.intellij.util.AsynchConsumer; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -53,6 +54,7 @@ public class CompositeCommittedChangesProvider implements CommittedChangesProvid Collections.addAll(myBaseVcss, baseVcss); } + @NotNull public CompositeCommittedChangesProvider.CompositeChangeBrowserSettings createDefaultSettings() { Map map = new HashMap(); for(AbstractVcs vcs: myBaseVcss) { diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java index 8a81602d9997..4560443f89cd 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebuggerManagerImpl.java @@ -60,10 +60,11 @@ import java.util.*; * @author nik */ @State( - name = XDebuggerManagerImpl.COMPONENT_NAME, - storages = {@Storage( - file = StoragePathMacros.WORKSPACE_FILE)}) -public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectComponent, PersistentStateComponent { + name = XDebuggerManagerImpl.COMPONENT_NAME, + storages = {@Storage( + file = StoragePathMacros.WORKSPACE_FILE)}) +public class XDebuggerManagerImpl extends XDebuggerManager + implements ProjectComponent, PersistentStateComponent { @NonNls public static final String COMPONENT_NAME = "XDebuggerManager"; private final Project myProject; private final XBreakpointManagerImpl myBreakpointManager; @@ -199,7 +200,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom } private XDebugSessionImpl startSession(final RunContentDescriptor contentToReuse, final XDebugProcessStarter processStarter, - final XDebugSessionImpl session) throws ExecutionException { + final XDebugSessionImpl session) throws ExecutionException { XDebugProcess process = processStarter.start(session); XDebugSessionData oldSessionData = contentToReuse != null ? mySessionData.get(contentToReuse) : null; @@ -331,5 +332,4 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom myBreakpointManagerState = breakpointManagerState; } } - } diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/asserttoif/IfStatementPredicate.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/asserttoif/IfStatementPredicate.java index aa86dace15fb..2a904a5b2a66 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/asserttoif/IfStatementPredicate.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/asserttoif/IfStatementPredicate.java @@ -61,7 +61,7 @@ class IfStatementPredicate implements PsiElementPredicate { } final PsiClass aClass = (PsiClass)target; final String qualifiedName = aClass.getQualifiedName(); - return "java.lang.AssertionError".equals(qualifiedName); + return CommonClassNames.JAVA_LANG_ASSERTION_ERROR.equals(qualifiedName); } else if (element instanceof PsiBlockStatement) { final PsiBlockStatement blockStatement = diff --git a/plugins/android-designer/src/META-INF/plugin.xml b/plugins/android-designer/src/META-INF/plugin.xml index e4e7726d743e..612d8c99c969 100644 --- a/plugins/android-designer/src/META-INF/plugin.xml +++ b/plugins/android-designer/src/META-INF/plugin.xml @@ -1,6 +1,9 @@ Android Designer com.intellij.android-designer + + Provides visual editing support for Android layout files. + JetBrains messages.AndroidDesignerBundle diff --git a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java index f7fd4655835d..605c39c71a91 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java +++ b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java @@ -113,7 +113,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { } }); - showProgress("Load configuration"); + showProgress("Loading configuration..."); myProfileAction = new ProfileAction(this, new Runnable() { @Override public void run() { @@ -253,7 +253,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { @Override public void run() { if (mySession == null) { - showProgress("Create RenderLib"); + showProgress("Creating RenderLib..."); } } }, 500); diff --git a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java index ee604d2c8b52..2368e126995a 100644 --- a/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java +++ b/plugins/android/jps-plugin/src/org/jetbrains/jps/android/AndroidSourceGeneratingBuilder.java @@ -906,7 +906,8 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { @Nullable private static String getDependencyFolder(@NotNull CompileContext context, @NotNull File sourceFile, @NotNull File genFolder) { - final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, sourceFile); + final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, + sourceFile); if (descriptor == null) { return null; } @@ -976,7 +977,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder { @Nullable private static String computePackageForFile(@NotNull CompileContext context, @NotNull File file) throws IOException { - final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file); + final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file); if (descriptor == null) { return null; } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java index 7f7cbe32d1c9..6738e4e69e03 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/changeBrowser/CvsCommittedChangesProvider.java @@ -63,6 +63,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi myProject = project; } + @NotNull public ChangeBrowserSettings createDefaultSettings() { return new ChangeBrowserSettings(); } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java index 4646aad457b6..696f8c6c8e5e 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java @@ -25,7 +25,7 @@ import com.intellij.openapi.components.PathMacroManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.impl.ProjectRootManagerImpl; @@ -170,14 +170,17 @@ public class EPathUtil { @Nullable public static String collapse2eclipseRelative2OtherModule(final @NotNull Project project, final @NotNull VirtualFile file) { - final Module module = ModuleUtil.findModuleForFile(file, project); + final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module != null) { return collapse2eclipsePathRelative2Module(file, module); - } else if (ProjectRootManager.getInstance(project).getFileIndex().isIgnored(file)) { //should check all modules then - for (Module aModule : ModuleManager.getInstance(project).getModules()) { - final String path = collapse2eclipsePathRelative2Module(file, aModule); - if (path != null) { - return path; + } else { //should check all modules then + final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); + if (fileIndex.isIgnored(file) || fileIndex.isInLibraryClasses(file)) { + for (Module aModule : ModuleManager.getInstance(project).getModules()) { + final String path = collapse2eclipsePathRelative2Module(file, aModule); + if (path != null) { + return path; + } } } } diff --git a/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java b/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java index 01d71205bfd2..dd61e4e92ba4 100644 --- a/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java +++ b/plugins/git4idea/src/git4idea/changes/GitCommittedChangeListProvider.java @@ -61,6 +61,7 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider< myProject = project; } + @NotNull public ChangeBrowserSettings createDefaultSettings() { return new ChangeBrowserSettings(); } diff --git a/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java b/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java index 4234af2553ed..2bc9f8eb0ed7 100644 --- a/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java +++ b/plugins/git4idea/src/git4idea/crlf/GitCrlfDialog.java @@ -52,7 +52,7 @@ public class GitCrlfDialog extends DialogWrapper { setOKButtonText("Fix and Commit"); setCancelButtonText("Cancel"); - setTitle("Line separators warning"); + setTitle("Line Separators Warning"); getCancelAction().putValue(DialogWrapper.FOCUSED_ACTION, true); init(); @@ -60,7 +60,7 @@ public class GitCrlfDialog extends DialogWrapper { @Override protected Action[] createActions() { - return new Action[] { getOKAction(), getCancelAction(), new DialogWrapperExitAction("Commit as Is", DONT_SET) }; + return new Action[] { getOKAction(), getCancelAction(), new DialogWrapperExitAction("Commit As Is", DONT_SET) }; } @Override diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchUiUtil.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchUiUtil.java index 9f5341545ec4..d84a1af832a5 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchUiUtil.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchUiUtil.java @@ -165,9 +165,6 @@ public class GitBranchUiUtil { return null; } GitRepositoryManager manager = GitUtil.getRepositoryManager(project); - if (manager == null) { - return null; - } VirtualFile file = getSelectedFile(project); if (file != null) { return manager.getRepositoryForRoot(getVcsRootFor(project, file)); diff --git a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.groovy b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.groovy index 2c2619153037..eba1a7b77022 100644 --- a/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.groovy +++ b/plugins/git4idea/tests/git4idea/branch/GitBranchWorkerTest.groovy @@ -773,10 +773,10 @@ class GitBranchWorkerTest { } private static void assertContent(String expectedContent, String actual) { + expectedContent = StringUtil.convertLineSeparators(expectedContent, LineSeparator.getSystemLineSeparator().separatorString).trim() + actual = actual.trim() assertEquals String.format("Content doesn't match.%nExpected:%n%s%nActual:%n%s%n", - substWhitespaces(expectedContent), substWhitespaces(actual)), - StringUtil.convertLineSeparators(expectedContent, LineSeparator.getSystemLineSeparator().separatorString).trim(), - actual.trim() + substWhitespaces(expectedContent), substWhitespaces(actual)), expectedContent, actual } private static String substWhitespaces(String s) { diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java index f442add9f798..471026a78d4b 100644 --- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java +++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java @@ -220,7 +220,7 @@ public class GroovyBuilder extends ModuleLevelBuilder { GroovycOSProcessHandler.OutputItem item, Map generationOutputs, String compilerOutput) throws IOException { if (chunk.getModules().size() > 1) { final BuildRootIndex rootsIndex = context.getProjectDescriptor().getBuildRootIndex(); - JavaSourceRootDescriptor descriptor = rootsIndex.getModuleAndRoot(context, new File(item.sourcePath)); + JavaSourceRootDescriptor descriptor = rootsIndex.findJavaRootDescriptor(context, new File(item.sourcePath)); if (descriptor != null) { ModuleBuildTarget srcTarget = descriptor.target; if (!srcTarget.equals(chunk.representativeTarget())) { @@ -283,7 +283,9 @@ public class GroovyBuilder extends ModuleLevelBuilder { for (GroovycOSProcessHandler.OutputItem item : successfullyCompiled) { final String sourcePath = FileUtil.toSystemIndependentName(item.sourcePath); final String outputPath = FileUtil.toSystemIndependentName(item.outputPath); - final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, new File(sourcePath)); + final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, + new File( + sourcePath)); if (moduleAndRoot != null) { final ModuleBuildTarget target = moduleAndRoot.target; context.getProjectDescriptor().dataManager.getSourceToOutputMap(target).appendOutput(sourcePath, outputPath); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties index 52a2e53b9862..7aee00157951 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties @@ -333,4 +333,5 @@ top.level.class.maynot.have.private.modifier=Top level class may not have 'priva top.level.class.maynot.have.protected.modifier=Top level class may not have 'protected' modifier property.missing=propertyMissing attribute.name.expected=Attribute name expected -java.style.for.each.statement.requires.a.type.declaration=Java-style for-each statement requires a type declaration \ No newline at end of file +java.style.for.each.statement.requires.a.type.declaration=Java-style for-each statement requires a type declaration +enums.may.not.have.extends.clause=Enums may not have 'extends' clause \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index c168691e949a..a0c9e87c6bbf 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -1341,6 +1341,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { if (typeDefinition.isInterface()) { checkReferenceList(myHolder, extendsClause, true, GroovyBundle.message("no.class.expected.here"), null); } + else if (typeDefinition.isEnum()) { + myHolder.createErrorAnnotation(extendsClause, GroovyBundle.message("enums.may.not.have.extends.clause")); + } else { checkReferenceList(myHolder, extendsClause, false, GroovyBundle.message("no.interface.expected.here"), new ChangeExtendsImplementsQuickFix(typeDefinition)); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java index 8b5774d0195f..0ac8d2a24dd2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java @@ -37,10 +37,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.*; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrBreakStatement; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrContinueStatement; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement; -import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrThrowStatement; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.*; import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; @@ -662,7 +659,7 @@ public class ControlFlowUtils { } else if (last instanceof ThrowingInstruction) { PsiElement element = last.getElement(); - if (!(element instanceof GrThrowStatement)) return true; + if (!(element instanceof GrThrowStatement || element instanceof GrAssertStatement)) return true; } PsiElement element = last.getElement(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java index ab980aa841df..8f4b24b2f836 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/MethodLateBoundReferencesSearcher.java @@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.findUsages; import com.intellij.openapi.application.QueryExecutorBase; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; @@ -72,6 +73,7 @@ public class MethodLateBoundReferencesSearcher extends QueryExecutorBase consumer) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java index 92f12a2bde79..e8deb158bf80 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java @@ -33,6 +33,8 @@ import com.intellij.psi.impl.source.tree.LeafPsiElement; import com.intellij.psi.templateLanguages.OuterLanguageElement; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.GroovyFileType; @@ -215,53 +217,27 @@ public class GroovyBlockGenerator implements GroovyElementTypes { private void calculateAlignments(List children, boolean classLevel) { - List currentGroup = null; + List currentGroup = null; + boolean spock = true; for (ASTNode child : children) { PsiElement psi = child.getPsi(); if (psi instanceof GrLabeledStatement) { - List table = getSpockTable(((GrLabeledStatement)psi).getStatement()); - if (table.isEmpty()) { - currentGroup = null; - } - else { - currentGroup = new ArrayList(); - for (LeafPsiElement expression : table) { - currentGroup.add(myAlignmentProvider.createAligner(expression, true, Alignment.Anchor.RIGHT)); - } - } + alignGroup(currentGroup, spock, classLevel); + currentGroup = ContainerUtil.newArrayList((GrStatement)psi); + spock = true; } - else if (currentGroup != null && isTablePart(psi)) { - List table = getSpockTable((GrStatement)psi); - for (int i = 0; i < Math.min(table.size(), currentGroup.size()); i++) { - currentGroup.get(i).append(table.get(i)); - } + else if (currentGroup != null && spock && isTablePart(psi)) { + currentGroup.add((GrStatement)psi); } else if (psi instanceof GrVariableDeclaration) { - final GrVariableDeclaration varDeclaration = (GrVariableDeclaration)psi; - GrVariable[] variables = varDeclaration.getVariables(); + GrVariable[] variables = ((GrVariableDeclaration)psi).getVariables(); if (variables.length > 0) { - if (!classLevel || currentGroup == null || fieldGroupEnded(psi)) { - currentGroup = new ArrayList(); - currentGroup.add(myAlignmentProvider.createAligner(true)); - currentGroup.add(myAlignmentProvider.createAligner(true)); - currentGroup.add(myAlignmentProvider.createAligner(true)); - } - - AlignmentProvider.Aligner varName = currentGroup.get(1); - for (GrVariable variable : variables) { - varName.append(variable.getNameIdentifierGroovy()); - } - - if (classLevel && mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) { - final AlignmentProvider.Aligner typeElement = currentGroup.get(0); - typeElement.append(varDeclaration.getTypeElementGroovy()); - - ASTNode current_eq = variables[variables.length - 1].getNode().findChildByType(GroovyTokenTypes.mASSIGN); - final AlignmentProvider.Aligner eq = currentGroup.get(2); - if (current_eq != null) { - eq.append(current_eq.getPsi()); - } + if (!classLevel || currentGroup == null || fieldGroupEnded(psi) || spock) { + alignGroup(currentGroup, spock, classLevel); + currentGroup = ContainerUtil.newArrayList(); + spock = false; } + currentGroup.add((GrStatement)psi); } } else { @@ -271,11 +247,70 @@ public class GroovyBlockGenerator implements GroovyElementTypes { continue; } } + alignGroup(currentGroup, spock, classLevel); currentGroup = null; } } } + private void alignGroup(@Nullable List group, boolean spock, boolean classLevel) { + if (group == null) { + return; + } + if (spock) { + alignSpockTable(group); + } else { + alignVariableDeclarations(group, classLevel); + } + } + + private void alignVariableDeclarations(List group, boolean classLevel) { + AlignmentProvider.Aligner typeElement = myAlignmentProvider.createAligner(true); + AlignmentProvider.Aligner varName = myAlignmentProvider.createAligner(true); + AlignmentProvider.Aligner eq = myAlignmentProvider.createAligner(true); + for (GrStatement statement : group) { + GrVariableDeclaration varDeclaration = (GrVariableDeclaration) statement; + GrVariable[] variables = varDeclaration.getVariables(); + for (GrVariable variable : variables) { + varName.append(variable.getNameIdentifierGroovy()); + } + + if (classLevel && mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) { + typeElement.append(varDeclaration.getTypeElementGroovy()); + + ASTNode current_eq = variables[variables.length - 1].getNode().findChildByType(GroovyTokenTypes.mASSIGN); + if (current_eq != null) { + eq.append(current_eq.getPsi()); + } + } + } + } + + private void alignSpockTable(List group) { + if (group.size() < 2) { + return; + } + GrStatement inner = ((GrLabeledStatement)group.get(0)).getStatement(); + boolean embedded = inner != null && isTablePart(inner); + + GrStatement first = embedded ? inner : group.get(1); + List alignments = ContainerUtil + .map2List(getSpockTable(first), new Function() { + @Override + public AlignmentProvider.Aligner fun(LeafPsiElement leaf) { + return myAlignmentProvider.createAligner(leaf, true, Alignment.Anchor.RIGHT); + } + }); + + int second = embedded ? 1 : 2; + for (int i = second; i < group.size(); i++) { + List table = getSpockTable(group.get(i)); + for (int j = 0; j < Math.min(table.size(), alignments.size()); j++) { + alignments.get(j).append(table.get(j)); + } + } + } + private boolean fieldGroupEnded(PsiElement psi) { if (!mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) return true; PsiElement prevSibling = psi.getPrevSibling(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java index 4de511021a00..6dacfc710bab 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java @@ -66,6 +66,7 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; import static com.intellij.patterns.PsiJavaPatterns.psiElement; import static com.intellij.patterns.StandardPatterns.or; +import static org.jetbrains.plugins.groovy.lang.completion.GroovyCompletionUtil.*; /** * @author ilyas @@ -148,11 +149,10 @@ public class GroovyCompletionData { addModifiers(position, result); } if (psiElement().afterLeaf(MODIFIERS).accepts(position) || - GroovyCompletionUtil.isInTypeDefinitionBody(position) && GroovyCompletionUtil.isNewStatement(position, true)) { + isInTypeDefinitionBody(position) && isNewStatement(position, true)) { addKeywords(result, true, PsiKeyword.SYNCHRONIZED); } - if (suggestFinalDef(position) || psiElement().afterLeaf( - psiElement().withText("(").withParent(GrForStatement.class)).accepts(position)) { + if (suggestFinalDef(position) || psiElement().afterLeaf(psiElement().withText("(").withParent(GrForStatement.class)).accepts(position)) { addKeywords(result, true, PsiKeyword.FINAL, "def"); } } @@ -160,7 +160,7 @@ public class GroovyCompletionData { } private static void addExtendsForTypeParams(PsiElement position, CompletionResultSet result) { - if (GroovyCompletionUtil.isWildcardCompletion(position)) { + if (isWildcardCompletion(position)) { addKeywords(result, true, PsiKeyword.EXTENDS, PsiKeyword.SUPER); } } @@ -314,13 +314,13 @@ public class GroovyCompletionData { return true; } - final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(context.getTextRange().getStartOffset() - 1, context); + final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context); if (leaf != null) { PsiElement parent = leaf.getParent(); if (parent instanceof GroovyFile) { GroovyFile groovyFile = (GroovyFile) parent; if (groovyFile.getPackageDefinition() == null) { - return GroovyCompletionUtil.isNewStatement(context, false); + return isNewStatement(context, false); } } } @@ -331,15 +331,15 @@ public class GroovyCompletionData { private static boolean suggestImport(PsiElement context) { if (context.getParent() != null && !(context.getParent() instanceof PsiErrorElement) && - GroovyCompletionUtil.isNewStatement(context, false) && + isNewStatement(context, false) && context.getParent().getParent() instanceof GroovyFile) { return true; } - final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(context.getTextRange().getStartOffset() - 1, context); + final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context); if (leaf != null) { PsiElement parent = leaf.getParent(); if (parent instanceof GroovyFile) { - return GroovyCompletionUtil.isNewStatement(context, false); + return isNewStatement(context, false); } } return context.getTextRange().getStartOffset() == 0 && !(context instanceof OuterLanguageElement); @@ -367,7 +367,7 @@ public class GroovyCompletionData { return true; } } - final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(context.getTextRange().getStartOffset() - 1, context); + final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context); if (leaf != null) { PsiElement prev = leaf; prev = PsiImplUtil.realPrevious(prev); @@ -378,7 +378,7 @@ public class GroovyCompletionData { } if (leaf.getParent() instanceof GroovyFile) { - return GroovyCompletionUtil.isNewStatement(context, false); + return isNewStatement(context, false); } } @@ -403,8 +403,8 @@ public class GroovyCompletionData { ASTNode node = prevSibling.getNode(); return !TokenSets.DOTS.contains(node.getElementType()); } - if (GroovyCompletionUtil.isNewStatement(context, true)) { - final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(offset - 1, context); + if (isNewStatement(context, true)) { + final PsiElement leaf = getLeafByOffset(offset - 1, context); if (leaf != null && (leaf.getParent() instanceof GrStatementOwner || leaf.getParent() instanceof GrLabeledStatement)) { return true; } @@ -458,17 +458,17 @@ public class GroovyCompletionData { private static boolean afterTry(PsiElement context) { if (context != null && - GroovyCompletionUtil.nearestLeftSibling(context) instanceof GrTryCatchStatement) { - GrTryCatchStatement tryStatement = (GrTryCatchStatement) GroovyCompletionUtil.nearestLeftSibling(context); + nearestLeftSibling(context) instanceof GrTryCatchStatement) { + GrTryCatchStatement tryStatement = (GrTryCatchStatement) nearestLeftSibling(context); if (tryStatement == null) return false; if (tryStatement.getFinallyClause() == null) { return true; } } if (context != null && - GroovyCompletionUtil.nearestLeftSibling(context) instanceof PsiErrorElement && - GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling() instanceof GrTryCatchStatement) { - GrTryCatchStatement tryStatement = (GrTryCatchStatement) GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling(); + nearestLeftSibling(context) instanceof PsiErrorElement && + nearestLeftSibling(context).getPrevSibling() instanceof GrTryCatchStatement) { + GrTryCatchStatement tryStatement = (GrTryCatchStatement) nearestLeftSibling(context).getPrevSibling(); if (tryStatement == null) return false; if (tryStatement.getFinallyClause() == null) { return true; @@ -476,8 +476,8 @@ public class GroovyCompletionData { } if (context != null && (context.getParent() instanceof GrReferenceExpression || context.getParent() instanceof PsiErrorElement) && - GroovyCompletionUtil.nearestLeftSibling(context.getParent()) instanceof GrTryCatchStatement) { - GrTryCatchStatement tryStatement = (GrTryCatchStatement) GroovyCompletionUtil.nearestLeftSibling(context.getParent()); + nearestLeftSibling(context.getParent()) instanceof GrTryCatchStatement) { + GrTryCatchStatement tryStatement = (GrTryCatchStatement) nearestLeftSibling(context.getParent()); if (tryStatement == null) return false; if (tryStatement.getFinallyClause() == null) { return true; @@ -488,13 +488,13 @@ public class GroovyCompletionData { private static boolean afterIfOrElse(PsiElement context) { if (context.getParent() != null && - GroovyCompletionUtil.nearestLeftSibling(context.getParent()) instanceof GrIfStatement) { + nearestLeftSibling(context.getParent()) instanceof GrIfStatement) { return true; } if (context.getParent() != null && - GroovyCompletionUtil.nearestLeftSibling(context) != null && - GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling() instanceof GrIfStatement) { - GrIfStatement statement = (GrIfStatement) GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling(); + nearestLeftSibling(context) != null && + nearestLeftSibling(context).getPrevSibling() instanceof GrIfStatement) { + GrIfStatement statement = (GrIfStatement) nearestLeftSibling(context).getPrevSibling(); if (statement.getElseBranch() == null) { return true; } @@ -512,7 +512,7 @@ public class GroovyCompletionData { private static boolean afterAbstractMethod(PsiElement context) { PsiElement candidate = null; - if (GroovyCompletionUtil.isInTypeDefinitionBody(context)) { + if (isInTypeDefinitionBody(context)) { PsiElement run = context; while(!(run.getParent() instanceof GrTypeDefinitionBody)) { run = run.getParent(); @@ -551,9 +551,9 @@ public class GroovyCompletionData { if (previous != null && GroovyTokenTypes.mAT.equals(previous.getNode().getElementType())) { return false; } - if (GroovyCompletionUtil.asSimpleVariable(context) || - GroovyCompletionUtil.asTypedMethod(context) || - GroovyCompletionUtil.asVariableInBlock(context)) { + if (asSimpleVariable(context) || + asTypedMethod(context) || + asVariableInBlock(context)) { return true; } if ((parent instanceof GrParameter && @@ -578,7 +578,7 @@ public class GroovyCompletionData { } return parent instanceof GrExpression && parent.getParent() instanceof GroovyFile && - GroovyCompletionUtil.isNewStatement(context, false); + isNewStatement(context, false); } private static boolean isInfixOperatorPosition(PsiElement context) { @@ -588,17 +588,17 @@ public class GroovyCompletionData { context.getParent().getParent() instanceof GrCommandArgumentList) { return true; } - if (GroovyCompletionUtil.nearestLeftSibling(context) instanceof PsiErrorElement && - GroovyCompletionUtil.endsWithExpression(GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling())) { + if (nearestLeftSibling(context) instanceof PsiErrorElement && + endsWithExpression(nearestLeftSibling(context).getPrevSibling())) { return true; } if (context.getParent() instanceof GrReferenceExpression && - GroovyCompletionUtil.nearestLeftLeaf(context) instanceof PsiErrorElement && - GroovyCompletionUtil.endsWithExpression(GroovyCompletionUtil.nearestLeftLeaf(context).getPrevSibling())) { + nearestLeftLeaf(context) instanceof PsiErrorElement && + endsWithExpression(nearestLeftLeaf(context).getPrevSibling())) { return true; } if (context.getParent() instanceof PsiErrorElement && - GroovyCompletionUtil.endsWithExpression(GroovyCompletionUtil.nearestLeftSibling(context.getParent()))) { + endsWithExpression(nearestLeftSibling(context.getParent()))) { return true; } @@ -606,12 +606,12 @@ public class GroovyCompletionData { } private static boolean suggestModifiers(PsiElement context) { - if (GroovyCompletionUtil.asSimpleVariable(context) || - GroovyCompletionUtil.asTypedMethod(context) || - GroovyCompletionUtil.isNewStatementInScript(context)) { + if (asSimpleVariable(context) || + asTypedMethod(context) || + isNewStatementInScript(context)) { return true; } - if (GroovyCompletionUtil.isFirstElementAfterPossibleModifiersInVariableDeclaration(context, false) && + if (isFirstElementAfterPossibleModifiersInVariableDeclaration(context, false) && !psiElement().afterLeaf("def").accepts(context)) { return true; } @@ -636,7 +636,7 @@ public class GroovyCompletionData { } if (contextParent instanceof GrExpression && contextParent.getParent() instanceof GroovyFile && - GroovyCompletionUtil.isNewStatement(context, false)) { + isNewStatement(context, false)) { return true; } if (context.getTextRange().getStartOffset() == 0 && !(context instanceof OuterLanguageElement)) { @@ -645,22 +645,16 @@ public class GroovyCompletionData { return contextParent instanceof GrExpression && contextParent.getParent() instanceof GrApplicationStatement && contextParent.getParent().getParent() instanceof GroovyFile && - GroovyCompletionUtil.isNewStatement(context, false); + isNewStatement(context, false); } public static boolean suggestFinalDef(PsiElement context) { - if (GroovyCompletionUtil.asSimpleVariable(context) || - GroovyCompletionUtil.asTypedMethod(context) || - GroovyCompletionUtil.asVariableInBlock(context) || - GroovyCompletionUtil.isNewStatementInScript(context)) { - return true; - } - if ((context.getParent() instanceof GrParameter && - ((GrParameter) context.getParent()).getTypeElementGroovy() == null) || - context.getParent() instanceof GrReferenceElement && - !(context.getParent() instanceof GrReferenceExpression) && - !(context.getParent().getParent() instanceof GrImportStatement) && - !(context.getParent().getParent() instanceof GrPackageDefinition)) { + if (asSimpleVariable(context) || + asTypedMethod(context) || + asVariableInBlock(context) || + isNewStatementInScript(context) && !isReferenceElementInNewExpr(context) || + isTypelessParameter(context) || + isCodeReferenceElementApplicableToModifierCompletion(context)) { return true; } if (PsiImplUtil.realPrevious(context.getParent().getPrevSibling()) instanceof GrModifierList) { @@ -671,6 +665,6 @@ public class GroovyCompletionData { } return context.getParent() instanceof GrExpression && context.getParent().getParent() instanceof GroovyFile && - GroovyCompletionUtil.isNewStatement(context, false); + isNewStatement(context, false); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java index e71f78596c48..315c00aa3f18 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java @@ -62,12 +62,14 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement; +import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClassTypeElement; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement; @@ -577,4 +579,24 @@ public class GroovyCompletionUtil { } return false; } + + public static boolean isReferenceElementInNewExpr(PsiElement context) { + if (context.getParent() instanceof GrCodeReferenceElement) { + PsiElement pparent = context.getParent().getParent(); + if (pparent instanceof GrNewExpression) return true; + } + + return false; + } + + static boolean isCodeReferenceElementApplicableToModifierCompletion(PsiElement context) { + return context.getParent() instanceof GrCodeReferenceElement && + !(context.getParent().getParent() instanceof GrImportStatement) && + !(context.getParent().getParent() instanceof GrPackageDefinition) && + !(context.getParent().getParent() instanceof GrNewExpression); + } + + static boolean isTypelessParameter(PsiElement context) { + return (context.getParent() instanceof GrParameter && ((GrParameter)context.getParent()).getTypeElementGroovy() == null); + } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/TypeDefinition.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/TypeDefinition.java index 25d76ec43ce2..a0278029fa22 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/TypeDefinition.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/TypeDefinition.java @@ -23,8 +23,8 @@ import org.jetbrains.plugins.groovy.GroovyBundle; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.Separators; -import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.declaration.Declaration; import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.modifiers.Modifiers; +import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.declaration.Declaration; import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members.ClassMember; import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members.EnumConstant; import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members.InterfaceMember; @@ -83,15 +83,14 @@ public class TypeDefinition implements GroovyElementTypes { return false; } - String name; - if (!mIDENT.equals(builder.getTokenType())) { + if (builder.getTokenType() != mIDENT) { builder.error(GroovyBundle.message("identifier.expected")); return false; - } else { - name = builder.getTokenText(); - builder.advanceLexer(); } + String name = builder.getTokenText(); + builder.advanceLexer(); + ParserUtils.getToken(builder, mNLS); TypeParameters.parse(builder); @@ -114,39 +113,38 @@ public class TypeDefinition implements GroovyElementTypes { return false; } - String name; - if (!mIDENT.equals(builder.getTokenType())) { + if (builder.getTokenType() != mIDENT) { builder.error(GroovyBundle.message("identifier.expected")); return false; - } else { - name = builder.getTokenText(); - builder.advanceLexer(); } + String name = builder.getTokenText(); + builder.advanceLexer(); + ParserUtils.getToken(builder, mNLS); TypeParameters.parse(builder); ParserUtils.getToken(builder, mNLS); - if (kEXTENDS.equals(builder.getTokenType())) { + if (builder.getTokenType() == kEXTENDS) { ReferenceElement.parseReferenceList(builder, kEXTENDS, EXTENDS_CLAUSE); ParserUtils.getToken(builder, mNLS); } - if (kIMPLEMENTS.equals(builder.getTokenType())) { + if (builder.getTokenType() == kIMPLEMENTS) { ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE); } ParserUtils.getToken(builder, mNLS); - if (mLCURLY.equals(builder.getTokenType())) { - parseClassBody(builder, name, parser); - } else { + if (builder.getTokenType() != mLCURLY) { builder.error(GroovyBundle.message("lcurly.expected")); return true; } + parseClassBody(builder, name, parser); + return true; } @@ -155,17 +153,21 @@ public class TypeDefinition implements GroovyElementTypes { return false; } - String name; - if (!mIDENT.equals(builder.getTokenType())) { + if (builder.getTokenType() != mIDENT) { builder.error(GroovyBundle.message("identifier.expected")); return false; - } else { - name = builder.getTokenText(); - builder.advanceLexer(); } - if (WRONGWAY.equals(ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE))) { - return true; + String name = builder.getTokenText(); + builder.advanceLexer(); + + if (builder.getTokenType() == kEXTENDS) { + ReferenceElement.parseReferenceList(builder, kEXTENDS, EXTENDS_CLAUSE); + ParserUtils.getToken(builder, mNLS); + } + + if (builder.getTokenType() == kIMPLEMENTS) { + ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE); } Separators.parse(builder); @@ -265,7 +267,7 @@ public class TypeDefinition implements GroovyElementTypes { return true; } - private static boolean parseEnumBlock(PsiBuilder builder, String enumName, GroovyParser parser) { + private static boolean parseEnumBlock(PsiBuilder builder, @Nullable String enumName, GroovyParser parser) { //see also InterfaceBlock, EnumBlock, AnnotationBlock PsiBuilder.Marker ebMarker = builder.mark(); @@ -278,7 +280,8 @@ public class TypeDefinition implements GroovyElementTypes { if (parseEnumConstantStart(builder, parser)) { EnumConstant.parseConstantList(builder, parser); - } else { + } + else { ClassMember.parse(builder, enumName, parser); } @@ -305,7 +308,7 @@ public class TypeDefinition implements GroovyElementTypes { return result; } - private static boolean parseInterfaceBlock(PsiBuilder builder, String interfaceName, GroovyParser parser) { + private static boolean parseInterfaceBlock(PsiBuilder builder, @Nullable String interfaceName, GroovyParser parser) { //see also InterfaceBlock, EnumBlock, AnnotationBlock PsiBuilder.Marker ibMarker = builder.mark(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/InterfaceMember.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/InterfaceMember.java index 05c73bb8cc91..303a93782d3f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/InterfaceMember.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/members/InterfaceMember.java @@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members; import com.intellij.lang.PsiBuilder; +import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.GroovyBundle; import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes; import org.jetbrains.plugins.groovy.lang.parser.GroovyParser; @@ -31,7 +32,7 @@ import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils; * @date: 20.03.2007 */ public class InterfaceMember implements GroovyElementTypes { - public static boolean parse(PsiBuilder builder, String interfaceName, GroovyParser parser) { + public static boolean parse(PsiBuilder builder, @Nullable String interfaceName, GroovyParser parser) { //constructor if (ConstructorDefinition.parse(builder, interfaceName, parser)) return true; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java index c368b4094d36..c7bbec2f1fc6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java @@ -378,25 +378,38 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { } public void visitAssertStatement(GrAssertStatement assertStatement) { + final InstructionImpl assertInstruction = startNode(assertStatement); + final GrExpression assertion = assertStatement.getAssertion(); if (assertion != null) { - myConditions.push(addNodeAndCheckPending(new ConditionInstruction(assertion))); assertion.accept(this); - final InstructionImpl assertInstruction = startNode(assertStatement); + + InstructionImpl positiveHead = myHead; + + List negations = collectAndRemoveAllPendingNegations(assertStatement); + if (!negations.isEmpty()) { + interruptFlow(); + reduceAllNegationsIntoInstruction(assertStatement, negations); + } + GrExpression errorMessage = assertStatement.getErrorMessage(); if (errorMessage != null) { errorMessage.accept(this); } - final PsiType type = TypesUtil.createTypeByFQClassName("java.lang.AssertionError", assertStatement); + addNode(new ThrowingInstruction(assertStatement)); + + final PsiType type = TypesUtil.createTypeByFQClassName(CommonClassNames.JAVA_LANG_ASSERTION_ERROR, assertStatement); ExceptionInfo info = findCatch(type); if (info != null) { - info.myThrowers.add(assertInstruction); + info.myThrowers.add(myHead); } else { - addPendingEdge(null, assertInstruction); + addPendingEdge(null, myHead); } - finishNode(assertInstruction); + + myHead = positiveHead; } + finishNode(assertInstruction); } public void visitThrowStatement(GrThrowStatement throwStatement) { @@ -525,7 +538,9 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor { return instruction; } else if (negations.size() == 1) { - return negations.get(0); + GotoInstruction instruction = negations.get(0); + myHead = instruction; + return instruction; } return null; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java index 08679aef8320..41ae01be0137 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java @@ -73,42 +73,6 @@ public class TypeInferenceHelper { return context != null ? context : InferenceContext.TOP_CONTEXT; } - @Nullable - public static PsiType getInferredTypeOld(@NotNull final GrReferenceExpression refExpr) { - return RecursionManager.doPreventingRecursion(refExpr, true, new NullableComputable() { - @Override - public PsiType compute() { - final GrControlFlowOwner scope = ControlFlowUtils.findControlFlowOwner(refExpr); - if (scope == null) return null; - - final Instruction[] flow = scope.getControlFlow(); - ReadWriteVariableInstruction instruction = ControlFlowUtils.findRWInstruction(refExpr, flow); - if (instruction == null) return null; - - if (instruction.isWrite()) { - return getInitializerType(refExpr); - } - - final DFAType type = getInferredType(refExpr.getReferenceName(), instruction, flow, scope, new HashSet()); - return type == null ? null : type.getResultType(); - } - }); - } - - @Nullable - public static PsiType getInferredTypeOld(@NotNull PsiElement place, String variableName) { - final GrControlFlowOwner scope = ControlFlowUtils.findControlFlowOwner(place); - if (scope == null) return null; - - final Instruction[] flow = scope.getControlFlow(); - Instruction instruction = ControlFlowUtils.findNearestInstruction(place, flow); - if (instruction == null) return null; - - final DFAType type = getInferredType(variableName, instruction, flow, scope, new HashSet()); - return type != null ? type.getResultType() : null; - } - - @Nullable public static PsiType getInferredType(@NotNull final GrReferenceExpression refExpr) { final GrControlFlowOwner scope = ControlFlowUtils.findControlFlowOwner(refExpr); @@ -144,13 +108,10 @@ public class TypeInferenceHelper { @Nullable private static DFAType getInferredType(@NotNull String varName, @NotNull Instruction instruction, @NotNull Instruction[] flow, @NotNull GrControlFlowOwner scope, Set trace) { final Pair> pair = getDefUseMaps(scope); - - List dfaResult = pair.second; - if (dfaResult == null) return null; + if (pair == null) return null; final int varIndex = pair.first.getVarIndex(varName); - - final DefinitionMap allDefs = dfaResult.get(instruction.num()); + final DefinitionMap allDefs = pair.second.get(instruction.num()); final int[] varDefs = allDefs.getDefinitions(varIndex); if (varDefs == null) return null; @@ -169,6 +130,7 @@ public class TypeInferenceHelper { return result; } + @Nullable private static Pair> getDefUseMaps(final GrControlFlowOwner scope) { return CachedValuesManager.getManager(scope.getProject()).getCachedValue(scope, new CachedValueProvider>>() { @Override @@ -188,8 +150,10 @@ public class TypeInferenceHelper { } } else if (instruction instanceof ArgumentInstruction) { - final int varIndex = getVarIndex(((ArgumentInstruction)instruction).getVariableName()); - m.registerDef(instruction, varIndex); + String variableName = ((ArgumentInstruction)instruction).getVariableName(); + if (variableName != null) { + m.registerDef(instruction, getVarIndex(variableName)); + } } else { super.fun(m, instruction); @@ -199,7 +163,8 @@ public class TypeInferenceHelper { final ReachingDefinitionsSemilattice lattice = new ReachingDefinitionsSemilattice(); final DFAEngine engine = new DFAEngine(flow, dfaInstance, lattice); final List dfaResult = engine.performDFAWithTimeout(); - return Result.create(Pair.create(dfaInstance, dfaResult), PsiModificationTracker.MODIFICATION_COUNT); + Pair> result = dfaResult == null ? null : Pair.create(dfaInstance, dfaResult); + return Result.create(result, PsiModificationTracker.MODIFICATION_COUNT); } }); } @@ -401,7 +366,13 @@ public class TypeInferenceHelper { TypeDfaState cache = varTypes.get().get(instruction.num()); if (!cache.containsVariable(variableName)) { - Set interesting = collectRequiredInstructions(instruction, variableName); + Pair> defUse = getDefUseMaps(scope); + if (defUse == null) { + tooComplex.add(instruction); + return null; + } + + Set interesting = collectRequiredInstructions(instruction, variableName, defUse); List dfaResult = performTypeDfa(scope, flow, interesting); if (dfaResult == null) { tooComplex.addAll(interesting); @@ -426,9 +397,9 @@ public class TypeInferenceHelper { return dfaType == null ? null : dfaType.negate(instruction); } - private Set collectRequiredInstructions(Instruction instruction, String variableName) { - Pair> defUse = getDefUseMaps(scope); - + private Set collectRequiredInstructions(@NotNull Instruction instruction, + @NotNull String variableName, + @NotNull Pair> defUse) { Set interesting = ContainerUtil.newHashSet(instruction); LinkedList> queue = ContainerUtil.newLinkedList(); queue.add(Pair.create(instruction, variableName)); @@ -445,22 +416,26 @@ public class TypeInferenceHelper { } private Set> findDependencies(Pair> defUse, - Instruction insn, - String varName) { - int[] definitions = defUse.second.get(insn.num()).getDefinitions(defUse.first.getVarIndex(varName)); + @NotNull Instruction insn, + @NotNull String varName) { + DefinitionMap definitionMap = defUse.second.get(insn.num()); + int varIndex = defUse.first.getVarIndex(varName); + int[] definitions = definitionMap.getDefinitions(varIndex); if (definitions == null) return Collections.emptySet(); - HashSet> pairs = ContainerUtil.newHashSet(); + LinkedHashSet> pairs = ContainerUtil.newLinkedHashSet(); for (int defIndex : definitions) { Instruction write = flow[defIndex]; pairs.add(Pair.create(write, varName)); PsiElement statement = findDependencyScope(write.getElement()); - pairs.addAll(findAllInstructionsInside(statement)); + if (statement != null) { + pairs.addAll(findAllInstructionsInside(statement)); + } } return pairs; } - private List> findAllInstructionsInside(PsiElement scope) { + private List> findAllInstructionsInside(@NotNull PsiElement scope) { final List> result = ContainerUtil.newArrayList(); scope.accept(new PsiRecursiveElementWalkingVisitor() { @Override @@ -480,7 +455,7 @@ public class TypeInferenceHelper { } @Nullable - private static PsiElement findDependencyScope(PsiElement element) { + private static PsiElement findDependencyScope(@Nullable PsiElement element) { return PsiTreeUtil.findFirstParent(element, new Condition() { @Override public boolean value(PsiElement element) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java index 6c8598abeaf0..1b974232bda8 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java @@ -405,7 +405,7 @@ public class TypesUtil { return type; } - public static PsiType boxPrimitiveType(PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope, boolean boxVoid) { + public static PsiType boxPrimitiveType(@Nullable PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope, boolean boxVoid) { if (result instanceof PsiPrimitiveType && (boxVoid || result != PsiType.VOID)) { PsiPrimitiveType primitive = (PsiPrimitiveType)result; String boxedTypeName = primitive.getBoxedTypeName(); @@ -417,7 +417,7 @@ public class TypesUtil { return result; } - public static PsiType boxPrimitiveType(PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope) { + public static PsiType boxPrimitiveType(@Nullable PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope) { return boxPrimitiveType(result, manager, resolveScope, false); } @NotNull diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumConstantInitializerImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumConstantInitializerImpl.java index 157572e407b8..906565d03019 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumConstantInitializerImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrEnumConstantInitializerImpl.java @@ -34,8 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub; * @author Maxim.Medvedev */ public class GrEnumConstantInitializerImpl extends GrAnonymousClassDefinitionImpl implements GrEnumConstantInitializer { - private static final Logger LOG = - Logger.getInstance("#org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.GrEnumConstantInitializerImpl"); + private static final Logger LOG = Logger.getInstance(GrEnumConstantInitializerImpl.class); public GrEnumConstantInitializerImpl(@NotNull ASTNode node) { super(node); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java index 51a6a03d3452..c889a77a13e7 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java @@ -39,6 +39,7 @@ import org.jetbrains.plugins.groovy.GroovyFileType; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConstantInitializer; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody; @@ -391,12 +392,16 @@ public class GrClassImplUtil { public static boolean isSameDeclaration(PsiElement place, PsiElement element) { if (element instanceof GrAccessorMethod) element = ((GrAccessorMethod)element).getProperty(); + if (!(element instanceof GrField)) return false; if (element instanceof GrScriptField) element = ((GrScriptField)element).getOriginalVariable(); + if (element == null) return false; + while (place != null) { if (place == element) return true; place = place.getParent(); if (place instanceof GrClosableBlock) return false; + if (place instanceof GrEnumConstantInitializer) return false; } return false; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java index 7af121dece2c..b83555bf9b3f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java @@ -201,7 +201,7 @@ public abstract class GroovyRefactoringUtil { } - public static void highlightOccurrences(Project project, Editor editor, PsiElement[] elements) { + public static void highlightOccurrences(Project project, @Nullable Editor editor, PsiElement[] elements) { if (editor == null) return; ArrayList highlighters = new ArrayList(); HighlightManager highlightManager = HighlightManager.getInstance(project); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GrVariableInliner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GrVariableInliner.java index 9cab0479bdd8..91d423edc5d5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GrVariableInliner.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GrVariableInliner.java @@ -28,6 +28,7 @@ import com.intellij.psi.util.PsiFormatUtilBase; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.usageView.UsageInfo; import com.intellij.util.containers.MultiMap; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; @@ -62,7 +63,7 @@ public class GrVariableInliner implements InlineHandler.Inliner { } @Nullable - public MultiMap getConflicts(PsiReference reference, PsiElement referenced) { + public MultiMap getConflicts(@NotNull PsiReference reference, @NotNull PsiElement referenced) { MultiMap conflicts = new MultiMap(); GrExpression expr = (GrExpression)reference.getElement(); if (expr.getParent() instanceof GrAssignmentExpression) { @@ -86,7 +87,7 @@ public class GrVariableInliner implements InlineHandler.Inliner { return conflicts; } - public void inlineUsage(final UsageInfo usage, final PsiElement referenced) { + public void inlineUsage(@NotNull final UsageInfo usage, @NotNull final PsiElement referenced) { inlineReference(usage, referenced, myTempExpr); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineHandler.java index 66d5df0d2d40..a1282a069328 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineHandler.java @@ -23,6 +23,7 @@ import com.intellij.psi.PsiMember; import com.intellij.refactoring.HelpID; import com.intellij.refactoring.util.CommonRefactoringUtil; import com.intellij.usageView.UsageViewUtil; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitution; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField; @@ -38,7 +39,7 @@ import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle; public class GroovyInlineHandler implements InlineHandler { @Nullable - public Settings prepareInlineElement(final PsiElement element, Editor editor, boolean invokedOnReference) { + public Settings prepareInlineElement(@NotNull final PsiElement element, @Nullable Editor editor, boolean invokedOnReference) { if (element instanceof GrField) { return GrInlineFieldUtil.inlineFieldSettings((GrField)element, editor, invokedOnReference); } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy index 8b6a02a96ac3..3bb489d4fa9b 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy @@ -35,7 +35,7 @@ public class GroovyCompletionTest extends GroovyCompletionTestBase { @Override protected void setUp() { super.setUp() - CamelHumpMatcher.forceStartMatching(getTestRootDisposable()); + CamelHumpMatcher.forceStartMatching(testRootDisposable); } @Override @@ -135,27 +135,27 @@ public class GroovyCompletionTest extends GroovyCompletionTestBase { public void testFieldSuggestedOnce1() { myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy"); - assertNull(myFixture.getLookupElements()); + assertNull(myFixture.lookupElements); } public void testFieldSuggestedOnce2() { myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy"); - assertNull(myFixture.getLookupElements()); + assertNull(myFixture.lookupElements); } public void testFieldSuggestedOnce3() { myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy"); - assertNull(myFixture.getLookupElements()); + assertNull(myFixture.lookupElements); } public void testFieldSuggestedOnce4() { myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy"); - assertNull(myFixture.getLookupElements()); + assertNull(myFixture.lookupElements); } public void testFieldSuggestedOnce5() { myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy"); - assertNull(myFixture.getLookupElements()); + assertNull(myFixture.lookupElements); } public void testFieldSuggestedInMethodCall() { @@ -300,7 +300,7 @@ public class GroovyCompletionTest extends GroovyCompletionTestBase { } public void testCompletionNamedArgumentWithoutSpace() { - def settings = CodeStyleSettingsManager.getSettings(getProject()).getCustomSettings(GroovyCodeStyleSettings.class) + def settings = CodeStyleSettingsManager.getSettings(project).getCustomSettings(GroovyCodeStyleSettings.class) settings.SPACE_IN_NAMED_ARGUMENT = false try { @@ -937,12 +937,12 @@ class Fopppp { public void testExcludeStringBuffer() { assert doContainsTest('StringBuffer', 'StringBufff') - CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = [StringBuffer.name] as String[] + CodeInsightSettings.instance.EXCLUDED_PACKAGES = [StringBuffer.name] as String[] try { assert !doContainsTest('StringBuffer', 'StringBufff') } finally { - CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = new String[0] + CodeInsightSettings.instance.EXCLUDED_PACKAGES = new String[0] } } @@ -1022,10 +1022,6 @@ while(true) { assertEquals 'stryng', myFixture.lookupElementStrings[0] } - private def caseSensitiveNone() { - CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE - } - public void testFieldVsPackage() { myFixture.addFileToProject 'aaa/bbb/Foo.groovy', 'package aaa.bbb; class Foo{}' def file = myFixture.addFileToProject('aaa/bar.groovy', ''' @@ -1340,7 +1336,7 @@ def map = [1:2] print map.metc '''); myFixture.complete(CompletionType.BASIC); - assertEmpty myFixture.getLookupElements() + assertEmpty myFixture.lookupElements } void testAnnotationCompletion0() { @@ -1572,4 +1568,8 @@ setBarrr() void testParenthesesAfterDot() { myFixture.testCompletionTyping(getTestName(false) + '.groovy', '\t', getTestName(false) + '_after.groovy') } + + void testNewExprDoesntCompleteDef() { + doNoVariantsTest('def a = \new ', 'def', 'final') + } } \ No newline at end of file diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy index 3da5c3713b40..8dfd44884b66 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.completion; - +package org.jetbrains.plugins.groovy.completion +import com.intellij.codeInsight.CodeInsightSettings import com.intellij.codeInsight.completion.CompletionType import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase - +import com.intellij.util.containers.ContainerUtil +import org.jetbrains.plugins.groovy.GroovyFileType /** * @author Maxim.Medvedev */ @@ -96,4 +97,17 @@ abstract public class GroovyCompletionTestBase extends LightCodeInsightFixtureTe myFixture.checkResult(after); } + public void doNoVariantsTest(String before, String... excludedVariants) { + myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, before) + myFixture.completeBasic() + final excluded = ContainerUtil.newHashSet(excludedVariants) + for (String lookup : myFixture.lookupElementStrings) { + assertFalse(lookup, excluded.contains(lookup)) + } + } + + protected static def caseSensitiveNone() { + CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE + } + } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy index 6a01df4ac5ce..9d4f8a5eeaea 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy @@ -17,37 +17,37 @@ import org.jetbrains.plugins.groovy.util.TestUtils public class ControlFlowTest extends LightCodeInsightFixtureTestCase { final String basePath = TestUtils.testDataPath + "groovy/controlFlow/" - public void testAssignment() throws Throwable { doTest(); } - public void testClosure1() throws Throwable { doTest(); } - public void testComplexAssign() throws Throwable { doTest(); } - public void testFor1() throws Throwable { doTest(); } - public void testForeach1() throws Throwable { doTest(); } - public void testGrvy1497() throws Throwable { doTest(); } - public void testIf1() throws Throwable { doTest(); } - public void testMultipleAssignment() throws Throwable { doTest(); } - public void testNested() throws Throwable { doTest(); } - public void testReturn() throws Throwable { doTest(); } - public void testSwitch1() throws Throwable { doTest(); } - public void testSwitch2() throws Throwable { doTest(); } - public void testSwitch3() throws Throwable { doTest(); } - public void testSwitch4() throws Throwable { doTest(); } - public void testSwitch5() throws Throwable { doTest(); } - public void testThrow1() throws Throwable { doTest(); } - public void testThrowInCatch() throws Throwable { doTest(); } - public void testTry1() throws Throwable { doTest(); } - public void testTry2() throws Throwable { doTest(); } - public void testTry3() throws Throwable { doTest(); } - public void testTry4() throws Throwable { doTest(); } - public void testTry5() throws Throwable { doTest(); } - public void testTry6() throws Throwable { doTest(); } - public void testTry7() throws Throwable { doTest(); } - public void testTry8() throws Throwable { doTest(); } - public void testTry9() throws Throwable { doTest(); } - public void testTry10() throws Throwable { doTest(); } - public void testWhile1() throws Throwable { doTest(); } - public void testWhile2() throws Throwable { doTest(); } - public void testWhileNonConstant() throws Throwable { doTest(); } - public void testIfInstanceofElse() throws Throwable { doTest(); } + public void testAssignment() { doTest(); } + public void testClosure1() { doTest(); } + public void testComplexAssign() { doTest(); } + public void testFor1() { doTest(); } + public void testForeach1() { doTest(); } + public void testGrvy1497() { doTest(); } + public void testIf1() { doTest(); } + public void testMultipleAssignment() { doTest(); } + public void testNested() { doTest(); } + public void testReturn() { doTest(); } + public void testSwitch1() { doTest(); } + public void testSwitch2() { doTest(); } + public void testSwitch3() { doTest(); } + public void testSwitch4() { doTest(); } + public void testSwitch5() { doTest(); } + public void testThrow1() { doTest(); } + public void testThrowInCatch() { doTest(); } + public void testTry1() { doTest(); } + public void testTry2() { doTest(); } + public void testTry3() { doTest(); } + public void testTry4() { doTest(); } + public void testTry5() { doTest(); } + public void testTry6() { doTest(); } + public void testTry7() { doTest(); } + public void testTry8() { doTest(); } + public void testTry9() { doTest(); } + public void testTry10() { doTest(); } + public void testWhile1() { doTest(); } + public void testWhile2() { doTest(); } + public void testWhileNonConstant() { doTest(); } + public void testIfInstanceofElse() { doTest(); } public void testReturnMapFromClosure() {doTest();} public void testSwitchInTryWithThrows() {doTest();} public void testClosure() {doTest();} @@ -56,6 +56,11 @@ public class ControlFlowTest extends LightCodeInsightFixtureTestCase { public void testOrInReturn() {doTest();} public void testVarInString() {doTest();} public void testMayBeStaticWithCondition() {doTest()} + public void testAssert0() { doTest() } + public void testAssert1() { doTest() } + public void testAssert2() { doTest() } + public void testAssert3() { doTest() } + public void testAssert4() { doTest() } public void doTest() { final List input = TestUtils.readInput(testDataPath + getTestName(true) + ".test"); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java index 692ac02075cf..4de0f885c9f5 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java @@ -120,6 +120,7 @@ public class FormatterTest extends GroovyFormatterTestCase { public void testSpockTable() throws Throwable { doTest(); } public void testSpockTableComments() throws Throwable { doTest(); } + public void testSpockTableWithStringComment() throws Throwable { doTest(); } public void testElseIfs() throws Throwable { getGroovySettings().SPECIAL_ELSE_IF_TREATMENT = false; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy index ca662474daf2..90cecfa9decf 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy @@ -896,6 +896,13 @@ def methodMissing(String methodName, args) { this.metaClass."$methodName" = closure closure() = 2 } +''') + } + + void testEnumExtendsList() { + testHighlighting('''\ +enum Ee extends Enum { +} ''') } } \ No newline at end of file diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy index 6b2ed66ace68..5587971184e6 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy @@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant @@ -47,7 +48,7 @@ public class ResolvePropertyTest extends GroovyResolveTestCase { PsiReference ref = configureByFile("closureOwner/A.groovy"); PsiElement resolved = ref.resolve(); assertInstanceOf(resolved, PsiVariable); - assertEquals(((PsiVariable) resolved).getType().getCanonicalText(), "W"); + assertEquals((resolved as PsiVariable).type.canonicalText, "W"); } public void testLocal1() throws Exception { @@ -117,21 +118,21 @@ public class ResolvePropertyTest extends GroovyResolveTestCase { } public void testField3() throws Exception { - GrReferenceElement ref = (GrReferenceElement) configureByFile("field3/A.groovy").getElement(); + GrReferenceElement ref = (GrReferenceElement)configureByFile("field3/A.groovy").element; GroovyResolveResult resolveResult = ref.advancedResolve(); - assertTrue(resolveResult.getElement() instanceof GrField); - assertFalse(resolveResult.isValidResult()); + assertTrue(resolveResult.element instanceof GrField); + assertFalse(resolveResult.validResult); } public void testToGetter() throws Exception { - GrReferenceElement ref = (GrReferenceElement) configureByFile("toGetter/A.groovy").getElement(); + GrReferenceElement ref = (GrReferenceElement)configureByFile("toGetter/A.groovy").element; PsiElement resolved = ref.resolve(); assertTrue(resolved instanceof GrMethod); assertTrue(PropertyUtil.isSimplePropertyGetter((PsiMethod) resolved)); } public void testToSetter() throws Exception { - GrReferenceElement ref = (GrReferenceElement) configureByFile("toSetter/A.groovy").getElement(); + GrReferenceElement ref = (GrReferenceElement)configureByFile("toSetter/A.groovy").element; PsiElement resolved = ref.resolve(); assertTrue(resolved instanceof GrMethod); assertTrue(PropertyUtil.isSimplePropertySetter((PsiMethod) resolved)); @@ -209,7 +210,7 @@ public class ResolvePropertyTest extends GroovyResolveTestCase { public void testUnderscoredField() throws Exception { PsiReference ref = configureByFile("underscoredField/UnderscoredField.groovy"); final GrField field = assertInstanceOf(ref.resolve(), GrField.class); - assertFalse(ref.isReferenceTo(field.getGetters()[0])); + assertFalse(ref.isReferenceTo(field.getters[0])); assertTrue(ref.isReferenceTo(field)); } @@ -298,7 +299,7 @@ print bar """ def ref = findReference() def target = assertInstanceOf(ref.resolve(), PsiField) - assertEquals target.getName(), "foo" + assertEquals target.name, "foo" } private void doTest(String fileName) throws Exception { @@ -322,7 +323,7 @@ print bar def ref = findReference() def resolved = ref.resolve(); assertNotNull resolved - assert ((PsiMethod) resolved).getName() == "isFoo" + assert ((PsiMethod)resolved).name == "isFoo" } public void testExplicitBooleanProperty() throws Exception { @@ -332,7 +333,7 @@ print bar print new A().foo"""); def ref = findReference() def resolved = ref.resolve(); - assert ((PsiMethod) resolved).getName() == "isFoo" + assert ((PsiMethod)resolved).name == "isFoo" } public void testStaticFieldAndNonStaticGetter() { @@ -353,8 +354,8 @@ print bar }""") def ref = findReference() def resolved = ref.resolve(); - assertInstanceOf resolved, GrField.class - assertTrue resolved.getModifierList().hasExplicitVisibilityModifiers() + assertInstanceOf resolved, GrField + assertTrue ((resolved as GrField).modifierList.hasExplicitVisibilityModifiers()) } public void testPropertyAndFieldDeclarationOutsideClass() { @@ -405,8 +406,8 @@ class Foo extends Bar { print new Foo().foo""") def ref = findReference() def resolved = ref.resolve(); - assertInstanceOf resolved, GrField.class - assertTrue resolved.getModifierList().hasExplicitVisibilityModifiers() + assertInstanceOf resolved, GrField + assertTrue ((resolved as GrField).modifierList.hasExplicitVisibilityModifiers()) } public void testPropertyAndFieldDeclarationWithSuperClass3() { @@ -442,8 +443,8 @@ class Foo extends Bar { print new Foo().foo""") def ref = findReference() def resolved = ref.resolve(); - assertInstanceOf resolved, GrField.class - assertTrue !resolved.getModifierList().hasExplicitVisibilityModifiers() + assertInstanceOf resolved, GrField + assertTrue (!(resolved as GrField).modifierList.hasExplicitVisibilityModifiers()) } public void testReadAccessToStaticallyImportedProperty() { @@ -568,13 +569,13 @@ setFoo(2) public void testFieldAccessInStaticContext() { def ref = configureByFile("fieldAccessInStaticContext/A.groovy") - def resolveResult = ref.advancedResolve() - assertTrue !resolveResult.staticsOK + def resolveResult = (ref as GrReferenceExpression).advancedResolve() + assertFalse resolveResult.staticsOK } public void testFieldAccessInClosureVsStaticContext() { def ref = configureByFile("fieldAccessInClosureVsStaticContext/A.groovy") - def resolveResult = ref.advancedResolve() + def resolveResult = (ref as GrReferenceExpression).advancedResolve() assertTrue resolveResult.staticsOK } @@ -895,4 +896,18 @@ class User { assertInstanceOf(ref.resolve(), GrField) } + + void testResolveEnumConstantInsideItsInitializer() { + def ref = configureByText('''\ +enum MyEnum { + CONST { + void get() { + CONST + } + } + +} +''') + assertNotNull(ref) + } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy index 6b46d50c2a0a..73dd4fdd2dfa 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy @@ -37,111 +37,111 @@ public class TypeInferenceTest extends GroovyResolveTestCase { final String basePath = TestUtils.testDataPath + "resolve/inference/" public void testTryFinallyFlow() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow/A.groovy").getElement(); - final PsiType type = ref.getType(); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow/A.groovy").element; + final PsiType type = ref.type; assertTrue(type instanceof PsiIntersectionType); - final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts(); + final PsiType[] conjuncts = ((PsiIntersectionType)type).conjuncts; assertEquals(conjuncts.length, 2); } public void testTryFinallyFlow1() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow1/A.groovy").getElement(); - final PsiType type = ref.getType(); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow1/A.groovy").element; + final PsiType type = ref.type; assertNotNull(type); assertTrue(type.equalsToText("java.lang.Integer")); } public void testTryFinallyFlow2() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow2/A.groovy").getElement(); - final PsiType type = ref.getType(); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow2/A.groovy").element; + final PsiType type = ref.type; assertNotNull(type); assertTrue(type.equalsToText("java.lang.Integer")); } public void testThrowVariable() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("throwVariable/A.groovy").getElement(); - final PsiType type = ref.getType(); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("throwVariable/A.groovy").element; + final PsiType type = ref.type; assertNotNull(type); - assertEquals("java.lang.Exception", type.getCanonicalText()); + assertEquals("java.lang.Exception", type.canonicalText); } public void testGrvy852() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy852/A.groovy").getElement(); - final PsiType type = ref.getType(); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy852/A.groovy").element; + final PsiType type = ref.type; assertNotNull(type); - assertEquals("java.lang.Object", type.getCanonicalText()); + assertEquals("java.lang.Object", type.canonicalText); } public void testGenericMethod() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericMethod/A.groovy").getElement(); - final PsiType type = ref.getType(); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericMethod/A.groovy").element; + final PsiType type = ref.type; assertNotNull(type); - assertEquals("java.util.List", type.getCanonicalText()); + assertEquals("java.util.List", type.canonicalText); } public void testCircular() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular/A.groovy").getElement(); - assertNull(ref.getType()); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular/A.groovy").element; + assertNull(ref.type); } public void testCircular1() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular1/A.groovy").getElement(); - assertNull(ref.getType()); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular1/A.groovy").element; + assertNull(ref.type); } public void testClosure() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure/A.groovy").getElement(); - assertNotNull(ref.getType()); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure/A.groovy").element; + assertNotNull(ref.type); } public void testClosure1() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure1/A.groovy").getElement(); - assertTrue(ref.getType().equalsToText("java.lang.Integer")); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure1/A.groovy").element; + assertTrue(ref.type.equalsToText("java.lang.Integer")); } public void testClosure2() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure2/A.groovy").getElement(); - assertTrue(ref.getType().equalsToText("java.lang.Integer")); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure2/A.groovy").element; + assertTrue(ref.type.equalsToText("java.lang.Integer")); } public void testGrvy1209() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy1209/A.groovy").getElement(); - assertTrue(ref.getType().equalsToText("java.lang.String")); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy1209/A.groovy").element; + assertTrue(ref.type.equalsToText("java.lang.String")); } public void testLeastUpperBoundClosureType() { - GrReferenceExpression ref = (GrReferenceExpression)configureByFile("leastUpperBoundClosureType/A.groovy").getElement(); - assertInstanceOf(ref.getType(), GrClosureType.class); + GrReferenceExpression ref = (GrReferenceExpression)configureByFile("leastUpperBoundClosureType/A.groovy").element; + assertInstanceOf(ref.type, GrClosureType.class); } public void testJavaLangClassType() { - final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("javaLangClassType/A.groovy").getElement(); - assertEquals("java.lang.String", ref.getType().getCanonicalText()); + final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("javaLangClassType/A.groovy").element; + assertEquals("java.lang.String", ref.type.canonicalText); } public void testGenericWildcard() { - final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericWildcard/A.groovy").getElement(); - assertEquals("A", ref.getType().getCanonicalText()); + final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericWildcard/A.groovy").element; + assertEquals("A", ref.type.canonicalText); } public void testArrayLikeAccessWithIntSequence() { - final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("arrayLikeAccessWithIntSequence/A.groovy").getElement(); - assertEquals("java.util.List", ref.getType().getCanonicalText()); + final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("arrayLikeAccessWithIntSequence/A.groovy").element; + assertEquals("java.util.List", ref.type.canonicalText); } public void testArrayAccess() { final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("arrayAccess/A.groovy"); - assertEquals(JAVA_LANG_STRING, ref.getType().getCanonicalText()); + assertEquals(JAVA_LANG_STRING, ref.type.canonicalText); } public void testReturnTypeByTailExpression() { final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("returnTypeByTailExpression/A.groovy"); - assertEquals(JAVA_LANG_STRING, ref.getType().getCanonicalText()); + assertEquals(JAVA_LANG_STRING, ref.type.canonicalText); } public void testParameterWithBuiltinType() { GrReferenceExpression refExpr = (GrReferenceExpression)configureByFile("parameterWithBuiltinType/A.groovy"); - assertEquals("java.lang.Integer", refExpr.getType().getCanonicalText()); + assertEquals("java.lang.Integer", refExpr.type.canonicalText); } public void testRawTypeInReturnExpression() { @@ -150,15 +150,15 @@ public class TypeInferenceTest extends GroovyResolveTestCase { public void testMethodCallInvokedOnArrayAccess() { final GrReferenceExpression reference = (GrReferenceExpression)configureByFile("A.groovy"); - assertEquals("java.lang.Integer", reference.getType().getCanonicalText()); + assertEquals("java.lang.Integer", reference.type.canonicalText); } private void assertTypeEquals(String expected, String fileName) { final PsiReference ref = configureByFile(getTestName(true) + "/" + fileName); assertInstanceOf(ref, GrReferenceExpression.class); - final PsiType type = ((GrReferenceExpression)ref).getType(); + final PsiType type = ((GrReferenceExpression)ref).type; assertNotNull(type); - assertEquals(expected, type.getCanonicalText()); + assertEquals(expected, type.canonicalText); } public void testTypeOfGroupBy() { @@ -170,7 +170,7 @@ public class TypeInferenceTest extends GroovyResolveTestCase { } public void testImplicitCallMethod() { - assertEquals("java.lang.String", ((GrExpression)configureByFile("A.groovy")).getType().getCanonicalText()); + assertEquals("java.lang.String", ((GrExpression)configureByFile("A.groovy")).type.canonicalText); } public void testTupleWithNullInIt() { @@ -220,7 +220,7 @@ public class TypeInferenceTest extends GroovyResolveTestCase { public void testNoSOF() { final PsiReference ref = configureByFile(getTestName(true) + "/A.groovy"); assertInstanceOf(ref, GrReferenceExpression.class); - final PsiType type = ((GrReferenceExpression)ref).getType(); + final PsiType type = ((GrReferenceExpression)ref).type; assertNull(type); } @@ -568,6 +568,15 @@ def method(List t) { ''', 'Tx') } + void testAssert() { + doTest('''\ +def foo(def var) { + assert var instanceof String + var.isEmpty() +} +''', 'java.lang.String') + } + private void doTest(String text, String type) { def file = myFixture.configureByText('_.groovy', text) def ref = file.findReferenceAt(myFixture.editor.caretModel.offset) as GrReferenceExpression diff --git a/plugins/groovy/testdata/groovy/controlFlow/assert0.test b/plugins/groovy/testdata/groovy/controlFlow/assert0.test new file mode 100644 index 000000000000..d6cd19161c40 --- /dev/null +++ b/plugins/groovy/testdata/groovy/controlFlow/assert0.test @@ -0,0 +1,15 @@ +assert x instanceof String : bar() +return x.isEmpty() +----- +0(1) element: null +1(2) element: ASSERT statement +2(3) READ x +3(4,6) Condition Instanceof expression +4(5) instanceof: x instanceof String +5(7) Negating goto instruction, condition=3Instanceof expression +6(9) instanceof: x instanceof String +7(8) READ bar +8(11) THROW. element: ASSERT statement +9(10) READ x +10(11) element: RETURN statement +11() element: null \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/controlFlow/assert1.test b/plugins/groovy/testdata/groovy/controlFlow/assert1.test new file mode 100644 index 000000000000..f13ca67b81e9 --- /dev/null +++ b/plugins/groovy/testdata/groovy/controlFlow/assert1.test @@ -0,0 +1,26 @@ +try { + assert x instanceof String : bar() +} +catch (java.lang.AssertionError e) { + return true +} + +return x.isEmpty() +----- +0(1) element: null +1(2) element: Open block +2(3) element: ASSERT statement +3(4) READ x +4(5,7) Condition Instanceof expression +5(6) instanceof: x instanceof String +6(8) Negating goto instruction, condition=4Instanceof expression +7(14) instanceof: x instanceof String +8(9) READ bar +9(10,11) THROW. element: Method call +10(11) THROW. element: ASSERT statement +11(12) element: Catch clause +12(13) WRITE e +13(16) element: RETURN statement +14(15) READ x +15(16) element: RETURN statement +16() element: null \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/controlFlow/assert2.test b/plugins/groovy/testdata/groovy/controlFlow/assert2.test new file mode 100644 index 000000000000..7655fe4ad7f5 --- /dev/null +++ b/plugins/groovy/testdata/groovy/controlFlow/assert2.test @@ -0,0 +1,10 @@ +assert cond() : 'abc' +print 2 +----- +0(1) element: null +1(2) element: ASSERT statement +2(3,4) READ cond +3(6) THROW. element: ASSERT statement +4(5) READ print +5(6) element: Call expression MAYBE_RETURN +6() element: null \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/controlFlow/assert3.test b/plugins/groovy/testdata/groovy/controlFlow/assert3.test new file mode 100644 index 000000000000..4ff61f1244af --- /dev/null +++ b/plugins/groovy/testdata/groovy/controlFlow/assert3.test @@ -0,0 +1,9 @@ +assert false +print 2 +----- +0(1) element: null +1(2,3) element: ASSERT statement +2(5) THROW. element: ASSERT statement +3(4) READ print +4(5) element: Call expression MAYBE_RETURN +5() element: null \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/controlFlow/assert4.test b/plugins/groovy/testdata/groovy/controlFlow/assert4.test new file mode 100644 index 000000000000..e43efeeab25f --- /dev/null +++ b/plugins/groovy/testdata/groovy/controlFlow/assert4.test @@ -0,0 +1,9 @@ +assert true +print 2 +----- +0(1) element: null +1(2,3) element: ASSERT statement +2(5) THROW. element: ASSERT statement +3(4) READ print +4(5) element: Call expression MAYBE_RETURN +5() element: null \ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/formatter/spockTableWithStringComment.test b/plugins/groovy/testdata/groovy/formatter/spockTableWithStringComment.test new file mode 100644 index 000000000000..679494ff8b95 --- /dev/null +++ b/plugins/groovy/testdata/groovy/formatter/spockTableWithStringComment.test @@ -0,0 +1,23 @@ +class HelloSpock extends spock.lang.Specification { + def "length of Spock's and his friends' names"() { + expect: + name.size() == length + + where: "something" + name || length + "Kirk" || 4 + "Scotty" || 6 + } +} +----- +class HelloSpock extends spock.lang.Specification { + def "length of Spock's and his friends' names"() { + expect: + name.size() == length + + where: "something" + name || length + "Kirk" || 4 + "Scotty" || 6 + } +} \ No newline at end of file diff --git a/plugins/groovy/testdata/highlighting/UsageInInjection.groovy b/plugins/groovy/testdata/highlighting/UsageInInjection.groovy index 3b0f5436015a..2d222f6d5511 100644 --- a/plugins/groovy/testdata/highlighting/UsageInInjection.groovy +++ b/plugins/groovy/testdata/highlighting/UsageInInjection.groovy @@ -1,18 +1,3 @@ -/* - * 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. - */ def x = new Date() def y = new Date() def z = new Date() diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java index 5b96d11cf327..93b0838e2785 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java @@ -29,6 +29,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.AsynchConsumer; import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.zmlx.hg4idea.*; import org.zmlx.hg4idea.command.HgLogCommand; @@ -151,6 +152,7 @@ public class HgCachingCommitedChangesProvider implements CachingCommittedChanges throw new UnsupportedOperationException(); //TODO implement method } + @NotNull public ChangeBrowserSettings createDefaultSettings() { return new ChangeBrowserSettings(); } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyConsoleFilterProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyConsoleFilterProvider.java deleted file mode 100644 index 443371864f2a..000000000000 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/plugins/groovy/MavenGroovyConsoleFilterProvider.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.idea.maven.plugins.groovy; - -import com.intellij.execution.filters.DefaultConsoleFiltersProvider; -import com.intellij.execution.filters.Filter; -import com.intellij.execution.filters.OpenFileHyperlinkInfo; -import com.intellij.openapi.editor.colors.CodeInsightColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.markup.EffectType; -import com.intellij.openapi.editor.markup.TextAttributes; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.search.GlobalSearchScope; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.awt.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author Sergey Evdokimov - */ -public class MavenGroovyConsoleFilterProvider extends DefaultConsoleFiltersProvider { - - private static final Pattern PATTERN = Pattern.compile("\\[ERROR\\] (\\S.+\\.groovy): (-?\\d{1,5}): .+", Pattern.DOTALL); - - @Override - public Filter[] getDefaultFilters(@NotNull final Project project, @NotNull GlobalSearchScope scope) { - return new Filter[]{ - new Filter() { - @Nullable - @Override - public Result applyFilter(String line, int entireLength) { - - // Example of gmaven error line: - // [ERROR] /home/user/ideaProjects/simpleMaven/src/main/groovy/com/A.groovy: 17: [Static type checking] - Cannot assign value of type java.lang.String to variable of type int - - if (!line.startsWith("[ERROR] ") || !line.contains(".groovy: ")) return null; - - Matcher matcher = PATTERN.matcher(line); - if (!matcher.matches()) return null; - - String path = matcher.group(1); - - VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path); - if (file == null) return null; - - int lineNumber = Integer.parseInt(matcher.group(2)) - 1; - if (lineNumber < 0) { - lineNumber = -1; - } - - TextAttributes attr = createCompilationErrorAttr(); - - return new Result(entireLength - line.length() + matcher.start(1), entireLength - line.length() + matcher.end(2), - new OpenFileHyperlinkInfo(project, file, lineNumber), attr); - } - - private TextAttributes createCompilationErrorAttr() { - TextAttributes attr = - EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES).clone(); - attr.setForegroundColor(Color.RED); - attr.setEffectColor(Color.RED); - attr.setEffectType(EffectType.LINE_UNDERSCORE); - attr.setFontType(Font.PLAIN); - return attr; - } - - } - }; - } - -} diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java index 5a7c50d9bd92..af638f28829c 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenConsoleImpl.java @@ -22,8 +22,11 @@ import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; @@ -31,6 +34,7 @@ import com.intellij.psi.search.GlobalSearchScope; import com.intellij.ui.content.Content; import com.intellij.ui.content.ContentFactory; import com.intellij.ui.content.MessageView; +import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.execution.MavenRunnerParameters; import org.jetbrains.idea.maven.execution.MavenRunnerSettings; import org.jetbrains.idea.maven.utils.MavenUtil; @@ -72,14 +76,35 @@ public class MavenConsoleImpl extends MavenConsole { return createConsoleBuilder(myProject).getConsole(); } - public static TextConsoleBuilder createConsoleBuilder(Project project) { + public static TextConsoleBuilder createConsoleBuilder(final Project project) { TextConsoleBuilder builder = TextConsoleBuilderFactory.getInstance().createBuilder(project); - List filters = ExceptionFilters.getFilters(GlobalSearchScope.allScope(project)); + final List filters = ExceptionFilters.getFilters(GlobalSearchScope.allScope(project)); for (Filter filter : filters) { builder.addFilter(filter); } - builder.addFilter(new RegexpFilter(project, CONSOLE_FILTER_REGEXP)); + builder.addFilter(new RegexpFilter(project, CONSOLE_FILTER_REGEXP) { + @Nullable + @Override + protected HyperlinkInfo createOpenFileHyperlink(String fileName, int line, int column) { + HyperlinkInfo res = super.createOpenFileHyperlink(fileName, line, column); + if (res == null && fileName.startsWith("\\") && SystemInfo.isWindows) { + // Maven cut prefix 'C:\' from paths on Windows + VirtualFile[] roots = ProjectRootManager.getInstance(project).getContentRoots(); + if (roots.length > 0) { + String projectPath = roots[0].getPath(); + if (projectPath.matches("[A-Z]:[\\\\/].+")) { + res = super.createOpenFileHyperlink(projectPath.charAt(0) + ":" + fileName, line, column); + } + } + + } + + return res; + } + }); + + builder.addFilter(new MavenGroovyConsoleFilter(project)); return builder; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGroovyConsoleFilter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGroovyConsoleFilter.java new file mode 100644 index 000000000000..017c888695e7 --- /dev/null +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenGroovyConsoleFilter.java @@ -0,0 +1,89 @@ +/* + * 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.idea.maven.project; + +import com.intellij.execution.filters.Filter; +import com.intellij.execution.filters.OpenFileHyperlinkInfo; +import com.intellij.openapi.editor.colors.CodeInsightColors; +import com.intellij.openapi.editor.colors.EditorColorsManager; +import com.intellij.openapi.editor.markup.EffectType; +import com.intellij.openapi.editor.markup.TextAttributes; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.Nullable; + +import java.awt.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author Sergey Evdokimov + */ +public class MavenGroovyConsoleFilter implements Filter { + + private static final Pattern PATTERN = Pattern.compile("\\[ERROR\\] (\\S.+\\.groovy): (-?\\d{1,5}): .+", Pattern.DOTALL); + + private final Project myProject; + + public MavenGroovyConsoleFilter(Project project) { + myProject = project; + } + + @Nullable + @Override + public Result applyFilter(String line, int entireLength) { + + // Example of gmaven error line: + // [ERROR] /home/user/ideaProjects/simpleMaven/src/main/groovy/com/A.groovy: 17: [Static type checking] - Cannot assign value of type java.lang.String to variable of type int + + if (!line.startsWith("[ERROR] ") || !line.contains(".groovy: ")) return null; + + Matcher matcher = PATTERN.matcher(line); + if (!matcher.matches()) return null; + + String path = matcher.group(1); + + VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path); + if (file == null) { + if (SystemInfo.isWindows && path.matches("/[A-Z]:/.+")) { + file = LocalFileSystem.getInstance().findFileByPath(path.substring(1)); + } + if (file == null) return null; + } + + int lineNumber = Integer.parseInt(matcher.group(2)) - 1; + if (lineNumber < 0) { + lineNumber = -1; + } + + TextAttributes attr = createCompilationErrorAttr(); + + return new Result(entireLength - line.length() + matcher.start(1), entireLength - line.length() + matcher.end(1), + new OpenFileHyperlinkInfo(myProject, file, lineNumber), attr); + } + + private static TextAttributes createCompilationErrorAttr() { + TextAttributes attr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(CodeInsightColors.HYPERLINK_ATTRIBUTES).clone(); + attr.setForegroundColor(Color.RED); + attr.setEffectColor(Color.RED); + attr.setEffectType(EffectType.LINE_UNDERSCORE); + attr.setFontType(Font.PLAIN); + return attr; + } + +} diff --git a/plugins/maven/src/main/resources/META-INF/groovy-support.xml b/plugins/maven/src/main/resources/META-INF/groovy-support.xml index de732f51b9fb..458ff05d910a 100644 --- a/plugins/maven/src/main/resources/META-INF/groovy-support.xml +++ b/plugins/maven/src/main/resources/META-INF/groovy-support.xml @@ -6,6 +6,5 @@ - \ No newline at end of file diff --git a/plugins/properties/src/com/intellij/lang/properties/BundleNameEvaluator.java b/plugins/properties/src/com/intellij/lang/properties/BundleNameEvaluator.java index e593671dc0d1..49877d3b3b04 100644 --- a/plugins/properties/src/com/intellij/lang/properties/BundleNameEvaluator.java +++ b/plugins/properties/src/com/intellij/lang/properties/BundleNameEvaluator.java @@ -32,6 +32,10 @@ public interface BundleNameEvaluator { } final PsiDirectory directory = psiFile.getParent(); + if (directory == null) { + return null; + } + final String packageQualifiedName = PropertiesUtil.getPackageQualifiedName(directory); if (packageQualifiedName != null) { diff --git a/plugins/properties/src/com/intellij/lang/properties/PropertiesUtil.java b/plugins/properties/src/com/intellij/lang/properties/PropertiesUtil.java index 06fc55c43354..ed3995267205 100644 --- a/plugins/properties/src/com/intellij/lang/properties/PropertiesUtil.java +++ b/plugins/properties/src/com/intellij/lang/properties/PropertiesUtil.java @@ -204,7 +204,7 @@ public class PropertiesUtil { } @Nullable - public static String getPackageQualifiedName(PsiDirectory directory) { + public static String getPackageQualifiedName(@NotNull PsiDirectory directory) { return ProjectRootManager.getInstance(directory.getProject()).getFileIndex().getPackageNameByDirectory(directory.getVirtualFile()); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java index 427512f0eb18..7ef0b2f3d0b6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java @@ -100,6 +100,7 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi }); } + @NotNull public ChangeBrowserSettings createDefaultSettings() { return new ChangeBrowserSettings(); } diff --git a/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml b/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml index ca2b538f5ef2..da8173ba69be 100644 --- a/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml +++ b/plugins/ui-designer/ui-designer-new/src/META-INF/plugin.xml @@ -1,6 +1,9 @@ UI Designer (Core) com.intellij.ui-designer-new + + Provides shared functionality for visual editing plugins. + JetBrains messages.DesignerBundle diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java index bc3094354c58..d03bdffa483a 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/InputTool.java @@ -229,6 +229,9 @@ public abstract class InputTool { protected void handleDragInProgress() { } + protected void handlePopup() { + } + protected void handleDoubleClick(int button) { } @@ -275,6 +278,12 @@ public abstract class InputTool { } } + public void mousePopup(MouseEvent event, EditableArea area) throws Exception { + setArea(area); + setEvent(event); + handlePopup(); + } + public void mouseDoubleClick(MouseEvent event, EditableArea area) throws Exception { setArea(area); setEvent(event); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java index c66f50cd188c..65e5913e6f1e 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java @@ -20,7 +20,6 @@ import com.intellij.designer.model.RadComponent; import com.intellij.designer.propertyTable.InplaceContext; import com.intellij.openapi.actionSystem.ActionManager; import com.intellij.openapi.actionSystem.ActionPopupMenu; -import com.intellij.openapi.util.SystemInfo; import org.jetbrains.annotations.Nullable; import java.awt.event.InputEvent; @@ -88,6 +87,14 @@ public class SelectionTool extends InputTool { handleMove(); // hack: update cursor } + @Override + protected void handlePopup() { + ActionManager actionManager = ActionManager.getInstance(); + ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(myArea.getPopupPlace(), myArea.getPopupActions()); + MouseEvent event = (MouseEvent)myInputEvent; + popupMenu.getComponent().show(myArea.getNativeComponent(), event.getX(), event.getY()); + } + @Override protected void handleDoubleClick(int button) { if (button == MouseEvent.BUTTON1 && myToolProvider != null && !myArea.isTree()) { @@ -149,11 +156,6 @@ public class SelectionTool extends InputTool { myTracker.mouseUp(event, area); } super.mouseUp(event, area); - if (event.isPopupTrigger() || (SystemInfo.isMac && event.getButton() == MouseEvent.BUTTON3)) { - ActionManager actionManager = ActionManager.getInstance(); - ActionPopupMenu popupMenu = actionManager.createActionPopupMenu(area.getPopupPlace(), area.getPopupActions()); - popupMenu.getComponent().show(area.getNativeComponent(), event.getX(), event.getY()); - } } @Override @@ -172,6 +174,15 @@ public class SelectionTool extends InputTool { super.mouseDrag(event, area); } + + @Override + public void mousePopup(MouseEvent event, EditableArea area) throws Exception { + if (myTracker != null) { + myTracker.mousePopup(event, area); + } + super.mousePopup(event, area); + } + @Override public void mouseDoubleClick(MouseEvent event, EditableArea area) throws Exception { super.mouseDoubleClick(event, area); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ToolProvider.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ToolProvider.java index 88c054048994..e72dc25b3f05 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ToolProvider.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/ToolProvider.java @@ -61,9 +61,15 @@ public abstract class ToolProvider { switch (event.getID()) { case MouseEvent.MOUSE_PRESSED: myTool.mouseDown(event, area); + if (event.isPopupTrigger()) { + myTool.mousePopup(event, area); + } break; case MouseEvent.MOUSE_RELEASED: myTool.mouseUp(event, area); + if (event.isPopupTrigger()) { + myTool.mousePopup(event, area); + } break; case MouseEvent.MOUSE_ENTERED: myTool.mouseEntered(event, area); @@ -75,6 +81,9 @@ public abstract class ToolProvider { if (event.getClickCount() == 2) { myTool.mouseDoubleClick(event, area); } + if (event.isPopupTrigger()) { + myTool.mousePopup(event, area); + } break; case MouseEvent.MOUSE_MOVED: myTool.mouseMove(event, area); diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltValidator.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltValidator.java index b69fd9979528..f755bbd58482 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltValidator.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/validation/XsltValidator.java @@ -58,12 +58,22 @@ public class XsltValidator { if (templateTag == null) { return; } + final XmlAttribute attribute = tag.getAttribute("name"); + if (attribute == null) { + return; + } + final PsiElement token = XsltSupport.getAttValueToken(attribute); + if (token == null) { + return; + } final SearchScope scope = new LocalSearchScope(templateTag); final Query refs = ReferencesSearch.search(variable, scope, false); if (isUnused(variable, refs)) { final String name = variable.getName(); + assert name != null; + final LocalQuickFix[] fixes; if (variable instanceof XsltParameter) { fixes = new LocalQuickFix[]{ new DeleteUnusedParameterFix(name, (XsltParameter)variable) }; @@ -71,11 +81,6 @@ public class XsltValidator { fixes = new LocalQuickFix[]{ new DeleteUnusedVariableFix(name, variable) }; } - final XmlAttribute attribute = tag.getAttribute("name"); - assert attribute != null; - - final PsiElement token = XsltSupport.getAttValueToken(attribute); - assert token != null; holder.registerProblem(token, ((DeleteUnusedElementBase)fixes[0]).getType() + " '" + name + "' is never used", ProblemHighlightType.LIKE_UNUSED_SYMBOL, fixes); }