From be773a9f1c73a6d6b40cb2e8ab681d3e20bd20e2 Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Fri, 1 Feb 2013 10:21:30 +0400
Subject: [PATCH 01/51] javafx: path refs in url attributes (IDEA-100135)
---
.../javaFX/fxml/refs/FxmlReferencesContributor.java | 3 +++
.../fxml/refs/JavaFxLocationReferenceProvider.java | 12 ++++++++++--
plugins/javaFX/testData/highlighting/imageIcon.fxml | 5 +++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java
index f4d44b4446d3..ffa0f044168e 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java
@@ -64,6 +64,9 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("@")).and(attributeValueInFxml),
new JavaFxLocationReferenceProvider());
+ registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName("url")).and(attributeValueInFxml),
+ new JavaFxLocationReferenceProvider());
+
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlTokenType.XML_TAG_CHARACTERS).inFile(inFxmlElementPattern()), new ImportReferenceProvider());
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().and(attributeValueInFxml),
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java
index 9e2f2eb771c4..c901ad7c9697 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxLocationReferenceProvider.java
@@ -32,8 +32,16 @@ class JavaFxLocationReferenceProvider extends PsiReferenceProvider {
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element,
@NotNull ProcessingContext context) {
final String value = ((XmlAttributeValue)element).getValue();
- final String relativePathToResource = value.substring(1);
- final FileReferenceSet set = new FileReferenceSet(relativePathToResource, element, 2, null, true);
+ final FileReferenceSet set;
+ if (value.startsWith("@")) {
+ set = new FileReferenceSet(value.substring(1), element, 2, null, true);
+ }
+ else {
+ set = new FileReferenceSet(value, element, 1, null, true);
+ if (value.startsWith("/")) {
+ set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
+ }
+ }
return set.getAllReferences();
}
}
diff --git a/plugins/javaFX/testData/highlighting/imageIcon.fxml b/plugins/javaFX/testData/highlighting/imageIcon.fxml
index 060671ad1c65..76d655bdbed7 100644
--- a/plugins/javaFX/testData/highlighting/imageIcon.fxml
+++ b/plugins/javaFX/testData/highlighting/imageIcon.fxml
@@ -10,6 +10,11 @@
+
+
+
+
+
unknownIcon.png"/>
From 356ee93e3328a3fdc3cba6fa28e5eb94f6685a87 Mon Sep 17 00:00:00 2001
From: Anton Makeev
Date: Thu, 31 Jan 2013 20:12:39 +0100
Subject: [PATCH 02/51] AppCode:Unit Testing: comparator corrected (CR-OC-150)
---
.../intellij/testIntegration/TestFinderHelper.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java
index 58fc1de4cbd1..8b419e4a58bb 100644
--- a/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java
+++ b/platform/lang-impl/src/com/intellij/testIntegration/TestFinderHelper.java
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.codeStyle.NameUtil;
+import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -72,12 +73,18 @@ public class TestFinderHelper {
public static List getSortedElements(final List> elementsWithWeights,
final boolean weightsAscending) {
+ return getSortedElements(elementsWithWeights, weightsAscending, null);
+ }
+
+ public static List getSortedElements(final List> elementsWithWeights,
+ final boolean weightsAscending,
+ @Nullable final Comparator sameNameComparator) {
Collections.sort(elementsWithWeights, new Comparator>() {
public int compare(Pair extends PsiNamedElement, Integer> o1, Pair extends PsiNamedElement, Integer> o2) {
int result = weightsAscending ? o1.second.compareTo(o2.second) : o2.second.compareTo(o1.second);
- if (result == 0) {
- result = Comparing.compare(o1.first.getName(), o2.first.getName());
- }
+ if (result == 0) result = Comparing.compare(o1.first.getName(), o2.first.getName());
+ if (result == 0 && sameNameComparator != null) result = sameNameComparator.compare(o1.first, o2.first);
+
return result;
}
});
From b6aba4ea010244bf5b10f4bdd716d6d3cad7890a Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Thu, 31 Jan 2013 17:12:31 +0400
Subject: [PATCH 03/51] support multiple remote groups
---
.../templates/RemoteTemplatesFactory.java | 50 ++++++++++++++++---
1 file changed, 42 insertions(+), 8 deletions(-)
diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
index 33b6d84e594c..67fb5a354d00 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
@@ -22,12 +22,15 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;
+import com.intellij.openapi.util.ClearableLazyValue;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.StreamUtil;
import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.ProjectTemplatesFactory;
+import com.intellij.util.ArrayUtil;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.MultiMap;
import com.intellij.util.net.HttpConfigurable;
import org.jdom.Element;
import org.jdom.JDOMException;
@@ -37,6 +40,7 @@ import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
+import java.util.Collection;
import java.util.List;
import java.util.zip.ZipInputStream;
@@ -47,32 +51,46 @@ import java.util.zip.ZipInputStream;
public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
private static final String URL = "http://download.jetbrains.com/idea/project_templates/";
+ private static final String SAMPLES_GALLERY = "Samples Gallery";
+ private final ClearableLazyValue> myTemplates = new ClearableLazyValue>() {
+ @NotNull
+ @Override
+ protected MultiMap compute() {
+ return getTemplates();
+ }
+ };
@NotNull
@Override
public String[] getGroups() {
- return new String[] { "Samples Gallery"};
+ myTemplates.drop();
+ return ArrayUtil.toStringArray(myTemplates.getValue().keySet());
}
@NotNull
@Override
public ProjectTemplate[] createTemplates(String group, WizardContext context) {
+ Collection templates = myTemplates.getValue().get(group);
+ return templates.toArray(new ProjectTemplate[templates.size()]);
+ }
+
+ private static MultiMap getTemplates() {
InputStream stream = null;
HttpURLConnection connection = null;
String code = ApplicationInfo.getInstance().getBuild().getProductCode();
try {
connection = getConnection(code + "_templates.xml");
stream = connection.getInputStream();
- String text = StreamUtil.readText(stream);
+ String text = StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
return createFromText(text);
}
catch (IOException ex) { // timeouts, lost connection etc
LOG.info(ex);
- return ProjectTemplate.EMPTY_ARRAY;
+ return MultiMap.emptyInstance();
}
catch (Exception e) {
LOG.error(e);
- return ProjectTemplate.EMPTY_ARRAY;
+ return MultiMap.emptyInstance();
}
finally {
StreamUtil.closeStream(stream);
@@ -83,11 +101,28 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
}
@SuppressWarnings("unchecked")
- public static ProjectTemplate[] createFromText(String text) throws IOException, JDOMException {
+ public static MultiMap createFromText(String text) throws IOException, JDOMException {
- List elements = JDOMUtil.loadDocument(text).getRootElement().getChildren("template");
+ Element rootElement = JDOMUtil.loadDocument(text).getRootElement();
+ List groups = rootElement.getChildren("group");
+ MultiMap map = new MultiMap();
+ if (groups.isEmpty()) { // sample gallery by default
+ map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement));
+ }
+ else {
+ for (Element group : groups) {
+ map.put(group.getChildText("name"), createGroupTemplates(group));
+ }
+ }
- List templates = ContainerUtil.mapNotNull(elements, new NullableFunction() {
+ return map;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static List createGroupTemplates(Element groupElement) {
+ List elements = groupElement.getChildren("template");
+
+ return ContainerUtil.mapNotNull(elements, new NullableFunction() {
@Override
public ProjectTemplate fun(final Element element) {
@@ -127,7 +162,6 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
};
}
});
- return templates.toArray(new ProjectTemplate[templates.size()]);
}
private static HttpURLConnection getConnection(String path) throws IOException {
From 949110f10a1ab33a741d29b1237dff6c4293fd4b Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Thu, 31 Jan 2013 18:17:10 +0400
Subject: [PATCH 04/51] project templates schema
---
.../platform/templates/IC_templates.xml | 3 +-
.../platform/templates/IU_template_groups.xml | 13 ++++++++
.../platform/templates/IU_template_groups.xsd | 32 +++++++++++++++++++
.../templates/RemoteTemplatesFactory.java | 20 ++++++------
4 files changed, 57 insertions(+), 11 deletions(-)
create mode 100644 java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml
create mode 100644 java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd
diff --git a/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml b/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml
index 8da6b26f055a..d8daaec7b869 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml
+++ b/java/idea-ui/src/com/intellij/platform/templates/IC_templates.xml
@@ -1,8 +1,7 @@
Java Hello World
-
-
+
HelloWorld.zip
diff --git a/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml
new file mode 100644
index 000000000000..52446026f3b6
--- /dev/null
+++ b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xml
@@ -0,0 +1,13 @@
+
+
+ Spring
+ Spring
+
+ Spring Core
+
+ SpringApp
+ IJ_BASE_PACKAGE
+ IJ_APPLICATION_SERVER
+
+
+
\ No newline at end of file
diff --git a/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd
new file mode 100644
index 000000000000..c7adb5afba89
--- /dev/null
+++ b/java/idea-ui/src/com/intellij/platform/templates/IU_template_groups.xsd
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
index 67fb5a354d00..e6bd637eb0fd 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/RemoteTemplatesFactory.java
@@ -34,6 +34,7 @@ import com.intellij.util.containers.MultiMap;
import com.intellij.util.net.HttpConfigurable;
import org.jdom.Element;
import org.jdom.JDOMException;
+import org.jdom.Namespace;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -52,6 +53,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
private static final String URL = "http://download.jetbrains.com/idea/project_templates/";
private static final String SAMPLES_GALLERY = "Samples Gallery";
+ private static final Namespace NAMESPACE = Namespace.getNamespace("http://www.jetbrains.com/projectTemplates");
private final ClearableLazyValue> myTemplates = new ClearableLazyValue>() {
@NotNull
@Override
@@ -104,14 +106,14 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
public static MultiMap createFromText(String text) throws IOException, JDOMException {
Element rootElement = JDOMUtil.loadDocument(text).getRootElement();
- List groups = rootElement.getChildren("group");
+ List groups = rootElement.getChildren("group", NAMESPACE);
MultiMap map = new MultiMap();
if (groups.isEmpty()) { // sample gallery by default
- map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement));
+ map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement, Namespace.NO_NAMESPACE));
}
else {
for (Element group : groups) {
- map.put(group.getChildText("name"), createGroupTemplates(group));
+ map.put(group.getChildText("name", NAMESPACE), createGroupTemplates(group, NAMESPACE));
}
}
@@ -119,14 +121,14 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
}
@SuppressWarnings("unchecked")
- private static List createGroupTemplates(Element groupElement) {
- List elements = groupElement.getChildren("template");
+ private static List createGroupTemplates(Element groupElement, final Namespace ns) {
+ List elements = groupElement.getChildren("template", ns);
return ContainerUtil.mapNotNull(elements, new NullableFunction() {
@Override
public ProjectTemplate fun(final Element element) {
- List plugins = element.getChildren("requiredPlugin");
+ List plugins = element.getChildren("requiredPlugin", ns);
for (Element plugin : plugins) {
String id = plugin.getTextTrim();
if (!PluginManager.isPluginInstalled(PluginId.getId(id))) {
@@ -135,7 +137,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
}
String type = element.getChildText("moduleType");
final ModuleType moduleType = ModuleTypeManager.getInstance().findByID(type);
- return new ArchivedProjectTemplate(element.getChildTextTrim("name")) {
+ return new ArchivedProjectTemplate(element.getChildTextTrim("name", ns)) {
@Override
protected ModuleType getModuleType() {
return moduleType;
@@ -143,7 +145,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
@Override
public ZipInputStream getStream() throws IOException {
- String path = element.getChildText("path");
+ String path = element.getChildText("path", ns);
final HttpURLConnection connection = getConnection(path);
return new ZipInputStream(connection.getInputStream()) {
@Override
@@ -157,7 +159,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
@Nullable
@Override
public String getDescription() {
- return element.getChildTextTrim("description");
+ return element.getChildTextTrim("description", ns);
}
};
}
From 1fb80062735856d9fed4d5835d7271c959e16907 Mon Sep 17 00:00:00 2001
From: Dmitry Avdeev
Date: Fri, 1 Feb 2013 12:52:39 +0400
Subject: [PATCH 05/51] IDEA-81697 Could not setup connection to JIRA server
---
.../src/main/java/com/intellij/tasks/jira/JiraRepository.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java b/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java
index 78f9764fc879..02e3d431ce25 100644
--- a/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java
+++ b/plugins/tasks/jira-connector/src/main/java/com/intellij/tasks/jira/JiraRepository.java
@@ -18,6 +18,7 @@ import com.intellij.util.xmlb.annotations.Tag;
import org.apache.axis.AxisProperties;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
@@ -117,6 +118,7 @@ public class JiraRepository extends BaseRepositoryImpl {
private HttpClient login() throws Exception {
HttpClient client = getHttpClient();
+ client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
if (myJira4) {
PostMethod postMethod = getLoginMethodFor4x();
client.executeMethod(postMethod);
From 6fbd294805de5aff6d8526cdcf25dc71966c287c Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Fri, 1 Feb 2013 12:23:02 +0400
Subject: [PATCH 06/51] javafx: fx:factory method ref (IDEA-100081)
---
.../fxml/refs/FxmlReferencesContributor.java | 4 +
.../refs/JavaFxFactoryReferenceProvider.java | 100 ++++++++++++++++++
.../testData/completion/factoryMethods.fxml | 10 ++
.../completion/factoryMethods_after.fxml | 10 ++
.../javaFX/fxml/JavaFxCompletionTest.java | 4 +
5 files changed, 128 insertions(+)
create mode 100644 plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java
create mode 100644 plugins/javaFX/testData/completion/factoryMethods.fxml
create mode 100644 plugins/javaFX/testData/completion/factoryMethods_after.fxml
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java
index ffa0f044168e..148538e77ba1 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/FxmlReferencesContributor.java
@@ -57,6 +57,10 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
.and(attributeValueInFxml),
new JavaFxComponentIdReferenceProvider());
+ registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_FACTORY))
+ .and(attributeValueInFxml),
+ new JavaFxFactoryReferenceProvider());
+
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("#"))
.and(attributeValueInFxml),
new JavaFxEventHandlerReferenceProvider());
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java
new file mode 100644
index 000000000000..d0d8f2e4456d
--- /dev/null
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.javaFX.fxml.refs;
+
+import com.intellij.psi.*;
+import com.intellij.psi.xml.XmlAttribute;
+import com.intellij.psi.xml.XmlAttributeValue;
+import com.intellij.psi.xml.XmlTag;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.ProcessingContext;
+import com.intellij.xml.XmlElementDescriptor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+* User: anna
+*/
+class JavaFxFactoryReferenceProvider extends PsiReferenceProvider {
+ @NotNull
+ @Override
+ public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
+ @NotNull ProcessingContext context) {
+ final XmlAttributeValue attributeValue = (XmlAttributeValue)element;
+ return new PsiReference[] {new JavaFXFactoryReference(attributeValue)};
+ }
+
+ private static class JavaFXFactoryReference extends PsiReferenceBase {
+ public JavaFXFactoryReference(XmlAttributeValue attributeValue) {
+ super(attributeValue);
+ }
+
+ @Nullable
+ @Override
+ public PsiElement resolve() {
+ final PsiClass psiClass = getTagClass(getElement());
+ if (psiClass != null) {
+ final PsiMethod[] psiMethods = psiClass.findMethodsByName(getElement().getValue(), false);
+ for (PsiMethod method : psiMethods) {
+ if (isFactoryMethod(method)) {
+ return method;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static boolean isFactoryMethod(PsiMethod method) {
+ return method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 0;
+ }
+
+ @Nullable
+ private static PsiClass getTagClass(XmlAttributeValue xmlAttributeValue) {
+ if (xmlAttributeValue == null) return null;
+ final PsiElement xmlAttribute = xmlAttributeValue.getParent();
+ final XmlTag xmlTag = ((XmlAttribute)xmlAttribute).getParent();
+ if (xmlTag != null) {
+ final XmlElementDescriptor descriptor = xmlTag.getDescriptor();
+ if (descriptor != null) {
+ final PsiElement declaration = descriptor.getDeclaration();
+ if (declaration instanceof PsiClass) {
+ return (PsiClass)declaration;
+ }
+ }
+ }
+ return null;
+ }
+
+ @NotNull
+ @Override
+ public Object[] getVariants() {
+ final PsiClass psiClass = getTagClass(getElement());
+ if (psiClass != null) {
+ final List methods = new ArrayList();
+ for (PsiMethod method : psiClass.getMethods()) {
+ if (isFactoryMethod(method)) {
+ methods.add(method);
+ }
+ }
+ return ArrayUtil.toObjectArray(methods);
+ }
+ return ArrayUtil.EMPTY_OBJECT_ARRAY;
+ }
+ }
+}
diff --git a/plugins/javaFX/testData/completion/factoryMethods.fxml b/plugins/javaFX/testData/completion/factoryMethods.fxml
new file mode 100644
index 000000000000..b10f088fbc38
--- /dev/null
+++ b/plugins/javaFX/testData/completion/factoryMethods.fxml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/javaFX/testData/completion/factoryMethods_after.fxml b/plugins/javaFX/testData/completion/factoryMethods_after.fxml
new file mode 100644
index 000000000000..6be1200c2452
--- /dev/null
+++ b/plugins/javaFX/testData/completion/factoryMethods_after.fxml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java
index 42cb5084adcf..d21c73adbe59 100644
--- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java
+++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java
@@ -85,6 +85,10 @@ public class JavaFxCompletionTest extends CompletionTestCase {
doTest("text");
}
+ public void testFactoryMethods() throws Exception {
+ doTest("observableArrayList");
+ }
+
private void doTest() throws Exception {
doTest(null);
}
From d71f26ee595b8e6394d3710cca8bbaa009ee0fdc Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Fri, 1 Feb 2013 12:42:32 +0400
Subject: [PATCH 07/51] javafx: fx:value check (IDEA-100269)
---
.../plugins/javaFX/fxml/JavaFxPsiUtil.java | 17 +++++++
.../JavaFxDefaultAttributeDescriptor.java | 50 +++++++++++++++++--
.../refs/JavaFxFactoryReferenceProvider.java | 25 ++--------
.../highlighting/valueOfAcceptance.fxml | 16 ++++++
.../javaFX/fxml/JavaFXHighlightingTest.java | 4 ++
5 files changed, 87 insertions(+), 25 deletions(-)
create mode 100644 plugins/javaFX/testData/highlighting/valueOfAcceptance.fxml
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
index 52203a2ab17f..ec1e699473cc 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
@@ -220,4 +220,21 @@ public class JavaFxPsiUtil {
}
return true;
}
+
+ @Nullable
+ public static PsiClass getTagClass(XmlAttributeValue xmlAttributeValue) {
+ if (xmlAttributeValue == null) return null;
+ final PsiElement xmlAttribute = xmlAttributeValue.getParent();
+ final XmlTag xmlTag = ((XmlAttribute)xmlAttribute).getParent();
+ if (xmlTag != null) {
+ final XmlElementDescriptor descriptor = xmlTag.getDescriptor();
+ if (descriptor != null) {
+ final PsiElement declaration = descriptor.getDeclaration();
+ if (declaration instanceof PsiClass) {
+ return (PsiClass)declaration;
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java
index 80b05a8d6397..b5894330eaea 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultAttributeDescriptor.java
@@ -16,10 +16,16 @@
package org.jetbrains.plugins.javaFX.fxml.descriptors;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiField;
-import com.intellij.psi.PsiModifier;
+import com.intellij.psi.*;
+import com.intellij.psi.xml.XmlAttribute;
+import com.intellij.psi.xml.XmlAttributeValue;
+import com.intellij.psi.xml.XmlElement;
+import com.intellij.psi.xml.XmlTag;
+import com.intellij.xml.XmlAttributeDescriptor;
+import com.intellij.xml.XmlElementDescriptor;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.fxml.FxmlConstants;
+import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
import java.util.List;
@@ -29,6 +35,7 @@ import java.util.List;
*/
public class JavaFxDefaultAttributeDescriptor extends JavaFxPropertyAttributeDescriptor {
private static final Logger LOG = Logger.getInstance("#" + JavaFxDefaultAttributeDescriptor.class.getName());
+ public static final String VALUE_OF = "valueOf";
private String myDefaultPropertyName = null;
public JavaFxDefaultAttributeDescriptor(String name, PsiClass psiClass) {
@@ -67,4 +74,41 @@ public class JavaFxDefaultAttributeDescriptor extends JavaFxPropertyAttributeDes
protected boolean isConstant(PsiField field) {
return field.hasModifierProperty(PsiModifier.STATIC) && field.hasModifierProperty(PsiModifier.FINAL) && field.hasModifierProperty(PsiModifier.PUBLIC);
}
+
+ @Nullable
+ @Override
+ public String validateValue(XmlElement context, String value) {
+ if (context instanceof XmlAttributeValue) {
+ final PsiElement parent = context.getParent();
+ if (parent instanceof XmlAttribute) {
+ final XmlAttribute attribute = (XmlAttribute)parent;
+ if (FxmlConstants.FX_VALUE.equals(attribute.getName())) {
+ final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)context);
+ if (tagClass != null) {
+ final PsiMethod method = getValueOfMethod(tagClass);
+ if (method == null) {
+ return "Unable to coerce '" + value + "' to " + tagClass.getQualifiedName() + ".";
+ }
+ }
+ }
+ }
+ }
+ return super.validateValue(context, value);
+ }
+
+ private static PsiMethod getValueOfMethod(PsiClass tagClass) {
+ final PsiMethod[] methods = tagClass.findMethodsByName(VALUE_OF, false);
+ for (PsiMethod method : methods) {
+ if (method.hasModifierProperty(PsiModifier.STATIC)) {
+ final PsiParameter[] parameters = method.getParameterList().getParameters();
+ if (parameters.length == 1) {
+ final PsiType type = parameters[0].getType();
+ if (type.equalsToText(CommonClassNames.JAVA_LANG_STRING) || type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
+ return method;
+ }
+ }
+ }
+ }
+ return null;
+ }
}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java
index d0d8f2e4456d..f2da17c1454e 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxFactoryReferenceProvider.java
@@ -16,14 +16,12 @@
package org.jetbrains.plugins.javaFX.fxml.refs;
import com.intellij.psi.*;
-import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
-import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ProcessingContext;
-import com.intellij.xml.XmlElementDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
import java.util.ArrayList;
import java.util.List;
@@ -48,7 +46,7 @@ class JavaFxFactoryReferenceProvider extends PsiReferenceProvider {
@Nullable
@Override
public PsiElement resolve() {
- final PsiClass psiClass = getTagClass(getElement());
+ final PsiClass psiClass = JavaFxPsiUtil.getTagClass(getElement());
if (psiClass != null) {
final PsiMethod[] psiMethods = psiClass.findMethodsByName(getElement().getValue(), false);
for (PsiMethod method : psiMethods) {
@@ -64,27 +62,10 @@ class JavaFxFactoryReferenceProvider extends PsiReferenceProvider {
return method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 0;
}
- @Nullable
- private static PsiClass getTagClass(XmlAttributeValue xmlAttributeValue) {
- if (xmlAttributeValue == null) return null;
- final PsiElement xmlAttribute = xmlAttributeValue.getParent();
- final XmlTag xmlTag = ((XmlAttribute)xmlAttribute).getParent();
- if (xmlTag != null) {
- final XmlElementDescriptor descriptor = xmlTag.getDescriptor();
- if (descriptor != null) {
- final PsiElement declaration = descriptor.getDeclaration();
- if (declaration instanceof PsiClass) {
- return (PsiClass)declaration;
- }
- }
- }
- return null;
- }
-
@NotNull
@Override
public Object[] getVariants() {
- final PsiClass psiClass = getTagClass(getElement());
+ final PsiClass psiClass = JavaFxPsiUtil.getTagClass(getElement());
if (psiClass != null) {
final List methods = new ArrayList();
for (PsiMethod method : psiClass.getMethods()) {
diff --git a/plugins/javaFX/testData/highlighting/valueOfAcceptance.fxml b/plugins/javaFX/testData/highlighting/valueOfAcceptance.fxml
new file mode 100644
index 000000000000..a4b16c30662e
--- /dev/null
+++ b/plugins/javaFX/testData/highlighting/valueOfAcceptance.fxml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+ "A"/>
+
+
+
+
+
+
+
+
diff --git a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
index 4a30d877f449..701e1beb9fa6 100644
--- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
+++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
@@ -147,6 +147,10 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase {
doDoTest(false, false);
}
+ public void testValueOfAcceptance() throws Exception {
+ doTest();
+ }
+
@NotNull
@Override
protected String getTestDataPath() {
From e3d9ffe550381f6267a0b5b5e1544c362f80581c Mon Sep 17 00:00:00 2001
From: irengrig
Date: Fri, 1 Feb 2013 14:00:27 +0400
Subject: [PATCH 08/51] IDEA-100285 Common Proxy : exception when parsing URL
with #
---
.../src/com/intellij/util/proxy/CommonProxy.java | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/platform/platform-api/src/com/intellij/util/proxy/CommonProxy.java b/platform/platform-api/src/com/intellij/util/proxy/CommonProxy.java
index 864b8b4a2c52..059332638865 100644
--- a/platform/platform-api/src/com/intellij/util/proxy/CommonProxy.java
+++ b/platform/platform-api/src/com/intellij/util/proxy/CommonProxy.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.util.net.HTTPProxySettingsPanel;
import org.jetbrains.annotations.NotNull;
@@ -283,15 +284,7 @@ public class CommonProxy extends ProxySelector {
}
private static URI createUri(final URL url) {
- final URI uri;
- try {
- uri = new URI(url.toString());
- }
- catch (URISyntaxException e) {
- LOG.info(e);
- throw new RuntimeException(e);
- }
- return uri;
+ return VfsUtil.toUri(url.toString());
}
public static class HostInfo {
From d1018da33293d71f27e3b2df62ceb89f9a466f58 Mon Sep 17 00:00:00 2001
From: Danila Ponomarenko
Date: Fri, 1 Feb 2013 14:44:19 +0400
Subject: [PATCH 09/51] EA-42014 fix
---
.../codeInsight/intention/PsiElementBaseIntentionAction.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java b/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java
index 9efc76f78cf2..d6e62c9bac38 100644
--- a/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java
+++ b/platform/lang-api/src/com/intellij/codeInsight/intention/PsiElementBaseIntentionAction.java
@@ -56,6 +56,7 @@ public abstract class PsiElementBaseIntentionAction extends BaseIntentionAction
@Override
public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+ if (file == null) return false;
final PsiManager manager = file.getManager();
if (manager == null) return false;
if (!manager.isInProject(file)) return false;
From acea8f462c61969c4b2d36bbacc43ddb85aafc12 Mon Sep 17 00:00:00 2001
From: "Nadya.Zabrodina"
Date: Fri, 1 Feb 2013 15:25:24 +0400
Subject: [PATCH 10/51] Refactor LightTest structure for HG.
---
.../org/zmlx/hg4idea/HgPlatformFacade.java | 8 ----
.../zmlx/hg4idea/HgPlatformFacadeImpl.java | 6 ---
.../org/zmlx/hg4idea/HgRepositoryManager.java | 32 ---------------
.../testSrc/hg4idea/test/HgExecutor.java | 24 +++--------
.../testSrc/hg4idea/test/HgLightTest.java | 24 ++++++-----
.../hg4idea/test/HgMockVcsManager.java | 7 +---
.../hg4idea/test/HgTestPlatformFacade.java | 19 +++------
.../hg4idea/test/HgTestRepositoryManager.java | 41 -------------------
.../test/diff/HgGetDiffForDirTest.java | 38 +++++++++--------
9 files changed, 45 insertions(+), 154 deletions(-)
delete mode 100644 plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryManager.java
delete mode 100644 plugins/hg4idea/testSrc/hg4idea/test/HgTestRepositoryManager.java
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacade.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacade.java
index 9697de70d25f..3eebfbd53098 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacade.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacade.java
@@ -29,12 +29,4 @@ public interface HgPlatformFacade extends DvcsPlatformFacade {
@NotNull
HgVcs getVcs(@NotNull Project project);
- @NotNull
- HgRepositoryManager getRepositoryManager(@NotNull Project project);
-
- //@NotNull
- //HgProjectSettings getSettings(Project project);
- //
- //@NotNull
- //HgCommandResultNotifier getNotificator(@NotNull Project project);
}
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacadeImpl.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacadeImpl.java
index 0a3ac43e0c81..4a13cb4b4d45 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacadeImpl.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPlatformFacadeImpl.java
@@ -25,12 +25,6 @@ import org.jetbrains.annotations.NotNull;
*/
public class HgPlatformFacadeImpl extends DvcsPlatformFacadeImpl implements HgPlatformFacade {
- @NotNull
- @Override
- public HgRepositoryManager getRepositoryManager(@NotNull Project project) {
- throw new UnsupportedOperationException();
- }
-
@NotNull
@Override
public HgVcs getVcs(@NotNull Project project) {
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryManager.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryManager.java
deleted file mode 100644
index 6b2cff148afe..000000000000
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryManager.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.zmlx.hg4idea;
-
-import com.intellij.openapi.vfs.VirtualFile;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.List;
-
-/**
- * @author Nadya Zabrodina
- */
-public interface HgRepositoryManager {
- /**
- * @return all repositories tracked by the manager.
- */
- @NotNull
- List getRepositories();
-}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgExecutor.java b/plugins/hg4idea/testSrc/hg4idea/test/HgExecutor.java
index b6785bcdb295..99a90cbd8d78 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/HgExecutor.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/HgExecutor.java
@@ -17,7 +17,6 @@ package hg4idea.test;
import com.intellij.dvcs.test.Executor;
import com.intellij.openapi.util.text.StringUtil;
-import org.zmlx.hg4idea.provider.HgRepositoryLocation;
import java.util.Arrays;
import java.util.List;
@@ -25,7 +24,7 @@ import java.util.List;
/**
* @author Nadya Zabrodina
*/
-class HgExecutor extends Executor {
+public class HgExecutor extends Executor {
private static final String HG_EXECUTABLE_ENV = "IDEA_TEST_HG_EXECUTABLE";
//private static final String TEAMCITY_HG_EXECUTABLE_ENV = "TEAMCITY_HG_PATH"; //todo var for server testing
@@ -37,31 +36,18 @@ class HgExecutor extends Executor {
return findExecutable("hg", "hg", "hg.exe", Arrays.asList(HG_EXECUTABLE_ENV));
}
- public String hg(String command) {
+ public static String hg(String command) {
printVersionTheFirstTime();
List split = StringUtil.split(command, " ");
split.add(0, HG_EXECUTABLE);
log("hg " + command);
- for (int attempt = 0; attempt < 3; attempt++) {
- String stdout = run(split);
- return stdout;
+ for(int attempt = 0; attempt < 3; attempt++) {
+ return run(split);
}
throw new RuntimeException("fatal error during execution of Hg command: " + command);
}
-
- public String hg(HgRepositoryLocation repository, String command) {
- if (repository != null) {
- cd(repository);
- }
- return hg(command);
- }
-
- public void cd(HgRepositoryLocation repository) {
- cd(repository.getRoot().getPath());
- }
-
- private void printVersionTheFirstTime() {
+ private static void printVersionTheFirstTime() {
if (!myVersionPrinted) {
myVersionPrinted = true;
hg("version");
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgLightTest.java b/plugins/hg4idea/testSrc/hg4idea/test/HgLightTest.java
index f8cd598b6bec..cf214a774e5c 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/HgLightTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/HgLightTest.java
@@ -15,6 +15,7 @@
*/
package hg4idea.test;
+import com.intellij.dvcs.test.Executor;
import com.intellij.dvcs.test.MockProject;
import com.intellij.dvcs.test.MockVirtualFile;
import com.intellij.openapi.application.PluginPathManager;
@@ -33,7 +34,7 @@ import static org.junit.Assume.assumeTrue;
/**
* @author Nadya Zabrodina
*/
-public class HgLightTest extends HgExecutor {
+public class HgLightTest {
//private static final String USER_NAME = "John Doe";
//private static final String USER_EMAIL = "John.Doe@example.com";
@@ -62,13 +63,14 @@ public class HgLightTest extends HgExecutor {
catch (IOException e) {
fail("Can not start test case!\n"); //todo change
}
- cd(myTestRoot);
- myProjectRoot = mkdir("project");
+ Executor.cd(myTestRoot);
+ myProjectRoot = Executor.mkdir("project");
myProject = new MockProject(myProjectRoot);
myPlatformFacade = new HgTestPlatformFacade();
- cd(".hg");
+ Executor.cd(".hg");
File pluginRoot = new File(PluginPathManager.getPluginHomePath("hg4idea"));
- File hgrcFile = new File(new File(pluginRoot, "testData\\repo\\dot_hg"), "hgrc");
+ String pathToHgrc = "testData\\repo\\dot_hg";
+ File hgrcFile = new File(new File(pluginRoot, FileUtil.toSystemIndependentName(pathToHgrc)), "hgrc");
File hgrc = new File(new File(myProjectRoot, ".hg"), "hgrc");
try {
FileUtil.copy(hgrcFile, hgrc);
@@ -96,11 +98,11 @@ public class HgLightTest extends HgExecutor {
return new MockVirtualFile(rootDir);
}
- private void initRepo(String repoRoot) {
- cd(repoRoot);
- hg("init");
- touch("file.txt");
- hg("add file.txt");
- hg("commit -m initial");
+ private static void initRepo(String repoRoot) {
+ Executor.cd(repoRoot);
+ HgExecutor.hg("init");
+ Executor.touch("file.txt");
+ HgExecutor.hg("add file.txt");
+ HgExecutor.hg("commit -m initial");
}
}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgMockVcsManager.java b/plugins/hg4idea/testSrc/hg4idea/test/HgMockVcsManager.java
index 5ca7089902c3..c1a80b9b86af 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/HgMockVcsManager.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/HgMockVcsManager.java
@@ -251,12 +251,7 @@ public class HgMockVcsManager extends ProjectLevelVcsManager {
@NotNull
@Override
public VcsRoot[] getAllVcsRoots() {
- List vcsRoots = new ArrayList();
- List repositories = myPlatformFacade.getRepositoryManager(myProject).getRepositories();
- for (VirtualFile repository : repositories) {
- vcsRoots.add(new VcsRoot(getVcsFor(repository), repository));
- }
- return vcsRoots.toArray(new VcsRoot[0]);
+ throw new UnsupportedOperationException();
}
@Override
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgTestPlatformFacade.java b/plugins/hg4idea/testSrc/hg4idea/test/HgTestPlatformFacade.java
index 76fa2fe065fc..7c21b0f638cc 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/HgTestPlatformFacade.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/HgTestPlatformFacade.java
@@ -20,19 +20,17 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import org.jetbrains.annotations.NotNull;
-import org.zmlx.hg4idea.*;
+import org.zmlx.hg4idea.HgGlobalSettings;
+import org.zmlx.hg4idea.HgPlatformFacade;
+import org.zmlx.hg4idea.HgProjectSettings;
+import org.zmlx.hg4idea.HgVcs;
/**
* @author Nadya Zabrodina
*/
-class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformFacade {
+public class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformFacade {
private HgMockVcs myVcs;
private HgMockVcsManager myVcsManager;
- private HgTestRepositoryManager myRepositoryManager;
-
- HgTestPlatformFacade() {
- myRepositoryManager = new HgTestRepositoryManager();
- }
@NotNull
@Override
@@ -44,6 +42,7 @@ class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformF
return myVcs;
}
+
@NotNull
@Override
public ProjectLevelVcsManager getVcsManager(@NotNull Project project) {
@@ -58,11 +57,5 @@ class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformF
public void showDialog(@NotNull DialogWrapper dialog) {
throw new UnsupportedOperationException();
}
-
- @NotNull
- @Override
- public HgRepositoryManager getRepositoryManager(@NotNull Project project) {
- return myRepositoryManager;
- }
}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgTestRepositoryManager.java b/plugins/hg4idea/testSrc/hg4idea/test/HgTestRepositoryManager.java
deleted file mode 100644
index bff58e4facc1..000000000000
--- a/plugins/hg4idea/testSrc/hg4idea/test/HgTestRepositoryManager.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package hg4idea.test;
-
-import com.intellij.openapi.vfs.VirtualFile;
-import org.jetbrains.annotations.NotNull;
-import org.zmlx.hg4idea.HgRepositoryManager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Nadya Zabrodina
- */
-public class HgTestRepositoryManager implements HgRepositoryManager {
-
- private final List myRepositories = new ArrayList();
-
- public void add(VirtualFile repository) {
- myRepositories.add(repository);
- }
-
- @NotNull
- @Override
- public List getRepositories() {
- return myRepositories;
- }
-}
diff --git a/plugins/hg4idea/testSrc/hg4idea/test/diff/HgGetDiffForDirTest.java b/plugins/hg4idea/testSrc/hg4idea/test/diff/HgGetDiffForDirTest.java
index bfae5ed4f242..d8bd6b561a63 100644
--- a/plugins/hg4idea/testSrc/hg4idea/test/diff/HgGetDiffForDirTest.java
+++ b/plugins/hg4idea/testSrc/hg4idea/test/diff/HgGetDiffForDirTest.java
@@ -15,9 +15,11 @@
*/
package hg4idea.test.diff;
+import com.intellij.dvcs.test.Executor;
import com.intellij.dvcs.test.MockVirtualFile;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.changes.Change;
+import hg4idea.test.HgExecutor;
import hg4idea.test.HgLightTest;
import org.junit.After;
import org.junit.Test;
@@ -53,28 +55,28 @@ public class HgGetDiffForDirTest extends HgLightTest {
@Test
public void testDiffForDir() {
- cd(myProjectRoot);
- touch("A.txt", "dsfdfdsf");
- hg("add A.txt");
- touch("B.txt");
- hg("add B.txt");
- hg("commit -m 2files_added");
- mkdir("dir");
- cd("dir");
- touch("C.txt");
- touch("D.txt");
- hg("add C.txt");
- hg("add D.txt");
- hg("commit -m createDir");
+ Executor.cd(myProjectRoot);
+ Executor.touch("A.txt", "dsfdfdsf");
+ HgExecutor.hg("add A.txt");
+ Executor.touch("B.txt");
+ HgExecutor.hg("add B.txt");
+ HgExecutor.hg("commit -m 2files_added");
+ Executor.mkdir("dir");
+ Executor.cd("dir");
+ Executor.touch("C.txt");
+ Executor.touch("D.txt");
+ HgExecutor.hg("add C.txt");
+ HgExecutor.hg("add D.txt");
+ HgExecutor.hg("commit -m createDir");
File dirFile = new File(myProjectRoot, "dir");
- String[] hash1 = hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
+ String[] hash1 = HgExecutor.hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
HgRevisionNumber r1number = HgRevisionNumber.getInstance(hash1[0], hash1[1]);
HgFileRevision rev1 =
new HgFileRevision(myProject, new HgFile(myRepository, dirFile), r1number, "", null, "", "", null, null, null, null);
- echo("C.txt", "aaaa");
- echo("D.txt", "dddd");
- hg("commit -m modifyDir");
- String[] hash2 = hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
+ Executor.echo("C.txt", "aaaa");
+ Executor.echo("D.txt", "dddd");
+ HgExecutor.hg("commit -m modifyDir");
+ String[] hash2 = HgExecutor.hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
HgRevisionNumber r2number = HgRevisionNumber.getInstance(hash2[0], hash2[1]);
HgFileRevision rev2 =
new HgFileRevision(myProject, new HgFile(myRepository, dirFile), r2number, "", null, "", "", null, null, null, null);
From 38c8d93a6b5edecdbca47c4d63c4e446c401ca3f Mon Sep 17 00:00:00 2001
From: Roman Shevchenko
Date: Thu, 31 Jan 2013 19:25:43 +0400
Subject: [PATCH 11/51] EA-43386 (dogs and nulls are forbidden)
---
.../fileChooser/ex/FileChooserDialogImpl.java | 21 +++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java
index 2b313d131512..f775685995ef 100644
--- a/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/fileChooser/ex/FileChooserDialogImpl.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,7 +124,8 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
show();
if (myChosenFiles.length > 0) {
callback.consume(Arrays.asList(myChosenFiles));
- } else if (callback instanceof FileChooser.FileChooserConsumer){
+ }
+ else if (callback instanceof FileChooser.FileChooserConsumer) {
((FileChooser.FileChooserConsumer)callback).cancelled();
}
}
@@ -357,13 +358,21 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
myFileSystemTree.registerMouseListener(group);
}
+ @Nullable
private VirtualFile[] getSelectedFilesInt() {
if (myTreeIsUpdating || !myUiUpdater.isEmpty()) {
- if (!isTextFieldActive() || StringUtil.isEmpty(myPathTextField.getTextFieldText()))
- return VirtualFile.EMPTY_ARRAY;
- final LocalFsFinder.VfsFile toFind = (LocalFsFinder.VfsFile)myPathTextField.getFile();
- return toFind == null || !toFind.exists() ? VirtualFile.EMPTY_ARRAY : new VirtualFile[]{toFind.getFile()};
+ if (isTextFieldActive() && !StringUtil.isEmpty(myPathTextField.getTextFieldText())) {
+ LookupFile toFind = myPathTextField.getFile();
+ if (toFind instanceof LocalFsFinder.VfsFile && toFind.exists()) {
+ VirtualFile file = ((LocalFsFinder.VfsFile)toFind).getFile();
+ if (file != null) {
+ return new VirtualFile[]{file};
+ }
+ }
+ }
+ return VirtualFile.EMPTY_ARRAY;
}
+
final List selectedFiles = Arrays.asList(myFileSystemTree.getSelectedFiles());
return VfsUtilCore.toVirtualFileArray(FileChooserUtil.getChosenFiles(myChooserDescriptor, selectedFiles));
}
From db4fe8f6934f2759eac4e9f94df28bf6f0f3bbf3 Mon Sep 17 00:00:00 2001
From: Roman Shevchenko
Date: Fri, 1 Feb 2013 15:20:27 +0400
Subject: [PATCH 12/51] EA-41519 (IOEs on process stream closing aren't errors)
---
.../com/intellij/execution/process/BaseOSProcessHandler.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java b/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java
index f9ca8c45599e..322e9cc8d973 100644
--- a/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java
+++ b/platform/util/src/com/intellij/execution/process/BaseOSProcessHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -159,7 +159,7 @@ public class BaseOSProcessHandler extends ProcessHandler {
myProcess.getOutputStream().close();
}
catch (IOException e) {
- LOG.error(e);
+ LOG.warn(e);
}
}
From a2bfe8ee163711c2e48d85572792f1c5094aa816 Mon Sep 17 00:00:00 2001
From: Roman Shevchenko
Date: Fri, 1 Feb 2013 15:42:44 +0400
Subject: [PATCH 13/51] File watcher start postponed to avoid deadlock in
component model
---
.../openapi/vfs/impl/local/FileWatcher.java | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java
index 33498fbf29c4..81dacf7d3de8 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java
@@ -44,6 +44,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import static com.intellij.util.containers.ContainerUtil.*;
@@ -83,6 +84,7 @@ public class FileWatcher {
private final ManagingFS myManagingFS;
private final File myExecutable;
+ private final AtomicBoolean myInitialized = new AtomicBoolean(false);
private volatile MyProcessHandler myProcessHandler;
private volatile int myStartAttemptCount = 0;
private volatile boolean myIsShuttingDown = false;
@@ -101,12 +103,21 @@ public class FileWatcher {
myExecutable = getExecutable();
if (disabled) {
+ myInitialized.set(true);
LOG.info("Native file watcher is disabled");
}
else if (myExecutable == null) {
+ myInitialized.set(true);
LOG.info("Native file watcher is not supported on this platform");
}
- else if (!myExecutable.exists()) {
+ }
+
+ private void init() {
+ if (!myInitialized.compareAndSet(false, true)) {
+ return;
+ }
+
+ if (!myExecutable.exists()) {
notifyOnFailure(ApplicationBundle.message("watcher.exe.not.found"), null);
}
else if (!myExecutable.canExecute()) {
@@ -244,7 +255,7 @@ public class FileWatcher {
}
public boolean isOperational() {
- return myProcessHandler != null;
+ return !myInitialized.get() || myProcessHandler != null;
}
public boolean isSettingRoots() {
@@ -280,6 +291,7 @@ public class FileWatcher {
}
public void setWatchRoots(final List recursive, final List flat) {
+ init();
setWatchRoots(recursive, flat, false);
}
@@ -309,8 +321,7 @@ public class FileWatcher {
writeLine("#");
}
catch (IOException e) {
- LOG.error(e);
- shutdownProcess();
+ LOG.warn(e);
}
myRecursiveWatchRoots = recursive;
From 9ea564af0d63c36901c6e315fd31a429c892612d Mon Sep 17 00:00:00 2001
From: Alexander Lobas
Date: Fri, 1 Feb 2013 16:08:01 +0400
Subject: [PATCH 14/51] Visual Edit
---
.../designSurface/DesignerEditorPanel.java | 20 ++++++++++++-------
.../designSurface/FlowBaseOperation.java | 14 ++++++++-----
.../designSurface/tools/SelectionTool.java | 4 +++-
.../intellij/designer/model/RadComponent.java | 2 +-
4 files changed, 26 insertions(+), 14 deletions(-)
diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
index 330c90a74c89..ad6d77e4d9c3 100644
--- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
+++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java
@@ -173,12 +173,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
@Override
public RadComponent findTarget(int x, int y, @Nullable ComponentTargetFilter filter) {
- if (myRootComponent != null) {
- FindComponentVisitor visitor = new FindComponentVisitor(myLayeredPane, filter, x, y);
- myRootComponent.accept(visitor, false);
- return visitor.getResult();
- }
- return null;
+ return DesignerEditorPanel.this.findTarget(x, y, filter);
}
@Override
@@ -727,10 +722,21 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider
public abstract String getPlatformTarget();
+ protected RadComponent findTarget(int x, int y, @Nullable ComponentTargetFilter filter) {
+ if (myRootComponent != null) {
+ FindComponentVisitor visitor = new FindComponentVisitor(myLayeredPane, filter, x, y);
+ myRootComponent.accept(visitor, false);
+ return visitor.getResult();
+ }
+ return null;
+ }
+
protected abstract ComponentDecorator getRootSelectionDecorator();
@Nullable
- protected abstract EditOperation processRootOperation(OperationContext context);
+ protected EditOperation processRootOperation(OperationContext context) {
+ return null;
+ }
protected abstract boolean execute(ThrowableRunnable operation, boolean updateProperties);
diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java
index e0a75b8fa64f..dbdbea94271f 100644
--- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java
+++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java
@@ -47,7 +47,7 @@ public abstract class FlowBaseOperation extends AbstractEditOperation {
createFirstInsertFeedback();
createInsertFeedback();
- if (myContainer.getChildren().isEmpty()) {
+ if (getChildren().isEmpty()) {
layer.add(myFirstInsertFeedback);
}
else {
@@ -57,6 +57,10 @@ public abstract class FlowBaseOperation extends AbstractEditOperation {
}
}
+ protected List getChildren() {
+ return myContainer.getChildren();
+ }
+
protected void createInsertFeedback() {
myInsertFeedback = new LineInsertFeedback(Color.green, !myHorizontal);
myInsertFeedback.size(myBounds.width, myBounds.height);
@@ -71,13 +75,13 @@ public abstract class FlowBaseOperation extends AbstractEditOperation {
public void showFeedback() {
createFeedback();
- if (!myContainer.getChildren().isEmpty()) {
+ if (!getChildren().isEmpty()) {
FeedbackLayer layer = myContext.getArea().getFeedbackLayer();
Point location = myContext.getLocation();
myChildTarget = null;
if (myHorizontal) {
- for (RadComponent child : myContainer.getChildren()) {
+ for (RadComponent child : getChildren()) {
Rectangle childBounds = getBounds(child, layer);
if (childBounds.x <= location.x && location.x <= childBounds.getMaxX()) {
myChildTarget = child;
@@ -86,7 +90,7 @@ public abstract class FlowBaseOperation extends AbstractEditOperation {
}
}
else {
- for (RadComponent child : myContainer.getChildren()) {
+ for (RadComponent child : getChildren()) {
Rectangle childBounds = getBounds(child, layer);
if (childBounds.y <= location.y && location.y <= childBounds.getMaxY()) {
myChildTarget = child;
@@ -131,7 +135,7 @@ public abstract class FlowBaseOperation extends AbstractEditOperation {
private RadComponent getSideChildTarget() {
Point location = myContext.getLocation();
- List children = myContainer.getChildren();
+ List children = getChildren();
RadComponent lastChild = children.get(children.size() - 1);
Rectangle childBounds = lastChild.getBounds(myContext.getArea().getFeedbackLayer());
diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java
index eed759966137..e6e6b05f92f1 100644
--- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java
+++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/tools/SelectionTool.java
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionPopupMenu;
import org.jetbrains.annotations.Nullable;
+import java.awt.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
@@ -75,7 +76,8 @@ public class SelectionTool extends InputTool {
}
}
else {
- setTracker(component.getDragTracker());
+ Point location = component.convertPoint(myArea.getNativeComponent(), myCurrentScreenX, myCurrentScreenY);
+ setTracker(component.getDragTracker(location, myArea.isTree()));
}
}
}
diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java
index 632e389b7c70..38115576a7f7 100644
--- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java
+++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/model/RadComponent.java
@@ -138,7 +138,7 @@ public abstract class RadComponent extends PropertiesContainer {
return null;
}
- public InputTool getDragTracker() {
+ public InputTool getDragTracker(Point location, boolean isTree) {
return new DragTracker(this);
}
From 8c638a841a6d9ff1f7de2b368630842ba633e255 Mon Sep 17 00:00:00 2001
From: irengrig
Date: Fri, 1 Feb 2013 16:33:27 +0400
Subject: [PATCH 15/51] Subversion: one more place where svnkit connection pool
was used
---
.../idea/svn/SvnFileSystemListener.java | 22 +++++--------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java
index b0e0d3251a18..30cb2a92a6af 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java
@@ -246,15 +246,15 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
final boolean is17 = SvnUtil.is17CopyPart(src);
if (is17) {
- SVNStatus srcStatus = getFileStatus(src);
+ SVNStatus srcStatus = getFileStatus(vcs, src);
final File toDir = dst.getParentFile();
- SVNStatus dstStatus = getFileStatus(toDir);
+ SVNStatus dstStatus = getFileStatus(vcs, toDir);
final boolean srcUnversioned = srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus);
if (srcUnversioned && (dstStatus == null || SvnVcs.svnStatusIsUnversioned(dstStatus))) {
return false;
}
if (srcUnversioned) {
- SVNStatus dstWasStatus = getFileStatus(dst);
+ SVNStatus dstWasStatus = getFileStatus(vcs, dst);
if (dstWasStatus == null || SvnVcs.svnStatusIsUnversioned(dstWasStatus)) {
return false;
}
@@ -309,7 +309,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
} else {
if (doUsualMove(vcs, src)) return true;
// check destination directory
- final SVNStatus dstParentStatus = getFileStatus(dst.getParentFile());
+ final SVNStatus dstParentStatus = getFileStatus(vcs, dst.getParentFile());
if (dstParentStatus == null || SvnVcs.svnStatusIsUnversioned(dstParentStatus)) {
try {
copyFileOrDir(src, dst);
@@ -482,7 +482,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
//
}
- SVNStatus status = getFileStatus(ioFile);
+ SVNStatus status = getFileStatus(vcs, ioFile);
if (status == null ||
SvnVcs.svnStatusIsUnversioned(status) ||
@@ -1031,18 +1031,6 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp
return new File(vf.getPath()).getAbsoluteFile();
}
- @Nullable
- private static SVNStatus getFileStatus(File file) {
- final SVNClientManager clientManager = SVNClientManager.newInstance();
- try {
- SVNStatusClient stClient = clientManager.getStatusClient();
- return getFileStatus(file, stClient);
- }
- finally {
- clientManager.dispose();
- }
- }
-
@Nullable
private static SVNStatus getFileStatus(SvnVcs vcs, File file) {
SVNStatusClient stClient = vcs.createStatusClient();
From 36cc111557519871b9e2ebf0706c45ac3fb0abf9 Mon Sep 17 00:00:00 2001
From: Oleg Sukhodolsky
Date: Fri, 1 Feb 2013 16:23:58 +0400
Subject: [PATCH 16/51] EA-40521: changed way to add new text to console
---
.../console/LanguageConsoleImpl.java | 29 +++++++------------
1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
index 2002d01dfac0..c321696b5729 100644
--- a/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
+++ b/platform/lang-impl/src/com/intellij/execution/console/LanguageConsoleImpl.java
@@ -389,31 +389,24 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
final boolean scrollToEnd = shouldScrollHistoryToEnd();
final int[] offsets = new int[attributedText.size() + 1];
int i = 0;
- offsets[i] = 0;
- final StringBuilder sb = new StringBuilder();
+ final Document history = myHistoryViewer.getDocument();
+ offsets[i] = history.getTextLength();
for (final Pair pair : attributedText) {
final String str = StringUtil.convertLineSeparators(pair.getFirst());
- final int lastOffset = offsets[i];
- offsets[++i] = lastOffset + str.length();
- sb.append(str);
+ appendToHistoryDocument(history, str);
+ offsets[++i] = history.getTextLength();
}
LOG.debug("printToHistory(): text processed");
- final Document history = myHistoryViewer.getDocument();
final MarkupModel markupModel = DocumentMarkupModel.forDocument(history, myProject, true);
- final int oldHistoryLength = history.getTextLength();
- appendToHistoryDocument(history, sb.toString());
- if ((oldHistoryLength + offsets[i]) != history.getTextLength()) {
- assert false : "Last offset - " + offsets[i] + " history length: old " + oldHistoryLength + ", new - " + history.getTextLength()
- + ", history - " + history;
- }
- LOG.debug("printToHistory(): text added");
i = 0;
for (final Pair pair : attributedText) {
- markupModel.addRangeHighlighter(oldHistoryLength + offsets[i],
- oldHistoryLength + offsets[i+1],
- HighlighterLayer.SYNTAX,
- pair.getSecond(),
- HighlighterTargetArea.EXACT_RANGE);
+ markupModel.addRangeHighlighter(
+ offsets[i],
+ offsets[i+1],
+ HighlighterLayer.SYNTAX,
+ pair.getSecond(),
+ HighlighterTargetArea.EXACT_RANGE
+ );
++i;
}
LOG.debug("printToHistory(): markup added");
From 8c739ac825c24b55255a3bbca26c444426e28884 Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Fri, 1 Feb 2013 14:28:45 +0400
Subject: [PATCH 17/51] javafx: handle constants rename (IDEA-100284)
---
.../EnumeratedAttributeReferenceProvider.java | 22 ++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java
index 8f8746082845..ef72a7fbb20e 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java
@@ -15,15 +15,14 @@
*/
package org.jetbrains.plugins.javaFX.fxml.refs;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiReference;
-import com.intellij.psi.PsiReferenceBase;
-import com.intellij.psi.PsiReferenceProvider;
+import com.intellij.psi.*;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
+import com.intellij.util.ArrayUtil;
import com.intellij.util.ProcessingContext;
import com.intellij.xml.XmlAttributeDescriptor;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxPropertyAttributeDescriptor;
/**
@@ -39,7 +38,20 @@ class EnumeratedAttributeReferenceProvider extends PsiReferenceProvider {
if (parent instanceof XmlAttribute) {
final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
if (descriptor instanceof JavaFxPropertyAttributeDescriptor && descriptor.isEnumerated()) {
- return new PsiReference[] {new PsiReferenceBase.Immediate(xmlAttributeValue, ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(xmlAttributeValue.getValue()))};
+ final PsiField enumConstant = ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(xmlAttributeValue.getValue());
+ return new PsiReference[] {new PsiReferenceBase(xmlAttributeValue){
+ @Nullable
+ @Override
+ public PsiElement resolve() {
+ return enumConstant;
+ }
+
+ @NotNull
+ @Override
+ public Object[] getVariants() {
+ return ArrayUtil.EMPTY_OBJECT_ARRAY;
+ }
+ }};
}
}
}
From 8b87a12222a0250d3ae254964293a4c7b9a5e563 Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Fri, 1 Feb 2013 15:54:47 +0400
Subject: [PATCH 18/51] javafx: check class instantiation (IDEA-100275)
---
.../javaFX/fxml/JavaFxCommonClassNames.java | 1 +
.../JavaFxClassBackedElementDescriptor.java | 30 +++++++++++++++++++
.../highlighting/instantiationAcceptance.fxml | 9 ++++++
.../javaFX/fxml/JavaFXHighlightingTest.java | 4 +++
4 files changed, 44 insertions(+)
create mode 100644 plugins/javaFX/testData/highlighting/instantiationAcceptance.fxml
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxCommonClassNames.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxCommonClassNames.java
index 78f185b6a31a..051b427e3de9 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxCommonClassNames.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxCommonClassNames.java
@@ -31,4 +31,5 @@ public class JavaFxCommonClassNames {
@NonNls public static final String JAVAFX_EVENT_EVENT_HANDLER = "javafx.event.EventHandler";
@NonNls public static final String JAVAFX_SCENE_NODE = "javafx.scene.Node";
@NonNls public static final String JAVAFX_SCENE_PAINT = "javafx.scene.paint.Paint";
+ @NonNls public static final String JAVAFX_FXML_BUILDER = "javafx.util.Builder";
}
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java
index 093a9bedf7d0..2cf007f383b6 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxClassBackedElementDescriptor.java
@@ -4,17 +4,22 @@ import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.daemon.Validator;
import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
+import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.xml.XmlAttributeImpl;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.searches.ClassInheritorsSearch;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
+import com.intellij.util.Processor;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.XmlElementsGroup;
@@ -279,6 +284,31 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor,
}
}
validateTagAccordingToFieldType(context, parentTag, host);
+ if (myPsiClass != null && myPsiClass.isValid()) {
+ if(myPsiClass.getConstructors().length > 0) {
+ final Project project = myPsiClass.getProject();
+ final PsiMethod noArgConstructor = myPsiClass
+ .findMethodBySignature(JavaPsiFacade.getElementFactory(project).createConstructor(myPsiClass.getName()), false);
+ if (noArgConstructor == null) {
+ final PsiClass builderClass = JavaPsiFacade.getInstance(project).findClass(JavaFxCommonClassNames.JAVAFX_FXML_BUILDER,
+ GlobalSearchScope.allScope(project));
+ if (builderClass != null) {
+ //todo cache this info
+ final PsiTypeParameter typeParameter = builderClass.getTypeParameters()[0];
+ if (ClassInheritorsSearch.search(builderClass).forEach(new Processor() {
+ @Override
+ public boolean process(PsiClass aClass) {
+ final PsiType initType =
+ TypeConversionUtil.getSuperClassSubstitutor(builderClass, aClass, PsiSubstitutor.EMPTY).substitute(typeParameter);
+ return !Comparing.equal(myPsiClass, PsiUtil.resolveClassInClassTypeOnly(initType));
+ }
+ })) {
+ host.addMessage(context, "Unable to instantiate", ValidationHost.ErrorType.ERROR);
+ }
+ }
+ }
+ }
+ }
}
private void validateTagAccordingToFieldType(XmlTag context, XmlTag parentTag, ValidationHost host) {
diff --git a/plugins/javaFX/testData/highlighting/instantiationAcceptance.fxml b/plugins/javaFX/testData/highlighting/instantiationAcceptance.fxml
new file mode 100644
index 000000000000..4a538b7bd0da
--- /dev/null
+++ b/plugins/javaFX/testData/highlighting/instantiationAcceptance.fxml
@@ -0,0 +1,9 @@
+
+
+
+
+
+ <File/>
+
+
+
diff --git a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
index 701e1beb9fa6..763665200ecc 100644
--- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
+++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
@@ -151,6 +151,10 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase {
doTest();
}
+ public void testInstantiationAcceptance() throws Exception {
+ doTest();
+ }
+
@NotNull
@Override
protected String getTestDataPath() {
From 8949c069943650528a9be1aff35e9172b2de9980 Mon Sep 17 00:00:00 2001
From: Anna Kozlova
Date: Fri, 1 Feb 2013 16:09:23 +0400
Subject: [PATCH 19/51] javafx: fqns in tag names (IDEA-100287)
---
.../plugins/javaFX/fxml/JavaFxPsiUtil.java | 13 +++++++++++--
.../javaFX/testData/highlighting/fQNtagNames.fxml | 4 ++++
.../plugins/javaFX/fxml/JavaFXHighlightingTest.java | 4 ++++
3 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 plugins/javaFX/testData/highlighting/fQNtagNames.fxml
diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
index ec1e699473cc..9941ea92b390 100644
--- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
+++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
+import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PsiTreeUtil;
@@ -82,7 +83,11 @@ public class JavaFxPsiUtil {
}
public static PsiClass findPsiClass(String name, XmlTag tag) {
- return findPsiClass(name, parseImports((XmlFile)tag.getContainingFile()), tag, tag.getProject());
+ final Project project = tag.getProject();
+ if (!StringUtil.getShortName(name).equals(name)) {
+ return JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project));
+ }
+ return findPsiClass(name, parseImports((XmlFile)tag.getContainingFile()), tag, project);
}
private static PsiClass findPsiClass(String name, List imports, XmlTag tag, Project project) {
@@ -155,7 +160,11 @@ public class JavaFxPsiUtil {
public static boolean isClassTag(String name) {
final String shortName = StringUtil.getShortName(name);
- return StringUtil.isCapitalized(name) && name.equals(shortName);
+ final boolean capitalized = StringUtil.isCapitalized(name);
+ if (name.equals(shortName)) {
+ return capitalized;
+ }
+ return !capitalized;
}
public static PsiMethod findPropertySetter(String attributeName, XmlTag context) {
diff --git a/plugins/javaFX/testData/highlighting/fQNtagNames.fxml b/plugins/javaFX/testData/highlighting/fQNtagNames.fxml
new file mode 100644
index 000000000000..6137837891f2
--- /dev/null
+++ b/plugins/javaFX/testData/highlighting/fQNtagNames.fxml
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
index 763665200ecc..236ca1a6a877 100644
--- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
+++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java
@@ -155,6 +155,10 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase {
doTest();
}
+ public void testFQNtagNames() throws Exception {
+ doTest();
+ }
+
@NotNull
@Override
protected String getTestDataPath() {
From 4c02bcc1ed89151b4b3df75a93d3def0f0ee97f6 Mon Sep 17 00:00:00 2001
From: Dmitry Trofimov
Date: Fri, 1 Feb 2013 14:10:59 +0100
Subject: [PATCH 20/51] Ability to save unfinished remote interpreter settings
(PY-7503).
---
.../com/intellij/remotesdk/RemoteSdkData.java | 4 ++++
.../intellij/remotesdk/RemoteSdkDataHolder.java | 17 +++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkData.java b/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkData.java
index eb5f0a0bc4d0..a8a14a49900a 100644
--- a/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkData.java
+++ b/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkData.java
@@ -53,4 +53,8 @@ public interface RemoteSdkData extends RemoteCredentials {
boolean isHelpersVersionChecked();
void setHelpersVersionChecked(boolean helpersVersionChecked);
+
+ boolean isInitialized();
+
+ void setInitialized(boolean initialized);
}
diff --git a/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkDataHolder.java b/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkDataHolder.java
index e167fe781139..2c9b731d380a 100644
--- a/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkDataHolder.java
+++ b/platform/platform-impl/src/com/intellij/remotesdk/RemoteSdkDataHolder.java
@@ -30,6 +30,7 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
private static final String HELPERS_PATH = "HELPERS_PATH";
private static final String REMOTE_ROOTS = "REMOTE_ROOTS";
private static final String REMOTE_PATH = "REMOTE_PATH";
+ private static final String INITIALIZED = "INITIALIZED";
private String myHost;
private int myPort;
@@ -52,6 +53,8 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
private List myRemoteRoots = new ArrayList();
+ private boolean myInitialized;
+
public RemoteSdkDataHolder(@NotNull final String defaultDirName) {
myHelpersDefaultDirName = defaultDirName;
}
@@ -285,6 +288,16 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
myHelpersVersionChecked = helpersVersionChecked;
}
+ @Override
+ public boolean isInitialized() {
+ return myInitialized;
+ }
+
+ @Override
+ public void setInitialized(boolean initialized) {
+ myInitialized = initialized;
+ }
+
public static boolean isRemoteSdk(@Nullable String path) {
if (path != null) {
return path.startsWith(SSH_PREFIX);
@@ -309,6 +322,8 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
setHelpersPath(StringUtil.nullize(element.getAttributeValue(HELPERS_PATH)));
setRemoteRoots(loadStringsList(element, REMOTE_ROOTS, REMOTE_PATH));
+
+ setInitialized(StringUtil.parseBoolean(element.getAttributeValue(INITIALIZED), true));
}
protected static List loadStringsList(Element element, String rootName, String attrName) {
@@ -336,6 +351,8 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
rootElement.setAttribute(INTERPRETER_PATH, StringUtil.notNullize(getInterpreterPath()));
rootElement.setAttribute(HELPERS_PATH, StringUtil.notNullize(getHelpersPath()));
+ rootElement.setAttribute(INITIALIZED, Boolean.toString(isInitialized()));
+
for (String remoteRoot : getRemoteRoots()) {
final Element child = new Element(REMOTE_ROOTS);
child.setAttribute(REMOTE_PATH, remoteRoot);
From 16a8fa455bdb689e2f439e5a2382a121c3579e82 Mon Sep 17 00:00:00 2001
From: "Gregory.Shrago"
Date: Fri, 1 Feb 2013 15:22:26 +0400
Subject: [PATCH 21/51] minor dynamic languages support fixes
---
.../src/com/intellij/psi/tree/IFileElementType.java | 4 ++++
.../com/intellij/psi/impl/file/impl/PsiVFSListener.java | 3 ++-
.../src/com/intellij/testFramework/ParsingTestCase.java | 8 ++++----
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/platform/core-api/src/com/intellij/psi/tree/IFileElementType.java b/platform/core-api/src/com/intellij/psi/tree/IFileElementType.java
index a9a3a83bc5a1..39149eab2e6e 100644
--- a/platform/core-api/src/com/intellij/psi/tree/IFileElementType.java
+++ b/platform/core-api/src/com/intellij/psi/tree/IFileElementType.java
@@ -31,6 +31,10 @@ public class IFileElementType extends ILazyParseableElementType {
super(debugName, language);
}
+ public IFileElementType(@NonNls @NotNull final String debugName, @Nullable final Language language, boolean register) {
+ super(debugName, language, register);
+ }
+
@Nullable
@Override
public ASTNode parseContents(final ASTNode chameleon) {
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
index 68079c75381f..a6427f42e510 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
@@ -318,7 +318,8 @@ public class PsiVFSListener extends VirtualFileAdapter {
VirtualFile parent = vFile.getParent();
final PsiDirectory parentDir = getCachedDirectory(parent);
- if (parentDir == null) {
+ // do not suppress reparse request for light files
+ if (parentDir == null && !FileContentUtil.FORCE_RELOAD_REQUESTOR.equals(event.getRequestor())) {
boolean fire = VirtualFile.PROP_NAME.equals(propertyName) && vFile.isDirectory();
if (fire) {
PsiDirectory psiDir = myFileManager.getCachedDirectory(vFile);
diff --git a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java
index 5de553b97230..071dd4b3a22b 100644
--- a/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java
@@ -271,15 +271,15 @@ public abstract class ParsingTestCase extends PlatformLiteFixture {
doCheckResult(myFullDataPath, targetDataName, text);
}
- private static void doCheckResult(String myFullDataPath, String targetDataName, String text) throws IOException {
+ public static void doCheckResult(String fullPath, String targetDataName, String text) throws IOException {
text = text.trim();
- String expectedFileName = myFullDataPath + File.separatorChar + targetDataName;
+ String expectedFileName = fullPath + File.separatorChar + targetDataName;
if (OVERWRITE_TESTDATA) {
VfsTestUtil.overwriteTestData(expectedFileName, text);
System.out.println("File " + expectedFileName + " created.");
}
try {
- String expectedText = doLoadFile(myFullDataPath, targetDataName);
+ String expectedText = doLoadFile(fullPath, targetDataName);
if (!Comparing.equal(expectedText, text)) {
throw new FileComparisonFailure(targetDataName, expectedText, text, expectedFileName);
}
@@ -304,7 +304,7 @@ public abstract class ParsingTestCase extends PlatformLiteFixture {
return text;
}
- private static void ensureParsed(PsiFile file) {
+ public static void ensureParsed(PsiFile file) {
file.accept(new PsiElementVisitor() {
@Override
public void visitElement(PsiElement element) {
From bc95bb4158e6442b2a69e72b480fc349110e8ff0 Mon Sep 17 00:00:00 2001
From: irengrig
Date: Fri, 1 Feb 2013 18:01:17 +0400
Subject: [PATCH 22/51] Do not use SVNWCAccess despite working copy is 200%
before-1.7 version and low-level access is needed
---
.../idea/svn/RootsToWorkingCopies.java | 1 +
.../src/org/jetbrains/idea/svn/SvnUtil.java | 26 +++++++------------
.../src/org/jetbrains/idea/svn/SvnVcs.java | 9 +------
.../svn/actions/CompareWithBranchAction.java | 4 ++-
4 files changed, 14 insertions(+), 26 deletions(-)
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java
index 083228821fd2..6cd0df2744d1 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java
@@ -129,6 +129,7 @@ public class RootsToWorkingCopies implements VcsListener {
try {
workingCopyRoot = SVNWCUtil.getWorkingCopyRoot(ioFile, true);
if (workingCopyRoot != null) {
+ // ok to use low-level 1.6 API, 1.7 is checked below
SVNWCAccess wcAccess = SVNWCAccess.newInstance(null);
try {
wcAccess.probeOpen(workingCopyRoot, false, 0);
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java
index c5f88f7d6760..f407b175e79a 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java
@@ -16,6 +16,7 @@
package org.jetbrains.idea.svn;
import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
@@ -45,8 +46,6 @@ import org.jetbrains.idea.svn.dialogs.LockDialog;
import org.tmatesoft.svn.core.*;
import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
-import org.tmatesoft.svn.core.internal.wc.admin.SVNEntry;
-import org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess;
import org.tmatesoft.svn.core.internal.wc2.SvnWcGeneration;
import org.tmatesoft.svn.core.io.SVNCapability;
import org.tmatesoft.svn.core.io.SVNRepository;
@@ -62,6 +61,7 @@ public class SvnUtil {
@NonNls public static final String WC_DB_FILE_NAME = "wc.db";
@NonNls public static final String DIR_PROPS_FILE_NAME = "dir-props";
@NonNls public static final String PATH_TO_LOCK_FILE = SVN_ADMIN_DIR_NAME + "/lock";
+ private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.SvnUtil");
private SvnUtil() { }
@@ -583,23 +583,15 @@ public class SvnUtil {
}
@Nullable
- public static SVNURL getUrl(final File file) {
- SVNWCAccess wcAccess = SVNWCAccess.newInstance(null);
+ public static SVNURL getUrl(final SvnVcs vcs, final File file) {
try {
- wcAccess.probeOpen(file, false, 0);
- SVNEntry entry = wcAccess.getVersionedEntry(file, false);
- return entry.getSVNURL();
- } catch (SVNException e) {
- //
- } finally {
- try {
- wcAccess.close();
- }
- catch (SVNException e) {
- //
- }
+ final SVNInfo info = vcs.createWCClient().doInfo(file, SVNRevision.UNDEFINED);
+ return info == null ? null : info.getURL(); // todo for moved items?
+ }
+ catch (SVNException e) {
+ LOG.debug(e);
+ return null;
}
- return null;
}
public static boolean doesRepositorySupportMergeInfo(final SvnVcs vcs, final SVNURL url) {
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
index 45e71c9f9c68..ce0874fec74b 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
@@ -91,7 +91,6 @@ import org.tmatesoft.svn.core.internal.util.jna.SVNJNAUtil;
import org.tmatesoft.svn.core.internal.wc.SVNAdminUtil;
import org.tmatesoft.svn.core.internal.wc.admin.SVNAdminArea14;
import org.tmatesoft.svn.core.internal.wc.admin.SVNAdminAreaFactory;
-import org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess;
import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import org.tmatesoft.svn.core.wc.*;
@@ -734,12 +733,6 @@ public class SvnVcs extends AbstractVcs {
return client;
}
- public SVNWCAccess createWCAccess() {
- final SVNWCAccess access = SVNWCAccess.newInstance(null);
- access.setOptions(myConfiguration.getOptions(myProject));
- return access;
- }
-
public ISVNOptions getSvnOptions() {
return myConfiguration.getOptions(myProject);
}
@@ -1128,7 +1121,7 @@ public class SvnVcs extends AbstractVcs {
final File ioFile = new File(vf.getPath());
SVNURL url = mapping.getUrlForFile(ioFile);
if (url == null) {
- url = SvnUtil.getUrl(ioFile);
+ url = SvnUtil.getUrl(this, ioFile);
if (url == null) {
notMatched.add(s);
continue;
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CompareWithBranchAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CompareWithBranchAction.java
index 58b48f2f93e9..1bfe1733c06a 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CompareWithBranchAction.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CompareWithBranchAction.java
@@ -223,7 +223,9 @@ public class CompareWithBranchAction extends AnAction implements DumbAware {
}
private void report16DirDiff(SvnVcs vcs, SVNURL url) throws SVNException {
- SVNWCAccess wcAccess = vcs.createWCAccess();
+ // here there's 1.6 copy so ok to use SVNWCAccess
+ final SVNWCAccess wcAccess = SVNWCAccess.newInstance(null);
+ wcAccess.setOptions(vcs.getSvnOptions());
SVNRepository repository = null;
SVNRepository repository2 = null;
try {
From 7b183e23664a67af2dfd63605f4d2f527f028c82 Mon Sep 17 00:00:00 2001
From: irengrig
Date: Fri, 1 Feb 2013 18:02:08 +0400
Subject: [PATCH 23/51] Subversion: correctly determine local path by URL (fix
SvnCommittedViewTest)
---
.../history/SvnRepositoryContentRevision.java | 12 +++++++++-
.../svn/history/SvnRepositoryLocation.java | 23 +++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java
index 836f6b4c83b1..459e9ab3a30e 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java
@@ -40,6 +40,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.SvnBundle;
import org.jetbrains.idea.svn.SvnRevisionNumber;
+import org.jetbrains.idea.svn.SvnUtil;
import org.jetbrains.idea.svn.SvnVcs;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.io.SVNRepository;
@@ -65,7 +66,16 @@ public class SvnRepositoryContentRevision implements ContentRevision, MarkerVcsC
myFilePath = localPath;
}
else {
- myFilePath = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(myPath, false);
+ FilePath local;
+ try {
+ final String fullPath = SvnUtil.appendMultiParts(repositoryRoot, myPath);
+ local = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(fullPath, false);
+ }
+ catch (SVNException e) {
+ // todo what to do safely?
+ local = VcsContextFactory.SERVICE.getInstance().createFilePathOnNonLocal(repositoryRoot, false);
+ }
+ myFilePath = local;
}
myRevision = revision;
}
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryLocation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryLocation.java
index 3d5bcaf0d92b..0366c21ea202 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryLocation.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryLocation.java
@@ -16,12 +16,18 @@
package org.jetbrains.idea.svn.history;
import com.intellij.openapi.vcs.FilePath;
+import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.RepositoryLocation;
import com.intellij.openapi.vcs.VcsException;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.NotNullFunction;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.svn.RootUrlInfo;
+import org.jetbrains.idea.svn.SvnUtil;
import org.jetbrains.idea.svn.SvnVcs;
+import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.SVNURL;
+import org.tmatesoft.svn.core.internal.util.SVNURLUtil;
import java.io.File;
@@ -62,9 +68,26 @@ public class SvnRepositoryLocation implements RepositoryLocation {
@Nullable
public static FilePath getLocalPath(final String fullPath, final NotNullFunction detector, final SvnVcs vcs) {
if (vcs.getProject().isDefault()) return null;
+ final SVNURL fullPathURL;
+ try {
+ fullPathURL = SVNURL.parseURIEncoded(fullPath);
+ }
+ catch (SVNException e) {
+ return null;
+ }
final RootUrlInfo rootForUrl = vcs.getSvnFileUrlMapping().getWcRootForUrl(fullPath);
if (rootForUrl != null) {
return LocationDetector.filePathByUrlAndPath(fullPath, rootForUrl.getUrl().toString(), rootForUrl.getIoFile().getAbsolutePath(), detector);
+ } else {
+ final VirtualFile[] underVcs = ProjectLevelVcsManager.getInstance(vcs.getProject()).getRootsUnderVcs(vcs);
+ if (underVcs.length == 0) return null;
+ for (VirtualFile vf : underVcs) {
+ final File ioFile = new File(vf.getPath());
+ final SVNURL url = SvnUtil.getUrl(vcs, ioFile);
+ if (url != null && SVNURLUtil.isAncestor(url, fullPathURL)) {
+ return LocationDetector.filePathByUrlAndPath(fullPath, url.toString(), ioFile.getPath(), detector);
+ }
+ }
}
return null;
From 43361a0c5d7e71577d40834e414e9fc7dccbf8f4 Mon Sep 17 00:00:00 2001
From: "Nadya.Zabrodina"
Date: Fri, 1 Feb 2013 19:47:34 +0400
Subject: [PATCH 24/51] IDEA-98713 Changes - Repository view never updates with
Mercurial
*Add colon when refresh repository view. (refresh all upwards revisions).
---
.../zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java
index 1cc26ab5040c..0d1a12e9a49a 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgCachingCommitedChangesProvider.java
@@ -202,7 +202,7 @@ public class HgCachingCommitedChangesProvider implements CachingCommittedChanges
if (changeBrowserSettings != null) {
args = new ArrayList();
if (changeBrowserSettings.USE_CHANGE_AFTER_FILTER) {
- args.add("-r " + changeBrowserSettings.getChangeAfterFilter());
+ args.add("-r " + changeBrowserSettings.getChangeAfterFilter() + ":");
}
}
List localRevisions = hgLogCommand.execute(hgFile, maxCount == 0 ? -1 : maxCount, true, args);
From 2b1efb5e9e48231b6e49009d10adfb1a60bf28ce Mon Sep 17 00:00:00 2001
From: Bas Leijdekkers
Date: Fri, 1 Feb 2013 17:19:28 +0100
Subject: [PATCH 25/51] IDEA-100178 ("make public" on a package local class
gives wrong error message.)
---
.../src/com/siyeh/ipp/modifiers/ModifierIntention.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ModifierIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ModifierIntention.java
index 767d3481bb93..cdde20ef83e6 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ModifierIntention.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/modifiers/ModifierIntention.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -94,7 +94,7 @@ abstract class ModifierIntention extends Intention implements LowPriorityAction
final String name = FileUtil.getNameWithoutExtension(javaFile.getName());
final String className = aClass.getName();
if (name.equals(className)) {
- MultiMap.emptyInstance();
+ return MultiMap.emptyInstance();
}
final MultiMap conflicts = new MultiMap();
conflicts.putValue(aClass, IntentionPowerPackBundle.message(
From f077c3183dd7befae75bbe803e18e6eb77644c55 Mon Sep 17 00:00:00 2001
From: Alexander Lobas
Date: Fri, 1 Feb 2013 20:31:03 +0400
Subject: [PATCH 26/51] Visual Edit
---
.../designSurface/FlowBaseOperation.java | 39 ++++++++++++-------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java
index dbdbea94271f..93956a554ed7 100644
--- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java
+++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/FlowBaseOperation.java
@@ -75,28 +75,17 @@ public abstract class FlowBaseOperation extends AbstractEditOperation {
public void showFeedback() {
createFeedback();
- if (!getChildren().isEmpty()) {
+ List children = getChildren();
+ if (!children.isEmpty()) {
FeedbackLayer layer = myContext.getArea().getFeedbackLayer();
Point location = myContext.getLocation();
myChildTarget = null;
if (myHorizontal) {
- for (RadComponent child : getChildren()) {
- Rectangle childBounds = getBounds(child, layer);
- if (childBounds.x <= location.x && location.x <= childBounds.getMaxX()) {
- myChildTarget = child;
- break;
- }
- }
+ handleHorizontal(children, layer, location);
}
else {
- for (RadComponent child : getChildren()) {
- Rectangle childBounds = getBounds(child, layer);
- if (childBounds.y <= location.y && location.y <= childBounds.getMaxY()) {
- myChildTarget = child;
- break;
- }
- }
+ handleVertical(children, layer, location);
}
if (myChildTarget == null) {
myChildTarget = getSideChildTarget();
@@ -110,6 +99,26 @@ public abstract class FlowBaseOperation extends AbstractEditOperation {
}
}
+ protected void handleHorizontal(List children, FeedbackLayer layer, Point location) {
+ for (RadComponent child : children) {
+ Rectangle childBounds = getBounds(child, layer);
+ if (childBounds.x <= location.x && location.x <= childBounds.getMaxX()) {
+ myChildTarget = child;
+ break;
+ }
+ }
+ }
+
+ protected void handleVertical(List children, FeedbackLayer layer, Point location) {
+ for (RadComponent child : children) {
+ Rectangle childBounds = getBounds(child, layer);
+ if (childBounds.y <= location.y && location.y <= childBounds.getMaxY()) {
+ myChildTarget = child;
+ break;
+ }
+ }
+ }
+
protected void setInsertFeedbackBounds(Rectangle targetBounds) {
if (myHorizontal) {
if (myInsertBefore) {
From f0ca9ae39a18c1d54ab0930a15994a4730dfa9ff Mon Sep 17 00:00:00 2001
From: "Gregory.Shrago"
Date: Fri, 1 Feb 2013 20:34:16 +0400
Subject: [PATCH 27/51] fix for NPE
PsiChangeHandler.queueElement(PsiChangeHandler.java:178)
---
.../src/com/intellij/psi/impl/file/impl/PsiVFSListener.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
index a6427f42e510..62b05c081bd0 100644
--- a/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
+++ b/platform/lang-impl/src/com/intellij/psi/impl/file/impl/PsiVFSListener.java
@@ -396,8 +396,10 @@ public class PsiVFSListener extends VirtualFileAdapter {
}
else if (newPsiFile != null) {
myFileManager.cacheViewProvider(vFile, fileViewProvider);
- treeEvent.setChild(newPsiFile);
- myManager.childAdded(treeEvent);
+ if (parentDir != null) {
+ treeEvent.setChild(newPsiFile);
+ myManager.childAdded(treeEvent);
+ }
}
}
}
From adaa859a28370b9cdc19ab1700ac3738b1d6ff17 Mon Sep 17 00:00:00 2001
From: peter
Date: Fri, 1 Feb 2013 12:23:45 +0100
Subject: [PATCH 28/51] IDEA-100107 Code completion settings dependent on
autopopup setting should be disabled when autopopup is off
---
.../intellij/application/options/CodeCompletionPanel.java | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeCompletionPanel.java b/platform/lang-impl/src/com/intellij/application/options/CodeCompletionPanel.java
index 99b1a6fdb314..2067a9cc6a4a 100644
--- a/platform/lang-impl/src/com/intellij/application/options/CodeCompletionPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/CodeCompletionPanel.java
@@ -65,7 +65,10 @@ public class CodeCompletionPanel {
new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
- myAutocompletionDelayField.setEnabled(myCbAutocompletion.isSelected());
+ boolean selected = myCbAutocompletion.isSelected();
+ myAutocompletionDelayField.setEnabled(selected);
+ myFocusLookup.setEnabled(selected);
+ myCbSelectByChars.setEnabled(selected);
}
}
);
From dc63d14614b0428ced121011e0278d1d6b547312 Mon Sep 17 00:00:00 2001
From: peter
Date: Fri, 1 Feb 2013 12:36:09 +0100
Subject: [PATCH 29/51] no completion preview when introducing a variable
---
.../codeInsight/lookup/impl/CompletionPreview.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java
index 206f098120ec..1f6437a71d1b 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/lookup/impl/CompletionPreview.java
@@ -15,7 +15,10 @@
*/
package com.intellij.codeInsight.lookup.impl;
-import com.intellij.codeInsight.lookup.*;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.codeInsight.lookup.LookupElementPresentation;
+import com.intellij.codeInsight.lookup.LookupEvent;
+import com.intellij.codeInsight.lookup.LookupListener;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
@@ -87,6 +90,11 @@ public class CompletionPreview implements Disposable {
return;
}
+ final EditorImpl editor = getEditorImpl();
+ if (editor.getSelectionModel().hasSelection() || editor.getSelectionModel().hasBlockSelection()) {
+ return;
+ }
+
String text = getPreviewText(item);
int prefixLength = myLookup.getPrefixLength(item);
@@ -103,7 +111,7 @@ public class CompletionPreview implements Disposable {
prefixLength = arrayList.get(arrayList.size() - 1).getEndOffset();
}
- final EditorImpl editor = getEditorImpl();
+
editor.setCustomImage(null);
BufferedImage previewImage = createPreviewImage(text.substring(prefixLength));
editor.setCustomImage(Pair.create(getCaretPoint(), previewImage));
From 1cfd13945cfb6c423da1c9995ec3f9bb0e8b6f7b Mon Sep 17 00:00:00 2001
From: peter
Date: Fri, 1 Feb 2013 13:21:54 +0100
Subject: [PATCH 30/51] IDEA-99882 Automatic completion of Groovy code is often
wrong (compared to my intention)
---
.../groovy/lang/completion/GroovyCompletionUtil.java | 9 ++++-----
.../groovy/completion/GroovyCompletionTest.groovy | 7 +++++++
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
index a2e133dea603..142cc63ad193 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
@@ -50,17 +50,17 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.formatter.GeeseUtil;
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
+import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
@@ -214,11 +214,10 @@ public class GroovyCompletionUtil {
public static boolean asVariableInBlock(PsiElement context) {
if (context.getParent() instanceof GrReferenceExpression) {
PsiElement parent = context.getParent().getParent();
- if (parent instanceof GrApplicationStatement) {
+ while (parent instanceof GrStatement) {
parent = parent.getParent();
}
- if ((parent instanceof GrCodeBlock || parent instanceof GrCaseSection || parent instanceof GrLabeledStatement) &&
- isNewStatement(context, true)) {
+ if ((parent instanceof GrControlFlowOwner || parent instanceof GrCaseSection) && isNewStatement(context, true)) {
return true;
}
}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy
index 4551f407fc1f..20a8e57a3bcd 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy
@@ -1663,4 +1663,11 @@ package bar
print new foo.Myclass()
''')
}
+
+ public void "test def before assignment"() {
+ assert doContainsTest("def", """
+void foo() {
+ = baz
+}""")
+ }
}
\ No newline at end of file
From 53a305b847c90024e45b089d9b81645aa95fb207 Mon Sep 17 00:00:00 2001
From: peter
Date: Fri, 1 Feb 2013 16:34:38 +0100
Subject: [PATCH 31/51] IDEA-99186 Ctrl+Space help when implementing/overriding
methods
---
.../completion/JavaCompletionSorting.java | 4 +-
.../JavaOverrideCompletionContributor.java | 123 ++++++++++++++++++
.../generation/OverrideImplementUtil.java | 44 +++++--
.../normal/ImplementViaCompletion.java | 7 +
.../normal/ImplementViaCompletion_after.java | 10 ++
.../completion/NormalCompletionTest.groovy | 15 +++
resources/src/META-INF/IdeaPlugin.xml | 2 +
7 files changed, 195 insertions(+), 10 deletions(-)
create mode 100644 java/java-impl/src/com/intellij/codeInsight/completion/JavaOverrideCompletionContributor.java
create mode 100644 java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion.java
create mode 100644 java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
index 63d55511f488..6e73bec5a290 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -132,7 +132,9 @@ public class JavaCompletionSorting {
public Comparable weigh(@NotNull LookupElement element) {
final Object o = element.getObject();
if (o instanceof PsiKeyword) return -3;
- if (!(o instanceof PsiMember)) return 0;
+ if (!(o instanceof PsiMember) || element.getUserData(JavaOverrideCompletionContributor.OVERRIDE_ELEMENT) != null) {
+ return 0;
+ }
if (((PsiMember)o).hasModifierProperty(PsiModifier.STATIC) && !hasNonVoid(infos)) {
if (o instanceof PsiMethod) return -5;
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaOverrideCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaOverrideCompletionContributor.java
new file mode 100644
index 000000000000..d71de30567c2
--- /dev/null
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaOverrideCompletionContributor.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.completion;
+
+import com.intellij.codeInsight.generation.GenerateMembersUtil;
+import com.intellij.codeInsight.generation.OverrideImplementExploreUtil;
+import com.intellij.codeInsight.generation.OverrideImplementUtil;
+import com.intellij.codeInsight.generation.PsiGenerationInfo;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.codeInsight.lookup.LookupElementBuilder;
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.util.Key;
+import com.intellij.psi.*;
+import com.intellij.psi.infos.CandidateInfo;
+import com.intellij.psi.util.PsiFormatUtil;
+import com.intellij.psi.util.PsiFormatUtilBase;
+import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.ui.RowIcon;
+import com.intellij.util.Consumer;
+
+import java.util.List;
+
+import static com.intellij.patterns.PlatformPatterns.psiElement;
+
+/**
+ * @author peter
+ */
+public class JavaOverrideCompletionContributor extends CompletionContributor {
+ static final Key OVERRIDE_ELEMENT = Key.create("OVERRIDE_ELEMENT");
+
+ @Override
+ public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet _result) {
+ if (parameters.getCompletionType() != CompletionType.BASIC && parameters.getCompletionType() != CompletionType.SMART) {
+ return;
+ }
+
+ PsiElement position = parameters.getPosition();
+ if (psiElement(PsiIdentifier.class).withParents(PsiJavaCodeReferenceElement.class, PsiTypeElement.class, PsiClass.class).
+ andNot(JavaCompletionData.AFTER_DOT).
+ andNot(psiElement().afterLeaf(psiElement().inside(PsiModifierList.class))).accepts(position)) {
+ final PsiClass parent = CompletionUtil.getOriginalElement((PsiClass)position.getParent().getParent().getParent());
+ if (parent != null) {
+ CompletionResultSet result = JavaCompletionSorting.addJavaSorting(parameters, _result);
+ addSuperSignatureElements(parent, true, result);
+ addSuperSignatureElements(parent, false, result);
+ }
+ }
+
+ }
+
+ private static void addSuperSignatureElements(final PsiClass parent, boolean implemented, CompletionResultSet result) {
+ for (CandidateInfo candidate : OverrideImplementExploreUtil.getMethodsToOverrideImplement(parent, implemented)) {
+ PsiMethod baseMethod = (PsiMethod)candidate.getElement();
+ if (!baseMethod.isConstructor()) {
+ PsiClass baseClass = baseMethod.getContainingClass();
+ List prototypes = OverrideImplementUtil.overrideOrImplementMethod(parent, baseMethod, candidate.getSubstitutor(), new Consumer() {
+ @Override
+ public void consume(PsiMethod method) {
+ OverrideImplementUtil.deleteDocComment(method);
+ }
+ });
+ if (!prototypes.isEmpty() && baseClass != null) {
+ result.addElement(createOverridingLookupElement(parent, implemented, baseMethod, baseClass, prototypes.get(0)));
+ }
+ }
+ }
+ }
+
+ private static LookupElementBuilder createOverridingLookupElement(final PsiClass parent,
+ boolean implemented,
+ final PsiMethod baseMethod,
+ PsiClass baseClass, final PsiMethod prototype) {
+ PsiIdentifier nameIdentifier = prototype.getNameIdentifier();
+ assert nameIdentifier != null;
+
+ String signature = prototype.getModifierList().getText();
+ if (!signature.isEmpty()) {
+ signature += " ";
+ }
+ PsiType returnType = prototype.getReturnType();
+ signature += TypeConversionUtil.erasure(returnType).getPresentableText() + " " + prototype.getName();
+
+ String parameters = PsiFormatUtil.formatMethod(prototype, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_NAME);
+
+ InsertHandler insertHandler = new InsertHandler() {
+ @Override
+ public void handleInsert(InsertionContext context, LookupElement item) {
+ context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());
+ context.commitDocument();
+
+ List prototypes = OverrideImplementUtil.overrideOrImplementMethod(parent, baseMethod, false);
+ List> infos = OverrideImplementUtil.convert2GenerationInfos(prototypes);
+ List> newInfos = GenerateMembersUtil.insertMembersAtOffset(context.getFile(), context.getStartOffset(), infos);
+ if (!newInfos.isEmpty()) {
+ newInfos.get(0).positionCaret(context.getEditor(), true);
+ }
+ }
+ };
+
+ RowIcon icon = new RowIcon(2);
+ icon.setIcon(baseMethod.getIcon(0), 0);
+ icon.setIcon(implemented ? AllIcons.Gutter.ImplementingMethod : AllIcons.Gutter.OverridingMethod, 1);
+
+ LookupElementBuilder element = LookupElementBuilder.create(baseMethod, signature).withLookupString(prototype.getName()).
+ withLookupString(signature).withInsertHandler(insertHandler).
+ appendTailText(parameters, false).appendTailText(" {...}", true).withTypeText(baseClass.getName()).withIcon(icon);
+ element.putUserData(OVERRIDE_ELEMENT, true);
+ return element;
+ }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
index 115545a38828..8a2fa775a35a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
@@ -61,6 +61,7 @@ import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.*;
import com.intellij.util.ArrayUtil;
+import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
@@ -95,7 +96,7 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
* @return list of method prototypes
*/
@NotNull
- public static Collection overrideOrImplementMethod(PsiClass aClass, PsiMethod method, boolean toCopyJavaDoc) throws IncorrectOperationException {
+ public static List overrideOrImplementMethod(PsiClass aClass, PsiMethod method, boolean toCopyJavaDoc) throws IncorrectOperationException {
final PsiClass containingClass = method.getContainingClass();
LOG.assertTrue(containingClass != null);
PsiSubstitutor substitutor = aClass.isInheritor(containingClass, true)
@@ -126,11 +127,18 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
}
@NotNull
- private static Collection overrideOrImplementMethod(PsiClass aClass,
+ private static List overrideOrImplementMethod(PsiClass aClass,
PsiMethod method,
PsiSubstitutor substitutor,
boolean toCopyJavaDoc,
boolean insertOverrideIfPossible) throws IncorrectOperationException {
+ return overrideOrImplementMethod(aClass, method, substitutor, createDefaultDecorator(aClass, method, toCopyJavaDoc, insertOverrideIfPossible));
+ }
+
+ public static List overrideOrImplementMethod(PsiClass aClass,
+ PsiMethod method,
+ PsiSubstitutor substitutor,
+ Consumer decorator) throws IncorrectOperationException {
if (!method.isValid() || !substitutor.isValid()) return Collections.emptyList();
List results = new ArrayList();
@@ -141,13 +149,14 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
}
else {
for (PsiMethod prototype : prototypes) {
- results.add(decorateMethod(aClass, method, toCopyJavaDoc, insertOverrideIfPossible, prototype));
+ decorator.consume(prototype);
+ results.add(prototype);
}
}
}
if (results.isEmpty()) {
PsiMethod method1 = GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);
-
+
PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
PsiMethod result = (PsiMethod)factory.createClass("Dummy").add(method1);
if (PsiUtil.isAnnotationMethod(result)) {
@@ -161,7 +170,8 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
defaultValue.getParent().deleteChildRange(defaultKeyword, defaultValue);
}
}
- results.add(decorateMethod(aClass, method, toCopyJavaDoc, insertOverrideIfPossible, result));
+ decorator.consume(result);
+ results.add(result);
}
for (Iterator iterator = results.iterator(); iterator.hasNext();) {
@@ -173,6 +183,18 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
return results;
}
+ public static Consumer createDefaultDecorator(final PsiClass aClass,
+ final PsiMethod method,
+ final boolean toCopyJavaDoc,
+ final boolean insertOverrideIfPossible) {
+ return new Consumer() {
+ @Override
+ public void consume(PsiMethod result) {
+ decorateMethod(aClass, method, toCopyJavaDoc, insertOverrideIfPossible, result);
+ }
+ };
+ }
+
private static PsiMethod decorateMethod(PsiClass aClass,
PsiMethod method,
boolean toCopyJavaDoc,
@@ -182,10 +204,7 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
PsiUtil.setModifierProperty(result, PsiModifier.NATIVE, false);
if (!toCopyJavaDoc){
- PsiDocComment comment = result.getDocComment();
- if (comment != null){
- comment.delete();
- }
+ deleteDocComment(result);
}
//method type params are not allowed when overriding from raw type
@@ -231,6 +250,13 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
return result;
}
+ public static void deleteDocComment(PsiMethod result) {
+ PsiDocComment comment = result.getDocComment();
+ if (comment != null){
+ comment.delete();
+ }
+ }
+
public static void annotateOnOverrideImplement(PsiMethod method, PsiClass targetClass, PsiMethod overridden) {
annotateOnOverrideImplement(method, targetClass, overridden,
CodeStyleSettingsManager.getSettings(method.getProject()).INSERT_OVERRIDE_ANNOTATION);
diff --git a/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion.java b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion.java
new file mode 100644
index 000000000000..85d7845803d8
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion.java
@@ -0,0 +1,7 @@
+interface Foo {
+ void run(T t, int myInt);
+}
+
+public class A implements Foo {
+ p
+}
diff --git a/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java
new file mode 100644
index 000000000000..a13b20e89807
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java
@@ -0,0 +1,10 @@
+interface Foo {
+ void run(T t, int myInt);
+}
+
+public class A implements Foo {
+ @Override
+ public void run(String s, int myInt) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
index ba50bdbe788c..0c7e3f1ce4bf 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy
@@ -1316,5 +1316,20 @@ class XInternalError {}
assert lookup.items.size() == 1
}
+ public void testImplementViaCompletion() {
+ configure()
+ myFixture.assertPreferredCompletionItems 0, 'private', 'protected', 'public', 'public void run'
+ def item = lookup.items[3]
+
+ def p = LookupElementPresentation.renderElement(item)
+ assert p.itemText == 'public void run'
+ assert p.tailText == '(s, myInt) {...}'
+ assert p.typeText == 'Foo'
+
+ lookup.currentItem = item
+ myFixture.type('\n')
+ checkResult()
+ }
+
}
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index 99fc80a5159c..debd34b9ffad 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -254,6 +254,8 @@
+
From 95ea1427962a9267f04be19f957fafeb504f2e64 Mon Sep 17 00:00:00 2001
From: peter
Date: Fri, 1 Feb 2013 16:46:58 +0100
Subject: [PATCH 32/51] one less weigher before stats+prefix
---
.../codeInsight/completion/JavaCompletionSorting.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
index 6e73bec5a290..693ba9843741 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -60,13 +60,15 @@ public class JavaCompletionSorting {
List afterPriority = new ArrayList();
if (!smart) {
- ContainerUtil.addIfNotNull(afterPriority, preferStatics(position, expectedTypes));
}
else {
afterPriority.add(new PreferDefaultTypeWeigher(expectedTypes, parameters));
}
ContainerUtil.addIfNotNull(afterPriority, recursion(parameters, expectedTypes));
afterPriority.add(new PreferSimilarlyEnding(expectedTypes, prefix));
+ if (smart) {
+ afterPriority.add(new PreferByKindWeigher(type, position, true));
+ }
List afterProximity = new ArrayList();
afterProximity.add(new PreferContainingSameWords(expectedTypes));
@@ -83,8 +85,8 @@ public class JavaCompletionSorting {
}
List afterPrefix = ContainerUtil.newArrayList();
- if (smart) {
- afterPriority.add(new PreferByKindWeigher(type, position, true));
+ if (!smart) {
+ ContainerUtil.addIfNotNull(afterPrefix, preferStatics(position, expectedTypes));
}
if (!smart && !afterNew) {
afterPrefix.add(new PreferExpected(false, expectedTypes));
From 2ae40f135f0c8d81ba1756b784536311c43e963e Mon Sep 17 00:00:00 2001
From: peter
Date: Fri, 1 Feb 2013 16:53:00 +0100
Subject: [PATCH 33/51] less weighers before stats+prefix
---
.../completion/JavaCompletionSorting.java | 9 ++-------
.../codeInsight/completion/PreferByKindWeigher.java | 13 ++++---------
2 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
index 693ba9843741..3bdf1874310b 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -59,16 +59,11 @@ public class JavaCompletionSorting {
final boolean afterNew = JavaSmartCompletionContributor.AFTER_NEW.accepts(position);
List afterPriority = new ArrayList();
- if (!smart) {
- }
- else {
+ if (smart) {
afterPriority.add(new PreferDefaultTypeWeigher(expectedTypes, parameters));
}
ContainerUtil.addIfNotNull(afterPriority, recursion(parameters, expectedTypes));
afterPriority.add(new PreferSimilarlyEnding(expectedTypes, prefix));
- if (smart) {
- afterPriority.add(new PreferByKindWeigher(type, position, true));
- }
List afterProximity = new ArrayList();
afterProximity.add(new PreferContainingSameWords(expectedTypes));
@@ -91,7 +86,7 @@ public class JavaCompletionSorting {
if (!smart && !afterNew) {
afterPrefix.add(new PreferExpected(false, expectedTypes));
}
- afterPrefix.add(new PreferByKindWeigher(type, position, false));
+ afterPrefix.add(new PreferByKindWeigher(type, position));
Collections.addAll(afterPrefix, new PreferNonGeneric(), new PreferAccessible(position), new PreferSimple(),
new PreferEnumConstants(parameters));
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java b/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java
index 8ed82061134f..a3a44ad6d4aa 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java
@@ -46,7 +46,8 @@ public class PreferByKindWeigher extends LookupElementWeigher {
psiElement(PsiVariable.class).withParent(PsiCatchSection.class)))));
static final ElementPattern IN_MULTI_CATCH_TYPE =
or(psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiCatchSection.class)),
- psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiParameter.class).withSuperParent(3, PsiCatchSection.class)));
+ psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiParameter.class)
+ .withSuperParent(3, PsiCatchSection.class)));
static final ElementPattern INSIDE_METHOD_THROWS_CLAUSE =
psiElement().afterLeaf(PsiKeyword.THROWS, ",").inside(psiElement(JavaElementType.THROWS_LIST));
static final ElementPattern IN_RESOURCE_TYPE =
@@ -55,15 +56,13 @@ public class PreferByKindWeigher extends LookupElementWeigher {
withParent(or(psiElement(PsiResourceVariable.class), psiElement(PsiResourceList.class)))));
private final CompletionType myCompletionType;
private final PsiElement myPosition;
- private final boolean myLocal;
private final Set myNonInitializedFields;
@NotNull private final Condition myRequiredSuper;
- public PreferByKindWeigher(CompletionType completionType, final PsiElement position, boolean local) {
- super("kind" + (local ? "Local" : "Global"));
+ public PreferByKindWeigher(CompletionType completionType, final PsiElement position) {
+ super("kind");
myCompletionType = completionType;
myPosition = position;
- myLocal = local;
myNonInitializedFields = JavaCompletionProcessor.getNonInitializedFields(position);
myRequiredSuper = createSuitabilityCondition(position);
}
@@ -155,10 +154,6 @@ public class PreferByKindWeigher extends LookupElementWeigher {
}
}
- if (myLocal) {
- return MyResult.normal;
- }
-
if (object instanceof String && item.getUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS) == Boolean.TRUE) {
return MyResult.superMethodParameters;
}
From 38faaa572ae119c973aa216e6c9b7c099a55fdff Mon Sep 17 00:00:00 2001
From: peter
Date: Fri, 1 Feb 2013 17:18:44 +0100
Subject: [PATCH 34/51] IDEA-96661 Java completion: don't add {} tail after
array completion variant
---
.../completion/JavaCompletionSorting.java | 2 +-
.../completion/JavaInheritorsGetter.java | 28 +++++++++++++++----
.../JavaPsiClassReferenceElement.java | 9 ++++--
.../codeInsight/lookup/PsiTypeLookupItem.java | 25 +++++++++--------
.../ArrayInitializerBeforeVarargs-out.java | 2 +-
.../ThrowExceptionConstructor-out.java | 2 +-
.../completion/SmartTypeCompletionTest.java | 9 ++++--
7 files changed, 51 insertions(+), 26 deletions(-)
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
index 3bdf1874310b..236e2e6768f6 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionSorting.java
@@ -404,7 +404,7 @@ public class JavaCompletionSorting {
public Comparable weigh(@NotNull LookupElement element) {
final PsiTypeLookupItem lookupItem = element.as(PsiTypeLookupItem.CLASS_CONDITION_KEY);
if (lookupItem != null) {
- return lookupItem.getBracketsCount();
+ return lookupItem.getBracketsCount() * 10 + (lookupItem.isAddArrayInitializer() ? 1 : 0);
}
if (element.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY) != null) {
return 239;
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java
index 52d493b551dd..9904c46f560a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaInheritorsGetter.java
@@ -50,6 +50,14 @@ public class JavaInheritorsGetter extends CompletionProvider extractClassTypes(ExpectedTypeInfo[] infos) {
final List expectedClassTypes = new SmartList();
for (PsiType type : ExpectedTypesGetter.extractTypes(infos, true)) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java
index 824a8907f435..349cb7b47890 100644
--- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java
+++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaPsiClassReferenceElement.java
@@ -155,9 +155,12 @@ public class JavaPsiClassReferenceElement extends LookupItem
+ h5
+ h4
+ h3
+
+
hh4
+ hh5
+
+ hh6
+ hhh6
+
+ hhh5
+ g4
+ g6
+ g3
+ g2
+
+
+
body
+
+body2
+body3
+
+
\ No newline at end of file
diff --git a/xml/tests/testData/structureView/ImplicitSections.tree b/xml/tests/testData/structureView/ImplicitSections.tree
new file mode 100644
index 000000000000..9903463aa790
--- /dev/null
+++ b/xml/tests/testData/structureView/ImplicitSections.tree
@@ -0,0 +1,24 @@
+-HtmlFile:ImplicitSections.html
+ -body
+ -[section]
+ h5
+ h4
+ -h3
+ -hh4
+ hh5
+ -h4 h3
+ hh4
+ hh3
+ hh6
+ hhh6
+ hhh5
+ -g4
+ g6
+ g3
+ g2
+ -body2
+ body3
+ -
+ -
+ hhh2
+ hhh1
\ No newline at end of file
diff --git a/xml/tests/testData/structureView/NoSectioningRoot.html b/xml/tests/testData/structureView/NoSectioningRoot.html
new file mode 100644
index 000000000000..d0b4849a0d9b
--- /dev/null
+++ b/xml/tests/testData/structureView/NoSectioningRoot.html
@@ -0,0 +1,17 @@
+
+ blockquote
+ body
+ details
+
+
+ figure
+ td |
+
+
+ 1
+ 2
+
+ 3
+ 4
+
+
\ No newline at end of file
diff --git a/xml/tests/testData/structureView/NoSectioningRoot.tree b/xml/tests/testData/structureView/NoSectioningRoot.tree
new file mode 100644
index 000000000000..e63bb3297a2e
--- /dev/null
+++ b/xml/tests/testData/structureView/NoSectioningRoot.tree
@@ -0,0 +1,9 @@
+-HtmlFile:NoSectioningRoot.html
+ [1 2 3 4]
+ blockquote
+ body
+ details
+ dialog
+ fieldset
+ figure
+ td
\ No newline at end of file
diff --git a/xml/tests/testData/structureView/Simple.html b/xml/tests/testData/structureView/Simple.html
new file mode 100644
index 000000000000..cb128240b9a9
--- /dev/null
+++ b/xml/tests/testData/structureView/Simple.html
@@ -0,0 +1,6 @@
+
+title
+
+
+
+
\ No newline at end of file
diff --git a/xml/tests/testData/structureView/Simple.tree b/xml/tests/testData/structureView/Simple.tree
new file mode 100644
index 000000000000..4f8e03e31bd5
--- /dev/null
+++ b/xml/tests/testData/structureView/Simple.tree
@@ -0,0 +1,2 @@
+-HtmlFile:Simple.html
+ []
\ No newline at end of file
From cd70acac56f68acabf673631238852efa67e9fd1 Mon Sep 17 00:00:00 2001
From: "Denis.Zhdanov"
Date: Sat, 2 Feb 2013 15:05:03 +0400
Subject: [PATCH 45/51] IDEA-96385 Uncomplete definition of variable in "Quick
Documentation" Window
---
.../codeInsight/javadoc/JavaDocInfoGenerator.java | 9 +++++++--
.../codeInsight/javadocIG/initializerWithReference.html | 1 +
.../codeInsight/javadocIG/initializerWithReference.java | 4 ++++
.../codeInsight/javadoc/JavaDocInfoGeneratorTest.java | 6 ++++++
4 files changed, 18 insertions(+), 2 deletions(-)
create mode 100644 java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.html
create mode 100644 java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.java
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
index 0b2397f4e1df..dca78ce60d56 100644
--- a/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/javadoc/JavaDocInfoGenerator.java
@@ -467,7 +467,7 @@ public class JavaDocInfoGenerator {
}
// not a javadoc in fact..
- private void generateVariableJavaDoc(@NonNls StringBuilder buffer, PsiVariable variable, boolean generatePrologueAndEpilogue) {
+ private static void generateVariableJavaDoc(@NonNls StringBuilder buffer, PsiVariable variable, boolean generatePrologueAndEpilogue) {
if (generatePrologueAndEpilogue)
generatePrologue(buffer);
@@ -604,7 +604,7 @@ public class JavaDocInfoGenerator {
}
}
- private void generateAnnotations (@NonNls StringBuilder buffer, PsiModifierListOwner owner) {
+ private static void generateAnnotations(@NonNls StringBuilder buffer, PsiModifierListOwner owner) {
final PsiModifierList ownerModifierList = owner.getModifierList();
if (ownerModifierList == null) return;
PsiAnnotation[] annotations = ownerModifierList.getAnnotations();
@@ -1861,5 +1861,10 @@ public class JavaDocInfoGenerator {
public void visitLiteralExpression(PsiLiteralExpression expression) {
myBuffer.append(expression.getText());
}
+
+ @Override
+ public void visitReferenceExpression(PsiReferenceExpression expression) {
+ myBuffer.append(expression.getText());
+ }
}
}
diff --git a/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.html b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.html
new file mode 100644
index 000000000000..f4ba3cbff9d1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.html
@@ -0,0 +1 @@
+ Testpublic int field = anotherField
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.java b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.java
new file mode 100644
index 000000000000..39a7384fdbb1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/javadocIG/initializerWithReference.java
@@ -0,0 +1,4 @@
+class Test {
+ public int field = anotherField;
+ public static int anotherField = 1;
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
index 666709af1083..e6595b98b11a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/javadoc/JavaDocInfoGeneratorTest.java
@@ -58,6 +58,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
public void testInitializerWithNew() throws Exception {
doTestField();
}
+
+ public void testInitializerWithReference() throws Exception {
+ doTestField();
+ }
private void doTestField() throws Exception {
PsiClass psiClass = getTestClass();
@@ -80,6 +84,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + getTestName(true) + ".html");
String htmlText = FileUtil.loadFile(htmlPath);
String docInfo = new JavaDocInfoGenerator(getProject(), field).generateDocInfo(null);
+ assertNotNull(docInfo);
assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(docInfo.trim()));
}
@@ -90,6 +95,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
final String info =
new JavaDocInfoGenerator(getProject(), JavaPsiFacade.getInstance(getProject()).findPackage(getTestName(true))).generateDocInfo(null);
String htmlText = FileUtil.loadFile(new File(packageInfo + File.separator + "packageInfo.html"));
+ assertNotNull(info);
assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(info.trim()));
}
From d6e3d9cad73f3a2caf6142b0e672e2804700a59e Mon Sep 17 00:00:00 2001
From: "Denis.Zhdanov"
Date: Sat, 2 Feb 2013 15:05:31 +0400
Subject: [PATCH 46/51] Restrict white space strategy by language
---
.../CompositeWhiteSpaceFormattingStrategy.java | 5 +++++
.../src/com/intellij/psi/formatter/FormatterUtil.java | 11 ++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/CompositeWhiteSpaceFormattingStrategy.java b/platform/lang-impl/src/com/intellij/psi/formatter/CompositeWhiteSpaceFormattingStrategy.java
index 2844adb44c57..ad19870515df 100644
--- a/platform/lang-impl/src/com/intellij/psi/formatter/CompositeWhiteSpaceFormattingStrategy.java
+++ b/platform/lang-impl/src/com/intellij/psi/formatter/CompositeWhiteSpaceFormattingStrategy.java
@@ -109,6 +109,11 @@ public class CompositeWhiteSpaceFormattingStrategy implements WhiteSpaceFormatti
@Override
public boolean containsWhitespacesOnly(@NotNull ASTNode node) {
+ for (WhiteSpaceFormattingStrategy strategy : myStrategies) {
+ if (strategy.containsWhitespacesOnly(node)) {
+ return true;
+ }
+ }
return false;
}
diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java b/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java
index 858da1d904ee..b208bd2ea1f7 100644
--- a/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java
+++ b/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.actions.ReformatAndOptimizeImportsProcessor;
import com.intellij.codeInsight.actions.ReformatCodeProcessor;
import com.intellij.lang.ASTFactory;
import com.intellij.lang.ASTNode;
+import com.intellij.lang.Language;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
@@ -254,12 +255,12 @@ public class FormatterUtil {
if (node == null) return false;
if (isWhitespaceOrEmpty(node)) return true;
- for (WhiteSpaceFormattingStrategy strategy : WhiteSpaceFormattingStrategyFactory.getAllStrategies()) {
- if (strategy.containsWhitespacesOnly(node)) {
- return true;
- }
+ PsiElement psi = node.getPsi();
+ if (psi == null) {
+ return false;
}
- return false;
+ Language language = psi.getLanguage();
+ return WhiteSpaceFormattingStrategyFactory.getStrategy(language).containsWhitespacesOnly(node);
}
/**
From 36cef29b5c7c911adfcd4ee7533899a268d17a41 Mon Sep 17 00:00:00 2001
From: Sergey Evdokimov
Date: Sun, 3 Feb 2013 00:21:33 +0400
Subject: [PATCH 47/51] Add javadoc
---
.../maven/dom/references/MavenDependencyReferenceProvider.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenDependencyReferenceProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenDependencyReferenceProvider.java
index d5a5a15f64cf..a72c8e329465 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenDependencyReferenceProvider.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/references/MavenDependencyReferenceProvider.java
@@ -11,6 +11,7 @@ import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager;
import org.jetbrains.idea.maven.plugins.api.MavenSoftAwareReferenceProvider;
/**
+ * Adds references to string like "groupId:artifactId:version"
* @author Sergey Evdokimov
*/
public class MavenDependencyReferenceProvider extends PsiReferenceProvider implements MavenSoftAwareReferenceProvider {
From 1ab9f952d6fcb70f52ac9fcc3648b6120653f240 Mon Sep 17 00:00:00 2001
From: Sergey Evdokimov
Date: Sun, 3 Feb 2013 01:26:01 +0400
Subject: [PATCH 48/51] IDEA-80064 Maven Model Inspection does not resolve
inherited properties
---
.../idea/maven/dom/MavenModelInspection.java | 46 --------------
.../idea/maven/dom/MavenPropertyResolver.java | 2 +-
.../dom/inspections/MavenModelInspection.java | 18 ++++++
.../dom/MavenCombineChildAttributeTest.groovy | 55 -----------------
...DependencyCompletionAndResolutionTest.java | 61 +++++++++++++++----
.../idea/maven/dom/MavenDomTestCase.java | 1 +
...MavenNotManagedProjectInspectionsTest.java | 10 +--
.../MavenRedundantGroupIdTest.groovy | 24 ++++++--
8 files changed, 95 insertions(+), 122 deletions(-)
delete mode 100644 plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenModelInspection.java
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenModelInspection.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenModelInspection.java
deleted file mode 100644
index 4ce00f70b3bd..000000000000
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenModelInspection.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.idea.maven.dom;
-
-import com.intellij.codeInspection.InspectionToolProvider;
-import com.intellij.util.xml.highlighting.BasicDomElementsInspection;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
-
-public class MavenModelInspection extends BasicDomElementsInspection implements InspectionToolProvider {
- public MavenModelInspection() {
- super(MavenDomProjectModel.class);
- }
-
- @NotNull
- public String getGroupDisplayName() {
- return MavenDomBundle.message("inspection.group");
- }
-
- @NotNull
- public String getDisplayName() {
- return MavenDomBundle.message("inspection.name");
- }
-
- @NotNull
- public String getShortName() {
- return "MavenModelInspection";
- }
-
- public Class[] getInspectionClasses() {
- return new Class[]{MavenModelInspection.class};
- }
-}
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
index 275772baa18c..7fe54ca40d43 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenPropertyResolver.java
@@ -153,7 +153,7 @@ public class MavenPropertyResolver {
VirtualFile file = MavenDomUtil.getVirtualFile(element);
if (file == null) return text;
- MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject());
+ MavenProjectsManager manager = MavenProjectsManager.getInstance(projectDom.getManager().getProject());
MavenProject mavenProject = manager.findProject(file);
if (mavenProject == null) return text;
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/inspections/MavenModelInspection.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/inspections/MavenModelInspection.java
index 359305790bc0..e9cf234c5d30 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/inspections/MavenModelInspection.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/inspections/MavenModelInspection.java
@@ -15,13 +15,16 @@
*/
package org.jetbrains.idea.maven.dom.inspections;
+import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.xml.Converter;
+import com.intellij.util.xml.DomUtil;
import com.intellij.util.xml.GenericDomValue;
import com.intellij.util.xml.highlighting.BasicDomElementsInspection;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.dom.MavenDomBundle;
import org.jetbrains.idea.maven.dom.converters.MavenDomSoftAwareConverter;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
+import org.jetbrains.idea.maven.project.MavenProjectsManager;
public class MavenModelInspection extends BasicDomElementsInspection {
public MavenModelInspection() {
@@ -43,8 +46,23 @@ public class MavenModelInspection extends BasicDomElementsInspectiontest
- project
- 1
-
-
-
-
- maven-compiler-plugin
-
-
-
-
-
- compile
-
-
-
-
-
-
-
-
-
-
-
-
- testProfile
-
-
-
- maven-compiler-plugin
-
-
-
-
-
- compile
-
-
-
-
-
-
-
-
-
-
-
-""")
-
- checkHighlighting()
- }
-
}
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java
index 905dcba3869b..48e8b72fcf83 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java
@@ -893,21 +893,60 @@ public class MavenDependencyCompletionAndResolutionTest extends MavenDomWithIndi
checkHighlighting();
}
- public void testDoNotHighlightProblemsInNotLoadedProject() throws Throwable {
- VirtualFile m = createModulePom("not-a-module",
- "test" +
- "project" +
- "1" +
+ public void testDontHighlightProblemsInNonManagedPom1() throws Throwable {
+ createProjectPom("test" +
+ "project" +
+ "1" +
+ "" +
+ " 4.0" +
+ "");
+
+ VirtualFile m = createModulePom("m1",
+ "m1" +
+
+ "" +
+ " test" +
+ " project" +
+ " 1" +
+ "" +
"" +
- " " +
- " xxx" +
- " xxx" +
- " xxx" +
- " " +
+ " " +
+ " junit" +
+ " junit" +
+ " ${junitVersion}" +
+ " " +
"");
- checkHighlighting(m);
+ importProject();
+
+ checkHighlighting(m, true, false, true);
+ }
+
+ public void testDontHighlightProblemsInNonManagedPom2() throws Throwable {
+ createProjectPom("test" +
+ "project" +
+ "1" +
+
+ "" +
+ " 4.0" +
+ "");
+
+ VirtualFile m = createModulePom("m1",
+ "m1" +
+
+ "" +
+ " test" +
+ " project" +
+ " 1" +
+ "" +
+ "" +
+ " ${junitVersion}" +
+ "");
+
+ importProject();
+
+ checkHighlighting(m, true, false, true);
}
public void testUpdateIndicesIntention() throws Throwable {
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java
index 36b037431930..1211ce5c60e6 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDomTestCase.java
@@ -58,6 +58,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.idea.maven.MavenImportingTestCase;
+import org.jetbrains.idea.maven.dom.inspections.MavenModelInspection;
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel;
import org.jetbrains.idea.maven.dom.references.MavenPsiElementWrapper;
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java
index 5160573eb00c..5727ff47960c 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenNotManagedProjectInspectionsTest.java
@@ -37,15 +37,15 @@ public class MavenNotManagedProjectInspectionsTest extends MavenDomTestCase {
"1" +
"" +
- " m1" +
- " m2" +
+ " m1" +
+ " m2" +
"" +
"" +
" " +
- " xxx" +
- " yyy" +
- " zzz" +
+ " xxx" +
+ " yyy" +
+ " zzz" +
" " +
"");
diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenRedundantGroupIdTest.groovy b/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenRedundantGroupIdTest.groovy
index e7fdda78e31b..1218cb13a0d9 100644
--- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenRedundantGroupIdTest.groovy
+++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/inspections/MavenRedundantGroupIdTest.groovy
@@ -19,7 +19,7 @@ class MavenRedundantGroupIdTest extends MavenDomTestCase {
public void testHighlighting1() {
createProjectPom("""
- mavenParent
+ my.group
childA
1.0
""")
@@ -34,9 +34,25 @@ class MavenRedundantGroupIdTest extends MavenDomTestCase {
1.0
- mavenParent
- childA
- 1.0
+ my.group
+ parent
+ 1.0
+
+""")
+
+ checkHighlighting()
+ }
+
+ public void testHighlighting3() {
+ createProjectPom("""
+ my.group
+ childA
+ 1.0
+
+
+ my.group
+ parent
+ 1.0
""")
From acb100d76743c8ce071f743245a81649c617d718 Mon Sep 17 00:00:00 2001
From: Sergey Evdokimov
Date: Sun, 3 Feb 2013 02:01:12 +0400
Subject: [PATCH 49/51] IDEA-100363 Non-managed pom.xml should has icon like a
simple xml file, non like managed project pom.xml
---
.../idea/maven/utils/MavenIconProvider.java | 22 +++++++++++++------
.../src/main/resources/META-INF/plugin.xml | 2 +-
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenIconProvider.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenIconProvider.java
index 3fa688447183..2b3c86cb9b59 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenIconProvider.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenIconProvider.java
@@ -15,23 +15,31 @@
*/
package org.jetbrains.idea.maven.utils;
-import com.intellij.ide.IconProvider;
+import com.intellij.ide.FileIconProvider;
import com.intellij.openapi.project.DumbAware;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiFile;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Iconable;
+import com.intellij.openapi.vfs.VirtualFile;
+import icons.MavenIcons;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import org.jetbrains.idea.maven.dom.MavenDomUtil;
+import org.jetbrains.idea.maven.project.MavenProjectsManager;
import javax.swing.*;
/**
* @author peter
*/
-public class MavenIconProvider extends IconProvider implements DumbAware {
+public class MavenIconProvider implements DumbAware, FileIconProvider {
@Nullable
- public Icon getIcon(@NotNull final PsiElement element, final int flags) {
- if (element instanceof PsiFile && MavenDomUtil.isMavenFile((PsiFile)element)) return icons.MavenIcons.MavenLogo;
+ @Override
+ public Icon getIcon(@NotNull VirtualFile file, @Iconable.IconFlags int flags, @Nullable Project project) {
+ if(project == null) return null;
+
+ if (MavenProjectsManager.getInstance(project).findProject(file) != null) {
+ return MavenIcons.MavenLogo;
+ }
+
return null;
}
}
diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml
index 062e05132250..2dbdbf8d81b0 100644
--- a/plugins/maven/src/main/resources/META-INF/plugin.xml
+++ b/plugins/maven/src/main/resources/META-INF/plugin.xml
@@ -56,7 +56,7 @@
-
+
From 1078d1220fce2263ca24cbeb15838116b9bb1e9d Mon Sep 17 00:00:00 2001
From: Konstantin Bulenkov
Date: Sat, 2 Feb 2013 23:06:51 +0100
Subject: [PATCH 50/51] Shift+Escape on jdk 7
---
.../intellij/openapi/wm/impl/ToolWindowManagerImpl.java | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
index 72c8b275c1e2..de2b85cc1e88 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java
@@ -989,6 +989,14 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
}
}
+ //todo[kb] it's just a temporary solution due a number of focus issues in JDK 7
+ if (SystemInfo.isJavaVersionAtLeast("1.7")) {
+ if (hasOpenEditorFiles()) {
+ activateEditorComponentImpl(getSplittersFromFocus(), commandList, false);
+ } else {
+ focusToolWinowByDefault(id);
+ }
+ }
execute(commandList);
}
From 369a4a5da1c47858d566a683666e338cc109f32f Mon Sep 17 00:00:00 2001
From: Sergey Evdokimov
Date: Sun, 3 Feb 2013 15:31:44 +0400
Subject: [PATCH 51/51] IDEA-100270 Unable to start Grails
---
.../griffon/GriffonCreateProjectDialog.java | 38 +++---
.../groovy/griffon/GriffonFramework.java | 20 ++-
.../plugins/groovy/mvc/MvcCommand.java | 118 ++++++++++++++++++
.../plugins/groovy/mvc/MvcFramework.java | 46 +++----
.../groovy/mvc/MvcRunConfiguration.java | 5 +-
.../plugins/groovy/mvc/MvcRunTarget.java | 7 +-
.../groovy/mvc/MvcRunTargetDialog.java | 10 +-
.../util/MvcTargetDialogCompletionUtils.java | 2 +-
8 files changed, 173 insertions(+), 73 deletions(-)
create mode 100644 plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommand.java
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonCreateProjectDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonCreateProjectDialog.java
index e149c4e64c99..e1d7b4bdb5c6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonCreateProjectDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonCreateProjectDialog.java
@@ -15,13 +15,12 @@
*/
package org.jetbrains.plugins.groovy.griffon;
+import com.intellij.execution.configurations.ParametersList;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.mvc.MvcCommand;
import javax.swing.*;
@@ -50,20 +49,29 @@ public class GriffonCreateProjectDialog extends DialogWrapper {
return myComponent;
}
- String getCommand() {
- if (myCreateAddon.isSelected()) return "create-addon";
- if (myCreateApp.isSelected()) return "create-app";
- if (myCreateArchetype.isSelected()) return "create-archetype";
- if (myCreatePlugin.isSelected()) return "create-plugin";
- throw new AssertionError("No selection");
- }
+ MvcCommand getCommand() {
+ String cmd;
- String[] getArguments() {
- String text = myOptionField.getText();
- if (StringUtil.isEmptyOrSpaces(text)) {
- return ArrayUtil.EMPTY_STRING_ARRAY;
+ if (myCreateAddon.isSelected()) {
+ cmd = "create-addon";
}
- return text.split(" ");
+ else if (myCreateApp.isSelected()) {
+ cmd = "create-app";
+ }
+ else if (myCreateArchetype.isSelected()) {
+ cmd = "create-archetype";
+ }
+ else if (myCreatePlugin.isSelected()) {
+ cmd = "create-plugin";
+ }
+ else {
+ throw new AssertionError("No selection");
+ }
+
+ String text = myOptionField.getText();
+ if (text == null) text = "";
+
+ return new MvcCommand(cmd, ParametersList.parse(text));
}
}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java
index ed8c1fedd42c..5e9ccae44555 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java
@@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.griffon;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.JavaParameters;
+import com.intellij.execution.configurations.ParametersList;
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.psi.PropertiesFile;
import com.intellij.openapi.application.AccessToken;
@@ -41,17 +42,13 @@ import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
-import com.intellij.util.ArrayUtil;
import gnu.trove.TIntArrayList;
import icons.JetgroovyIcons;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
-import org.jetbrains.plugins.groovy.mvc.MvcFramework;
-import org.jetbrains.plugins.groovy.mvc.MvcModuleStructureUtil;
-import org.jetbrains.plugins.groovy.mvc.MvcPathMacros;
-import org.jetbrains.plugins.groovy.mvc.MvcProjectStructure;
+import org.jetbrains.plugins.groovy.mvc.*;
import javax.swing.*;
import java.io.File;
@@ -105,7 +102,7 @@ public class GriffonFramework extends MvcFramework {
return null;
}
- return createCommandAndShowErrors(null, module, true, dialog.getCommand(), dialog.getArguments());
+ return createCommandAndShowErrors(null, module, true, dialog.getCommand());
}
@Override
@@ -231,8 +228,7 @@ public class GriffonFramework extends MvcFramework {
public JavaParameters createJavaParameters(@NotNull Module module, boolean forCreation, boolean forTests,
boolean classpathFromDependencies,
@Nullable String jvmParams,
- @NotNull String command,
- @NotNull String... args) throws ExecutionException {
+ @NotNull MvcCommand command) throws ExecutionException {
JavaParameters params = new JavaParameters();
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
@@ -284,7 +280,8 @@ public class GriffonFramework extends MvcFramework {
throw new ExecutionException("Failed to initialize griffon module: module " + module.getName() + " contains more than one root");
}
- args = ArrayUtil.mergeArrays(new String[]{roots[0].getName()}, args);
+ command.getArgs().add(0, roots[0].getName());
+
rootFile = roots[0].getParent();
}
else {
@@ -331,8 +328,9 @@ public class GriffonFramework extends MvcFramework {
params.setWorkingDirectory(workDir);
- String argsString = args.length == 0 ? command : command + ' ' + StringUtil.join(args, " ");
- params.getProgramParametersList().add(argsString);
+ ParametersList paramList = new ParametersList();
+ command.addToParametersList(paramList);
+ params.getProgramParametersList().add(paramList.getParametersString());
params.setDefaultCharset(module.getProject());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommand.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommand.java
new file mode 100644
index 000000000000..5ddb553ab38b
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcCommand.java
@@ -0,0 +1,118 @@
+package org.jetbrains.plugins.groovy.mvc;
+
+import com.intellij.execution.configurations.ParametersList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.*;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class MvcCommand {
+
+ public static final Collection ourEnvironments = Arrays.asList("prod", "test", "dev");
+
+ private String myEnv;
+ private String myCommand;
+
+ private final ArrayList myArgs = new ArrayList();
+ private final ArrayList myProperties = new ArrayList();
+
+ public MvcCommand() {
+ }
+
+ public MvcCommand(String command, String ... args) {
+ myCommand = command;
+ Collections.addAll(myArgs, args);
+ }
+
+ @Nullable
+ public String getEnv() {
+ return myEnv;
+ }
+
+ public void setEnv(@Nullable String env) {
+ myEnv = env;
+ }
+
+ @Nullable
+ public String getCommand() {
+ return myCommand;
+ }
+
+ public void setCommand(@Nullable String command) {
+ myCommand = command;
+ }
+
+ /**
+ * Returns MODIFIABLE list of arguments
+ */
+ public ArrayList getArgs() {
+ return myArgs;
+ }
+
+ public void setArgs(List args) {
+ if (args == myArgs) return;
+
+ myArgs.clear();
+ myArgs.addAll(args);
+ }
+
+ /**
+ * Returns MODIFIABLE list of system properties definition written before command (e.g. -Dgrails.port=9090 run-app)
+ */
+ public ArrayList getProperties() {
+ return myProperties;
+ }
+
+ public void setProperties(List properties) {
+ if (myProperties == properties) return;
+
+ myProperties.clear();
+ myProperties.addAll(properties);
+ }
+
+ public void addToParametersList(@NotNull ParametersList list) {
+ if (myEnv != null) {
+ list.add(myEnv);
+ }
+
+ list.addAll(myProperties);
+
+ if (myCommand != null) {
+ list.add(myCommand);
+ }
+
+ list.addAll(myArgs);
+ }
+
+ @NotNull
+ public static MvcCommand parse(@NotNull String cmd) {
+ String[] args = ParametersList.parse(cmd);
+
+ MvcCommand res = new MvcCommand();
+
+ int i = 0;
+
+ while (res.myCommand == null && i < args.length) {
+ String s = args[i];
+
+ if (s.startsWith("-D")) {
+ res.myProperties.add(s);
+ }
+ else if (res.myEnv == null && ourEnvironments.contains(s)) {
+ res.myEnv = s;
+ }
+ else {
+ res.myCommand = s;
+ }
+
+ i++;
+ }
+
+ res.myArgs.addAll(Arrays.asList(args).subList(i, args.length));
+
+ return res;
+ }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
index c3afadde2332..44190d8d0411 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
@@ -166,7 +166,7 @@ public abstract class MvcFramework {
return null;
}
- return createCommandAndShowErrors(null, module, true, result == 0 ? "create-app" : "create-plugin");
+ return createCommandAndShowErrors(null, module, true, new MvcCommand(result == 0 ? "create-app" : "create-plugin"));
}
public abstract void updateProjectStructure(@NotNull final Module module);
@@ -316,32 +316,12 @@ public abstract class MvcFramework {
from.remove(extension.getCompilerOutputPathForTests());
}
-
- public static Pair parsedCmd(String cmdLine) {
- return parsedCmd(ParametersList.parse(cmdLine));
- }
-
- public static Pair parsedCmd(String[] args) {
- if (args.length == 0) {
- return new Pair("", ArrayUtil.EMPTY_STRING_ARRAY);
- }
- if (args.length == 1) {
- return new Pair(args[0], ArrayUtil.EMPTY_STRING_ARRAY);
- }
-
- String[] array = new String[args.length - 1];
- System.arraycopy(args, 1, array, 0, array.length);
-
- return new Pair(args[0], array);
- }
-
public abstract JavaParameters createJavaParameters(@NotNull Module module,
boolean forCreation,
boolean forTests,
boolean classpathFromDependencies,
@Nullable String jvmParams,
- @NotNull String command,
- @NotNull String... args) throws ExecutionException;
+ @NotNull MvcCommand command) throws ExecutionException;
protected static void ensureRunConfigurationExists(Module module, ConfigurationType configurationType, String name) {
final RunManagerEx runManager = RunManagerEx.getInstanceEx(module.getProject());
@@ -373,19 +353,24 @@ public abstract class MvcFramework {
public abstract String getSdkHomePropertyName();
@Nullable
- public GeneralCommandLine createCommandAndShowErrors(@NotNull Module module, @NotNull String command, @NotNull String... args) {
- return createCommandAndShowErrors(null, module, command, args);
+ public GeneralCommandLine createCommandAndShowErrors(@NotNull Module module, @NotNull String command, String... args) {
+ return createCommandAndShowErrors(null, module, new MvcCommand(command, args));
}
@Nullable
- public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, @NotNull String command, @NotNull String... args) {
- return createCommandAndShowErrors(vmOptions, module, false, command, args);
+ public GeneralCommandLine createCommandAndShowErrors(@NotNull Module module, @NotNull MvcCommand command) {
+ return createCommandAndShowErrors(null, module, command);
}
@Nullable
- public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, final boolean forCreation, @NotNull String command, @NotNull String... args) {
+ public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, @NotNull MvcCommand command) {
+ return createCommandAndShowErrors(vmOptions, module, false, command);
+ }
+
+ @Nullable
+ public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, final boolean forCreation, @NotNull MvcCommand command) {
try {
- return createCommand(module, vmOptions, forCreation, command, args);
+ return createCommand(module, vmOptions, forCreation, command);
}
catch (ExecutionException e) {
Messages.showErrorDialog(e.getMessage(), "Failed to run grails command: " + command);
@@ -397,9 +382,8 @@ public abstract class MvcFramework {
public GeneralCommandLine createCommand(@NotNull Module module,
@Nullable String jvmParams,
final boolean forCreation,
- @NotNull String command,
- @NotNull String... args) throws ExecutionException {
- final JavaParameters params = createJavaParameters(module, forCreation, false, true, jvmParams, command, args);
+ @NotNull MvcCommand command) throws ExecutionException {
+ final JavaParameters params = createJavaParameters(module, forCreation, false, true, jvmParams, command);
addJavaHome(params, module);
final GeneralCommandLine commandLine = createCommandLine(params);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java
index d6c2a74a2815..6e0cec286e8f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunConfiguration.java
@@ -288,10 +288,9 @@ public abstract class MvcRunConfiguration extends ModuleBasedConfiguration parsedCmd = MvcFramework.parsedCmd(myCmdLine);
+ MvcCommand cmd = MvcCommand.parse(myCmdLine);
- final JavaParameters params = myFramework.createJavaParameters(myModule, false, myForTests, depsClasspath, vmParams, parsedCmd.first,
- parsedCmd.second);
+ final JavaParameters params = myFramework.createJavaParameters(myModule, false, myForTests, depsClasspath, vmParams, cmd);
addEnvVars(params);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java
index a88782104954..6efc6665504e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTarget.java
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.groovy.mvc;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.module.Module;
-import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
/**
@@ -36,11 +35,9 @@ public class MvcRunTarget extends MvcActionBase {
Module selectedModule = dialog.getSelectedModule();
- String[] targetArgs = dialog.getTargetArguments();
+ MvcCommand cmd = MvcCommand.parse(dialog.getTargetArguments());
- Pair parsedCmd = MvcFramework.parsedCmd(targetArgs);
-
- final GeneralCommandLine commandLine = framework.createCommandAndShowErrors(dialog.getVmOptions(), selectedModule, parsedCmd.first, parsedCmd.second);
+ final GeneralCommandLine commandLine = framework.createCommandAndShowErrors(dialog.getVmOptions(), selectedModule, cmd);
if (commandLine == null) return;
MvcConsole.executeProcess(selectedModule, commandLine, null, false);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
index d1da3439d662..668554bdcb6e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
@@ -147,7 +147,8 @@ public class MvcRunTargetDialog extends DialogWrapper {
return (String)myTargetField.getEditor().getItem();
}
- public String[] getTargetArguments() {
+ @NotNull
+ public String getTargetArguments() {
String text = getSelectedText();
text = text.trim();
@@ -155,12 +156,7 @@ public class MvcRunTargetDialog extends DialogWrapper {
text = text.substring(GRAILS_PREFIX.length());
}
- Iterable iterable = StringUtil.tokenize(text, " ");
- ArrayList args = new ArrayList();
- for (String s : iterable) {
- args.add(s);
- }
- return ArrayUtil.toStringArray(args);
+ return text;
}
protected JComponent createCenterPanel() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/MvcTargetDialogCompletionUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/MvcTargetDialogCompletionUtils.java
index 17c11008a90e..626cbd7acdb6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/MvcTargetDialogCompletionUtils.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/util/MvcTargetDialogCompletionUtils.java
@@ -77,7 +77,7 @@ public class MvcTargetDialogCompletionUtils {
List res = new ArrayList();
- if (text.substring(0, offset).matches("\\s*(grails\\s*)?(?:(:?-\\S+|dev|prod|test)\\s+)*\\S*")) {
+ if (text.substring(0, offset).matches("\\s*(grails\\s*)?(?:(:?-D\\S+|dev|prod|test)\\s+)*\\S*")) {
// Complete command name because command name is not typed.
for (String completionVariant : getAllTargetNames(module)) {
res.add(TailTypeDecorator.withTail(LookupElementBuilder.create(completionVariant), TailType.SPACE));