From e078d1b31f0abd3d3d7bfbc7f21fa4e279982b4c Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 31 Jan 2013 15:35:13 +0100 Subject: [PATCH 01/29] fix leak in groovy introduce tests --- .../plugins/groovy/intentions/IntroduceLocalVariableTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy index 24e5d5522575..afcbce22bb4f 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/IntroduceLocalVariableTest.groovy @@ -65,7 +65,7 @@ public class IntroduceLocalVariableTest extends GrIntentionTestCase { @Override void show() { - // nop + close(0) } @Override From 2c9f51fad26dd26da0f15dc47397a4122794bde8 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 31 Jan 2013 17:16:13 +0400 Subject: [PATCH 02/29] javafx: fx:reference source ref --- .../fxml/refs/FxmlReferencesContributor.java | 6 ++ .../JavaFxComponentIdReferenceProvider.java | 67 +++++++++++++++++++ .../highlighting/referenceAttributes.fxml | 4 +- .../highlighting/sourceAttrRecognition.fxml | 2 +- .../javaFX/fxml/JavaFXHighlightingTest.java | 3 +- 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxComponentIdReferenceProvider.java 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 8b1d0d9917bd..f4d44b4446d3 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 @@ -51,6 +51,12 @@ public class FxmlReferencesContributor extends PsiReferenceContributor { .and(attributeValueInFxml), new JavaFxSourceReferenceProvider()); + registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_ELEMENT_SOURCE) + .withParent(XmlPatterns.xmlTag() + .withName(FxmlConstants.FX_REFERENCE))) + .and(attributeValueInFxml), + new JavaFxComponentIdReferenceProvider()); + registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("#")) .and(attributeValueInFxml), new JavaFxEventHandlerReferenceProvider()); diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxComponentIdReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxComponentIdReferenceProvider.java new file mode 100644 index 000000000000..04550a8055a7 --- /dev/null +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxComponentIdReferenceProvider.java @@ -0,0 +1,67 @@ +/* + * 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 org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; + +import java.util.HashMap; +import java.util.Map; + +/** +* User: anna +*/ +class JavaFxComponentIdReferenceProvider extends PsiReferenceProvider { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, + @NotNull ProcessingContext context) { + final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue)element; + final String referencesId = xmlAttributeValue.getValue(); + final Map fileIds = new HashMap(); + xmlAttributeValue.getContainingFile().accept(new XmlRecursiveElementVisitor() { + @Override + public void visitXmlTag(XmlTag tag) { + super.visitXmlTag(tag); + final XmlAttribute attribute = tag.getAttribute(FxmlConstants.FX_ID); + if (attribute != null) { + fileIds.put(attribute.getValue(), attribute.getValueElement()); + } + } + }); + + return new PsiReference[]{new PsiReferenceBase(xmlAttributeValue) { + @Nullable + @Override + public PsiElement resolve() { + return fileIds.get(referencesId); + } + + @NotNull + @Override + public Object[] getVariants() { + return ArrayUtil.toStringArray(fileIds.keySet()); + } + }}; + } +} diff --git a/plugins/javaFX/testData/highlighting/referenceAttributes.fxml b/plugins/javaFX/testData/highlighting/referenceAttributes.fxml index 6dd49d046575..e1f5e19afc2e 100644 --- a/plugins/javaFX/testData/highlighting/referenceAttributes.fxml +++ b/plugins/javaFX/testData/highlighting/referenceAttributes.fxml @@ -1,5 +1,5 @@ - - + <fx:reference GridPane.halignment="CENTER" /> + lbl"/> diff --git a/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml b/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml index 15153423931a..b17af0779ad1 100644 --- a/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml +++ b/plugins/javaFX/testData/highlighting/sourceAttrRecognition.fxml @@ -3,7 +3,7 @@ - + myImage"/> my_button.fxml"/> 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 2453baf5ccf3..e04cd6e35778 100644 --- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java +++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java @@ -3,6 +3,7 @@ package org.jetbrains.plugins.javaFX.fxml; import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase; import com.intellij.codeInsight.daemon.impl.analysis.XmlPathReferenceInspection; import com.intellij.codeInspection.LocalInspectionTool; +import com.intellij.codeInspection.htmlInspections.RequiredAttributesInspection; import com.intellij.openapi.application.PluginPathManager; import com.intellij.psi.PsiClass; import com.intellij.psi.PsiField; @@ -24,7 +25,7 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase { @Override protected LocalInspectionTool[] configureLocalInspectionTools() { - return new LocalInspectionTool[] {new XmlPathReferenceInspection()}; + return new LocalInspectionTool[] {new XmlPathReferenceInspection(), new RequiredAttributesInspection() }; } public void testLoginForm() throws Exception { From 942955682f16e740deab3e5235e93129f9a8e856 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 31 Jan 2013 17:52:22 +0400 Subject: [PATCH 03/29] javafx: attributes from referenced tag supported (IDEA-100124) --- ...avaFxDefaultPropertyElementDescriptor.java | 47 +++++++++++++++++-- .../completion/referencedAttributes.fxml | 8 ++++ .../referencedAttributes_after.fxml | 8 ++++ .../javaFX/fxml/JavaFxCompletionTest.java | 4 ++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 plugins/javaFX/testData/completion/referencedAttributes.fxml create mode 100644 plugins/javaFX/testData/completion/referencedAttributes_after.fxml diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java index 2c682cf56fbf..674a55ad0b55 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java @@ -17,7 +17,10 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiReference; +import com.intellij.psi.util.PsiTreeUtil; 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.xml.XmlAttributeDescriptor; @@ -30,6 +33,7 @@ import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -37,11 +41,11 @@ import java.util.List; */ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescriptor{ private final String myName; - private PsiElement myElement; + private final XmlTag myXmlTag; public JavaFxDefaultPropertyElementDescriptor(String name, XmlTag tag) { myName = name; - myElement = tag; + myXmlTag = tag; } @Override @@ -74,11 +78,41 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip descriptors.add(new JavaFxDefaultAttributeDescriptor(defaultAttrName, getName())); } JavaFxClassBackedElementDescriptor.collectStaticAttributesDescriptors(context, descriptors); + final XmlTag referencedTag = getReferencedTag(getName(), myXmlTag); + if (referencedTag != null) { + final XmlElementDescriptor referencedDescriptor = referencedTag.getDescriptor(); + if (referencedDescriptor != null) { + final XmlAttributeDescriptor[] attributesDescriptors = referencedDescriptor.getAttributesDescriptors(referencedTag); + if (attributesDescriptors != null) { + Collections.addAll(descriptors, attributesDescriptors); + } + } + } return descriptors.toArray(new XmlAttributeDescriptor[descriptors.size()]); } return XmlAttributeDescriptor.EMPTY; } + @Nullable + private static XmlTag getReferencedTag(String name, XmlTag tag) { + if (name.equals(FxmlConstants.FX_REFERENCE)) { + final XmlAttribute attribute = tag.getAttribute(FxmlConstants.FX_ELEMENT_SOURCE); + if (attribute != null) { + final XmlAttributeValue valueElement = attribute.getValueElement(); + if (valueElement != null) { + final PsiReference reference = valueElement.getReference(); + if (reference != null) { + final PsiElement resolve = reference.resolve(); + if (resolve instanceof XmlAttributeValue) { + return PsiTreeUtil.getParentOfType(resolve, XmlTag.class); + } + } + } + } + } + return null; + } + @Nullable @Override public XmlAttributeDescriptor getAttributeDescriptor(@NonNls String attributeName, @Nullable XmlTag context) { @@ -91,6 +125,13 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip if (propertySetter != null) { return new JavaFxStaticPropertyAttributeDescriptor(propertySetter, attributeName); } + final XmlTag referencedTag = getReferencedTag(getName(), myXmlTag); + if (referencedTag != null) { + final XmlElementDescriptor referencedDescriptor = referencedTag.getDescriptor(); + if (referencedDescriptor != null) { + return referencedDescriptor.getAttributeDescriptor(attributeName, referencedTag); + } + } } return null; } @@ -125,7 +166,7 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip @Override public PsiElement getDeclaration() { - return myElement; + return myXmlTag; } @Override diff --git a/plugins/javaFX/testData/completion/referencedAttributes.fxml b/plugins/javaFX/testData/completion/referencedAttributes.fxml new file mode 100644 index 000000000000..ac36d9d0f84b --- /dev/null +++ b/plugins/javaFX/testData/completion/referencedAttributes.fxml @@ -0,0 +1,8 @@ + + + + + + /> + diff --git a/plugins/javaFX/testData/completion/referencedAttributes_after.fxml b/plugins/javaFX/testData/completion/referencedAttributes_after.fxml new file mode 100644 index 000000000000..1e9128c4cc8d --- /dev/null +++ b/plugins/javaFX/testData/completion/referencedAttributes_after.fxml @@ -0,0 +1,8 @@ + + + + + + + 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 2c0bce26bb7d..42cb5084adcf 100644 --- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java +++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxCompletionTest.java @@ -81,6 +81,10 @@ public class JavaFxCompletionTest extends CompletionTestCase { doTest("NEGATIVE_INFINITY"); } + public void testReferencedAttributes() throws Exception { + doTest("text"); + } + private void doTest() throws Exception { doTest(null); } From c0cabd721a5f6544d75244f4d378de7e572d0028 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 31 Jan 2013 18:35:02 +0400 Subject: [PATCH 04/29] cleanup --- .../fxml/descriptors/JavaFxPropertyAttributeDescriptor.java | 3 +-- .../javaFX/fxml/refs/EnumeratedAttributeReferenceProvider.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java index 07aac3184d32..6b49c7d3abf2 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java @@ -87,9 +87,8 @@ public class JavaFxPropertyAttributeDescriptor implements XmlAttributeDescriptor public PsiField getEnumConstant(String attrValue) { if (isEnumerated()) { - final String fieldNameIgnoreCase = StringUtil.stripQuotesAroundValue(attrValue); final PsiClass aClass = getEnum(); - return aClass.findFieldByName(fieldNameIgnoreCase.toUpperCase(), false); + return aClass.findFieldByName(attrValue.toUpperCase(), false); } return null; } 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 ce12b2e051d6..8f8746082845 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 @@ -39,7 +39,7 @@ 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(element.getText()))}; + return new PsiReference[] {new PsiReferenceBase.Immediate(xmlAttributeValue, ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(xmlAttributeValue.getValue()))}; } } } From 74ec95bea257399d824e3b243106a7f80c54d409 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Thu, 31 Jan 2013 18:50:14 +0400 Subject: [PATCH 05/29] IDEA-97665 Provide an option to specify fall back fonts Colors scheme now listens for font preferences changes and updates its caches accordingly --- .../options/colors/ColorAndFontOptions.java | 4 ++-- .../editor/colors/EditorColorsScheme.java | 2 ++ .../editor/colors/FontPreferences.java | 20 ++++++++++++++++- .../colors/impl/AbstractColorsScheme.java | 22 +++++++++++++++++-- .../colors/impl/DelegateColorScheme.java | 10 +++++++++ .../openapi/editor/impl/EditorImpl.java | 15 +++++++++++-- 6 files changed, 66 insertions(+), 7 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index c45acb38add3..5d7ae51e43e9 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -1067,10 +1067,10 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract } public void apply(EditorColorsScheme scheme) { - getFontPreferences().copyTo(scheme.getFontPreferences()); + scheme.setFontPreferences(getFontPreferences()); scheme.setLineSpacing(myLineSpacing); scheme.setQuickDocFontSize(getQuickDocFontSize()); - getConsoleFontPreferences().copyTo(scheme.getConsoleFontPreferences()); + scheme.setConsoleFontPreferences(getConsoleFontPreferences()); scheme.setConsoleLineSpacing(getConsoleLineSpacing()); for (EditorSchemeAttributeDescriptor descriptor : myDescriptors) { diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java index d0e32bc0e239..d21e26e750b7 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/EditorColorsScheme.java @@ -54,6 +54,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem */ @NotNull FontPreferences getFontPreferences(); + void setFontPreferences(@NotNull FontPreferences preferences); String getEditorFontName(); void setEditorFontName(String fontName); @@ -78,6 +79,7 @@ public interface EditorColorsScheme extends Cloneable, JDOMExternalizable, Schem */ @NotNull FontPreferences getConsoleFontPreferences(); + void setConsoleFontPreferences(@NotNull FontPreferences preferences); String getConsoleFontName(); void setConsoleFontName(String fontName); diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java index 73d1b8f4b991..2d88151f088e 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java @@ -44,21 +44,33 @@ public class FontPreferences { @NotNull private final TObjectIntHashMap myFontSizes = new TObjectIntHashMap(); @NotNull private final List myEffectiveFontFamilies = ContainerUtilRt.newArrayList(); @NotNull private final List myRealFontFamilies = ContainerUtilRt.newArrayList(); + + @Nullable Runnable myChangeListener; /** * Font size to use by default. Default value is {@link #DEFAULT_FONT_SIZE}. */ private int myTemplateFontSize = DEFAULT_FONT_SIZE; - + + public void setChangeListener(@Nullable Runnable changeListener) { + myChangeListener = changeListener; + } + public void clear() { myEffectiveFontFamilies.clear(); myRealFontFamilies.clear(); myFontSizes.clear(); + if (myChangeListener != null) { + myChangeListener.run(); + } } public void clearFonts() { myEffectiveFontFamilies.clear(); myRealFontFamilies.clear(); + if (myChangeListener != null) { + myChangeListener.run(); + } } public boolean hasSize(@NotNull String fontName) { @@ -76,6 +88,9 @@ public class FontPreferences { public void setSize(@NotNull String fontFamily, int size) { myFontSizes.put(fontFamily, size); myTemplateFontSize = size; + if (myChangeListener != null) { + myChangeListener.run(); + } } /** @@ -132,6 +147,9 @@ public class FontPreferences { if (!myEffectiveFontFamilies.contains(effectiveFontFamily)) { myEffectiveFontFamilies.add(effectiveFontFamily); } + if (myChangeListener != null) { + myChangeListener.run(); + } } public void copyTo(@NotNull final FontPreferences preferences) { diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index d41e826c268c..b446df31d6a4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -90,6 +90,12 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { protected AbstractColorsScheme(EditorColorsScheme parentScheme, DefaultColorSchemesManager defaultColorSchemesManager) { myParentScheme = parentScheme; myDefaultColorSchemesManager = defaultColorSchemesManager; + myFontPreferences.setChangeListener(new Runnable() { + @Override + public void run() { + initFonts(); + } + }); } public AbstractColorsScheme(DefaultColorSchemesManager defaultColorSchemesManager) { @@ -179,7 +185,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { public FontPreferences getFontPreferences() { return myFontPreferences; } - + + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myFontPreferences); + initFonts(); + } + @Override public String getEditorFontName() { if (myFallbackFontName != null) { @@ -581,7 +593,13 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { public FontPreferences getConsoleFontPreferences() { return myConsoleFontPreferences; } - + + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myConsoleFontPreferences); + initFonts(); + } + @Override public String getConsoleFontName() { return myConsoleFontPreferences.getFontFamily(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java index 1e0b2e285007..663b84789653 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/DelegateColorScheme.java @@ -84,6 +84,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { return myDelegate.getFontPreferences(); } + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + myDelegate.setFontPreferences(preferences); + } + @Override public int getEditorFontSize() { return myDelegate.getEditorFontSize(); @@ -158,6 +163,11 @@ public abstract class DelegateColorScheme implements EditorColorsScheme { return myDelegate.getConsoleFontPreferences(); } + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + myDelegate.setConsoleFontPreferences(preferences); + } + @Override public String getConsoleFontName() { return myDelegate.getConsoleFontName(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java index 09e75b3f70f2..9f76d6a6a943 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorImpl.java @@ -5684,7 +5684,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi private class MyColorSchemeDelegate implements EditorColorsScheme { - private final FontPreferences myFontPreferences = new FontPreferences(); + private final FontPreferences myFontPreferences = new FontPreferences(); private final Map myOwnAttributes = ContainerUtilRt.newHashMap(); private final Map myOwnColors = ContainerUtilRt.newHashMap(); private final EditorColorsScheme myCustomGlobalScheme; @@ -5807,6 +5807,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi return myFontPreferences.getEffectiveFontFamilies().isEmpty() ? getGlobal().getFontPreferences() : myFontPreferences; } + @Override + public void setFontPreferences(@NotNull FontPreferences preferences) { + preferences.copyTo(myFontPreferences); + initFonts(); + } + @Override public String getEditorFontName() { if (myFaceName == null) { @@ -5874,7 +5880,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi public FontPreferences getConsoleFontPreferences() { return getGlobal().getConsoleFontPreferences(); } - + + @Override + public void setConsoleFontPreferences(@NotNull FontPreferences preferences) { + getGlobal().setConsoleFontPreferences(preferences); + } + @Override public String getConsoleFontName() { return getGlobal().getConsoleFontName(); From 7c4f6a12cb0a35b70499c0b9085cc495ac865693 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 31 Jan 2013 15:51:46 +0100 Subject: [PATCH 06/29] logic fixed --- .../src/com/intellij/psi/impl/search/LowLevelSearchUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java index 44860d211e60..fbf027c42b48 100644 --- a/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java +++ b/platform/indexing-impl/src/com/intellij/psi/impl/search/LowLevelSearchUtil.java @@ -205,7 +205,7 @@ public class LowLevelSearchUtil { if (index > startOffset) { char c = textArray != null ? textArray[index - 1]:text.charAt(index - 1); if (Character.isJavaIdentifierPart(c) && c != '$') { - if (searcher.isHandleEscapeSequences() && (index < 2 || !isNotEscapedBackslash(text, textArray, startOffset, index-2))) { //escape sequence + if (!searcher.isHandleEscapeSequences() || (index < 2 || !isNotEscapedBackslash(text, textArray, startOffset, index-2))) { //escape sequence continue; } } From afed2341a927b5ecee781cc273730cf0b83abbe7 Mon Sep 17 00:00:00 2001 From: "Maxim.Mossienko" Date: Thu, 31 Jan 2013 15:57:30 +0100 Subject: [PATCH 07/29] [r=Eugene.Juravlev] fix OOME caused by increase of indexed file above indexed limit (RUBY-12980) --- .../src/com/intellij/util/indexing/FileBasedIndexImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java index 4899bcd267e5..e83a755bd922 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java @@ -2113,7 +2113,7 @@ public class FileBasedIndexImpl extends FileBasedIndex { final VirtualFile file = fileContent.getVirtualFile(); final boolean reallyRemoved = myFilesToUpdate.remove(file); if (reallyRemoved && file.isValid()) { - if (onlyRemoveOutdatedData) { + if (onlyRemoveOutdatedData || isTooLarge(file)) { // on shutdown there is no need to re-index the file, just remove outdated data from indices final List> affected = new ArrayList>(); for (final ID indexId : myRequiringContentIndices) { // non requiring content indices should be flushed From cfb15f3f382e6c8f9cbb3870b7671dbdb276ab3a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 31 Jan 2013 19:03:35 +0400 Subject: [PATCH 08/29] IDEA-100140 (one place to split them all) --- .../configurations/ParametersList.java | 8 +-- .../src/com/intellij/openapi/ui/Messages.java | 54 +++++++++---------- .../openapi/execution/ParametersListTest.java | 17 ++++-- .../util/execution/ParametersListUtil.java | 19 +++++-- 4 files changed, 57 insertions(+), 41 deletions(-) diff --git a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java index 503d217ba1f7..dfc36e7ca9b1 100644 --- a/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.java +++ b/platform/platform-api/src/com/intellij/execution/configurations/ParametersList.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. @@ -194,7 +194,7 @@ public class ParametersList implements Cloneable { for (ListIterator iterator = myParameters.listIterator(); iterator.hasNext(); ) { final String param = iterator.next(); if (param.startsWith(parameterPrefix)) { - if ("".equals(replacement)) { + if (replacement != null && replacement.isEmpty()) { iterator.remove(); } else { @@ -203,7 +203,7 @@ public class ParametersList implements Cloneable { return; } } - if (!"".equals(replacement)) { + if (replacement != null && !replacement.isEmpty()) { myParameters.add(position, replacement); } } @@ -211,7 +211,7 @@ public class ParametersList implements Cloneable { public void replaceOrPrepend(final @NonNls String parameter, final @NonNls String replacement) { replaceOrAdd(parameter, replacement, 0); } - + public void set(int ind, final @NonNls String value) { myParameters.set(ind, value); } diff --git a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java index fd9063a2a148..8bf4f680fcac 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/Messages.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/Messages.java @@ -30,6 +30,7 @@ import com.intellij.ui.*; import com.intellij.ui.components.JBScrollPane; import com.intellij.ui.mac.MacMessages; import com.intellij.util.PairFunction; +import com.intellij.util.execution.ParametersListUtil; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.*; @@ -96,14 +97,14 @@ public class Messages { } /** - * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! + * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! */ public static int showDialog(@Nullable Project project, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon) { return showDialog(project, message, title, options, defaultOptionIndex, icon, null); } /** - * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! + * Please, use {@link #showOkCancelDialog} or {@link #showYesNoCancelDialog} if possible (these dialogs implements native OS behavior)! */ public static int showDialog(@Nullable Project project, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, @Nullable DialogWrapper.DoNotAskOption doNotAskOption) { @@ -162,7 +163,7 @@ public class Messages { return MacMessages.getInstance() .showMessageDialog(title, message, options, false, SwingUtilities.getWindowAncestor(parent), defaultOptionIndex, defaultOptionIndex, null); } - + MessageDialog dialog = new MessageDialog(parent, message, title, options, defaultOptionIndex, defaultOptionIndex, icon, false); dialog.show(); return dialog.getExitCode(); @@ -183,7 +184,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showMessageDialog(title, message, options, false, null, defaultOptionIndex, focusedOptionIndex, doNotAskOption); } - + //what's it? if (application.isUnitTestMode()) throw new RuntimeException(message); MessageDialog dialog = new MessageDialog(message, title, options, defaultOptionIndex, focusedOptionIndex, icon, doNotAskOption); dialog.show(); @@ -219,7 +220,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project)); return; } - + showDialog(project, message, title, new String[]{OK_BUTTON}, 0, icon); } @@ -228,7 +229,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(parent)); return; } - + showDialog(parent, message, title, new String[]{OK_BUTTON}, 0, icon); } @@ -243,7 +244,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON); return; } - + showDialog(message, title, new String[]{OK_BUTTON}, 0, icon); } @@ -254,7 +255,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, WindowManager.getInstance().suggestParentWindow(project)); } - + return showDialog(project, message, title, new String[]{yesText, noText}, 0, icon); } @@ -265,7 +266,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, WindowManager.getInstance().suggestParentWindow(project)); } - + return showYesNoDialog(project, message, title, YES_BUTTON, NO_BUTTON, icon); } @@ -276,7 +277,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, YES_BUTTON, NO_BUTTON, SwingUtilities.getWindowAncestor(parent)); } - + return showDialog(parent, message, title, new String[]{YES_BUTTON, NO_BUTTON}, 0, icon); } @@ -292,10 +293,10 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, yesText, noText, null, doNotAskOption); } - + return showDialog(message, title, new String[]{yesText, noText}, 0, icon, doNotAskOption); } - + /** * Use this method only if you do not know project or component * @@ -306,7 +307,7 @@ public class Messages { public static int showYesNoDialog(String message, String title, String yesText, String noText, @Nullable Icon icon) { return showYesNoDialog(message, title, yesText, noText, icon, null); } - + /** * Use this method only if you do not know project or component * @@ -328,7 +329,7 @@ public class Messages { return MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project), doNotAskOption); } - + return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption); } @@ -336,7 +337,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, WindowManager.getInstance().suggestParentWindow(project)); } - + return showDialog(project, message, title, new String[]{okText, cancelText}, 0, icon); } @@ -387,7 +388,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoDialog(title, message, okText, cancelText, null, doNotAskOption); } - + return showDialog(message, title, new String[]{okText, cancelText}, 0, icon, doNotAskOption); } @@ -445,7 +446,7 @@ public class Messages { MacMessages.getInstance().showErrorDialog(CommonBundle.getErrorTitle(), message, OK_BUTTON, SwingUtilities.getWindowAncestor(component)); return; } - + showDialog(component, message, CommonBundle.getErrorTitle(), new String[]{OK_BUTTON}, 0, getErrorIcon()); } @@ -469,7 +470,7 @@ public class Messages { MacMessages.getInstance().showErrorDialog(CommonBundle.getWarningTitle(), message, OK_BUTTON, WindowManager.getInstance().suggestParentWindow(project)); return; } - + showDialog(project, message, title, new String[]{OK_BUTTON}, 0, getWarningIcon()); } @@ -493,7 +494,7 @@ public class Messages { MacMessages.getInstance().showErrorDialog(CommonBundle.getWarningTitle(), message, OK_BUTTON, null); return; } - + showDialog(message, title, new String[]{OK_BUTTON}, 0, getWarningIcon()); } @@ -536,7 +537,7 @@ public class Messages { if (canShowMacSheetPanel()) { return MacMessages.getInstance().showYesNoCancelDialog(title, message, yes, no, cancel, null, doNotAskOption); } - + return showDialog(message, title, new String[]{yes, no, cancel}, 0, icon, doNotAskOption); } @@ -549,7 +550,7 @@ public class Messages { public static int showYesNoCancelDialog(String message, String title, String yes, String no, String cancel, Icon icon) { return showYesNoCancelDialog(message, title, yes, no, cancel, icon, null); } - + /** * Use this method only if you do not know project or component * @@ -809,7 +810,7 @@ public class Messages { MacMessages.getInstance().showOkMessageDialog(title, message, OK_BUTTON, SwingUtilities.getWindowAncestor(component)); return; } - + showMessageDialog(component, message, title, getInformationIcon()); } @@ -843,7 +844,7 @@ public class Messages { } /** - * Shows dialog with text area to edit long strings that don't fit in text field + * Shows dialog with text area to edit long strings that don't fit in text field. */ public static void showTextAreaDialog(final JTextField textField, final String title, @NonNls final String dimensionServiceKey) { if (isApplicationInUnitTestOrHeadless()) { @@ -853,8 +854,7 @@ public class Messages { final JTextArea textArea = new JTextArea(10, 50); textArea.setWrapStyleWord(true); textArea.setLineWrap(true); - String s = textField.getText().replaceAll("[ ]*=[ ]*", "=").replaceAll("=\\-", "=\\ \\-"); - List lines = StringUtil.splitHonorQuotes(s, ' '); + List lines = ParametersListUtil.parse(textField.getText(), true); textArea.setText(StringUtil.join(lines, "\n")); InsertPathAction.copyFromTo(textField, textArea); final DialogBuilder builder = new DialogBuilder(textField); @@ -946,7 +946,7 @@ public class Messages { public MessageDialog(Component parent, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon) { this(parent, message, title, options, defaultOptionIndex, icon, false); } - + public MessageDialog(Component parent, String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, boolean canBeParent) { this(parent, message, title, options, defaultOptionIndex, -1, icon, canBeParent); } @@ -960,7 +960,7 @@ public class Messages { public MessageDialog(String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon) { this(message, title, options, defaultOptionIndex, icon, false); } - + public MessageDialog(String message, String title, String[] options, int defaultOptionIndex, @Nullable Icon icon, boolean canBeParent) { super(canBeParent); _init(title, message, options, defaultOptionIndex, -1, icon, null); diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java index fa13285ef1d4..73b73a408cba 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/execution/ParametersListTest.java @@ -17,8 +17,12 @@ package com.intellij.openapi.execution; import com.intellij.execution.configurations.ParametersList; import com.intellij.execution.configurations.ParamsGroup; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.util.execution.ParametersListUtil; import org.junit.Test; +import java.util.List; + import static java.util.Arrays.asList; import static org.junit.Assert.*; @@ -171,12 +175,12 @@ public class ParametersListTest { "C:\\phing.bat"); checkTokenizer("-Dp.1=\"some text\" -Dp.2=\\\"value\\\"", "-Dp.1=some text", "-Dp.2=\"value\""); - checkTokenizer("-Dp.1=value\n\"-Dp.2=-\"\n-Dp.3=value", - "-Dp.1=value", "-Dp.2=-", "-Dp.3=value"); + checkTokenizer("-Dp.1=- -dump-config", + "-Dp.1=-", "-dump-config"); } @Test - public void joiningParams() throws Exception { + public void joiningParams() { String[] parameters = {"simpleParam", "param with spaces", "withQuote=\"", "param=\"complex quoted\""}; ParametersList parametersList = new ParametersList(); parametersList.addAll(parameters); @@ -186,16 +190,19 @@ public class ParametersListTest { } @Test - public void properties() throws Exception { + public void properties() { ParametersList params = new ParametersList(); params.addProperty("foo.foo", "\"bar bar\" bar"); assertEquals(1, params.getProperties().size()); assertEquals("\"bar bar\" bar", params.getProperties().get("foo.foo")); } - private static void checkTokenizer(final String paramString, final String... expected) { + private static void checkTokenizer(String paramString, String... expected) { ParametersList params = new ParametersList(); params.addParametersString(paramString); assertEquals(asList(expected), params.getList()); + + List lines = ParametersListUtil.parse(paramString, true); + assertEquals(paramString, StringUtil.join(lines, " ")); } } diff --git a/platform/util/src/com/intellij/util/execution/ParametersListUtil.java b/platform/util/src/com/intellij/util/execution/ParametersListUtil.java index 9d8ac99297c1..01bd06127b94 100644 --- a/platform/util/src/com/intellij/util/execution/ParametersListUtil.java +++ b/platform/util/src/com/intellij/util/execution/ParametersListUtil.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. @@ -70,7 +70,7 @@ public class ParametersListUtil { } /** - *

Converts single parameter string (as created by {@link #join(java.util.List)}) into list of parameters.

+ *

Splits single parameter string (as created by {@link #join(List)}) into list of parameters.

*

*

* Conversion rules: @@ -90,11 +90,16 @@ public class ParametersListUtil { * '"a \"1 2\"" b' => ['a="1 2"', 'b'] *

* - * @param string parameter string to split. + * @param parameterString parameter string to split. * @return array of parameters. */ @NotNull public static List parse(@NotNull String parameterString) { + return parse(parameterString, false); + } + + @NotNull + public static List parse(@NotNull String parameterString, boolean keepQuotes) { parameterString = parameterString.trim(); final ArrayList params = ContainerUtilRt.newArrayList(); @@ -110,7 +115,9 @@ public class ParametersListUtil { if (!escapedQuote) { inQuotes = !inQuotes; nonEmpty = true; - continue; + if (!keepQuotes) { + continue; + } } escapedQuote = false; } @@ -127,7 +134,9 @@ public class ParametersListUtil { else if (ch == '\\') { if (i < parameterString.length() - 1 && parameterString.charAt(i + 1) == '"') { escapedQuote = true; - continue; + if (!keepQuotes) { + continue; + } } } From 98949ba96c546b1b6ecb1015ddcf10d6b643f1a6 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Thu, 31 Jan 2013 19:31:50 +0400 Subject: [PATCH 09/29] IDEA-99724 Wrong text selection on doubleclick --- .../wordSelection/NaturalLanguageTextSelectioner.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java index 7aa5cfb6715f..fb2a60a607ff 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/wordSelection/NaturalLanguageTextSelectioner.java @@ -31,7 +31,9 @@ import java.util.List; import java.util.Set; public class NaturalLanguageTextSelectioner extends ExtendWordSelectionHandlerBase { - private static final Set NATURAL = ContainerUtil.newTroveSet('(', ')', '.', ',', ':', ';', '!', '?', '$', '@', '%', '\"', '\'', '<', '>', '[', ']'); + private static final Set NATURAL = ContainerUtil.newTroveSet( + '(', ')', '.', ',', ':', ';', '!', '?', '$', '@', '%', '\"', '\'', '<', '>', '[', ']', '_' + ); private static final Set SENTENCE_END = ContainerUtil.newTroveSet('.', '!', '?'); @Override From 69f8e74aa8e95f57730131c55c9dac1022ef1cd3 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Thu, 31 Jan 2013 19:34:26 +0400 Subject: [PATCH 10/29] Visual Edit --- .../designer/componentTree/TreeEditOperation.java | 10 +++------- .../feedbacks/RoundRectangleFeedback.java | 14 +++++++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java index 9bc36e53acd8..b122bdeeb96a 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/TreeEditOperation.java @@ -19,6 +19,7 @@ import com.intellij.designer.designSurface.AbstractEditOperation; import com.intellij.designer.designSurface.FeedbackTreeLayer; import com.intellij.designer.designSurface.OperationContext; import com.intellij.designer.model.RadComponent; +import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.Nullable; import java.awt.*; @@ -66,13 +67,8 @@ public abstract class TreeEditOperation extends AbstractEditOperation { } } - private boolean isChildren(RadComponent component) { - for (Object child : myContainer.getTreeChildren()) { - if (child == component) { - return true; - } - } - return false; + protected final boolean isChildren(RadComponent component) { + return ArrayUtil.indexOf(myContainer.getTreeChildren(), component) != -1; } @Override diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java index fbd126a2c437..a1ce15a0e5fb 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/feedbacks/RoundRectangleFeedback.java @@ -21,6 +21,8 @@ import java.awt.*; * @author Alexander Lobas */ public class RoundRectangleFeedback extends RectangleFeedback { + private static final BasicStroke STROKE = new BasicStroke(2); + private final int myRadius; public RoundRectangleFeedback(Color color, int line, int radius) { @@ -30,9 +32,15 @@ public class RoundRectangleFeedback extends RectangleFeedback { @Override protected void paintFeedback(Graphics g) { + Graphics2D g2d = (Graphics2D)g; + + Stroke oldStroke = g2d.getStroke(); + g2d.setStroke(STROKE); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + Dimension size = getSize(); - for (int i = 0; i < myLine; i++) { - g.drawRoundRect(i, i, size.width - i - i - 1, size.height - i - i - 1, myRadius, myRadius); - } + g.drawRoundRect(0, 0, size.width - 1, size.height - 1, myRadius, myRadius); + + g2d.setStroke(oldStroke); } } \ No newline at end of file From 74bba098a0e817d8d54d10f56d8229376cfccf01 Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Thu, 31 Jan 2013 19:54:49 +0400 Subject: [PATCH 11/29] official GitHub theme is now used, fixed name case --- colorSchemes/src/colorSchemes/github.xml | 662 +++++++++++++---------- 1 file changed, 367 insertions(+), 295 deletions(-) diff --git a/colorSchemes/src/colorSchemes/github.xml b/colorSchemes/src/colorSchemes/github.xml index 10ee41801d9e..ea6d3b4212b3 100644 --- a/colorSchemes/src/colorSchemes/github.xml +++ b/colorSchemes/src/colorSchemes/github.xml @@ -1,38 +1,39 @@ - + @@ -1164,12 +1191,12 @@ @@ -1833,32 +1890,30 @@ From d4aa97fc4ece319e466c5d8f2d67283c38d7e837 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 31 Jan 2013 19:23:30 +0400 Subject: [PATCH 12/29] javafx: fx:define subtags --- .../JavaFxDefaultPropertyElementDescriptor.java | 8 +++++++- plugins/javaFX/testData/highlighting/definedElements.fxml | 8 ++++++++ .../plugins/javaFX/fxml/JavaFXHighlightingTest.java | 4 ++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 plugins/javaFX/testData/highlighting/definedElements.fxml diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java index 674a55ad0b55..f63e9f8abcee 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxDefaultPropertyElementDescriptor.java @@ -66,7 +66,13 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip @Nullable @Override public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) { - return null; //To change body of implemented methods use File | Settings | File Templates. + if (myName.equals(FxmlConstants.FX_DEFINE)) { + final String name = childTag.getName(); + if (JavaFxPsiUtil.isClassTag(name)) { + return new JavaFxClassBackedElementDescriptor(name, childTag); + } + } + return null; } @Override diff --git a/plugins/javaFX/testData/highlighting/definedElements.fxml b/plugins/javaFX/testData/highlighting/definedElements.fxml new file mode 100644 index 000000000000..c080cdfcd5a3 --- /dev/null +++ b/plugins/javaFX/testData/highlighting/definedElements.fxml @@ -0,0 +1,8 @@ + + + + + + + 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 e04cd6e35778..36f720e473b6 100644 --- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java +++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java @@ -126,6 +126,10 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase { doTest(); } + public void testDefinedElements() throws Exception { + doTest(); + } + public void testIncludeBtn() throws Exception { configureByFiles(null, getTestName(true) + ".fxml", "btn.fxml"); doDoTest(false, false); From d48bfe6243be8b3d5c2023d33bd4a563999030d0 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 31 Jan 2013 19:44:27 +0400 Subject: [PATCH 13/29] javafx: support properties (IDEA-100221) --- .../JavaFxPropertyElementDescriptor.java | 14 ++++++++++---- .../propertyElementsWithAnyAttributes.fxml | 8 ++++++++ .../javaFX/fxml/JavaFXHighlightingTest.java | 4 ++++ 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 plugins/javaFX/testData/highlighting/propertyElementsWithAnyAttributes.fxml diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java index 2ded59af3b49..36a4c8563228 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyElementDescriptor.java @@ -2,12 +2,10 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors; import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiType; +import com.intellij.psi.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.searches.ClassInheritorsSearch; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlTag; @@ -17,6 +15,7 @@ import com.intellij.xml.XmlAttributeDescriptor; import com.intellij.xml.XmlElementDescriptor; import com.intellij.xml.XmlElementsGroup; import com.intellij.xml.XmlNSDescriptor; +import com.intellij.xml.impl.schema.AnyXmlAttributeDescriptor; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; @@ -107,6 +106,13 @@ public class JavaFxPropertyElementDescriptor implements XmlElementDescriptor { @Nullable @Override public XmlAttributeDescriptor getAttributeDescriptor(@NonNls String attributeName, @Nullable XmlTag context) { + final PsiElement element = getDeclaration(); + if (element instanceof PsiField) { + final PsiType type = ((PsiField)element).getType(); + if (InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) { + return new AnyXmlAttributeDescriptor(attributeName); + } + } return null; } diff --git a/plugins/javaFX/testData/highlighting/propertyElementsWithAnyAttributes.fxml b/plugins/javaFX/testData/highlighting/propertyElementsWithAnyAttributes.fxml new file mode 100644 index 000000000000..091d1a3d597c --- /dev/null +++ b/plugins/javaFX/testData/highlighting/propertyElementsWithAnyAttributes.fxml @@ -0,0 +1,8 @@ + + + + + + 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 36f720e473b6..b5244ca7d2ee 100644 --- a/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java +++ b/plugins/javaFX/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXHighlightingTest.java @@ -130,6 +130,10 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase { doTest(); } + public void testPropertyElementsWithAnyAttributes() throws Exception { + doTest(); + } + public void testIncludeBtn() throws Exception { configureByFiles(null, getTestName(true) + ".fxml", "btn.fxml"); doDoTest(false, false); From 32ef183f969bc88a1c0a3c227ed1e05ed74b0403 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 31 Jan 2013 20:27:01 +0400 Subject: [PATCH 14/29] javafx: check controller not specified (IDEA-100225) --- .../plugins/javaFX/fxml/JavaFxPsiUtil.java | 36 +++++++++++++++++++ .../JavaFxPropertyAttributeDescriptor.java | 25 +++++++++++-- .../JavaFxEventHandlerReferenceProvider.java | 20 ++--------- .../handlerWithoutController.fxml | 6 ++++ .../handlerWithoutPageLanguage.fxml | 6 ++++ .../javaFX/fxml/JavaFXHighlightingTest.java | 8 +++++ 6 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 plugins/javaFX/testData/highlighting/handlerWithoutController.fxml create mode 100644 plugins/javaFX/testData/highlighting/handlerWithoutPageLanguage.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 da77e2827430..52203a2ab17f 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/JavaFxPsiUtil.java @@ -21,10 +21,12 @@ 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.util.InheritanceUtil; import com.intellij.psi.util.PropertyUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.TypeConversionUtil; import com.intellij.psi.xml.*; +import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -184,4 +186,38 @@ public class JavaFxPsiUtil { } return null; } + + public static PsiClass getControllerClass(PsiFile containingFile) { + if (containingFile instanceof XmlFile) { + final XmlTag rootTag = ((XmlFile)containingFile).getRootTag(); + if (rootTag != null) { + final XmlAttribute attribute = rootTag.getAttribute(FxmlConstants.FX_CONTROLLER); + if (attribute != null) { + final String attributeValue = attribute.getValue(); + if (!StringUtil.isEmptyOrSpaces(attributeValue)) { + return JavaPsiFacade.getInstance(containingFile.getProject()).findClass(attributeValue, containingFile.getResolveScope()); + } + } + } + } + return null; + } + + public static boolean checkIfAttributeHandler(XmlAttribute attribute) { + final String attributeName = attribute.getName(); + final XmlTag xmlTag = attribute.getParent(); + final XmlElementDescriptor descriptor = xmlTag.getDescriptor(); + if (descriptor == null) return false; + final PsiElement currentTagClass = descriptor.getDeclaration(); + if (!(currentTagClass instanceof PsiClass)) return false; + final PsiField handlerField = ((PsiClass)currentTagClass).findFieldByName(attributeName, true); + if (handlerField == null) { + return false; + } + final PsiClass objectPropertyClass = getPropertyClass(handlerField); + if (objectPropertyClass == null || !InheritanceUtil.isInheritor(objectPropertyClass, JavaFxCommonClassNames.JAVAFX_EVENT_EVENT_HANDLER)) { + return false; + } + return true; + } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java index 6b49c7d3abf2..d18941d4777a 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/descriptors/JavaFxPropertyAttributeDescriptor.java @@ -2,7 +2,10 @@ package org.jetbrains.plugins.javaFX.fxml.descriptors; import com.intellij.openapi.util.text.StringUtil; 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.XmlFile; import com.intellij.util.ArrayUtil; import com.intellij.xml.XmlAttributeDescriptor; import org.jetbrains.annotations.Nullable; @@ -92,10 +95,27 @@ public class JavaFxPropertyAttributeDescriptor implements XmlAttributeDescriptor } return null; } - + @Nullable @Override public String validateValue(XmlElement context, String value) { + if (context instanceof XmlAttributeValue) { + final XmlAttributeValue xmlAttributeValue = (XmlAttributeValue)context; + final PsiElement parent = xmlAttributeValue.getParent(); + if (parent instanceof XmlAttribute && JavaFxPsiUtil.checkIfAttributeHandler((XmlAttribute)parent)) { + final PsiClass controllerClass = JavaFxPsiUtil.getControllerClass(context.getContainingFile()); + if (value.startsWith("#")) { + if (controllerClass == null) { + return "No controller specified for top level element"; + } + } + else { + if (JavaFxPsiUtil.parseInjectedLanguages((XmlFile)context.getContainingFile()).isEmpty()) { + return "Page language not specified."; + } + } + } + } return null; } @@ -115,7 +135,8 @@ public class JavaFxPropertyAttributeDescriptor implements XmlAttributeDescriptor } @Override - public void init(PsiElement element) {} + public void init(PsiElement element) { + } @Override public Object[] getDependences() { diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java index d1b030b514c4..8a7711ebb0b6 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxEventHandlerReferenceProvider.java @@ -17,14 +17,10 @@ package org.jetbrains.plugins.javaFX.fxml.refs; import com.intellij.openapi.diagnostic.Logger; import com.intellij.psi.*; -import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.xml.XmlAttribute; import com.intellij.psi.xml.XmlAttributeValue; -import com.intellij.psi.xml.XmlTag; import com.intellij.util.ProcessingContext; -import com.intellij.xml.XmlElementDescriptor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.javaFX.fxml.JavaFxCommonClassNames; import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil; /** @@ -43,20 +39,8 @@ class JavaFxEventHandlerReferenceProvider extends JavaFxControllerBasedReference final XmlAttribute attribute = (XmlAttribute)xmlAttributeValue.getContext(); if (attribute == null) return PsiReference.EMPTY_ARRAY; - final String attributeName = attribute.getName(); - final XmlTag xmlTag = attribute.getParent(); - final XmlElementDescriptor descriptor = xmlTag.getDescriptor(); - if (descriptor == null) return PsiReference.EMPTY_ARRAY; - final PsiElement currentTagClass = descriptor.getDeclaration(); - if (!(currentTagClass instanceof PsiClass)) return PsiReference.EMPTY_ARRAY; - final PsiField handlerField = ((PsiClass)currentTagClass).findFieldByName(attributeName, true); - if (handlerField == null) { - return PsiReference.EMPTY_ARRAY; - } - final PsiClass objectPropertyClass = JavaFxPsiUtil.getPropertyClass(handlerField); - if (objectPropertyClass == null || !InheritanceUtil.isInheritor(objectPropertyClass, JavaFxCommonClassNames.JAVAFX_EVENT_EVENT_HANDLER)) { - return PsiReference.EMPTY_ARRAY; - } + if (!JavaFxPsiUtil.checkIfAttributeHandler(attribute)) return PsiReference.EMPTY_ARRAY; + final PsiElement currentTagClass = attribute.getParent().getDescriptor().getDeclaration(); final String eventHandlerName = attValueString.substring(1); final PsiMethod[] methods = controllerClass.findMethodsByName(eventHandlerName, true); diff --git a/plugins/javaFX/testData/highlighting/handlerWithoutController.fxml b/plugins/javaFX/testData/highlighting/handlerWithoutController.fxml new file mode 100644 index 000000000000..2662596e3f7d --- /dev/null +++ b/plugins/javaFX/testData/highlighting/handlerWithoutController.fxml @@ -0,0 +1,6 @@ + + + + +