diff --git a/.idea/libraries/Ant.xml b/.idea/libraries/Ant.xml index dfdd147fd7bc..4d69c6899db3 100644 --- a/.idea/libraries/Ant.xml +++ b/.idea/libraries/Ant.xml @@ -28,7 +28,6 @@ - diff --git a/.idea/libraries/CGLIB.xml b/.idea/libraries/CGLIB.xml index 061f6f213744..b7e692fa647e 100644 --- a/.idea/libraries/CGLIB.xml +++ b/.idea/libraries/CGLIB.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/DTDParser.xml b/.idea/libraries/DTDParser.xml index dcc82b44e627..c40d012406c8 100644 --- a/.idea/libraries/DTDParser.xml +++ b/.idea/libraries/DTDParser.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/EasyMock.xml b/.idea/libraries/EasyMock.xml index 05648438f07a..cc51a3eea9a6 100644 --- a/.idea/libraries/EasyMock.xml +++ b/.idea/libraries/EasyMock.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Eclipse.xml b/.idea/libraries/Eclipse.xml index 09b7e2c73bd4..7fa7c6724800 100644 --- a/.idea/libraries/Eclipse.xml +++ b/.idea/libraries/Eclipse.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Gant.xml b/.idea/libraries/Gant.xml index ec46297abec3..ccd8bf04bef7 100644 --- a/.idea/libraries/Gant.xml +++ b/.idea/libraries/Gant.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Groovy.xml b/.idea/libraries/Groovy.xml index 82c7bd9c0740..39ef164c7fa7 100644 --- a/.idea/libraries/Groovy.xml +++ b/.idea/libraries/Groovy.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JDOM.xml b/.idea/libraries/JDOM.xml index 17d2e7336796..bce78cc5489e 100644 --- a/.idea/libraries/JDOM.xml +++ b/.idea/libraries/JDOM.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JMock1.xml b/.idea/libraries/JMock1.xml index ca4dac06d5e2..28bec95a2700 100644 --- a/.idea/libraries/JMock1.xml +++ b/.idea/libraries/JMock1.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/JUnit3.xml b/.idea/libraries/JUnit3.xml index c8e5da0d1ec9..c1b662d9bfb0 100644 --- a/.idea/libraries/JUnit3.xml +++ b/.idea/libraries/JUnit3.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/JUnit4.xml b/.idea/libraries/JUnit4.xml index 6e7ba44fb1d0..3293fe32308b 100644 --- a/.idea/libraries/JUnit4.xml +++ b/.idea/libraries/JUnit4.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/JavaHelp.xml b/.idea/libraries/JavaHelp.xml index 458f03548750..a581fbd1d42b 100644 --- a/.idea/libraries/JavaHelp.xml +++ b/.idea/libraries/JavaHelp.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Jaxen.xml b/.idea/libraries/Jaxen.xml index dd17c6df93a6..8c9fa7adb99c 100644 --- a/.idea/libraries/Jaxen.xml +++ b/.idea/libraries/Jaxen.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Log4J.xml b/.idea/libraries/Log4J.xml index 6e3948c15fc9..3179b1470772 100644 --- a/.idea/libraries/Log4J.xml +++ b/.idea/libraries/Log4J.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Mac.xml b/.idea/libraries/Mac.xml index 256d4c9e54a9..a12291d435e5 100644 --- a/.idea/libraries/Mac.xml +++ b/.idea/libraries/Mac.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/Mocks.xml b/.idea/libraries/Mocks.xml index 5a52b9d16391..e4bf218554bf 100644 --- a/.idea/libraries/Mocks.xml +++ b/.idea/libraries/Mocks.xml @@ -12,7 +12,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/NanoXML.xml b/.idea/libraries/NanoXML.xml index b189c1aeccf4..0bb733ed7323 100644 --- a/.idea/libraries/NanoXML.xml +++ b/.idea/libraries/NanoXML.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/OroMatcher.xml b/.idea/libraries/OroMatcher.xml index 11cae893cfea..91713b2ea1e2 100644 --- a/.idea/libraries/OroMatcher.xml +++ b/.idea/libraries/OroMatcher.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/TestNG.xml b/.idea/libraries/TestNG.xml index 5ab2412b1a6e..a5778213fdef 100644 --- a/.idea/libraries/TestNG.xml +++ b/.idea/libraries/TestNG.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Trove4j.xml b/.idea/libraries/Trove4j.xml index ffb447bb506b..3f41197d62e8 100644 --- a/.idea/libraries/Trove4j.xml +++ b/.idea/libraries/Trove4j.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/Velocity.xml b/.idea/libraries/Velocity.xml index 6af932840678..3d7e67090faf 100644 --- a/.idea/libraries/Velocity.xml +++ b/.idea/libraries/Velocity.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/XStream.xml b/.idea/libraries/XStream.xml index 1ae2bba6df3e..d910ea261e1e 100644 --- a/.idea/libraries/XStream.xml +++ b/.idea/libraries/XStream.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/Xerces.xml b/.idea/libraries/Xerces.xml index 70f9b6a585a0..c5dbcdcf4e97 100644 --- a/.idea/libraries/Xerces.xml +++ b/.idea/libraries/Xerces.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/XmlBeans.xml b/.idea/libraries/XmlBeans.xml index 9ba2a85a0698..77058a249a98 100644 --- a/.idea/libraries/XmlBeans.xml +++ b/.idea/libraries/XmlBeans.xml @@ -5,7 +5,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/XmlRPC.xml b/.idea/libraries/XmlRPC.xml index 4dc45f5b4c27..ac9c9a5dbc94 100644 --- a/.idea/libraries/XmlRPC.xml +++ b/.idea/libraries/XmlRPC.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/asm.xml b/.idea/libraries/asm.xml index 449c600c9d8d..183a1bb65b08 100644 --- a/.idea/libraries/asm.xml +++ b/.idea/libraries/asm.xml @@ -4,7 +4,6 @@ - diff --git a/.idea/libraries/commons_codec.xml b/.idea/libraries/commons_codec.xml index 3921ae1a3395..edbee5956ef0 100644 --- a/.idea/libraries/commons_codec.xml +++ b/.idea/libraries/commons_codec.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/commons_collections.xml b/.idea/libraries/commons_collections.xml index 489c3f067ebf..346eec1cf896 100644 --- a/.idea/libraries/commons_collections.xml +++ b/.idea/libraries/commons_collections.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/commons_lang.xml b/.idea/libraries/commons_lang.xml index ba16df792f70..735f56f94f1e 100644 --- a/.idea/libraries/commons_lang.xml +++ b/.idea/libraries/commons_lang.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/commons_net.xml b/.idea/libraries/commons_net.xml index 73d5abb5afc1..a67717822b3e 100644 --- a/.idea/libraries/commons_net.xml +++ b/.idea/libraries/commons_net.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/jcip.xml b/.idea/libraries/jcip.xml index 5109f151a699..1a6bfae9c4c1 100644 --- a/.idea/libraries/jcip.xml +++ b/.idea/libraries/jcip.xml @@ -3,7 +3,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/jgoodies_forms.xml b/.idea/libraries/jgoodies_forms.xml index 0acd33f16bd7..6d2c19a1d4c8 100644 --- a/.idea/libraries/jgoodies_forms.xml +++ b/.idea/libraries/jgoodies_forms.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/jna.xml b/.idea/libraries/jna.xml index 8c0751775e1e..9fbb37eb48fc 100644 --- a/.idea/libraries/jna.xml +++ b/.idea/libraries/jna.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/microba.xml b/.idea/libraries/microba.xml index 893e0dcc7f2a..771a1df5a98f 100644 --- a/.idea/libraries/microba.xml +++ b/.idea/libraries/microba.xml @@ -4,7 +4,5 @@ - - \ No newline at end of file diff --git a/.idea/libraries/picocontainer.xml b/.idea/libraries/picocontainer.xml index 0850ebb24085..e07ed90f94b5 100644 --- a/.idea/libraries/picocontainer.xml +++ b/.idea/libraries/picocontainer.xml @@ -3,7 +3,6 @@ - diff --git a/.idea/libraries/tcServiceMessages.xml b/.idea/libraries/tcServiceMessages.xml index e3cc93f1d751..2117ae66d481 100644 --- a/.idea/libraries/tcServiceMessages.xml +++ b/.idea/libraries/tcServiceMessages.xml @@ -3,7 +3,6 @@ - diff --git a/java/compiler/impl/compiler-impl.iml b/java/compiler/impl/compiler-impl.iml index 4f7473c9ff2a..381f3496886b 100644 --- a/java/compiler/impl/compiler-impl.iml +++ b/java/compiler/impl/compiler-impl.iml @@ -23,8 +23,6 @@ - - diff --git a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java index 3a833f51f11c..b4f6f769e207 100644 --- a/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java +++ b/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java @@ -48,6 +48,7 @@ public abstract class RunConfigurationExtension { public static final ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.runConfigurationExtension"); public static final Key RUN_EXTENSIONS = Key.create("run.extension.elemnts"); public abstract void handleStartProcess(final ModuleBasedConfiguration configuration, final OSProcessHandler handler); + @Nullable public abstract SettingsEditor createEditor(T configuration); public abstract String getEditorTitle(); public abstract String getName(); diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java index 729972d24cdf..64018fe883de 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/AddSupportForFrameworksPanel.java @@ -285,7 +285,7 @@ public class AddSupportForFrameworksPanel implements Disposable { String underlyingFrameworkId = provider.getUnderlyingFrameworkId(); FrameworkSupportNode parentNode = null; if (underlyingFrameworkId != null) { - FrameworkSupportProvider parentProvider = findProvider(underlyingFrameworkId); + FrameworkSupportProvider parentProvider = findProvider(underlyingFrameworkId, myProviders); if (parentProvider == null) { LOG.info("Cannot find id = " + underlyingFrameworkId); return null; @@ -300,8 +300,8 @@ public class AddSupportForFrameworksPanel implements Disposable { } @Nullable - private FrameworkSupportProvider findProvider(@NotNull String id) { - for (FrameworkSupportProvider provider : myProviders) { + private static FrameworkSupportProvider findProvider(@NotNull String id, final List providers) { + for (FrameworkSupportProvider provider : providers) { if (id.equals(provider.getId())) { return provider; } @@ -362,13 +362,7 @@ public class AddSupportForFrameworksPanel implements Disposable { } private void sortFrameworks(final List nodes) { - DFSTBuilder builder = new DFSTBuilder(GraphGenerator.create(CachingSemiGraph.create(new ProvidersGraph(myProviders)))); - if (!builder.isAcyclic()) { - Pair pair = builder.getCircularDependency(); - LOG.error("Circular dependency between providers '" + pair.getFirst().getId() + "' and '" + pair.getSecond().getId() + "' was found."); - } - - final Comparator comparator = builder.comparator(); + final Comparator comparator = getFrameworkSupportProvidersComparator(myProviders); Collections.sort(nodes, new Comparator() { public int compare(final FrameworkSupportNode o1, final FrameworkSupportNode o2) { return comparator.compare(o1.getProvider(), o2.getProvider()); @@ -376,7 +370,19 @@ public class AddSupportForFrameworksPanel implements Disposable { }); } - private class ProvidersGraph implements GraphGenerator.SemiGraph { + public static Comparator getFrameworkSupportProvidersComparator(final List providers) { + DFSTBuilder + builder = new DFSTBuilder(GraphGenerator.create(CachingSemiGraph.create( + new ProvidersGraph(providers)))); + if (!builder.isAcyclic()) { + Pair pair = builder.getCircularDependency(); + LOG.error("Circular dependency between providers '" + pair.getFirst().getId() + "' and '" + pair.getSecond().getId() + "' was found."); + } + + return builder.comparator(); + } + + private static class ProvidersGraph implements GraphGenerator.SemiGraph { private final List myFrameworkSupportProviders; public ProvidersGraph(final List frameworkSupportProviders) { @@ -392,13 +398,13 @@ public class AddSupportForFrameworksPanel implements Disposable { List dependencies = new ArrayList(); String underlyingId = provider.getUnderlyingFrameworkId(); if (underlyingId != null) { - FrameworkSupportProvider underlyingProvider = findProvider(underlyingId); + FrameworkSupportProvider underlyingProvider = findProvider(underlyingId, myFrameworkSupportProviders); if (underlyingProvider != null) { dependencies.add(underlyingProvider); } } for (String id : ids) { - FrameworkSupportProvider dependency = findProvider(id); + FrameworkSupportProvider dependency = findProvider(id, myFrameworkSupportProviders); if (dependency != null) { dependencies.add(dependency); } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java index 14865f42312a..8a831a5077be 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworksTree.java @@ -17,6 +17,8 @@ package com.intellij.ide.util.newProjectWizard; import com.intellij.ui.CheckboxTree; import com.intellij.ui.CheckedTreeNode; +import com.intellij.ui.TreeSpeedSearch; +import com.intellij.util.containers.Convertor; import com.intellij.util.ui.tree.TreeUtil; import javax.swing.*; @@ -63,6 +65,20 @@ public class FrameworksTree extends CheckboxTree { super.processMouseEvent(e); } + @Override + protected void installSpeedSearch() { + new TreeSpeedSearch(this, new Convertor() { + @Override + public String convert(TreePath path) { + final Object node = path.getLastPathComponent(); + if (node instanceof FrameworkSupportNode) { + return ((FrameworkSupportNode)node).getTitle(); + } + return ""; + } + }); + } + public boolean isProcessingMouseEventOnCheckbox() { return myProcessingMouseEventOnCheckbox; } diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java index 26ab9a35bf03..87dd1330a927 100644 --- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java +++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/StepSequence.java @@ -23,6 +23,7 @@ package com.intellij.ide.util.newProjectWizard; import com.intellij.ide.util.projectWizard.ModuleWizardStep; import com.intellij.openapi.module.ModuleType; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -41,7 +42,7 @@ public class StepSequence { myParentSequence = stepSequence; } - public void addCommonStep(ModuleWizardStep step){ + public void addCommonStep(@NotNull ModuleWizardStep step){ myCommonSteps.add(step); } diff --git a/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java b/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java index b2a8c3692d6f..32d08259fbcf 100644 --- a/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java +++ b/java/java-impl/src/com/intellij/ide/actions/CreateClassAction.java @@ -34,7 +34,7 @@ import org.jetbrains.annotations.NotNull; * * @since 5.1 */ -public class CreateClassAction extends CreateTemplateInPackageAction { +public class CreateClassAction extends JavaCreateTemplateInPackageAction { public CreateClassAction() { super(IdeBundle.message("action.create.new.class"), IdeBundle.message("action.create.new.class"), Icons.CLASS_ICON, true); } diff --git a/java/java-impl/src/com/intellij/ide/actions/JavaCreateTemplateInPackageAction.java b/java/java-impl/src/com/intellij/ide/actions/JavaCreateTemplateInPackageAction.java new file mode 100644 index 000000000000..9171a14b36e6 --- /dev/null +++ b/java/java-impl/src/com/intellij/ide/actions/JavaCreateTemplateInPackageAction.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ide.actions; + +import com.intellij.psi.JavaDirectoryService; +import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiElement; +import com.intellij.util.IncorrectOperationException; + +import javax.swing.*; + +public abstract class JavaCreateTemplateInPackageAction extends CreateTemplateInPackageAction { + + protected JavaCreateTemplateInPackageAction(String text, String description, Icon icon, boolean inSourceOnly) { + super(text, description, icon, inSourceOnly); + } + + @Override + protected boolean checkPackageExists(PsiDirectory directory) { + return JavaDirectoryService.getInstance().getPackage(directory) != null; + } + + protected void doCheckCreate(PsiDirectory dir, String className, String templateName) throws IncorrectOperationException { + JavaDirectoryService.getInstance().checkCreateClass(dir, className); + } + +} diff --git a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java index d203f7aa8d85..ec37e90cb4e1 100644 --- a/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java +++ b/java/java-impl/src/com/intellij/javadoc/JavadocConfiguration.java @@ -29,8 +29,10 @@ import com.intellij.execution.process.ProcessEvent; import com.intellij.execution.process.ProcessTerminatedListener; import com.intellij.execution.runners.ExecutionEnvironment; import com.intellij.ide.BrowserUtil; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.projectRoots.JavaSdk; import com.intellij.openapi.projectRoots.JavaSdkType; @@ -38,6 +40,7 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.projectRoots.ex.PathUtilEx; import com.intellij.openapi.roots.*; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.util.PathUtil; @@ -49,8 +52,12 @@ import org.jetbrains.annotations.NotNull; import javax.swing.*; import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; +import java.util.regex.Pattern; /** * @author Eugene Zhuravlev @@ -75,6 +82,7 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl private final Project myProject; private AnalysisScope myGenerationScope; + private static final Logger LOGGER = Logger.getInstance("#" + JavadocConfiguration.class.getName()); public void setGenerationScope(AnalysisScope generationScope) { myGenerationScope = generationScope; @@ -236,22 +244,42 @@ public class JavadocConfiguration implements ModuleRunProfile, JDOMExternalizabl parameters.add(classPathString); } - parameters.add("-sourcepath"); - parameters.add(OrderEnumerator.orderEntries(myProject).withoutSdk().withoutLibraries().getSourcePathsList().getPathsString()); - if (OUTPUT_DIRECTORY != null) { parameters.add("-d"); parameters.add(OUTPUT_DIRECTORY.replace('/', File.separatorChar)); } - final Collection packages = new HashSet(); - final Collection sources = new HashSet(); - myGenerationOptions.accept(new MyContentIterator(myProject, packages, sources)); - if (packages.size() + sources.size() == 0) { - throw new CantRunException(JavadocBundle.message("javadoc.generate.no.classes.in.selected.packages.error")); + try { + File sourcepathTempFile = File.createTempFile("javadoc", "args.txt"); + sourcepathTempFile.deleteOnExit(); + parameters.add("@" + sourcepathTempFile.getCanonicalPath()); + final PrintWriter writer = new PrintWriter(new FileWriter(sourcepathTempFile)); + try { + writer.println("-sourcepath"); + writer.println(OrderEnumerator.orderEntries(myProject).withoutSdk().withoutLibraries().getSourcePathsList().getPathsString()); + final Collection packages = new HashSet(); + final Collection sources = new HashSet(); + final Runnable findRunnable = new Runnable() { + public void run() { + myGenerationOptions.accept(new MyContentIterator(myProject, packages, sources)); + } + }; + if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(findRunnable, "Search for sources to generate javadoc in...", false, myProject)) { + return; + } + if (packages.size() + sources.size() == 0) { + throw new CantRunException(JavadocBundle.message("javadoc.generate.no.classes.in.selected.packages.error")); + } + writer.println(StringUtil.join(packages, " ")); + writer.println(StringUtil.join(sources, " ")); + } + finally { + writer.close(); + } + } + catch (IOException e) { + LOGGER.error(e); } - parameters.addAll(new ArrayList(packages)); - parameters.addAll(new ArrayList(sources)); } protected OSProcessHandler startProcess() throws ExecutionException { diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java index 67abae3ba884..a674ea013098 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/PsiResolveHelperImpl.java @@ -185,6 +185,9 @@ public class PsiResolveHelperImpl implements PsiResolveHelper { if (wildcardToCapture != null) { if (lowerBound != PsiType.NULL) { if (!wildcardToCapture.isAssignableFrom(lowerBound)) return getFailedInferenceConstraint(typeParameter); + if (wildcardToCapture.isSuper()) { + return new Pair(wildcardToCapture, ConstraintType.SUPERTYPE); + } lowerBound = GenericsUtil.getLeastUpperBound(lowerBound, wildcardToCapture, typeParameter.getManager()); } else { diff --git a/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java b/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java index b615d96b6693..08719452aab8 100644 --- a/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java +++ b/java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java @@ -48,7 +48,11 @@ public class OptimizeImportsRefactoringHelper implements RefactoringHelper javaFiles) { - PsiDocumentManager.getInstance(project).commitAllDocuments(); + ApplicationManager.getApplication().runWriteAction(new Runnable() { + public void run() { + PsiDocumentManager.getInstance(project).commitAllDocuments(); + } + }); final Set> redundants = new HashSet>(); final Runnable findRedundantImports = new Runnable() { public void run() { diff --git a/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties b/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties index 178a50c038f1..f01ed4fc2c82 100644 --- a/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties +++ b/java/java-impl/src/com/intellij/refactoring/RefactorJBundle.properties @@ -190,7 +190,7 @@ the.refactoring.is.not.supported.on.non.static.inner.classes=The refactoring is the.selected.class.has.no.members.to.extract=The selected class has no members to extract. references.to.extract=References to extract extracting.from.class=Extracting from class: -extracted.class.command.name=Extracted class {0} +extracted.class.command.name=Extracted delegate {0} method.to.extract.parameters.from.label=Method to extract parameters from: name.for.new.parameter.label=Name for new parameter: method.selected.has.no.parameters=Method selected has no parameters. diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java index 9901f3a6dbd2..2122580a4488 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java +++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodDialog.java @@ -229,6 +229,11 @@ public class ExtractMethodDialog extends AbstractExtractDialog { if (canBeVarargs) { myCbMakeVarargs = new NonFocusableCheckBox(RefactoringBundle.message("declare.varargs.checkbox")); updateVarargsEnabled(); + myCbMakeVarargs.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + updateSignature(); + } + }); myCbMakeVarargs.setSelected(false); panel.add(myCbMakeVarargs); } diff --git a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java index 574899db05d0..a0df14bbc042 100644 --- a/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/extractclass/ExtractClassHandler.java @@ -31,10 +31,6 @@ import org.jetbrains.annotations.NotNull; public class ExtractClassHandler implements RefactoringActionHandler { - protected static String getRefactoringName() { - return RefactorJBundle.message("extract.class"); - } - protected static String getHelpID() { return HelpID.ExtractClass; } diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java index 967b5054fd2d..69f89f7678b0 100644 --- a/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java +++ b/java/java-impl/src/com/intellij/refactoring/introduceField/IntroduceFieldHandler.java @@ -65,9 +65,13 @@ public class IntroduceFieldHandler extends BaseExpressionToFieldHandler { protected Settings showRefactoringDialog(Project project, Editor editor, PsiClass parentClass, PsiExpression expr, PsiType type, PsiExpression[] occurences, PsiElement anchorElement, PsiElement anchorElementIfAll) { - final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expr, PsiMethod.class); - PsiElement element = expr.getUserData(ElementToWorkOn.PARENT); - if (element == null) element = expr; + final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expr != null ? expr : anchorElement, PsiMethod.class); + PsiElement element = null; + if (expr != null) { + element = expr.getUserData(ElementToWorkOn.PARENT); + if (element == null) element = expr; + } + if (element == null) element = anchorElement; final PsiModifierListOwner staticParentElement = PsiUtil.getEnclosingStaticElement(element, parentClass); boolean declareStatic = staticParentElement != null; 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 d2252ddb0632..e9c123c3d693 100644 --- a/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/invertBoolean/InvertBooleanProcessor.java @@ -233,7 +233,9 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor { ((PsiPrefixExpression)expression.getParent()).getOperationSign().getTokenType() == JavaTokenType.EXCL) { expression = (PsiExpression)expression.getParent(); } - expression.replace(CodeInsightServicesUtil.invertCondition(expression)); + if (!(expression.getParent() instanceof PsiExpressionStatement)) { + expression.replace(CodeInsightServicesUtil.invertCondition(expression)); + } } catch (IncorrectOperationException e) { LOG.error(e); diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java index 59df4a4a9f39..fd26092d74cb 100644 --- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java +++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpConflictsUtil.java @@ -63,9 +63,9 @@ public class PullUpConflictsUtil { } public static MultiMap checkConflicts(final MemberInfo[] infos, - PsiClass subclass, + final PsiClass subclass, @Nullable PsiClass superClass, - PsiPackage targetPackage, + final PsiPackage targetPackage, PsiDirectory targetDirectory, final InterfaceContainmentVerifier interfaceContainmentVerifier, boolean movedMembers2Super) { @@ -143,6 +143,39 @@ public class PullUpConflictsUtil { } RefactoringConflictsUtil.analyzeModuleConflicts(subclass.getProject(), checkModuleConflictsList, new UsageInfo[0], targetRepresentativeElement, conflicts); + for (final PsiMethod abstractMethod : abstractMethods) { + final boolean toDifferentPackage = + !Comparing.strEqual(targetPackage.getQualifiedName(), StringUtil.getPackageName(subclass.getQualifiedName())); + abstractMethod.accept(new ClassMemberReferencesVisitor(subclass) { + @Override + protected void visitClassMemberReferenceElement(PsiMember classMember, PsiJavaCodeReferenceElement classMemberReference) { + if (classMember != null && willBeMoved(classMember, movedMembers)) { + boolean isAccessible = false; + if (classMember.hasModifierProperty(PsiModifier.PRIVATE)) { + isAccessible = true; + } + else if (classMember.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) && + toDifferentPackage) { + isAccessible = true; + } + if (isAccessible) { + String message = RefactoringUIUtil.getDescription(abstractMethod, false) + + " uses " + + RefactoringUIUtil.getDescription(classMember, true) + + " which won't be accessible from the subclass."; + message = CommonRefactoringUtil.capitalize(message); + conflicts.putValue(classMember, message); + } + } + } + }); + if (abstractMethod.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) && toDifferentPackage) { + String message = "Can't make " + RefactoringUIUtil.getDescription(abstractMethod, false) + + " abstract as it won't be accessible from the subclass."; + message = CommonRefactoringUtil.capitalize(message); + conflicts.putValue(abstractMethod, message); + } + } return conflicts; } diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java index 6ddce912fa95..bc6d43828c3b 100644 --- a/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java +++ b/java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java @@ -156,19 +156,21 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor { protected void performRefactoring(final UsageInfo[] usages) { try { // correct references to moved members from the outside - LanguageExtension extension=new LanguageExtension("com.intellij.refactoring.moveMemberHandler"); PsiClass targetClass = JavaPsiFacade.getInstance(myProject) .findClass(myOptions.getTargetClassName(), GlobalSearchScope.projectScope(myProject)); if (targetClass == null) return; final Map anchors = new HashMap(); for (PsiMember member : myMembersToMove) { - anchors.put(member, extension.forLanguage(member.getLanguage()).getAnchor(member, targetClass)); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage()); + if (handler != null) { + anchors.put(member, handler.getAnchor(member, targetClass)); + } } ArrayList otherUsages = new ArrayList(); for (UsageInfo usageInfo : usages) { MoveMembersUsageInfo usage = (MoveMembersUsageInfo)usageInfo; if (!usage.reference.isValid()) continue; - final MoveMemberHandler handler = extension.forLanguage(usageInfo.getElement().getLanguage()); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(usageInfo.getElement().getLanguage()); if (handler!=null) { if (handler.changeExternalUsage(myOptions, usage)) continue; } @@ -189,13 +191,15 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor { } } final RefactoringElementListener elementListener = getTransaction().getElementListener(member); - final MoveMemberHandler handler = extension.forLanguage(member.getLanguage()); - PsiMember newMember=handler.doMove(myOptions, member, anchors.get(member), targetClass); - elementListener.elementMoved(newMember); + final MoveMemberHandler handler = MoveMemberHandler.EP_NAME.forLanguage(member.getLanguage()); + if (handler != null) { + PsiMember newMember=handler.doMove(myOptions, member, anchors.get(member), targetClass); + elementListener.elementMoved(newMember); - fixModifierList(newMember, usages); - for (PsiReference reference : refsToBeRebind) { - reference.bindToElement(newMember); + fixModifierList(newMember, usages); + for (PsiReference reference : refsToBeRebind) { + reference.bindToElement(newMember); + } } } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java new file mode 100644 index 000000000000..d68f90786e9b --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InferenceWithSuperBounds.java @@ -0,0 +1,16 @@ +public class ExampleProblem { + void asserting(T t, Simple l){ + } + + Simple comp(K k){ + return null; + } + + public void main(String[] args) { + asserting(0, comp(0)); + } +} + +class Simple{ + +} diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/a/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/a/Test.java new file mode 100644 index 000000000000..1de09028ad92 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/a/Test.java @@ -0,0 +1,5 @@ +package a; + +public abstract class Test { + abstract void x(); +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/E.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/E.java new file mode 100644 index 000000000000..e6e4b670d00a --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/E.java @@ -0,0 +1,2 @@ +package b; +class E{} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/TestSubclass.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/TestSubclass.java new file mode 100644 index 000000000000..ac7700e1dfa2 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/after/b/TestSubclass.java @@ -0,0 +1,8 @@ +package b; + +import a.Test; + +public class TestSubclass extends Test { + @java.lang.Override void x() { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/a/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/a/Test.java new file mode 100644 index 000000000000..5fe720246445 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/a/Test.java @@ -0,0 +1,5 @@ +package a; +public class Test { + void x() { + } +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/b/E.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/b/E.java new file mode 100644 index 000000000000..e6e4b670d00a --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictAbstractPackageLocalMethod/before/b/E.java @@ -0,0 +1,2 @@ +package b; +class E{} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/Test.java new file mode 100644 index 000000000000..c19d63941b3b --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/Test.java @@ -0,0 +1,5 @@ +public abstract class Test { + abstract void x(); + + private void xx(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/TestSubclass.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/TestSubclass.java new file mode 100644 index 000000000000..54bd69ab2a95 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/after/TestSubclass.java @@ -0,0 +1,7 @@ +public class TestSubclass extends Test { + @java.lang.Override + void x() { + xx(); + } + +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/before/Test.java b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/before/Test.java new file mode 100644 index 000000000000..0196b2c91f82 --- /dev/null +++ b/java/java-tests/testData/refactoring/extractSuperClass/conflictMoveAbstractWithPrivateMethod/before/Test.java @@ -0,0 +1,7 @@ +public class Test { + void x() { + xx(); + } + + private void xx(){} +} \ No newline at end of file diff --git a/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue.java b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue.java new file mode 100644 index 000000000000..162ec480abe0 --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue.java @@ -0,0 +1,9 @@ +class C { + boolean foo() { + return false; + } + + void bar() { + foo(); + } +} diff --git a/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue_after.java b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue_after.java new file mode 100644 index 000000000000..4741aeb6c41c --- /dev/null +++ b/java/java-tests/testData/refactoring/invertBoolean/unusedReturnValue_after.java @@ -0,0 +1,9 @@ +class C { + boolean fooInverted() { + return true; + } + + void bar() { + fooInverted(); + } +} 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 d6b425be2701..a68ee6bf6d3f 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java @@ -49,6 +49,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase { public void testExplicitMethodParameters() throws Exception { doTest(false); } public void testExplicitMethodParameters1() throws Exception { doTest(false); } public void testInferenceWithBounds() throws Exception {doTest(false);} + public void testInferenceWithSuperBounds() throws Exception {doTest(false);} public void testVariance() throws Exception {doTest(false);} public void testForeachTypes() throws Exception {doTest(false);} public void testRawOverridingMethods() throws Exception {doTest(false);} diff --git a/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java b/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java index eb63696cd21a..9b843125a545 100644 --- a/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java +++ b/java/java-tests/testSrc/com/intellij/ide/util/frameworkSupport/FrameworkSupportProviderTestCase.java @@ -4,6 +4,7 @@ import com.intellij.facet.Facet; import com.intellij.facet.FacetManager; import com.intellij.facet.FacetTypeId; import com.intellij.facet.ui.FacetBasedFrameworkSupportProvider; +import com.intellij.ide.util.newProjectWizard.AddSupportForFrameworksPanel; import com.intellij.ide.util.newProjectWizard.FrameworkSupportNode; import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportCommunicator; import com.intellij.ide.util.newProjectWizard.impl.FrameworkSupportModelImpl; @@ -31,7 +32,9 @@ public abstract class FrameworkSupportProviderTestCase extends IdeaTestCase { super.setUp(); myFrameworkSupportModel = new FrameworkSupportModelImpl(getProject(), null); myNodes = new HashMap(); - for (FrameworkSupportProvider provider : FrameworkSupportProvider.EXTENSION_POINT.getExtensions()) { + final FrameworkSupportProvider[] providers = FrameworkSupportProvider.EXTENSION_POINT.getExtensions().clone(); + Arrays.sort(providers, AddSupportForFrameworksPanel.getFrameworkSupportProvidersComparator(new ArrayList(Arrays.asList(providers)))); + for (FrameworkSupportProvider provider : providers) { final FrameworkSupportNode node = new FrameworkSupportNode(provider, null, myFrameworkSupportModel, null, getTestRootDisposable()); myNodes.put(provider, node); myFrameworkSupportModel.registerComponent(provider, node); diff --git a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java index b49809edf0af..e55123aa576a 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/ExtractSuperClassTest.java @@ -47,6 +47,20 @@ public class ExtractSuperClassTest extends CodeInsightTestCase { new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class)); } + public void testConflictMoveAbstractWithPrivateMethod() throws Exception { + doTest("Test", "TestSubclass", + new String[] {"Method x() uses method Test.xx() which won't be accessible from the subclass."}, + new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class, true), + new RefactoringTestUtil.MemberDescriptor("xx", PsiMethod.class)); + } + + public void testConflictAbstractPackageLocalMethod() throws Exception { + doTest("a.Test", "TestSubclass", + new String[] {"Can't make method x() abstract as it won't be accessible from the subclass."}, + "b", + new RefactoringTestUtil.MemberDescriptor("x", PsiMethod.class, true)); + } + public void testConflictUsingPackageLocalMethod() throws Exception { doTest("a.Test", "TestSubclass", new String[] {"method Sup.foo() won't be accessible"}, diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java index 8a35526861a7..90591310658e 100644 --- a/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java +++ b/java/java-tests/testSrc/com/intellij/refactoring/InvertBooleanTest.java @@ -25,6 +25,7 @@ public class InvertBooleanTest extends LightCodeInsightTestCase { public void testParameter() throws Exception { doTest(); } //inverting boolean parameter public void testParameter1() throws Exception { doTest(); } //inverting boolean parameter more advanced stuff + public void testUnusedReturnValue() throws Exception { doTest(); } private void doTest() throws Exception { configureByFile(TEST_ROOT + getTestName(true) + ".java"); diff --git a/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java b/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java index b52b91b3b495..a8b32cbc3614 100644 --- a/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/ModuleRootsExternalizationTest.java @@ -159,13 +159,11 @@ public class ModuleRootsExternalizationTest extends ModuleTestCase { "" + "" + "" + - "" + "" + "" + "" + "" + "" + - "" + "" + "" + "", module); diff --git a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java index a9578c24654e..b1bbd7a29e74 100644 --- a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java @@ -47,7 +47,7 @@ public class LibraryTest extends IdeaTestCase { final Element element = new Element("root"); library.writeExternal(element); - assertEquals("", + assertEquals("", new XMLOutputter().outputString(element)); ApplicationManager.getApplication().runWriteAction(new Runnable() { diff --git a/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java b/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java index 537d367c7bdb..9a6a53966be9 100644 --- a/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java +++ b/java/jsp-base-openapi/src/com/intellij/psi/jsp/JspDirectiveKind.java @@ -19,6 +19,7 @@ package com.intellij.psi.jsp; * @author ven */ public enum JspDirectiveKind { + /** Mapped to both page and tag directives */ PAGE, INCLUDE, TAGLIB, diff --git a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java index d2ebffc8bfbd..b475e65c66c4 100644 --- a/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java +++ b/java/openapi/src/com/intellij/ui/classFilter/ClassFilterEditor.java @@ -29,9 +29,9 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.TableUtil; import com.intellij.ui.UIBundle; +import com.intellij.ui.table.JBTable; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.ItemRemovable; -import com.intellij.util.ui.Table; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -66,7 +66,7 @@ public class ClassFilterEditor extends JPanel { myAddClassButton = new JButton(getAddButtonText()); myAddPatternButton = new JButton(getAddPatternButtonText()); myRemoveButton = new JButton(UIBundle.message("button.remove")); - myTable = new Table(); + myTable = new JBTable(); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTable); add(scrollPane, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 3, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 6), 0, 0)); @@ -347,4 +347,8 @@ public class ClassFilterEditor extends JPanel { TableUtil.removeSelectedItems(myTable); } } + + public void setAddPatternButtonVisible(boolean visible) { + myAddPatternButton.setVisible(visible); + } } diff --git a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java index 428ee23b2e46..1ace770954c4 100644 --- a/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java +++ b/platform/lang-api/src/com/intellij/execution/runners/ExecutionUtil.java @@ -28,6 +28,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.wm.ToolWindowId; import com.intellij.openapi.wm.ToolWindowManager; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.event.HyperlinkEvent; @@ -47,16 +48,16 @@ public class ExecutionUtil { } public static void handleExecutionError(@NotNull final Project project, - @NotNull String toolWindowId, + @NotNull final String toolWindowId, @NotNull String taskName, @NotNull ExecutionException e) { if (e instanceof RunCanceledByUserException) return; + LOG.debug(e); + String error = e.getMessage(); HyperlinkListener listener = null; - LOG.debug(error); - if (error.contains("87") && e instanceof ProcessNotCreatedException) { final String commandLineString = ((ProcessNotCreatedException)e).getCommandLine().getCommandLineString(); if (commandLineString.length() > 1024 * 32) { @@ -72,12 +73,18 @@ public class ExecutionUtil { }; } } - String message = ExecutionBundle.message("error.running.configuration.with.error.error.message", taskName, error); + final String message = ExecutionBundle.message("error.running.configuration.with.error.error.message", taskName, error); if (ApplicationManager.getApplication().isUnitTestMode()) { LOG.error(message); } - ToolWindowManager.getInstance(project).notifyByBalloon(toolWindowId, MessageType.ERROR, message, null, listener); + final HyperlinkListener finalListener = listener; + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + ToolWindowManager.getInstance(project).notifyByBalloon(toolWindowId, MessageType.ERROR, message, null, finalListener); + } + }); } } diff --git a/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java b/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java index 6b3c81872974..443078992067 100644 --- a/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java +++ b/platform/lang-api/src/com/intellij/lang/LanguageDocumentation.java @@ -22,8 +22,6 @@ package com.intellij.lang; import com.intellij.lang.documentation.CompositeDocumentationProvider; import com.intellij.lang.documentation.DocumentationProvider; -import java.util.List; - public class LanguageDocumentation extends LanguageExtension { public static final LanguageDocumentation INSTANCE = new LanguageDocumentation(); @@ -32,11 +30,6 @@ public class LanguageDocumentation extends LanguageExtension providers = allForLanguage(l); - if (providers.size() < 2) { - return super.forLanguage(l); - } - - return new CompositeDocumentationProvider(providers); + return CompositeDocumentationProvider.wrapProviders(allForLanguage(l)); } } \ No newline at end of file diff --git a/platform/lang-api/src/com/intellij/lang/PsiBuilder.java b/platform/lang-api/src/com/intellij/lang/PsiBuilder.java index e730513dad5d..c9c10570ad5d 100644 --- a/platform/lang-api/src/com/intellij/lang/PsiBuilder.java +++ b/platform/lang-api/src/com/intellij/lang/PsiBuilder.java @@ -111,21 +111,27 @@ public interface PsiBuilder extends UserDataHolder { void done(IElementType type); /** - * Like done(), but collapses all tokens between start and end markers into single leaf node of given type. + * Like {@linkplain #done(IElementType)}, but collapses all tokens between start and end markers + * into single leaf node of given type. * * @param type the type of the node in the AST tree. */ void collapse(IElementType type); /** - * TODO doc + * Like {@linkplain #done(IElementType)}, but the marker is completed (end marker inserted) + * before specified one. All markers added between start of this marker and the marker specified as end one + * must be either dropped or completed. + * * @param type the type of the node in the AST tree. * @param before marker to complete this one before. */ void doneBefore(IElementType type, Marker before); /** - * TODO doc + * Like {@linkplain #doneBefore(IElementType, Marker)}, but in addition an error element with given text + * is inserted right before this marker's end. + * * @param type the type of the node in the AST tree. * @param before marker to complete this one before. * @param errorMessage for error element. @@ -139,6 +145,14 @@ public interface PsiBuilder extends UserDataHolder { * @param message for error element. */ void error(String message); + + /** + * Like {@linkplain #error(String)}, but the marker is completed before specified one. + * + * @param message for error element. + * @param before marker to complete this one before. + */ + void errorBefore(String message, Marker before); } /** diff --git a/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java b/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java index 98aa3ac92463..0cdf910f30da 100644 --- a/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java +++ b/platform/lang-api/src/com/intellij/lang/documentation/CompositeDocumentationProvider.java @@ -28,24 +28,25 @@ public class CompositeDocumentationProvider implements DocumentationProvider, Ex private final List myProviders; - public CompositeDocumentationProvider (DocumentationProvider ... documentationProviders) { - this(Arrays.asList(documentationProviders)); + public static DocumentationProvider wrapProviders(Collection providers) { + ArrayList list = new ArrayList(); + for (DocumentationProvider provider : providers) { + if (provider instanceof CompositeDocumentationProvider) { + list.addAll(((CompositeDocumentationProvider)provider).getProviders()); + } + else if (provider != null) { + list.add(provider); + } + } + return list.size() == 1 ? list.get(0) : new CompositeDocumentationProvider(Collections.unmodifiableList(list)); } - public CompositeDocumentationProvider(Collection providers) { - myProviders = new ArrayList(providers); - } - - public void inject (DocumentationProvider provider) { - myProviders.add ( provider ); - } - - public void remove (DocumentationProvider provider) { - myProviders.remove ( provider ); + private CompositeDocumentationProvider(List providers) { + myProviders = providers; } public List getProviders() { - return Collections.unmodifiableList(myProviders); + return myProviders; } public String getQuickNavigateInfo(PsiElement element) { diff --git a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java index 950d9660c986..bc9ddaf7a954 100644 --- a/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java +++ b/platform/lang-api/src/com/intellij/lang/refactoring/InlineActionHandler.java @@ -38,6 +38,10 @@ public abstract class InlineActionHandler { return canInlineElement(element); } + public boolean isEnabledOnElement(PsiElement element, Editor editor) { + return isEnabledOnElement(element); + } + public abstract boolean isEnabledForLanguage(Language l); public abstract boolean canInlineElement(PsiElement element); diff --git a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java index 34509ab6cb43..02577d3b0d7b 100644 --- a/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java +++ b/platform/lang-api/src/com/intellij/psi/util/PsiUtilBase.java @@ -431,6 +431,14 @@ public class PsiUtilBase { return narrowLanguage(lang, file.getLanguage()); } + @Nullable + public static PsiElement getElementAtCaret(Editor editor) { + Project project = editor.getProject(); + if (project == null) return null; + PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); + return file == null ? null : file.findElementAt(editor.getCaretModel().getOffset()); + } + public static Language getDialect(@NotNull PsiElement element) { return narrowLanguage(element.getLanguage(), element.getContainingFile().getLanguage()); } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java index 9f1ddcece42c..0f6dcfa19449 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationManager.java @@ -64,7 +64,6 @@ import com.intellij.ui.popup.NotLookupOrSearchCondition; import com.intellij.ui.popup.PopupUpdateProcessor; import com.intellij.util.Alarm; import com.intellij.util.Processor; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.ui.update.Activatable; import com.intellij.util.ui.update.UiNotifyConnector; import org.jetbrains.annotations.NonNls; @@ -777,22 +776,16 @@ public class DocumentationManager { DocumentationProvider elementProvider = element == null || elementLanguage.is(containingFileLanguage) ? null : LanguageDocumentation.INSTANCE.forLanguage(elementLanguage); - addProviderToResult(result, elementProvider); - addProviderToResult(result, originalProvider); + result.add(elementProvider); + result.add(originalProvider); if (containingFile != null) { final Language baseLanguage = containingFile.getViewProvider().getBaseLanguage(); if (!baseLanguage.is(containingFileLanguage)) { - addProviderToResult(result, LanguageDocumentation.INSTANCE.forLanguage(baseLanguage)); + result.add(LanguageDocumentation.INSTANCE.forLanguage(baseLanguage)); } } - // return extensible documentation provider even if the list is empty - return new CompositeDocumentationProvider(result); - } - - private static void addProviderToResult(final Set result, final DocumentationProvider t) { - if (t instanceof CompositeDocumentationProvider) result.addAll(((CompositeDocumentationProvider)t).getProviders()); - else ContainerUtil.addIfNotNull(t, result); + return CompositeDocumentationProvider.wrapProviders(result); } @Nullable diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index 720fb1d6a01d..10aaab15bc90 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -70,6 +70,7 @@ public class TemplateState implements Disposable { private Editor myEditor; private TemplateImpl myTemplate; + private TemplateImpl myPrevTemplate; private TemplateSegments mySegments = null; private Map myPredefinedVariableValues; @@ -219,6 +220,7 @@ public class TemplateState implements Disposable { mySegments = null; } myTemplateRange = null; + myPrevTemplate = myTemplate; myTemplate = null; releaseEditor(); myTabStopHighlighters.clear(); @@ -271,6 +273,7 @@ public class TemplateState implements Disposable { myTemplateIndented = false; myCurrentVariableNumber = -1; mySegments = new TemplateSegments(myEditor); + myPrevTemplate = myTemplate; myTemplate = template; //myArgument = argument; myPredefinedVariableValues = predefinedVarValues; @@ -378,7 +381,7 @@ public class TemplateState implements Disposable { private void afterChangedUpdate() { if (isFinished()) return; - LOG.assertTrue(myTemplate != null); + LOG.assertTrue(myTemplate != null, myPrevTemplate != null ? myPrevTemplate.getKey() : "prev template is null"); if (myDocumentChanged) { if (myDocumentChangesTerminateTemplate || mySegments.isInvalid()) { final int oldIndex = myCurrentVariableNumber; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java b/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java index 75710be70ddf..78653db5d643 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/export/ExportToHTMLDialog.java @@ -25,12 +25,11 @@ import com.intellij.ui.OptionGroup; import javax.swing.*; -// TODO copy-paste result of com.intellij.codeEditor.printing.ExportToHTMLDialog public class ExportToHTMLDialog extends DialogWrapper{ - private JCheckBox myCbOpenInBrowser; private final Project myProject; - private TextFieldWithBrowseButton myTargetDirectoryField; - private final boolean myCanBeOpenInBrowser; + protected JCheckBox myCbOpenInBrowser; + protected TextFieldWithBrowseButton myTargetDirectoryField; + protected final boolean myCanBeOpenInBrowser; public ExportToHTMLDialog(Project project, final boolean canBeOpenInBrowser) { super(project, true); @@ -54,11 +53,15 @@ public class ExportToHTMLDialog extends DialogWrapper{ if (!myCanBeOpenInBrowser) return null; OptionGroup optionGroup = new OptionGroup(InspectionsBundle.message("inspection.export.options.panel.title")); + addOptions(optionGroup); + + return optionGroup.createPanel(); + } + + protected void addOptions(OptionGroup optionGroup) { myCbOpenInBrowser = new JCheckBox(); myCbOpenInBrowser.setText(InspectionsBundle.message("inspection.export.open.option")); optionGroup.add(myCbOpenInBrowser); - - return optionGroup.createPanel(); } public void reset() { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 5980a99f166a..6d80319c7077 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -572,7 +572,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren if (myTree == null) return null; TreePath[] paths = myTree.getSelectionPaths(); - if (paths == null) return null; + if (paths == null || paths.length == 0) return null; if (paths.length > 1) { if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) { diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java b/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java index 81e8677fcac8..656101855044 100644 --- a/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java +++ b/platform/lang-impl/src/com/intellij/execution/ExecutionMode.java @@ -15,10 +15,14 @@ */ package com.intellij.execution; +import com.intellij.execution.process.ProcessListener; import com.intellij.util.Function; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import java.util.ArrayList; +import java.util.List; /** * @author Roman.Chernyatchik @@ -32,6 +36,7 @@ public abstract class ExecutionMode { private final JComponent myProgressParentComponent; private Function myShouldCancelFun; private final Object CANCEL_FUN_LOCK = new Object(); + private List myListeners = new ArrayList(1); public ExecutionMode(final boolean cancelable, @Nullable final String title, @@ -94,4 +99,12 @@ public abstract class ExecutionMode { } } + public void addProcessListener(@NotNull final ProcessListener listener) { + myListeners.add(listener); + } + + @NotNull + public List getProcessListeners() { + return myListeners; + } } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java b/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java index a03ac3ec6ef5..b0a81e064c17 100644 --- a/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java +++ b/platform/lang-impl/src/com/intellij/execution/ExecutionModes.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; /** - * @author oleg + * @author Roman.Chernyatchik, oleg */ public class ExecutionModes { /** diff --git a/java/java-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java b/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java similarity index 91% rename from java/java-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java rename to platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java index aa9db99da131..477de5f94a47 100644 --- a/java/java-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/CreateTemplateInPackageAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2010 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectFileIndex; import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.psi.JavaDirectoryService; import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiElement; import com.intellij.util.IncorrectOperationException; @@ -71,7 +70,7 @@ public abstract class CreateTemplateInPackageAction extend ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); for (PsiDirectory dir : view.getDirectories()) { - if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && JavaDirectoryService.getInstance().getPackage(dir) != null) { + if (projectFileIndex.isInSourceContent(dir.getVirtualFile()) && checkPackageExists(dir)) { return true; } } @@ -79,6 +78,8 @@ public abstract class CreateTemplateInPackageAction extend return false; } + protected abstract boolean checkPackageExists(PsiDirectory directory); + @Nullable private T checkOrCreate(String newName, PsiDirectory directory, String templateName, boolean check) throws IncorrectOperationException { PsiDirectory dir = directory; @@ -113,10 +114,9 @@ public abstract class CreateTemplateInPackageAction extend return doCreate(dir, className, templateName); } - protected void doCheckCreate(PsiDirectory dir, String className, String templateName) throws IncorrectOperationException { - JavaDirectoryService.getInstance().checkCreateClass(dir, className); - } + protected abstract void doCheckCreate(PsiDirectory dir, String className, String templateName) throws IncorrectOperationException; + @Nullable protected abstract T doCreate(final PsiDirectory dir, final String className, String templateName) throws IncorrectOperationException; } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java index 7414c7558ee9..139614aae1c7 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarPanel.java @@ -23,6 +23,7 @@ import com.intellij.ide.IdeView; import com.intellij.ide.projectView.ProjectView; import com.intellij.ide.projectView.impl.AbstractProjectViewPane; import com.intellij.ide.projectView.impl.ProjectRootsUtil; +import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.customization.CustomActionsSchema; import com.intellij.ide.util.DeleteHandler; import com.intellij.ide.util.DirectoryChooserUtil; @@ -190,7 +191,7 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup } }); - installBorder(-1); + installBorder(-1, false); myCopyPasteDelegator = new CopyPasteDelegator(myProject, NavBarPanel.this) { @NotNull @@ -554,6 +555,10 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup } }); + if (!isValid()) { + validate(); + } + myNodePopup.showUnderneathOf(item); } } @@ -758,14 +763,26 @@ public class NavBarPanel extends OpaquePanel.List implements DataProvider, Popup myModelUpdateAlarm.cancelAllRequests(); } - public void installBorder(final int rightOffset) { + public void installBorder(final int rightOffset, final boolean isDocked) { setBorder(new Border() { public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int width, final int height) { g.setColor(c.getBackground() != null ? c.getBackground().darker() : Color.darkGray); + + boolean drawTopBorder = true; + if (isDocked) { + if (!UISettings.getInstance().SHOW_MAIN_TOOLBAR) { + drawTopBorder = false; + } + } + if (rightOffset == -1) { - g.drawLine(0, 0, width - 1, 0); + if (drawTopBorder) { + g.drawLine(0, 0, width - 1, 0); + } } else { - g.drawLine(0, 0, width - rightOffset + 3, 0); + if (drawTopBorder) { + g.drawLine(0, 0, width - rightOffset + 3, 0); + } } g.drawLine(0, height - 1 , width, height - 1); diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java index 9d4b1ddbce10..f9ca00a2875a 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarRootPaneExtension.java @@ -70,7 +70,7 @@ public class NavBarRootPaneExtension extends IdeRootPaneNorthExtension { myPanel.add(closeLabel, BorderLayout.EAST); myPanel.putClientProperty("NavBarPanel", myNavigationBar); - myNavigationBar.installBorder(0); + myNavigationBar.installBorder(0, true); myPanel.setBorder(myNavigationBar.getBorder()); myNavigationBar.setBorder(null); } diff --git a/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java index cdbf6f125a2a..1c48d7361168 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/ide/util/NavigationItemListCellRenderer.java @@ -67,13 +67,14 @@ public class NavigationItemListCellRenderer extends OpaquePanel implements ListC final Color listBg = leftCellRendererComponent.getBackground(); add(leftCellRendererComponent, BorderLayout.WEST); - setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground()); + setBackground(isSelected ? UIUtil.getListSelectionBackground() : listBg); if (hasRightRenderer){ final DefaultListCellRenderer moduleRenderer = factory.getModuleRenderer(); final Component rightCellRendererComponent = moduleRenderer.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + ((JComponent)rightCellRendererComponent).setOpaque(false); rightCellRendererComponent.setBackground(listBg); add(rightCellRendererComponent, BorderLayout.EAST); final JPanel spacer = new NonOpaquePanel(); diff --git a/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java b/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java index 06c1483059e0..c66fe2146a6a 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java +++ b/platform/lang-impl/src/com/intellij/ide/util/PlatformModuleRendererFactory.java @@ -28,38 +28,40 @@ import java.awt.*; */ public class PlatformModuleRendererFactory extends ModuleRendererFactory { public DefaultListCellRenderer getModuleRenderer() { - return new DefaultListCellRenderer() { - public Component getListCellRendererComponent(final JList list, - final Object value, - final int index, - final boolean isSelected, - final boolean cellHasFocus) { - final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - String text = ""; - if (value instanceof NavigationItem) { - final ItemPresentation presentation = ((NavigationItem)value).getPresentation(); - if (presentation != null) { - String containerText = presentation.getLocationString(); - if (containerText != null && containerText.length() > 0) { - text = " " + containerText; - } - } - } - - - setText(text); - setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); - setHorizontalTextPosition(SwingConstants.LEFT); - setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground()); - setForeground(isSelected ? UIUtil.getListSelectionForeground() : UIUtil.getInactiveTextColor()); - return component; - } - }; + return new PlatformModuleRenderer(); } @Override public boolean rendersLocationString() { return true; } + + public static class PlatformModuleRenderer extends DefaultListCellRenderer { + public Component getListCellRendererComponent(final JList list, + final Object value, + final int index, + final boolean isSelected, + final boolean cellHasFocus) { + final Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + String text = ""; + if (value instanceof NavigationItem) { + final ItemPresentation presentation = ((NavigationItem)value).getPresentation(); + if (presentation != null) { + String containerText = presentation.getLocationString(); + if (containerText != null && containerText.length() > 0) { + text = " " + containerText; + } + } + } + + + setText(text); + setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2)); + setHorizontalTextPosition(SwingConstants.LEFT); + setBackground(isSelected ? UIUtil.getListSelectionBackground() : UIUtil.getListBackground()); + setForeground(isSelected ? UIUtil.getListSelectionForeground() : UIUtil.getInactiveTextColor()); + return component; + } + } } diff --git a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java index 5a9a5ca63995..f8f1e5de4b4b 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java +++ b/platform/lang-impl/src/com/intellij/ide/util/gotoByName/GotoFileCellRenderer.java @@ -16,6 +16,7 @@ package com.intellij.ide.util.gotoByName; +import com.intellij.ide.util.PlatformModuleRendererFactory; import com.intellij.ide.util.PsiElementListCellRenderer; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; @@ -26,6 +27,7 @@ import com.intellij.psi.PsiFile; import com.intellij.util.ui.FilePathSplittingPolicy; import org.jetbrains.annotations.Nullable; +import javax.swing.*; import java.awt.*; import java.io.File; @@ -72,6 +74,16 @@ public class GotoFileCellRenderer extends PsiElementListCellRenderer{ return url; } + @Override + protected DefaultListCellRenderer getRightCellRenderer() { + final DefaultListCellRenderer rightRenderer = super.getRightCellRenderer(); + if (rightRenderer instanceof PlatformModuleRendererFactory.PlatformModuleRenderer) { + // that renderer will display file path, but we're showing it ourselves - no need to show twice + return null; + } + return rightRenderer; + } + protected int getIconFlags() { return 0; } diff --git a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java index 64bcae71ece0..7a55ed3f5969 100644 --- a/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java +++ b/platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java @@ -298,6 +298,11 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { myBuilder.error(this, message); } + public void errorBefore(final String message, final Marker before) { + myType = TokenType.ERROR_ELEMENT; + myBuilder.errorBefore(this, message, before); + } + public IElementType getTokenType() { return myType; } @@ -564,15 +569,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { @SuppressWarnings({"SuspiciousMethodCalls"}) public void doneBefore(Marker marker, Marker before) { -// TODO: there could be not done markers after 'marker' and that's normal - if (((StartMarker)marker).myDoneMarker != null) { - LOG.error("Marker already done."); - } - - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker never been added."); - } + doValidityChecks(marker, before); int beforeIndex = myProduction.lastIndexOf(before); @@ -594,15 +591,27 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } public void error(Marker marker, String message) { - doValidityChecks(marker); + doValidityChecks(marker, null); DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message); ((StartMarker)marker).myDoneMarker = doneMarker; myProduction.add(doneMarker); } + @SuppressWarnings({"SuspiciousMethodCalls"}) + public void errorBefore(Marker marker, String message, Marker before) { + doValidityChecks(marker, before); + + int beforeIndex = myProduction.lastIndexOf(before); + + DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message); + doneMarker.myLexemeIndex = ((StartMarker)before).myLexemeIndex; + ((StartMarker)marker).myDoneMarker = doneMarker; + myProduction.add(beforeIndex, doneMarker); + } + public void done(final Marker marker) { - doValidityChecks(marker); + doValidityChecks(marker, null); DoneMarker doneMarker = DONE_MARKERS.alloc(); doneMarker.myStart = (StartMarker)marker; @@ -618,30 +627,41 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder { } @SuppressWarnings({"UseOfSystemOutOrSystemErr", "SuspiciousMethodCalls"}) - private void doValidityChecks(final Marker marker) { - if (myDebugMode) { - final DoneMarker doneMarker = ((StartMarker)marker).myDoneMarker; - if (doneMarker != null) { - LOG.error("Marker already done."); - } - int idx = myProduction.lastIndexOf(marker); - if (idx < 0) { - LOG.error("Marker never been added."); - } + private void doValidityChecks(final Marker marker, @Nullable final Marker before) { + if (!myDebugMode) return; - for (int i = myProduction.size() - 1; i > idx; i--) { - Object item = myProduction.get(i); - if (item instanceof StartMarker) { - StartMarker otherMarker = (StartMarker)item; - if (otherMarker.myDoneMarker == null) { - final Throwable debugAllocOther = otherMarker.myDebugAllocationPosition; - final Throwable debugAllocThis = ((StartMarker)marker).myDebugAllocationPosition; - if (debugAllocOther != null) { - debugAllocThis.printStackTrace(System.err); - debugAllocOther.printStackTrace(System.err); - } - LOG.error("Another not done marker added after this one. Must be done before this."); + final DoneMarker doneMarker = ((StartMarker)marker).myDoneMarker; + if (doneMarker != null) { + LOG.error("Marker already done."); + } + int idx = myProduction.lastIndexOf(marker); + if (idx < 0) { + LOG.error("Marker has never been added."); + } + + int endIdx = myProduction.size(); + if (before != null) { + endIdx = myProduction.lastIndexOf(before); + if (endIdx < 0) { + LOG.error("'Before' marker has never been added."); + } + if (idx > endIdx) { + LOG.error("'Before' marker precedes this one."); + } + } + + for (int i = endIdx - 1; i > idx; i--) { + Object item = myProduction.get(i); + if (item instanceof StartMarker) { + StartMarker otherMarker = (StartMarker)item; + if (otherMarker.myDoneMarker == null) { + final Throwable debugAllocOther = otherMarker.myDebugAllocationPosition; + final Throwable debugAllocThis = ((StartMarker)marker).myDebugAllocationPosition; + if (debugAllocOther != null) { + debugAllocThis.printStackTrace(System.err); + debugAllocOther.printStackTrace(System.err); } + LOG.error("Another not done marker added after this one. Must be done before this."); } } } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index 091ccf348d86..762e7b6bd738 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -277,7 +277,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { if (roots.size() == 0 && rootType.skipWriteIfEmpty()) continue; //compatibility iml/ipr final Element rootTypeElement = new Element(rootType.name()); roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT); - element.addContent(rootTypeElement); + if (rootTypeElement.getAttributes().size() > 0 || rootTypeElement.getContent().size() > 0) element.addContent(rootTypeElement); } List urls = new ArrayList(myJarDirectories.keySet()); Collections.sort(urls, new Comparator() { diff --git a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java index a605677e93a7..16a574ef9f67 100644 --- a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java +++ b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java @@ -25,6 +25,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.ToolWindowId; +import com.intellij.openapi.wm.ToolWindowType; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -43,7 +44,7 @@ public class PlatformProjectViewOpener implements DirectoryProjectConfigurator { public void run() { if (project.isDisposed()) return; final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW); - if (toolWindow != null) { + if (toolWindow != null && toolWindow.getType() != ToolWindowType.SLIDING) { toolWindow.activate(null); } } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java b/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java index fea3861e633b..997c4578e2f4 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/include/FileIncludeIndex.java @@ -17,6 +17,7 @@ package com.intellij.psi.impl.include; import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.containers.FactoryMap; @@ -68,14 +69,14 @@ public class FileIncludeIndex extends FileBasedIndexExtension, FileContent> getIndexer() { - return new DataIndexer, FileContent>() { + public DataIndexer, FileContent> getIndexer() { + return new DataIndexer, FileContent>() { @NotNull - public Map> map(FileContent inputData) { + public Map> map(FileContent inputData) { - Map> map = new FactoryMap>() { + Map> map = new FactoryMap>() { @Override - protected List create(FileIncludeIndex.Key key) { + protected List create(Key key) { return new ArrayList(); } }; @@ -144,6 +145,9 @@ public class FileIncludeIndex extends FileBasedIndexExtension result = new HashSet(); + LinkedHashSet result = new LinkedHashSet(); final NameSuggestionProvider[] providers = Extensions.getExtensions(NameSuggestionProvider.EP_NAME); for(NameSuggestionProvider provider: providers) { SuggestedNameInfo info = provider.getSuggestedNames(myPsiElement, myNameSuggestionContext, result); diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java index 09c9ebdc6f5d..6b375936fafe 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/inplace/VariableInplaceRenamer.java @@ -227,7 +227,9 @@ public class VariableInplaceRenamer { } //add highlights - addHighlights(rangesToHighlight, topLevelEditor, myHighlighters, highlightManager); + if (myHighlighters != null) { // can be null if finish is called during testing + addHighlights(rangesToHighlight, topLevelEditor, myHighlighters, highlightManager); + } } }); } diff --git a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java index 7dbc4a248c92..11c207c33154 100644 --- a/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java @@ -23,6 +23,7 @@ import com.intellij.concurrency.Job; import com.intellij.concurrency.JobUtil; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.IndexNotReadyException; +import com.intellij.openapi.util.Ref; import com.intellij.util.Alarm; import com.intellij.util.Function; import com.intellij.util.ui.EmptyIcon; @@ -66,29 +67,37 @@ public class DeferredIconImpl implements DeferredIcon { if (!myIsScheduled) { myIsScheduled = true; - final Component target; + final Ref target = new Ref(null); + final Ref paintingParent = new Ref(null); + final Ref paintingParentRec = new Ref(null); final Container list = SwingUtilities.getAncestorOfClass(JList.class, c); if (list != null) { - target = list; + target.set(list); } else { final Container tree = SwingUtilities.getAncestorOfClass(JTree.class, c); if (tree != null) { - target = tree; + target.set(tree); } else { final Container table = SwingUtilities.getAncestorOfClass(JTable.class, c); if (table != null) { - target = table; + target.set(table); } else { - target = c; + target.set(c); } } } - myLastTarget = new WeakReference(target); + Container pp = SwingUtilities.getAncestorOfClass(PaintingParent.class, c); + paintingParent.set(pp); + if (paintingParent.get() != null) { + paintingParentRec.set(((PaintingParent)pp).getChildRec(c)); + } + + myLastTarget = new WeakReference(target.get()); JobUtil.submitToJobThread(new Runnable() { public void run() { @@ -100,10 +109,23 @@ public class DeferredIconImpl implements DeferredIcon { //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { public void run() { + Component actualTarget = target.get(); + if (SwingUtilities.getWindowAncestor(actualTarget) == null) { + actualTarget = paintingParent.get(); + if (actualTarget == null || SwingUtilities.getWindowAncestor(actualTarget) == null) { + actualTarget = null; + myLastTarget = null; + } + } + + if (actualTarget == null) return; + + myLastTarget = new WeakReference(actualTarget); + if (shouldRevalidate) { // revalidate will not work: jtree caches size of nodes - if (target instanceof JTree) { - final TreeUI ui = ((JTree)target).getUI(); + if (actualTarget instanceof JTree) { + final TreeUI ui = ((JTree)actualTarget).getUI(); if (ui instanceof BasicTreeUI) { // this call is "fake" and only need to reset tree layout cache ((BasicTreeUI)ui).setLeftChildIndent(((Integer)UIManager.get("Tree.leftChildIndent")).intValue()); @@ -111,11 +133,16 @@ public class DeferredIconImpl implements DeferredIcon { } } - if (c == target) { + if (c == actualTarget) { c.repaint(x, y, getIconWidth(), getIconHeight()); } else { - ourRepaintScheduler.pushDirtyComponent(target); + Rectangle rec = null; + if (paintingParentRec.get() != null) { + rec = paintingParentRec.get(); + } + + ourRepaintScheduler.pushDirtyComponent(actualTarget, rec); } } }); @@ -191,20 +218,44 @@ public class DeferredIconImpl implements DeferredIcon { private static class RepaintScheduler { private final Alarm myAlarm = new Alarm(); - private final Set myQueue = new LinkedHashSet(); + private final Set myQueue = new LinkedHashSet(); - public void pushDirtyComponent(Component c) { + public void pushDirtyComponent(final Component c, final Rectangle rec) { myAlarm.cancelAllRequests(); myAlarm.addRequest(new Runnable() { public void run() { - for (Component component : myQueue) { - component.repaint(); + for (RepaintRequest each : myQueue) { + Rectangle r = each.getRectangle(); + if (r != null) { + each.getComponent().repaint(r.x, r.y, r.width, r.height); + } else { + each.getComponent().repaint(); + } } myQueue.clear(); } }, 50); - myQueue.add(c); + myQueue.add(new RepaintRequest(c, rec)); } } + + private static class RepaintRequest { + private Component myComponent; + private Rectangle myRectangle; + + private RepaintRequest(Component component, Rectangle rectangle) { + myComponent = component; + myRectangle = rectangle; + } + + public Component getComponent() { + return myComponent; + } + + public Rectangle getRectangle() { + return myRectangle; + } + } + } diff --git a/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java b/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java index f4ce4668a557..df4c6a5403c2 100644 --- a/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java +++ b/platform/lang-impl/src/com/intellij/ui/TextFieldWithAutoCompletion.java @@ -97,25 +97,30 @@ public class TextFieldWithAutoCompletion extends EditorTextField { } public void actionPerformed(final AnActionEvent e) { - final Editor editor = getEditor(); - assert editor != null; - - editor.getSelectionModel().removeSelection(); - final String lookupPrefix = getCurrentLookupPrefix(getCurrentTextPrefix()); - final LookupImpl lookup = - (LookupImpl)LookupManager.getInstance(getProject()).createLookup(editor, - calcLookupItems(lookupPrefix), - lookupPrefix != null ? lookupPrefix : "", - LookupArranger.DEFAULT); - final String advertisementText = getAdvertisementText(); - if (!StringUtil.isEmpty(advertisementText)) { - lookup.setAdvertisementText(advertisementText); - lookup.refreshUi(); - } - lookup.show(); + showLookup(); } } + public void showLookup() { + if (LookupManager.getInstance(getProject()).getActiveLookup() != null) return; + final Editor editor = getEditor(); + assert editor != null; + + editor.getSelectionModel().removeSelection(); + final String lookupPrefix = getCurrentLookupPrefix(getCurrentTextPrefix()); + final LookupImpl lookup = + (LookupImpl)LookupManager.getInstance(getProject()).createLookup(editor, + calcLookupItems(lookupPrefix), + lookupPrefix != null ? lookupPrefix : "", + LookupArranger.DEFAULT); + final String advertisementText = getAdvertisementText(); + if (!StringUtil.isEmpty(advertisementText)) { + lookup.setAdvertisementText(advertisementText); + lookup.refreshUi(); + } + lookup.show(); + } + public void setAdvertisementText(@Nullable String text) { myAdText = text; } diff --git a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java index 243aca81a128..111228759fff 100644 --- a/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java +++ b/platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java @@ -20,72 +20,205 @@ import com.intellij.lexer.LexerBase; import com.intellij.psi.impl.DebugUtil; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; -import org.jetbrains.annotations.NotNull; +import com.sun.tools.internal.xjc.util.NullStream; import org.junit.Test; +import java.io.PrintStream; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; public class LightPsiBuilderTest { + private static final IElementType ROOT = new IElementType("ROOT", Language.ANY); + private static final IElementType LETTER = new IElementType("LETTER", Language.ANY); + private static final IElementType DIGIT = new IElementType("DIGIT", Language.ANY); + private static final IElementType OTHER = new IElementType("OTHER", Language.ANY); + private static final IElementType COLLAPSED = new IElementType("COLLAPSED", Language.ANY); @Test public void testPlain() { - doTest( - "a<\n" + + " PsiErrorElement:with error\n" + + " \n" + + " Element(OTHER)\n" + + " PsiElement(LETTER)('b')\n"); + } + + @Test + public void testErrorBefore() throws Exception { + doTest("a1", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker letter = builder.mark(); + builder.advanceLexer(); + letter.done(LETTER); + final PsiBuilder.Marker digit = builder.mark(); + builder.advanceLexer(); + digit.done(DIGIT); + digit.precede().errorBefore("something lost", digit); + } + }, + "Element(ROOT)\n" + + " Element(LETTER)\n" + + " PsiElement(LETTER)('a')\n" + + " PsiErrorElement:something lost\n" + + " \n" + + " Element(DIGIT)\n" + + " PsiElement(DIGIT)('1')\n"); + } + + @Test + public void testValidityChecksOnDone() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + builder.mark(); + first.done(LETTER); + } + }); + } + + @Test + public void testValidityChecksOnDoneBefore1() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + final PsiBuilder.Marker second = builder.mark(); + second.precede(); + first.doneBefore(LETTER, second); + } + }); + } + + @Test + public void testValidityChecksOnDoneBefore2() throws Exception { + doFailTest("a", + new Parser() { + public void parse(PsiBuilder builder) { + final PsiBuilder.Marker first = builder.mark(); + builder.advanceLexer(); + final PsiBuilder.Marker second = builder.mark(); + second.doneBefore(LETTER, first); + } + }); + } + + private interface Parser { + void parse(PsiBuilder builder); + } + + private static void doTest(final String text, final Parser parser, final String expected) { final PsiBuilder builder = new PsiBuilderImpl(new MyTestLexer(), TokenSet.EMPTY, TokenSet.EMPTY, text); - final ASTNode root = parser.parse(new IElementType("ROOT", Language.ANY), builder); + final PsiBuilder.Marker rootMarker = builder.mark(); + parser.parse(builder); + rootMarker.done(ROOT); + final ASTNode root = builder.getTreeBuilt(); assertEquals(expected, DebugUtil.nodeTreeToString(root, true)); } - private static class MyTestLexer extends LexerBase { - public static IElementType TOKEN = new IElementType("TOKEN", Language.ANY); + private static void doFailTest(final String text, final Parser parser) { + final PrintStream std = System.err; + //noinspection IOResourceOpenedButNotSafelyClosed + System.setErr(new PrintStream(new NullStream())); + try { + try { + final PsiBuilder builder = new PsiBuilderImpl(new MyTestLexer(), TokenSet.EMPTY, TokenSet.EMPTY, text); + builder.setDebugMode(true); + parser.parse(builder); + fail("should fail"); + } + catch (AssertionError e) { + //System.out.println("caught: " + e); + if ("should fail".equals(e.getMessage())) throw e; + } + } + finally { + System.setErr(std); + } + } + private static class MyTestLexer extends LexerBase { private CharSequence myBuffer = ""; private int myIndex = 0; private int myBufferEnd = 1; @@ -101,7 +234,18 @@ public class LightPsiBuilderTest { } public IElementType getTokenType() { - return myIndex < myBufferEnd ? TOKEN : null; + if (myIndex >= myBufferEnd) { + return null; + } + else if (Character.isDigit(myBuffer.charAt(myIndex))) { + return DIGIT; + } + else if (Character.isLetter(myBuffer.charAt(myIndex))) { + return LETTER; + } + else { + return OTHER; + } } public int getTokenStart() { diff --git a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java index 4bccb70d3d8a..2f956a7c7a59 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java @@ -27,10 +27,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import java.util.*; public class GeneralCommandLine { private Map myEnvParams; diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index 08b873b12410..c83a76455c33 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java @@ -33,6 +33,7 @@ public class ParametersList implements Cloneable{ private static final Logger LOG = Logger.getInstance("#com.intellij.execution.configurations.ParametersList"); private List myParameters = new ArrayList(); private Map myMacroMap = null; + private List myGroups = new ArrayList(); public boolean hasParameter(@NonNls final String param) { return myParameters.contains(param); @@ -63,11 +64,15 @@ public class ParametersList implements Cloneable{ buffer.append(separator); buffer.append(GeneralCommandLine.quote(param)); } + for (ParamsGroup paramsGroup : myGroups) { + // params group parameters string already contains a separator + buffer.append(paramsGroup.getParametersList().getParametersString()); + } return buffer.toString(); } public String[] getArray() { - return ArrayUtil.toStringArray(myParameters); + return ArrayUtil.toStringArray(getList()); } public void addParametersString(final String parameters) { @@ -83,6 +88,42 @@ public class ParametersList implements Cloneable{ myParameters.add(expandMacros(parameter)); } + public ParamsGroup addParamsGroup(@NotNull final String groupId) { + return addParamsGroup(new ParamsGroup(groupId)); + } + + public ParamsGroup addParamsGroup(@NotNull final ParamsGroup group) { + myGroups.add(group); + return group; + } + + public ParamsGroup addParamsGroupAt(final int index, + @NotNull final String groupId) { + final ParamsGroup group = new ParamsGroup(groupId); + myGroups.add(index, group); + return group; + } + + public int getParamsGroupsCount() { + return myGroups.size(); + } + + public List getParameters() { + return Collections.unmodifiableList(myParameters); + } + + public List getParamsGroups() { + return Collections.unmodifiableList(myGroups); + } + + public ParamsGroup getParamsGroupAt(final int index) { + return myGroups.get(index); + } + + public ParamsGroup removeParamsGroup(final int index) { + return myGroups.remove(index); + } + public void addAt(final int index, @NotNull final String parameter) { myParameters.add(index, expandMacros(parameter)); } @@ -119,7 +160,20 @@ public class ParametersList implements Cloneable{ } public List getList() { - return Collections.unmodifiableList(myParameters); + if (myGroups.isEmpty()) { + return Collections.unmodifiableList(myParameters); + } + + final List params = new ArrayList(); + + // params + params.addAll(myParameters); + + // recursively add groups + for (ParamsGroup group : myGroups) { + params.addAll(group.getParameters()); + } + return Collections.unmodifiableList(params); } public void prepend(@NonNls final String parameter) { @@ -143,6 +197,10 @@ public class ParametersList implements Cloneable{ try { final ParametersList clone = (ParametersList)super.clone(); clone.myParameters = new ArrayList(myParameters); + clone.myGroups = new ArrayList(myGroups.size() + 1); + for (ParamsGroup group : myGroups) { + clone.myGroups.add(group.clone()); + } return clone; } catch (CloneNotSupportedException e) { diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java b/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java new file mode 100644 index 000000000000..7e207440ad0e --- /dev/null +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParamsGroup.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.execution.configurations; + +import com.intellij.openapi.diagnostic.Logger; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * @author Roman.Chernyatchik + * + * Group of linked params. Sometime it's much more convenient to split cmdline in logical groups. + * In this case it will be easier to patch such grouped argements using custom extentions + * + * E.g.: we want to add Coverage support to all existing Ruby run configurations(ruby applications, + * different kinds of ruby tests, rails configuration, etc). Coverage support require to reorder args + * in cmdline, add rcov runner script, etc. Without groups it would be harder to parse abstract list of arguments + */ +public class ParamsGroup implements Cloneable{ + private static final Logger LOG = Logger.getInstance(ParamsGroup.class.getName()); + + private String myGroupId; + private ParametersList myGroupParams = new ParametersList(); + + public ParamsGroup(@NotNull final String groupId) { + myGroupId = groupId; + } + + public String getId() { + return myGroupId; + } + + public void addParameter(@NotNull @NonNls final String parameter) { + myGroupParams.add(parameter); + } + + public void addParameters(final String... parameters) { + for (String parameter : parameters) { + addParameter(parameter); + } + } + + public void addParameters(final List parameters) { + for (final String parameter : parameters) { + addParameter(parameter); + } + } + + public List getParameters() { + return myGroupParams.getList(); + } + + public ParametersList getParametersList() { + return myGroupParams; + } + + public ParamsGroup clone() { + try { + final ParamsGroup clone = (ParamsGroup)super.clone(); + clone.myGroupId = myGroupId; + clone.myGroupParams = myGroupParams.clone(); + return clone; + } + catch (CloneNotSupportedException e) { + LOG.error(e); + return null; + } + } + + @Override + public String toString() { + return myGroupId; + } +} 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 0c6efad5db99..e9c6eab32b81 100644 --- a/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java +++ b/platform/platform-api/src/com/intellij/ide/wizard/AbstractWizard.java @@ -25,6 +25,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.ui.CommandButtonGroup; import com.intellij.ui.components.panels.OpaquePanel; import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -221,7 +222,7 @@ public abstract class AbstractWizard extends DialogWrapper { return mySteps.get(myCurrentStep); } - public void addStep(final T step) { + public void addStep(@NotNull final T step) { mySteps.add(step); if (step instanceof StepAdapter) { diff --git a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java index 313073589174..8ed063a63bbf 100644 --- a/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java @@ -646,6 +646,17 @@ public class VfsUtil { return result; } + public static VirtualFile createDirectoryIfMissing(VirtualFile parent, String relativePath) throws IOException { + for (String each : StringUtil.split(relativePath, "/")) { + VirtualFile child = parent.findChild(each); + if (child == null) { + child = parent.createChildDirectory(LocalFileSystem.getInstance(), each); + } + parent = child; + } + return parent; + } + @Nullable public static VirtualFile createDirectoryIfMissing(@NotNull String dir) throws IOException { return doCreateDirectoriesIfMissing(FileUtil.toSystemIndependentName(dir)); diff --git a/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java b/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java index 93c9dc5e301d..3dec125ac557 100644 --- a/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java +++ b/platform/platform-api/src/com/intellij/ui/HyperlinkLabel.java @@ -16,9 +16,11 @@ package com.intellij.ui; +import com.intellij.ide.BrowserUtil; import com.intellij.openapi.editor.markup.EffectType; import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; @@ -108,6 +110,15 @@ public class HyperlinkLabel extends HighlightableComponent { adjustSize(); } + public void setHyperlinkTarget(@NotNull final String url) { + addHyperlinkListener(new HyperlinkListener() { + @Override + public void hyperlinkUpdate(HyperlinkEvent e) { + BrowserUtil.launchBrowser(url); + } + }); + } + public void addHyperlinkListener(HyperlinkListener listener) { myListeners.add(listener); } diff --git a/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java b/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java index 3a5e81d6557b..f0a43d9f290f 100644 --- a/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java +++ b/platform/platform-api/src/com/intellij/ui/OptionalChooserComponent.java @@ -26,16 +26,16 @@ import java.util.List; * @author oleg * This component represents a list of checkboxes. */ - public abstract class OptionalChooserComponent implements CheckBoxListListener { +public abstract class OptionalChooserComponent implements CheckBoxListListener { private JPanel myContentPane; private CheckBoxList myList; private DefaultListModel myListModel; - private final List> myInitialList; - private ArrayList> myWorkingList; + private List> myInitialList; + private ArrayList> myWorkingList; - public OptionalChooserComponent(@NotNull final List> list) { - myInitialList = list; - myWorkingList = new ArrayList>(myInitialList); + public OptionalChooserComponent(@NotNull final List> list) { + setInitialList(list); + myWorkingList = new ArrayList>(myInitialList); // fill list reset(); @@ -46,7 +46,7 @@ import java.util.List; } public void checkBoxSelectionChanged(int index, boolean value) { - final Pair pair = myWorkingList.remove(index); + final Pair pair = myWorkingList.remove(index); myWorkingList.add(index, Pair.create(pair.first, value)); } @@ -56,17 +56,25 @@ import java.util.List; } public void reset() { - myWorkingList = new ArrayList>(myInitialList); - update(); + myWorkingList = new ArrayList>(myInitialList); + refresh(); } - public abstract JCheckBox createCheckBox(final String path, final boolean checked); + protected abstract JCheckBox createCheckBox(final T value, final boolean checked); + + public int getSelectedIndex() { + return myList.getSelectedIndex(); + } public boolean isModified() { return !myWorkingList.equals(myInitialList); } - public ArrayList> getValue() { + public void setInitialList(@NotNull final List> list) { + myInitialList = list; + } + + public ArrayList> getCurrentModel() { return myWorkingList; } @@ -75,9 +83,9 @@ import java.util.List; myInitialList.addAll(myWorkingList); } - public void update() { + public void refresh() { myListModel.clear(); - for (Pair pair : myWorkingList) { + for (Pair pair : myWorkingList) { myListModel.addElement(createCheckBox(pair.first, pair.second)); } } diff --git a/platform/platform-api/src/com/intellij/ui/PaintingParent.java b/platform/platform-api/src/com/intellij/ui/PaintingParent.java new file mode 100644 index 000000000000..a49f1235e11f --- /dev/null +++ b/platform/platform-api/src/com/intellij/ui/PaintingParent.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.ui; + +import org.jetbrains.annotations.Nullable; + +import java.awt.*; + +/** + * Used for deferred re-painting (i.e. for deferred icons). As a paint() method is invoked through the normal AWT painting cycle, deferred painting + * of children may be queued. It means that actual data used for painting is pushed for calculation and, as it gets ready, there is need for repaint. + * The target component for further repaint() is either the component that was originally exposed to painting or, if it's no longer showing (in case of a flyweight + * renderer) -- the first component up in the hierarchy that implements PaintingParent. + * + */ +public interface PaintingParent { + + /** + * Returns rectangle of a child component for further repainting + * @param c + * @return a rectange, if null -- the whole component will be repainted + */ + @Nullable + Rectangle getChildRec(Component c); + +} diff --git a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java index 39c936efa3da..d34b068305f9 100644 --- a/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java +++ b/platform/platform-api/src/com/intellij/util/concurrency/QueueProcessor.java @@ -85,7 +85,7 @@ public class QueueProcessor { myProcessor.consume(next); } catch (Exception e) { - LOG.error(e); + LOG.warn(e); } synchronized (myQueue) { diff --git a/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java b/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java index 60cdc3f185c3..68fbd4500600 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/OpenProjectFileChooserDescriptor.java @@ -60,7 +60,7 @@ public class OpenProjectFileChooserDescriptor extends FileChooserDescriptor { public static Icon getImporterIcon(final VirtualFile virtualFile, final boolean open) { final ProjectOpenProcessor provider = ProjectOpenProcessor.getImportProvider(virtualFile); if(provider!=null) { - return virtualFile.isDirectory() ? ourProjectIcon : provider.getIcon(); + return virtualFile.isDirectory() && provider.lookForProjectsInDirectory() ? ourProjectIcon : provider.getIcon(); } return null; } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index 16811705de04..3a8d88acdbfd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -70,6 +70,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -132,6 +134,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec synchronized (myInitLock) { if (myPanels == null) { myPanels = new JPanel(new BorderLayout()); + myPanels.setBorder(new MyBorder()); mySplitters = new EditorsSplitters(this); myPanels.add(mySplitters, BorderLayout.CENTER); } @@ -139,6 +142,23 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec } } + private class MyBorder implements Border { + @Override + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { + } + + @Override + public Insets getBorderInsets(Component c) { + boolean filesOpen = mySplitters != null && mySplitters.getOpenFiles().length > 0; + return new Insets(filesOpen ? 1 : 0, 0, 0, 0); + } + + @Override + public boolean isBorderOpaque() { + return false; + } + } + public JComponent getPreferredFocusedComponent() { assertReadAccess(); final EditorWindow window = getSplitters().getCurrentWindow(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java index a23ab8fb9e91..2a54b574ba1b 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/welcomeScreen/WelcomeScreen.java @@ -440,7 +440,7 @@ public class WelcomeScreen { final boolean e2 = ((IdeaPluginDescriptorImpl)o2).isEnabled(); if (e1 && !e2) return -1; if (!e1 && e2) return 1; - return o1.getName().compareTo(o2.getName()); + return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase()); } }; Collections.sort(installedPlugins, pluginsComparator); diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java index a41c7b301680..cd29df862013 100644 --- a/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/mac/MacFileChooserDialogImpl.java @@ -18,6 +18,7 @@ package com.intellij.ui.mac; import com.intellij.openapi.fileChooser.FileChooserDescriptor; import com.intellij.openapi.fileChooser.MacFileChooserDialog; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.mac.foundation.Foundation; @@ -99,6 +100,11 @@ public class MacFileChooserDialogImpl implements MacFileChooserDialog { if (Foundation.isClassRespondsToSelector(Foundation.getClass("NSOpenPanel"), Foundation.createSelector("_setIncludeNewFolderButton:"))) { invoke(chooser, "_setIncludeNewFolderButton:", true); } + if (Registry.is("ide.mac.filechooser.showhidden.files")) { + if (Foundation.isClassRespondsToSelector(Foundation.getClass("NSOpenPanel"), Foundation.createSelector("setShowsHiddenFiles:"))) { + invoke(chooser, "setShowsHiddenFiles:", true); + } + } invoke(chooser, "setDelegate:", self); diff --git a/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java b/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java index d792a353759e..bb45302c876b 100644 --- a/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java +++ b/platform/platform-impl/testSrc/com/intellij/openapi/execution/ParametersListTest.java @@ -16,14 +16,17 @@ package com.intellij.openapi.execution; import com.intellij.execution.configurations.ParametersList; -import com.intellij.util.Assertion; +import com.intellij.execution.configurations.ParamsGroup; +import com.intellij.testFramework.UsefulTestCase; import com.intellij.util.ArrayUtil; -import junit.framework.TestCase; +import com.intellij.util.Assertion; + +import java.util.Collections; /** * @author dyoma */ -public class ParametersListTest extends TestCase { +public class ParametersListTest extends UsefulTestCase { private final Assertion CHECK = new Assertion(); public void testAddParametersString() { @@ -41,4 +44,127 @@ public class ParametersListTest extends TestCase { String[] strings = ArrayUtil.toStringArray(params.getList()); CHECK.compareAll(expected, strings); } + + public void testParamsGroup_Empty() { + ParametersList params = new ParametersList(); + + assertEquals(0, params.getParamsGroupsCount()); + assertTrue(params.getParamsGroups().isEmpty()); + } + + public void testParamsGroup_Add() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + assertEquals("id1", group1.getId()); + assertEquals(1, params.getParamsGroupsCount()); + assertSameElements(Collections.singletonList(group1), params.getParamsGroups()); + + final ParamsGroup group2 = params.addParamsGroup("id2"); + assertEquals("id2", group2.getId()); + assertEquals(2, params.getParamsGroupsCount()); + assertOrderedEquals(params.getParamsGroups(), group1, group2); + } + + public void testParamsGroup_AddAt() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + final ParamsGroup group2 = params.addParamsGroup("id2"); + + final ParamsGroup group12 = params.addParamsGroupAt(1, "id12"); + final ParamsGroup group01 = params.addParamsGroupAt(0, "id01"); + + assertOrderedEquals(params.getParamsGroups(), group01, group1, group12, group2); + } + + public void testParamsGroup_Remove() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + final ParamsGroup group2 = params.addParamsGroup("id2"); + final ParamsGroup group3 = params.addParamsGroup("id3"); + final ParamsGroup group4 = params.addParamsGroup("id4"); + + params.removeParamsGroup(0); + assertOrderedEquals(params.getParamsGroups(), group2, group3, group4); + + params.removeParamsGroup(1); + assertOrderedEquals(params.getParamsGroups(), group2, group4); + } + + public void testParamsGroup_GroupParams() { + ParametersList params = new ParametersList(); + params.add("param1"); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + group1.addParameter("group1_param1"); + + params.add("param2"); + group1.addParameter("group1_param2"); + + + final ParamsGroup group2 = params.addParamsGroup("id2"); + group2.addParameter("group2_param1"); + + params.add("param3"); + + assertOrderedEquals(params.getParameters(), "param1", "param2", "param3"); + assertOrderedEquals(params.getList(), "param1", "param2", "param3", "group1_param1", "group1_param2", "group2_param1"); + assertOrderedEquals(params.getArray(), "param1", "param2", "param3", "group1_param1", "group1_param2", "group2_param1"); + assertEquals("param1 param2 param3 group1_param1 group1_param2 group2_param1", params.getParametersString().trim()); + + final ParametersList group1_params = group1.getParametersList(); + assertOrderedEquals(group1_params.getParameters(), "group1_param1", "group1_param2"); + assertOrderedEquals(group1_params.getList(), "group1_param1", "group1_param2"); + assertOrderedEquals(group1_params.getArray(), "group1_param1", "group1_param2"); + assertEquals("group1_param1 group1_param2", group1_params.getParametersString().trim()); + + final ParametersList group2_params = group2.getParametersList(); + assertOrderedEquals(group2_params.getParameters(), "group2_param1"); + assertOrderedEquals(group2_params.getList(), "group2_param1"); + assertOrderedEquals(group2_params.getArray(), "group2_param1"); + assertEquals("group2_param1", group2_params.getParametersString().trim()); + } + + public void testParamsGroup_SubGroups() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + group1.addParameter("group1_param1"); + group1.addParameter("group1_param2"); + + final ParamsGroup group2 = params.addParamsGroup("id2"); + group2.addParameter("group2_param1"); + + final ParamsGroup group1_1 = group1.getParametersList().addParamsGroup("id1_1"); + group1_1.addParameter("group1_1_param1"); + + final ParamsGroup group1_2 = group1.getParametersList().addParamsGroup("id1_2"); + group1_2.addParameter("group1_2_param1"); + + assertOrderedEquals(params.getList(), "group1_param1", "group1_param2", "group1_1_param1", "group1_2_param1", "group2_param1"); + assertOrderedEquals(params.getList(), "group1_param1", "group1_param2", "group1_1_param1", "group1_2_param1", "group2_param1"); + assertEquals("group1_param1 group1_param2 group1_1_param1 group1_2_param1 group2_param1", params.getParametersString().trim()); + } + + public void testParamsGroup_Clone() { + ParametersList params = new ParametersList(); + + final ParamsGroup group1 = params.addParamsGroup("id1"); + group1.addParameter("group1_param1"); + final ParamsGroup group2 = params.addParamsGroup("id2"); + group2.addParameter("group2_param1"); + final ParamsGroup group3 = params.addParamsGroup("id3"); + group3.addParameter("group3_param1"); + + final ParametersList params_clone = params.clone(); + + // let's change original params group + params.removeParamsGroup(0); + group2.addParameter("group2_param2"); + + assertEquals("group2_param1 group2_param2 group3_param1", params.getParametersString().trim()); + assertEquals("group1_param1 group2_param1 group3_param1", params_clone.getParametersString().trim()); + } } diff --git a/platform/platform-resources-en/src/messages/ActionsBundle.properties b/platform/platform-resources-en/src/messages/ActionsBundle.properties index 9000f6fe48b2..527d5e8b0da8 100644 --- a/platform/platform-resources-en/src/messages/ActionsBundle.properties +++ b/platform/platform-resources-en/src/messages/ActionsBundle.properties @@ -496,8 +496,8 @@ action.InvertBoolean.text=Invert _Boolean... action.InvertBoolean.description=Makes the method return or variable contain the opposite value and corrects the references action.IntroduceParameterObject.text=Introduce Parameter Ob_ject... action.IntroduceParameterObject.description=Replaces method parameters list with object -action.ExtractClass.text=E_xtract Class... -action.ExtractClass.description=Extract Class +action.ExtractClass.text=E_xtract Delegate... +action.ExtractClass.description=Extract Delegate action.IntroduceVariable.text=Introduce _Variable... action.IntroduceVariable.description=Put a result of the selected expression into a variable action.IntroduceField.text=Introduce _Field... diff --git a/platform/platform-resources-en/src/messages/RefactoringBundle.properties b/platform/platform-resources-en/src/messages/RefactoringBundle.properties index 69c2d469036d..031d2b333c23 100644 --- a/platform/platform-resources-en/src/messages/RefactoringBundle.properties +++ b/platform/platform-resources-en/src/messages/RefactoringBundle.properties @@ -452,11 +452,10 @@ instances.upcasted.to.object=Instances upcasted to Object instances.upcasted.to.java.lang.object.found=Instances upcasted to java.lang.Object found replace.inheritance.with.delegation.command=Replacing inheritance with delegation in {0} replace.inheritance.with.delegation.elements.header=Replace inheritance with delegation +# Inline included file inline.included.file.title=Inline included file -the.caret.should.be.positioned.on.the.include.directive.to.inline=The caret should be positioned on the include directive to inline -cannot.determine.the.structure.of.included.file=Cannot determine the structure of included file. -included.file.uses.another.syntax=Included file uses another syntax. -cannot.resolve.included.file=Cannot resolve included file +the.caret.should.be.positioned.on.the.included.file.to.inline=The caret should be positioned on the included file reference to inline + inline.the.contents.include.prompt=Inline the contents of ''{0}''? remove.include.prompt=Included file is no longer used. Remove it? delete.include.command=Delete {0} diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 1d5704c563e6..7671ea69a6c3 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -62,6 +62,7 @@ ide.splitter.mouseZone=6 ide.tabbedPane.bufferedPaint=true ide.use.native.mac.filechooser=false +ide.mac.filechooser.showhidden.files=false debugger.valueTooltipAutoShow=true debugger.valueTooltipAutoShow.description=Auto show tooltip on mouse over diff --git a/platform/platform-resources/src/DefaultColorSchemesManager.xml b/platform/platform-resources/src/DefaultColorSchemesManager.xml index df7b3a0e20cf..c9c317cbce69 100644 --- a/platform/platform-resources/src/DefaultColorSchemesManager.xml +++ b/platform/platform-resources/src/DefaultColorSchemesManager.xml @@ -284,7 +284,7 @@ @@ -293,7 +293,7 @@ @@ -302,7 +302,7 @@ diff --git a/resources/src/idea/XmlActions.xml b/platform/platform-resources/src/META-INF/XmlActions.xml similarity index 97% rename from resources/src/idea/XmlActions.xml rename to platform/platform-resources/src/META-INF/XmlActions.xml index 56dc5c8e9b04..243c6ea3713c 100644 --- a/resources/src/idea/XmlActions.xml +++ b/platform/platform-resources/src/META-INF/XmlActions.xml @@ -25,7 +25,6 @@ - + diff --git a/platform/usageView/src/com/intellij/usages/TextChunk.java b/platform/usageView/src/com/intellij/usages/TextChunk.java index 3888ddae0f8b..bc2cabcef047 100644 --- a/platform/usageView/src/com/intellij/usages/TextChunk.java +++ b/platform/usageView/src/com/intellij/usages/TextChunk.java @@ -23,7 +23,7 @@ public class TextChunk { private final AttributesFlyweight myAttributes; private final String myText; - public TextChunk(TextAttributes attributesKey, @NotNull String text) { + public TextChunk(@NotNull TextAttributes attributesKey, @NotNull String text) { myAttributes = attributesKey.getFlyweight(); myText = text; } diff --git a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java index 7d10f844cf4b..d7bc0a6acb7a 100644 --- a/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java +++ b/platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java @@ -24,6 +24,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.RangeMarker; +import com.intellij.openapi.editor.markup.TextAttributes; import com.intellij.openapi.fileEditor.*; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; @@ -91,7 +92,7 @@ public class UsageInfo2UsageAdapter implements UsageInModule, UsageInLibrary, Us initChunks(); } else { // element over light virtual file myTextChunks = new TextChunk[] { - new TextChunk(null, element.getText()) + new TextChunk(new TextAttributes(), element.getText()) }; myOffset = element.getTextOffset(); } diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 538ec7bc0d67..a62221988df3 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -887,6 +887,11 @@ public class StringUtil { @NotNull public static List split(@NotNull String s, @NotNull String separator) { + return split(s, separator, true); + } + + @NotNull public static List split(@NotNull String s, @NotNull String separator, + boolean excludeSeparator) { if (separator.length() == 0) { return Collections.singletonList(s); } @@ -895,11 +900,12 @@ public class StringUtil { while (true) { int index = s.indexOf(separator, pos); if (index == -1) break; - String token = s.substring(pos, index); + final int nextPos = index + separator.length(); + String token = s.substring(pos, excludeSeparator ? index : nextPos); if (token.length() != 0) { result.add(token); } - pos = index + separator.length(); + pos = nextPos; } if (pos < s.length()) { result.add(s.substring(pos, s.length())); diff --git a/platform/util/src/com/intellij/util/concurrency/FutureResult.java b/platform/util/src/com/intellij/util/concurrency/FutureResult.java index b6172f59b96f..356ec5845238 100644 --- a/platform/util/src/com/intellij/util/concurrency/FutureResult.java +++ b/platform/util/src/com/intellij/util/concurrency/FutureResult.java @@ -19,12 +19,12 @@ public class FutureResult implements Future { } public boolean isDone() { - return mySema.availablePermits() > 0; + return myValue != null; } public void set(T result) { assert myValue == null; - + myValue = Ref.create(Pair.create((Object)result, true)); mySema.release(); } @@ -37,8 +37,8 @@ public class FutureResult implements Future { } public T get() throws InterruptedException, ExecutionException { + mySema.acquire(); try { - mySema.acquire(); return doGet(); } finally { @@ -47,8 +47,8 @@ public class FutureResult implements Future { } public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { + if (!mySema.tryAcquire(timeout, unit)) throw new TimeoutException(); try { - if (!mySema.tryAcquire(timeout, unit)) throw new TimeoutException(); return doGet(); } finally { diff --git a/platform/util/src/com/intellij/util/io/PersistentHashMap.java b/platform/util/src/com/intellij/util/io/PersistentHashMap.java index b5f0aa509f79..8cf3e40ed56c 100644 --- a/platform/util/src/com/intellij/util/io/PersistentHashMap.java +++ b/platform/util/src/com/intellij/util/io/PersistentHashMap.java @@ -32,7 +32,7 @@ import java.util.Collection; */ public class PersistentHashMap extends PersistentEnumerator{ private static final Logger LOG = Logger.getInstance("#com.intellij.util.io.PersistentHashMap"); - + private static final int APPEND_CACHE_DATA_THRESHOLD = 20 * 1024 * 1024; // 20 MB private PersistentHashMapValueStorage myValueStorage; private final DataExternalizer myValueExternalizer; private static final long NULL_ADDR = 0; @@ -50,6 +50,10 @@ public class PersistentHashMap extends PersistentEnumerator{ super(new ByteArrayOutputStream()); } + public int getBufferSize() { + return ((ByteArrayOutputStream)out).size(); + } + public void writeTo(OutputStream stream) throws IOException { ((ByteArrayOutputStream)out).writeTo(stream); } @@ -63,6 +67,8 @@ public class PersistentHashMap extends PersistentEnumerator{ } } + private int myBytesInMemoryCount = 0; + private final LimitedPool myStreamPool = new LimitedPool(10, new LimitedPool.ObjectFactory() { public AppendStream create() { return new AppendStream(); @@ -92,6 +98,8 @@ public class PersistentHashMap extends PersistentEnumerator{ updateValueId(id, headerRecord); myStreamPool.recycle(value); + + myBytesInMemoryCount -= bytes.length; } catch (IOException e) { throw new RuntimeException(e); @@ -187,7 +195,18 @@ public class PersistentHashMap extends PersistentEnumerator{ public synchronized void appendData(Key key, ValueDataAppender appender) throws IOException { synchronized (ourLock) { markDirty(true); - appender.append(myAppendCache.get(key)); + + final AppendStream stream = myAppendCache.get(key); + final int sizeBefore = stream.getBufferSize(); + appender.append(stream); + myBytesInMemoryCount += (stream.getBufferSize() - sizeBefore); + + if (myBytesInMemoryCount > APPEND_CACHE_DATA_THRESHOLD) { + LOG.warn( + "PersistentHashMap: OVER " + APPEND_CACHE_DATA_THRESHOLD + " BYTES IN APPEND STREAM CACHE, FORCING CACHE FLUSH (not optimal serialization format?) File: " + getDataFile(myFile).getPath() + ); + myAppendCache.clear(); + } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java index 658bd0752582..adcd39b5dac4 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java @@ -210,7 +210,8 @@ public class LineStatusTracker { private static void paintGutterFragment(Editor editor, Graphics g, Rectangle r, TextAttributesKey diffAttributeKey) { EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx(); - g.setColor(editor.getColorsScheme().getAttributes(diffAttributeKey).getErrorStripeColor()); + final Color stripeColor = editor.getColorsScheme().getAttributes(diffAttributeKey).getErrorStripeColor(); + g.setColor(stripeColor); int endX = gutter.getWhitespaceSeparatorOffset(); int x = r.x + r.width - 2; int width = endX - x; diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java index 4a24013a7074..f924a5fb70a4 100644 --- a/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java +++ b/platform/xdebugger-api/src/com/intellij/xdebugger/XDebugSession.java @@ -16,6 +16,7 @@ package com.intellij.xdebugger; +import com.intellij.execution.ExecutionException; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.configurations.RunProfile; import com.intellij.openapi.project.Project; @@ -113,6 +114,7 @@ public interface XDebugSession extends AbstractDebuggerSession { void addSessionListener(@NotNull XDebugSessionListener listener); void removeSessionListener(@NotNull XDebugSessionListener listener); + void reportError(String message); @NotNull String getSessionName(); diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java index 2384d409f96d..b2ebacdc00b9 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/XDebugSessionImpl.java @@ -20,6 +20,7 @@ import com.intellij.execution.filters.HyperlinkInfo; import com.intellij.execution.filters.OpenFileHyperlinkInfo; import com.intellij.execution.process.ProcessHandler; import com.intellij.execution.runners.ExecutionEnvironment; +import com.intellij.execution.runners.ExecutionUtil; import com.intellij.execution.runners.ProgramRunner; import com.intellij.execution.ui.ConsoleView; import com.intellij.execution.ui.ConsoleViewContentType; @@ -28,8 +29,11 @@ import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.application.Result; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.MessageType; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.wm.ToolWindowId; +import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.util.EventDispatcher; import com.intellij.util.ui.UIUtil; import com.intellij.xdebugger.*; @@ -536,6 +540,16 @@ public class XDebugSessionImpl implements XDebugSession { } } + @Override + public void reportError(final String message) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + @Override + public void run() { + ToolWindowManager.getInstance(myProject).notifyByBalloon(ToolWindowId.DEBUG, MessageType.ERROR, message, null, null); + } + }); + } + private class MyBreakpointListener implements XBreakpointListener> { public void breakpointAdded(@NotNull final XBreakpoint breakpoint) { if (!myBreakpointsDisabled) { diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java index 043ea018f324..7d825378e8a5 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/bugs/ThrowableInstanceNeverThrownInspection.java @@ -83,6 +83,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { } else if (parent instanceof PsiReturnStatement) { return; } + if (PsiTreeUtil.getParentOfType(parent, PsiCallExpression.class) != null) return; final PsiElement typedParent = PsiTreeUtil.getParentOfType(expression, PsiAssignmentExpression.class, @@ -129,6 +130,7 @@ public class ThrowableInstanceNeverThrownInspection extends BaseInspection { } else if (usageParent instanceof PsiReturnStatement) { return; } + if (PsiTreeUtil.getParentOfType(usageParent, PsiCallExpression.class) != null) return; } } registerError(expression, expression); diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java index b6445f7bf1da..f87fa95e2cae 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/ThrowableInstanceNeverThrown.java @@ -1,5 +1,8 @@ package com.siyeh.igtest.bugs.throwable_instance_never_thrown; +import java.io.IOException; +import java.util.*; + public class ThrowableInstanceNeverThrown { void foo() throws Exception { @@ -30,4 +33,14 @@ public class ThrowableInstanceNeverThrown { void leftBehind() throws Throwable { final RuntimeException e = new RuntimeException("throw me"); } + + void exceptionIsCollected() { + List exs = new ArrayList(); + exs.add(new IOException()); + IOException io2 = new IOException(); + exs.add(io2); + methodCall(io2); + } + + void methodCall(IOException e){} } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml index 0c197b2f6208..9dfb5295b08f 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/bugs/throwable_instance_never_thrown/expected.xml @@ -3,14 +3,14 @@ ThrowableInstanceNeverThrown.java - 14 + 17 Throwable instance not thrown Runtime exception instance <code>new RuntimeException()</code> is not thrown ThrowableInstanceNeverThrown.java - 31 + 34 Throwable instance not thrown Runtime exception instance <code>new RuntimeException("throw me")</code> is not thrown diff --git a/plugins/IntelliLang/src/META-INF/plugin.xml b/plugins/IntelliLang/src/META-INF/plugin.xml index a03cb883b532..086bf2d42211 100644 --- a/plugins/IntelliLang/src/META-INF/plugin.xml +++ b/plugins/IntelliLang/src/META-INF/plugin.xml @@ -20,20 +20,20 @@ org.intellij.plugins.intelliLang.inject.InjectLanguageAction - Language Injections + Language Injection org.intellij.plugins.intelliLang.inject.UnInjectLanguageAction - + Language Injection org.intellij.plugins.intelliLang.inject.EditInjectionSettingsAction - + Language Injection org.intellij.plugins.intelliLang.inject.quickedit.QuickEditAction - + Language Injection diff --git a/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/after.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/after.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/before.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/before.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/description.html new file mode 100644 index 000000000000..20ae1483ef3c --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/EditInjectionSettingsAction/description.html @@ -0,0 +1,5 @@ + + +Opens language injection settings if available. + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template index caf04b69bf78..391250caa0ad 100644 --- a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template +++ b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/after.java.template @@ -1,7 +1 @@ -class XmlConstants { - String ROOT_TAG = ""; - - void foo(){ - "".replaceAll("[^a-b]", ""); - } -} +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template index 2744467fdd71..391250caa0ad 100644 --- a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template +++ b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/before.java.template @@ -1,3 +1 @@ -class XmlConstants { - String ROOT_TAG = ""; -} +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html index e69de29bb2d1..44a47d111940 100644 --- a/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html +++ b/plugins/IntelliLang/src/intentionDescriptions/InjectLanguageAction/description.html @@ -0,0 +1,5 @@ + + +Injects language into text-holding program element (string literal, XML attribute and tag body, etc.). + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/after.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/after.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/before.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/before.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/description.html new file mode 100644 index 000000000000..0fd0a0873b88 --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/QuickEditAction/description.html @@ -0,0 +1,5 @@ + + +Edit injected fragment in a designated editor without outer language escaping and concatenations. + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/after.java.template b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/after.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/after.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/before.java.template b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/before.java.template new file mode 100644 index 000000000000..391250caa0ad --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/before.java.template @@ -0,0 +1 @@ +XXX \ No newline at end of file diff --git a/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/description.html b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/description.html new file mode 100644 index 000000000000..b1f57e463b65 --- /dev/null +++ b/plugins/IntelliLang/src/intentionDescriptions/UnInjectLanguageAction/description.html @@ -0,0 +1,5 @@ + + +Removes language injection if it is configurable. + + \ No newline at end of file diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java index f2d400ad9bae..2c8426d2c4b2 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/EditInjectionSettingsAction.java @@ -53,7 +53,7 @@ public class EditInjectionSettingsAction implements IntentionAction { @NotNull public String getFamilyName() { - return InjectLanguageAction.INJECT_LANGUAGE_FAMILY; + return "Edit Injection Settings"; } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java index 63f609448bc8..36b012b60073 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java @@ -51,7 +51,7 @@ import java.util.Collections; import java.util.List; public class InjectLanguageAction implements IntentionAction { - @NonNls protected static final String INJECT_LANGUAGE_FAMILY = "Inject Language"; + @NonNls private static final String INJECT_LANGUAGE_FAMILY = "Inject Language"; @NotNull public String getText() { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java index 4847d2c0fe73..80555e8de3c6 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/UnInjectLanguageAction.java @@ -50,7 +50,7 @@ public class UnInjectLanguageAction implements IntentionAction { @NotNull public String getFamilyName() { - return InjectLanguageAction.INJECT_LANGUAGE_FAMILY; + return getText(); } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java index c94135fc6765..d5043ac80a32 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/quickedit/QuickEditAction.java @@ -89,7 +89,7 @@ public class QuickEditAction implements IntentionAction { @NotNull public String getFamilyName() { - return "Quick Edit"; + return "Edit Injected Fragment"; } public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { diff --git a/plugins/cvs/cvs-core/cvs-core.iml b/plugins/cvs/cvs-core/cvs-core.iml index 53189febbd11..f170b4099106 100644 --- a/plugins/cvs/cvs-core/cvs-core.iml +++ b/plugins/cvs/cvs-core/cvs-core.iml @@ -15,7 +15,6 @@ - diff --git a/plugins/eclipse/testData/iml/allProps/expected/expected.iml b/plugins/eclipse/testData/iml/allProps/expected/expected.iml index e859b2f34993..03ebc91eb508 100644 --- a/plugins/eclipse/testData/iml/allProps/expected/expected.iml +++ b/plugins/eclipse/testData/iml/allProps/expected/expected.iml @@ -94,8 +94,6 @@ - - @@ -103,8 +101,6 @@ - - diff --git a/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml b/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml index 739c0f9ea674..6043d6eda204 100644 --- a/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml +++ b/plugins/eclipse/testData/iml/emptySrc/expected/expected.iml @@ -12,7 +12,6 @@ - diff --git a/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml b/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml index 0eced5ed6f50..24c383002455 100644 --- a/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml +++ b/plugins/eclipse/testData/iml/resolvedVariables/expected/expected.iml @@ -12,7 +12,6 @@ - @@ -23,7 +22,6 @@ - diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml index aa21265058b8..5fa1b17970c1 100644 --- a/plugins/git4idea/git4idea.iml +++ b/plugins/git4idea/git4idea.iml @@ -16,7 +16,6 @@ - diff --git a/plugins/groovy/jetgroovy.iml b/plugins/groovy/jetgroovy.iml index 3b210de157c4..3ead47ab4a1e 100644 --- a/plugins/groovy/jetgroovy.iml +++ b/plugins/groovy/jetgroovy.iml @@ -26,8 +26,6 @@ - - diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template new file mode 100644 index 000000000000..221308e2c833 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/after.groovy.template @@ -0,0 +1 @@ +def objects = [foo, bar] \ No newline at end of file diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template new file mode 100644 index 000000000000..9944d004075f --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/before.groovy.template @@ -0,0 +1 @@ +def objects = new Object[] {foo, bar} diff --git a/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html new file mode 100644 index 000000000000..a57eb1cb3c81 --- /dev/null +++ b/plugins/groovy/resources/intentionDescriptions/ConvertJavaStyleArrayCreationIntention/description.html @@ -0,0 +1,7 @@ + + + +This intention converts java-style array creation to groovy syntax. + + + diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index 0418c136e6bf..1eedae80b8bd 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -375,6 +375,11 @@ --> + + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle + intention.category.groovy/intention.category.conversions + org.jetbrains.plugins.groovy.intentions.conversions.ConvertJavaStyleArrayCreationIntention + org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle intention.category.groovy/intention.category.conversions diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java index b9a747629595..d4f37ff3cdcb 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java @@ -17,7 +17,7 @@ package org.jetbrains.plugins.groovy.actions; import com.intellij.ide.actions.CreateFileFromTemplateDialog; -import com.intellij.ide.actions.CreateTemplateInPackageAction; +import com.intellij.ide.actions.JavaCreateTemplateInPackageAction; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataKeys; import com.intellij.openapi.project.DumbAware; @@ -32,7 +32,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.util.LibrariesUtil; -public class NewGroovyClassAction extends CreateTemplateInPackageAction implements DumbAware { +public class NewGroovyClassAction extends JavaCreateTemplateInPackageAction implements DumbAware { public NewGroovyClassAction() { super(GroovyBundle.message("newclass.menu.action.text"), GroovyBundle.message("newclass.menu.action.description"), GroovyIcons.CLASS, true); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java index 3d5a251ba14c..c63c8a664c12 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java @@ -17,7 +17,7 @@ package org.jetbrains.plugins.groovy.actions; import com.intellij.ide.actions.CreateFileFromTemplateDialog; -import com.intellij.ide.actions.CreateTemplateInPackageAction; +import com.intellij.ide.actions.JavaCreateTemplateInPackageAction; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataKeys; import com.intellij.openapi.project.DumbAware; @@ -33,7 +33,7 @@ import org.jetbrains.plugins.groovy.GroovyIcons; import org.jetbrains.plugins.groovy.lang.psi.GroovyFile; import org.jetbrains.plugins.groovy.util.LibrariesUtil; -public class NewScriptAction extends CreateTemplateInPackageAction implements DumbAware { +public class NewScriptAction extends JavaCreateTemplateInPackageAction implements DumbAware { private static final String GROOVY_DSL_SCRIPT_TMPL = "GroovyDslScript.gdsl"; public NewScriptAction() { 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 e9429f30b52e..ef9bbbb5c317 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -283,6 +283,7 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { if (body != null) checkDuplicateMethod(body.getGroovyMethods(), myHolder); checkImplementedMethodsOfClass(myHolder, typeDefinition); checkConstructors(myHolder, typeDefinition); + highligtClassReference(myHolder, typeDefinition.getNameIdentifierGroovy()); } private static void checkConstructors(AnnotationHolder holder, GrTypeDefinition typeDefinition) { @@ -1296,6 +1297,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { if (member instanceof PsiMethod) { annotation.setTextAttributes(!isStatic ? DefaultHighlighter.METHOD_CALL : DefaultHighlighter.STATIC_METHOD_ACCESS); } + if (member instanceof PsiClass) { + highligtClassReference(holder, refExpr); + } } @@ -1536,16 +1540,24 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator { private static void highlightAnnotation(AnnotationHolder holder, PsiElement refElement, GroovyResolveResult result) { PsiElement element = result.getElement(); PsiElement parent = refElement.getParent(); - if (element instanceof PsiClass && ((PsiClass)element).isAnnotationType() && !(parent instanceof GrImportStatement)) { - Annotation annotation = holder.createInfoAnnotation(parent, null); - annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); - GroovyPsiElement context = result.getCurrentFileResolveContext(); - if (context instanceof GrImportStatement) { - annotation = holder.createInfoAnnotation(((GrImportStatement)context).getImportReference(), null); + if (element instanceof PsiClass) { + if (((PsiClass)element).isAnnotationType() && !(parent instanceof GrImportStatement)) { + Annotation annotation = holder.createInfoAnnotation(parent, null); annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); + GroovyPsiElement context = result.getCurrentFileResolveContext(); + if (context instanceof GrImportStatement) { + annotation = holder.createInfoAnnotation(((GrImportStatement)context).getImportReference(), null); + annotation.setTextAttributes(DefaultHighlighter.ANNOTATION); + } + } else { + highligtClassReference(holder, refElement); } } + } + private static void highligtClassReference(AnnotationHolder holder, PsiElement classReference) { + final Annotation annotation = holder.createInfoAnnotation(classReference, null); + annotation.setTextAttributes(DefaultHighlighter.CLASS_REFERENCE); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java index a924b235f92a..a3b5dd8321e9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/DefaultHighlighter.java @@ -70,6 +70,8 @@ public class DefaultHighlighter { static final String METHOD_CALL_ID = "Method call"; @NonNls static final String STATIC_METHOD_ACCESS_ID = "Static method access"; + @NonNls + static final String CLASS_REFERENCE_ID = "Class"; @NonNls @@ -103,6 +105,9 @@ public class DefaultHighlighter { public static TextAttributesKey DOC_COMMENT_TAG = TextAttributesKey.createTextAttributesKey(DOC_COMMENT_TAG_ID, SyntaxHighlighterColors.DOC_COMMENT_TAG.getDefaultAttributes()); + public static TextAttributesKey CLASS_REFERENCE = + TextAttributesKey.createTextAttributesKey(CLASS_REFERENCE_ID, HighlighterColors.TEXT.getDefaultAttributes().clone()); + public static final TextAttributes KEYWORD_ATTRIBUTES = SyntaxHighlighterColors.KEYWORD.getDefaultAttributes().clone(); static{ diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java index d19624f62087..e9bab50b59a5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/highlighter/GroovyColorsAndFontsPage.java @@ -67,7 +67,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { new AttributesDescriptor(DefaultHighlighter.ANNOTATION_ID, DefaultHighlighter.ANNOTATION), new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.STATIC_FIELD), new AttributesDescriptor(DefaultHighlighter.STATIC_FIELD_ID, DefaultHighlighter.INSTANCE_FIELD), - new AttributesDescriptor(DefaultHighlighter.STATIC_METHOD_ACCESS_ID, DefaultHighlighter.STATIC_METHOD_ACCESS), + new AttributesDescriptor(DefaultHighlighter.CLASS_REFERENCE_ID, DefaultHighlighter.CLASS_REFERENCE), }; @NotNull @@ -83,23 +83,23 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { @NonNls @NotNull public String getDemoText() { - return "import javax.swing.JPanel\n" + + return "import javax.swing.JPanel\n" + " ### \n" + "/**\n" + " * This is Groovydoc comment\n" + - " * @see java.lang.String#equals\n" + + " * @see java.lang.String#equals\n" + " */\n" + "@SpecialBean \n" + - "class Demo {\n" + + "class Demo {\n" + " def property\n" + "//This is a line comment\n" + "/* This is a block comment */\n" + " static def foo(int i) { return [i, i, property] }\n" + - " static def panel = new JPanel()\n" + + " static def panel = new JPanel()\n" + "}\n" + "\n" + - "Demo.panel.size = " + - "Demo.foo(\"123${456}789\".toInteger()) \n" + + "Demo.panel.size = " + + "Demo.foo(\"123${456}789\".toInteger()) \n" + "'JetBrains'.matches(/Jw+Bw+/) \n" + "def x=1 + unresolved" ; @@ -115,6 +115,7 @@ public class GroovyColorsAndFontsPage implements ColorSettingsPage { map.put("gdoc", DefaultHighlighter.DOC_COMMENT_CONTENT); map.put("doctag", DefaultHighlighter.DOC_COMMENT_TAG); map.put("unresolved", DefaultHighlighter.UNRESOLVED_ACCESS); + map.put("classref", DefaultHighlighter.CLASS_REFERENCE); return map; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties index 113f31b0d971..beb7dffac824 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties @@ -82,4 +82,7 @@ do.not.create.first.new=Use &existing first parameter as map for named arguments convert.cannot.itself=Refactoring is not available for map parameter itself perform.refactoring=Performing refactoring map.param.name=Map parameter &name: -convert.param.to.map.entry=Convert parameter to map entry \ No newline at end of file +convert.param.to.map.entry=Convert parameter to map entry + +convert.java.style.array.creation.intention.name=Convert java-style array creation +convert.java.style.array.creation.intention.family.name=Convert Java-Style Array Creation to Groovy Syntax \ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java new file mode 100644 index 000000000000..a2c6052d879e --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertJavaStyleArrayCreationIntention.java @@ -0,0 +1,65 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.plugins.groovy.intentions.conversions; + +import com.intellij.psi.PsiElement; +import com.intellij.util.IncorrectOperationException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.intentions.base.Intention; +import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock; +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.path.GrMethodCallExpression; + +/** + * @author Maxim.Medvedev + */ +public class ConvertJavaStyleArrayCreationIntention extends Intention { + @Override + protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { + final GrClosableBlock block = ((GrMethodCallExpression)element).getClosureArguments()[0]; + final String text = block.getText(); + int start = block.getLBrace().getStartOffsetInParent() + 1; + int finish = block.getRBrace().getStartOffsetInParent(); + String newText = "[" + text.substring(start, finish) + "]"; + final GrExpression newExpr = GroovyPsiElementFactory.getInstance(element.getProject()).createExpressionFromText(newText); + ((GrMethodCallExpression)element).replaceWithStatement(newExpr); + } + + @NotNull + @Override + protected PsiElementPredicate getElementPredicate() { + return new PsiElementPredicate() { + @Override + public boolean satisfiedBy(PsiElement element) { + if (!(element instanceof GrMethodCallExpression)) return false; + final GrExpression expression = ((GrMethodCallExpression)element).getInvokedExpression(); + if (!(expression instanceof GrNewExpression)) return false; + if (((GrNewExpression)expression).getArrayCount() == 0) return false; + + if (((GrMethodCallExpression)element).getArgumentList().getText().trim().length() > 0) return false; + + final GrClosableBlock[] closureArguments = ((GrMethodCallExpression)element).getClosureArguments(); + if (closureArguments.length != 1) return false; + final GrClosableBlock block = closureArguments[0]; + if (block.getLBrace() == null || block.getRBrace() == null) return false; + return true; + } + }; + } +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java index 3ce5f8148c7d..494bdb90eb55 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java @@ -185,42 +185,53 @@ public class ConvertParameterToMapEntryIntention extends Intention { //final List calls = getCallOccurrences(occurrences); try { for (PsiElement occurrence : occurrences) { - if (occurrence instanceof GrReferenceExpression && occurrence.getParent() instanceof GrCall) { - final GrReferenceExpression refExpr = (GrReferenceExpression)occurrence; - final GrClosureSignature signature = generateSignature(owner, refExpr); - if (signature == null) continue; - final GrCall call = (GrCall)refExpr.getParent(); - final GrArgumentList argumentList = call.getArgumentList(); - final GrClosableBlock[] closureArguments = - call instanceof GrCallExpression ? ((GrCallExpression)call).getClosureArguments() : GrClosableBlock.EMPTY_ARRAY; - - final GrClosureSignatureUtil.ArgInfo[] argInfos = - GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, closureArguments, owner.getResolveScope()); - if (argInfos == null) continue; - final GrClosureSignatureUtil.ArgInfo argInfo = argInfos[index]; - - final GrNamedArgument namedArg; - if (argInfo.isMultiArg) { - if (argInfo.args.size() == 0) continue; - String arg = "[" + StringUtil.join(ContainerUtil.map(argInfo.args, new Function() { - public String fun(PsiElement element) { - return element.getText(); - } - }), ", ") + "]"; - for (PsiElement psiElement : argInfo.args) { - psiElement.delete(); + GrReferenceExpression refExpr = null; + if (occurrence instanceof GrReferenceExpression) { + final PsiElement parent = occurrence.getParent(); + if (parent instanceof GrCall) { + refExpr = (GrReferenceExpression)occurrence; + } + else if (parent instanceof GrReferenceExpression) { + final PsiElement resolved = ((GrReferenceExpression)parent).resolve(); + if (resolved instanceof PsiMethod && "call".equals(((PsiMethod)resolved).getName())) { + refExpr = (GrReferenceExpression)parent; } - namedArg = factory.createNamedArgument(paramName, factory.createExpressionFromText(arg)); } - else { - if (argInfo.args.size() == 0) continue; - final PsiElement argument = argInfo.args.iterator().next(); - assert argument instanceof GrExpression; - namedArg = factory.createNamedArgument(paramName, (GrExpression)argument); - argument.delete(); - } - ((GrCall)refExpr.getParent()).addNamedArgument(namedArg); } + if (refExpr == null) continue; + final GrClosureSignature signature = generateSignature(owner, refExpr); + if (signature == null) continue; + final GrCall call = (GrCall)refExpr.getParent(); + final GrArgumentList argumentList = call.getArgumentList(); + final GrClosableBlock[] closureArguments = + call instanceof GrCallExpression ? ((GrCallExpression)call).getClosureArguments() : GrClosableBlock.EMPTY_ARRAY; + + final GrClosureSignatureUtil.ArgInfo[] argInfos = + GrClosureSignatureUtil.mapParametersToArguments(signature, argumentList, closureArguments, owner.getResolveScope()); + if (argInfos == null) continue; + final GrClosureSignatureUtil.ArgInfo argInfo = argInfos[index]; + + final GrNamedArgument namedArg; + if (argInfo.isMultiArg) { + if (argInfo.args.size() == 0) continue; + String arg = "[" + StringUtil.join(ContainerUtil.map(argInfo.args, new Function() { + public String fun(PsiElement element) { + return element.getText(); + } + }), ", ") + "]"; + for (PsiElement psiElement : argInfo.args) { + psiElement.delete(); + } + namedArg = factory.createNamedArgument(paramName, factory.createExpressionFromText(arg)); + } + else { + if (argInfo.args.size() == 0) continue; + final PsiElement argument = argInfo.args.iterator().next(); + assert argument instanceof GrExpression; + namedArg = factory.createNamedArgument(paramName, (GrExpression)argument); + argument.delete(); + } + ((GrCall)refExpr.getParent()).addNamedArgument(namedArg); } } catch (IncorrectOperationException e) { @@ -369,10 +380,8 @@ public class ConvertParameterToMapEntryIntention extends Intention { final PsiElement namedElem = getReferencedElement(owner); if (namedElem == null) return true; final Ref result = new Ref(true); - final Task task = new Task.Modal(project, GroovyIntentionsBundle.message("find.method.ro.closure.usages.0", - owner instanceof GrClosableBlock - ? CLOSURE_CAPTION - : METHOD_CAPTION), true) { + final Task task = new Task.Modal(project, GroovyIntentionsBundle + .message("find.method.ro.closure.usages.0", owner instanceof GrClosableBlock ? CLOSURE_CAPTION : METHOD_CAPTION), true) { public void run(@NotNull final ProgressIndicator indicator) { final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject()); final Query query = ReferencesSearch.search(namedElem, projectScope); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java index c2f07fe0df08..23a3fd0794f6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java @@ -227,38 +227,11 @@ public class PsiImplUtil { } public static void setName(String name, PsiElement nameElement) { - ASTNode node = nameElement.getNode(); - ASTNode newNameNode = GroovyPsiElementFactory.getInstance(nameElement.getProject()).createReferenceNameFromText(name).getNode(); - assert newNameNode != null && node != null; - node.getTreeParent().replaceChild(node, newNameNode); + final PsiElement newNameElement = GroovyPsiElementFactory.getInstance(nameElement.getProject()).createReferenceNameFromText(name); + nameElement.replace(newNameElement); } public static boolean isExtendsSignature(MethodSignature superSignatureCandidate, MethodSignature subSignature) { - /*final String name1 = superSignatureCandidate.getName(); - final String name2 = subSignature.getName(); - if (!name1.equals(name2)) return false; - - final PsiType[] superTypes = superSignatureCandidate.getParameterTypes(); - final PsiType[] subTypes = subSignature.getParameterTypes(); - if (subTypes.length != superTypes.length) return false; - for (int i = 0; i < subTypes.length - 1; i++) { - PsiType superType = TypeConversionUtil.erasure(superTypes[i]); - PsiType subType = subTypes[i]; - if (!superType.isAssignableFrom(subType)) return false; - } - - if (superTypes.length > 0) { - final PsiType lastSuperType = TypeConversionUtil.erasure(superTypes[superTypes.length - 1]); - final PsiType lastSubType = subTypes[superTypes.length - 1]; - if (lastSuperType instanceof PsiArrayType && !(lastSubType instanceof PsiArrayType)) { - final PsiType componentType = ((PsiArrayType) lastSuperType).getComponentType(); - if (!lastSubType.isConvertibleFrom(componentType)) return false; - } else { - if (!lastSuperType.isAssignableFrom(lastSubType)) return false; - } - } - - return true;*/ return MethodSignatureUtil.isSubsignature(superSignatureCandidate, subSignature); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java index 68d1dc80d232..b21d9252909f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionImpl.java @@ -138,6 +138,7 @@ public abstract class GrTypeDefinitionImpl extends GroovyBaseElementImplject[] {1, 2, 3} \ No newline at end of file diff --git a/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy new file mode 100644 index 000000000000..2be10eba8fd1 --- /dev/null +++ b/plugins/groovy/testdata/intentions/convertJavaStyleArrayCreation/Conversion_after.groovy @@ -0,0 +1 @@ +def foo = [1, 2, 3] \ No newline at end of file diff --git a/plugins/groovy/testdata/paramToMap/callMethod/A.groovy b/plugins/groovy/testdata/paramToMap/callMethod/A.groovy new file mode 100644 index 000000000000..23d1c8b94211 --- /dev/null +++ b/plugins/groovy/testdata/paramToMap/callMethod/A.groovy @@ -0,0 +1,3 @@ +def clos = { int i -> println(i) } +clos(1) +clos.call(1) \ No newline at end of file diff --git a/plugins/groovy/testdata/paramToMap/callMethod/A.test b/plugins/groovy/testdata/paramToMap/callMethod/A.test new file mode 100644 index 000000000000..0b7f54921e34 --- /dev/null +++ b/plugins/groovy/testdata/paramToMap/callMethod/A.test @@ -0,0 +1,3 @@ +def clos = { Map attrs -> println(attrs.i) } +clos(i: 1) +clos.call(i: 1) diff --git a/plugins/maven/facade-api/maven-facade-api.iml b/plugins/maven/facade-api/maven-facade-api.iml index 8ba63b8dc7db..56173f227d95 100644 --- a/plugins/maven/facade-api/maven-facade-api.iml +++ b/plugins/maven/facade-api/maven-facade-api.iml @@ -14,8 +14,6 @@ - - diff --git a/plugins/maven/facade-impl/maven-facade-impl.iml b/plugins/maven/facade-impl/maven-facade-impl.iml index 9240cd8ba91c..ae61f67a346f 100644 --- a/plugins/maven/facade-impl/maven-facade-impl.iml +++ b/plugins/maven/facade-impl/maven-facade-impl.iml @@ -16,8 +16,6 @@ - - @@ -25,8 +23,6 @@ - - @@ -34,8 +30,6 @@ - - @@ -43,8 +37,6 @@ - - @@ -52,8 +44,6 @@ - - @@ -61,8 +51,6 @@ - - @@ -70,8 +58,6 @@ - - @@ -79,8 +65,6 @@ - - @@ -88,8 +72,6 @@ - - @@ -97,8 +79,6 @@ - - @@ -106,8 +86,6 @@ - - @@ -115,8 +93,6 @@ - - @@ -124,8 +100,6 @@ - - @@ -133,8 +107,6 @@ - - diff --git a/plugins/relaxng/relaxng.iml b/plugins/relaxng/relaxng.iml index d7d35d40c904..6ff34b95fc39 100644 --- a/plugins/relaxng/relaxng.iml +++ b/plugins/relaxng/relaxng.iml @@ -18,7 +18,6 @@ - @@ -29,8 +28,6 @@ - - @@ -38,8 +35,6 @@ - - @@ -47,8 +42,6 @@ - - diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java index ee5354b8515f..6252728de819 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java @@ -22,6 +22,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.analysis.CreateNSDeclarationIntentionFix; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.lang.xml.XMLLanguage; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; @@ -44,6 +45,8 @@ import org.jetbrains.annotations.Nullable; * Date: 24.07.2007 */ public class PrefixReferenceProvider extends PsiReferenceProviderBase { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.references.PrefixReferenceProvider"); + @NotNull public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { final XmlAttributeValue value = (XmlAttributeValue)element; @@ -102,7 +105,7 @@ public class PrefixReferenceProvider extends PsiReferenceProviderBase { QuickFixAction.registerQuickFixAction(info, new CreateNSDeclarationIntentionFix(tag, reference.getCanonicalText())); } catch (Throwable e) { - e.printStackTrace(); + LOG.error(e); } } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java index a0af4a70dd45..a2baae294ffc 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java @@ -17,7 +17,9 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; @@ -33,7 +35,6 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; -import javax.swing.*; import java.net.MalformedURLException; import java.net.URL; import java.util.Set; @@ -44,6 +45,8 @@ import java.util.Set; * Date: 19.11.2007 */ public class MessageViewHelper { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.MessageViewHelper"); + private final Project myProject; private final Set myErrors = new THashSet(); @@ -91,23 +94,23 @@ public class MessageViewHelper { try { file = VfsUtil.findFileByURL(new URL(systemId)); } catch (MalformedURLException e) { - System.err.println("systemId = " + systemId); - e.printStackTrace(); + LOG.warn("systemId = " + systemId); + LOG.error(e); } } final VirtualFile file1 = file; - SwingUtilities.invokeLater( - new Runnable() { - public void run() { - myErrorsView.addMessage( - warning ? MessageCategory.WARNING : MessageCategory.ERROR, - new String[]{ ex.getLocalizedMessage() }, - file1, - ex.getLineNumber() - 1, - ex.getColumnNumber() - 1, null); - } - } + ApplicationManager.getApplication().invokeLater( + new Runnable() { + public void run() { + myErrorsView.addMessage( + warning ? MessageCategory.WARNING : MessageCategory.ERROR, + new String[]{ex.getLocalizedMessage()}, + file1, + ex.getLineNumber() - 1, + ex.getColumnNumber() - 1, null); + } + } ); } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java index 2e41399879ca..232938704cd1 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java @@ -16,6 +16,7 @@ package org.intellij.plugins.relaxNG.validation; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfo; @@ -62,12 +63,15 @@ import java.io.StringReader; * Date: 19.07.2007 */ public class RngParser { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.RngParser"); + static final Key> SCHEMA_KEY = Key.create("SCHEMA"); static final Key> PATTERN_KEY = Key.create("PATTERN"); public static final DefaultHandler DEFAULT_HANDLER = new DefaultHandler() { public void error(SAXParseException e) throws SAXException { - System.out.println("e.getMessage() = " + e.getMessage() + " [" + e.getSystemId() + "]"); + LOG.info("e.getMessage() = " + e.getMessage() + " [" + e.getSystemId() + "]"); + LOG.info(e); } }; @@ -90,9 +94,9 @@ public class RngParser { return (DPattern)p.parse(checking ? new CheckingSchemaBuilder(sb, eh) : sb); } catch (BuildException e) { - e.printStackTrace(); + LOG.info(e); } catch (IllegalSchemaException e) { - System.out.println("invalid schema: " + file.getVirtualFile().getPresentableUrl()); + LOG.info("invalid schema: " + file.getVirtualFile().getPresentableUrl()); } return null; } @@ -166,7 +170,7 @@ public class RngParser { return Result.createSingleDependency(schema, descriptorFile); } } catch (Exception e) { - e.printStackTrace(); + LOG.info(e); return Result.createSingleDependency(null, descriptorFile); } } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java index 2956996170f3..02a835452697 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java @@ -17,6 +17,7 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.codeInsight.daemon.Validator; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.psi.PsiDocumentManager; @@ -40,6 +41,7 @@ import org.xml.sax.SAXParseException; * Date: 30.07.2007 */ public class XmlInstanceValidator { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.MessageViewHelper"); public static void doValidation(@NotNull final XmlDocument doc, final Validator.ValidationHost host, final XmlFile descriptorFile) { try { @@ -61,9 +63,11 @@ public class XmlInstanceValidator { doc.accept(new Psi2SaxAdapter(handler)); } catch (ProcessCanceledException e) { - throw e; + LOG.error(e); + } catch (RuntimeException e) { + LOG.error(e); } catch (Exception e) { - e.printStackTrace(); + LOG.info(e); } } diff --git a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java index a25cff996b95..08dc74d42a96 100644 --- a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java +++ b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java @@ -85,7 +85,7 @@ public abstract class HighlightingTestBase extends TestCase implements IdeaCodeI } }); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException(e); } } diff --git a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java index e6dbd57757a3..4a15eea85615 100644 --- a/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java +++ b/plugins/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java @@ -50,8 +50,8 @@ public class SpellCheckerSettingsPane implements Disposable { private JPanel panelForDictionaryChooser; private JPanel panelForAcceptedWords; private JPanel panelForFolderChooser; - private final OptionalChooserComponent optionalChooserComponent; - private final PathsChooserComponent pathsChooserComponent; + private OptionalChooserComponent optionalChooserComponent; + private PathsChooserComponent pathsChooserComponent; private final List> allDictionaries = new ArrayList>(); private final List dictionariesFolders = new ArrayList(); private final WordsPanel wordsPanel; @@ -96,20 +96,20 @@ public class SpellCheckerSettingsPane implements Disposable { } paths.add(path); - final ArrayList> currentDictionaries = optionalChooserComponent.getValue(); + final ArrayList> currentDictionaries = optionalChooserComponent.getCurrentModel(); SPFileUtil.processFilesRecursively(path, new Consumer() { public void consume(final String s) { currentDictionaries.add(Pair.create(s, true)); } }); - optionalChooserComponent.update(); + optionalChooserComponent.refresh(); return true; } public boolean removePath(List paths, String path) { if (paths.remove(path)) { final ArrayList> result = new ArrayList>(); - final ArrayList> currentDictionaries = optionalChooserComponent.getValue(); + final ArrayList> currentDictionaries = optionalChooserComponent.getCurrentModel(); for (Pair pair : currentDictionaries) { if (!pair.first.startsWith(FileUtil.toSystemDependentName(path))) { result.add(pair); @@ -117,7 +117,7 @@ public class SpellCheckerSettingsPane implements Disposable { } currentDictionaries.clear(); currentDictionaries.addAll(result); - optionalChooserComponent.update(); + optionalChooserComponent.refresh(); return true; } return false; @@ -127,7 +127,7 @@ public class SpellCheckerSettingsPane implements Disposable { panelForFolderChooser.add(pathsChooserComponent.getContentPane(), BorderLayout.CENTER); - optionalChooserComponent = new OptionalChooserComponent(allDictionaries) { + optionalChooserComponent = new OptionalChooserComponent(allDictionaries) { @Override public JCheckBox createCheckBox(String path, boolean checked) { if (isUserDictionary(path)) { diff --git a/plugins/svn4idea/svn4idea-tests.iml b/plugins/svn4idea/svn4idea-tests.iml index 798757278775..5039b6b4a9f5 100644 --- a/plugins/svn4idea/svn4idea-tests.iml +++ b/plugins/svn4idea/svn4idea-tests.iml @@ -16,7 +16,6 @@ - @@ -30,8 +29,6 @@ - - diff --git a/plugins/svn4idea/svn4idea.iml b/plugins/svn4idea/svn4idea.iml index fd765b400568..e00b72d68d9c 100644 --- a/plugins/svn4idea/svn4idea.iml +++ b/plugins/svn4idea/svn4idea.iml @@ -22,7 +22,6 @@ - @@ -33,8 +32,6 @@ - - @@ -43,8 +40,6 @@ - - diff --git a/resources/src/idea/IdeaActions.xml b/resources/src/idea/IdeaActions.xml index 7213ffbd919f..57745c3c45dc 100644 --- a/resources/src/idea/IdeaActions.xml +++ b/resources/src/idea/IdeaActions.xml @@ -678,7 +678,4 @@ - - - diff --git a/xml/impl/resources/liveTemplates/zen_html.xml b/xml/impl/resources/liveTemplates/zen_html.xml new file mode 100644 index 000000000000..97584af43ad1 --- /dev/null +++ b/xml/impl/resources/liveTemplates/zen_html.xml @@ -0,0 +1,1153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/impl/resources/liveTemplates/zen_xsl.xml b/xml/impl/resources/liveTemplates/zen_xsl.xml new file mode 100644 index 000000000000..de97235db242 --- /dev/null +++ b/xml/impl/resources/liveTemplates/zen_xsl.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java b/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java index ddd130748c77..7991581bfb17 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java +++ b/xml/impl/src/com/intellij/codeInsight/template/XmlDefaultLiveTemplatesProvider.java @@ -22,6 +22,6 @@ import com.intellij.codeInsight.template.impl.DefaultLiveTemplatesProvider; */ public class XmlDefaultLiveTemplatesProvider implements DefaultLiveTemplatesProvider { public String[] getDefaultLiveTemplateFiles() { - return new String[] { "/liveTemplates/html_xml" }; + return new String[] { "/liveTemplates/html_xml", "/liveTemplates/zen_html", "/liveTemplates/zen_xsl" }; } } diff --git a/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java index 0acceb6df469..c33e58464d2d 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/zencoding/XmlZenCodingTemplate.java @@ -262,7 +262,7 @@ public class XmlZenCodingTemplate extends ZenCodingTemplate { private static TemplateImpl generateTagTemplate(String tagName, CustomTemplateCallback callback) { StringBuilder builder = new StringBuilder("<"); builder.append(tagName).append('>'); - if (isTrueXml(callback) || !HtmlUtil.isSingleHtmlTag(tagName)) { + if (!HtmlUtil.isSingleHtmlTag(tagName)) { builder.append("$END$'); } return new TemplateImpl("", builder.toString(), ""); diff --git a/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java b/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java index 88dcb7b1622a..84430d374af5 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java +++ b/xml/impl/src/com/intellij/codeInsight/template/zencoding/nodes/GenerationNode.java @@ -206,7 +206,7 @@ public class GenerationNode { return template; } - private static TemplateImpl invokeXmlTemplate(XmlTemplateToken token, + private static TemplateImpl invokeXmlTemplate(final XmlTemplateToken token, CustomTemplateCallback callback, final int numberInIteration, @Nullable ZenCodingGenerator generator, @@ -227,6 +227,7 @@ public class GenerationNode { public void run() { XmlTag tag1 = hasChildren ? expandEmptyTagIfNeccessary(tag) : tag; setAttributeValues(tag1, attr2value, numberInIteration); + token.setFile((XmlFile)tag1.getContainingFile()); } }); } @@ -272,7 +273,6 @@ public class GenerationNode { if (flag) { builder.append(">'); final XmlTag tag1 = XmlElementFactory.getInstance(tag.getProject()).createTagFromText(builder.toString(), XMLLanguage.INSTANCE); - tag.replace(tag1); return tag1; } return tag; diff --git a/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java b/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java index 8b0d6f269e90..9727f397e814 100644 --- a/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java +++ b/xml/impl/src/com/intellij/ide/actions/CreateHtmlFileAction.java @@ -56,7 +56,7 @@ public class CreateHtmlFileAction extends CreateFromTemplateAction { .setTitle(XmlBundle.message("new.html.file.action")) .addKind("HTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML_TEMPLATE_NAME) .addKind("HTML5 file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_HTML5_TEMPLATE_NAME) - .addKind("XHTML file", StdFileTypes.HTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME); + .addKind("XHTML file", StdFileTypes.XHTML.getIcon(), FileTemplateManager.INTERNAL_XHTML_TEMPLATE_NAME); } @Override diff --git a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java index 2d4f79eff89d..ef8dc3839ce9 100644 --- a/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java +++ b/xml/impl/src/com/intellij/xml/util/XmlRefCountHolder.java @@ -30,6 +30,8 @@ import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.*; +import com.intellij.util.NullableFunction; +import com.intellij.util.containers.ContainerUtil; import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.NotNull; @@ -97,14 +99,17 @@ public class XmlRefCountHolder { if (list == null) { list = new ArrayList>(); myId2AttributeListMap.put(id, list); - } else if (!soft) { + } + else if (!soft) { // mark as duplicate - if (list.size() == 1) { - if (!list.get(0).second.booleanValue()) { - myPossiblyDuplicateIds.add(list.get(0).first); - myPossiblyDuplicateIds.add(attributeValue); + List notSoft = ContainerUtil.mapNotNull(list, new NullableFunction, XmlAttributeValue>() { + @Override + public XmlAttributeValue fun(Pair pair) { + return pair.second ? null : pair.first; } - } else { + }); + if (!notSoft.isEmpty()) { + myPossiblyDuplicateIds.addAll(notSoft); myPossiblyDuplicateIds.add(attributeValue); } } diff --git a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java b/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java index 60c822b92d3a..5e0129ab5df5 100644 --- a/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java +++ b/xml/openapi/src/com/intellij/psi/xml/XmlTagChild.java @@ -20,7 +20,6 @@ import org.jetbrains.annotations.Nullable; public interface XmlTagChild extends XmlElement{ XmlTagChild[] EMPTY_ARRAY = new XmlTagChild[0]; - @Nullable XmlTag getParentTag(); @Nullable