From 57b5f13e97005fc6ad959c9acb02a8dc5dfb35bc Mon Sep 17 00:00:00 2001 From: Gregory Shrago Date: Thu, 20 May 2010 18:07:33 +0400 Subject: [PATCH 01/10] use assignments if DFA is not available --- .../src/com/intellij/codeInspection/dataFlow/DfaUtil.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java index 1bcbe7ae9380..99588b50c8c9 100644 --- a/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java +++ b/java/java-impl/src/com/intellij/codeInspection/dataFlow/DfaUtil.java @@ -143,7 +143,6 @@ public class DfaUtil { return codeBlock; } - @Nullable("null means DFA analysis has failed (too complex to analyze)") public static Collection getPossibleInitializationElements(final PsiElement qualifierExpression) { if (qualifierExpression instanceof PsiMethodCallExpression) { return Collections.singletonList(qualifierExpression); @@ -152,8 +151,7 @@ public class DfaUtil { final PsiElement targetElement = ((PsiReferenceExpression)qualifierExpression).resolve(); if (targetElement instanceof PsiVariable) { final Collection variableValues = getCachedVariableValues((PsiVariable)targetElement, qualifierExpression); - if (variableValues == null) return null; - if (variableValues.isEmpty() && targetElement instanceof PsiField) { + if ((variableValues == null || variableValues.isEmpty())) { return getVariableAssignmentsInFile((PsiVariable)targetElement, false); } return variableValues; From cd078354ec5c76afd8c6d140860294082ad24829 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Thu, 20 May 2010 14:54:02 +0400 Subject: [PATCH 02/10] PsiDocParamRef to find owner via PsiDocComment.getOwner() --- .../com/intellij/psi/impl/source/javadoc/PsiDocParamRef.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocParamRef.java b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocParamRef.java index d1ed0fbe0b06..d46e566e3b99 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocParamRef.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocParamRef.java @@ -24,6 +24,7 @@ import com.intellij.psi.impl.source.tree.Factory; import com.intellij.psi.impl.source.tree.LeafElement; import com.intellij.psi.impl.source.tree.SharedImplUtil; import com.intellij.psi.infos.CandidateInfo; +import com.intellij.psi.javadoc.PsiDocComment; import com.intellij.psi.javadoc.PsiDocTagValue; import com.intellij.psi.javadoc.PsiDocToken; import com.intellij.psi.scope.PsiScopeProcessor; @@ -50,7 +51,9 @@ public class PsiDocParamRef extends CompositePsiElement implements PsiDocTagValu public PsiReference getReference() { PsiReference cachedReference = myCachedReference; if (cachedReference != null) return cachedReference; - final PsiDocCommentOwner owner = PsiTreeUtil.getParentOfType(this, PsiDocCommentOwner.class); + final PsiDocComment comment = PsiTreeUtil.getParentOfType(this, PsiDocComment.class); + if (comment == null) return null; + final PsiDocCommentOwner owner = comment.getOwner(); if (!(owner instanceof PsiMethod) && !(owner instanceof PsiClass)) return null; final ASTNode valueToken = findChildByType(JavaDocTokenType.DOC_TAG_VALUE_TOKEN); From 7d963a8df24c32c959d4c35e8703802706500d77 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 19 May 2010 16:52:36 +0400 Subject: [PATCH 03/10] Loaded PsiFunctions from default filters are transmitted as LookUpElements (PY-990) --- .../src/com/intellij/util/containers/CollectionFactory.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/platform/util/src/com/intellij/util/containers/CollectionFactory.java b/platform/util/src/com/intellij/util/containers/CollectionFactory.java index bcbf4c02e43d..ac6f57f463d8 100644 --- a/platform/util/src/com/intellij/util/containers/CollectionFactory.java +++ b/platform/util/src/com/intellij/util/containers/CollectionFactory.java @@ -47,6 +47,10 @@ public class CollectionFactory { return new ArrayList(); } + public static HashSet hashSet() { + return new HashSet(); + } + public static LinkedHashMap linkedMap() { return new LinkedHashMap(); } From 8e85ad0eede38b648285fc20974d6ed36bb0918d Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Wed, 19 May 2010 22:45:46 +0400 Subject: [PATCH 04/10] fixed javadoc --- platform/lang-api/src/com/intellij/lang/ASTNode.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/lang-api/src/com/intellij/lang/ASTNode.java b/platform/lang-api/src/com/intellij/lang/ASTNode.java index 0734ac0c6b2e..78f70fcc5bed 100644 --- a/platform/lang-api/src/com/intellij/lang/ASTNode.java +++ b/platform/lang-api/src/com/intellij/lang/ASTNode.java @@ -108,16 +108,16 @@ public interface ASTNode extends UserDataHolder { ASTNode getLastChildNode(); /** - * Returns the previous sibling of this node in the tree. + * Returns the next sibling of this node in the tree. * - * @return the previous sibling node. + * @return the next sibling node. */ ASTNode getTreeNext(); /** - * Returns the next sibling of this node in the tree. + * Returns the previous sibling of this node in the tree. * - * @return the next sibling node. + * @return the previous sibling node. */ ASTNode getTreePrev(); From 992736c2f05f615c1e912141884065cdade5b1f3 Mon Sep 17 00:00:00 2001 From: Maxim Medvedev Date: Thu, 20 May 2010 18:43:23 +0400 Subject: [PATCH 05/10] exception fix --- ...tionalWithIdenticalBranchesInspection.java | 7 +++-- .../filters/types/BuiltInTypeFilter.java | 29 ++++++++++--------- .../psi/impl/GroovyPsiElementFactoryImpl.java | 11 +++++-- .../GroovyWithTypeCastSurrounder.java | 2 +- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyConditionalWithIdenticalBranchesInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyConditionalWithIdenticalBranchesInspection.java index 8c031b7625de..27ce86a987db 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyConditionalWithIdenticalBranchesInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyConditionalWithIdenticalBranchesInspection.java @@ -53,9 +53,10 @@ public class GroovyConditionalWithIdenticalBranchesInspection extends BaseInspec return "Collapse conditional expression"; } - public void doFix(Project project, ProblemDescriptor descriptor) - throws IncorrectOperationException { - final GrConditionalExpression expression = (GrConditionalExpression) descriptor.getPsiElement(); + public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { + final PsiElement element = descriptor.getPsiElement(); + if (!(element instanceof GrConditionalExpression)) return; + final GrConditionalExpression expression = (GrConditionalExpression)element; final GrExpression thenBranch = expression.getThenBranch(); replaceExpression(expression, thenBranch.getText()); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/filters/types/BuiltInTypeFilter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/filters/types/BuiltInTypeFilter.java index d867f977afc1..bcbf212dc661 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/filters/types/BuiltInTypeFilter.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/filters/types/BuiltInTypeFilter.java @@ -37,9 +37,10 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil; */ public class BuiltInTypeFilter implements ElementFilter { public boolean isAcceptable(Object element, PsiElement context) { - PsiElement previous = PsiImplUtil.realPrevious(context.getParent().getPrevSibling()); - if (previous != null && - GroovyTokenTypes.mAT.equals(previous.getNode().getElementType())) { + final PsiElement parent = context.getParent(); + if (parent == null) return false; + PsiElement previous = PsiImplUtil.realPrevious(parent.getPrevSibling()); + if (previous != null && GroovyTokenTypes.mAT.equals(previous.getNode().getElementType())) { return false; } if (GroovyCompletionUtil.asSimpleVariable(context) || @@ -47,29 +48,29 @@ public class BuiltInTypeFilter implements ElementFilter { GroovyCompletionUtil.asVariableInBlock(context)) { return true; } - if ((context.getParent() instanceof GrParameter && - ((GrParameter) context.getParent()).getTypeElementGroovy() == null) || - context.getParent() instanceof GrReferenceElement && - !(context.getParent().getParent() instanceof GrImportStatement) && - !(context.getParent().getParent() instanceof GrPackageDefinition) && - !(context.getParent().getParent() instanceof GrArgumentList)) { + if ((parent instanceof GrParameter && + ((GrParameter)parent).getTypeElementGroovy() == null) || + parent instanceof GrReferenceElement && + !(parent.getParent() instanceof GrImportStatement) && + !(parent.getParent() instanceof GrPackageDefinition) && + !(parent.getParent() instanceof GrArgumentList)) { PsiElement prevSibling = context.getPrevSibling(); - if (context.getParent() instanceof GrReferenceElement && prevSibling != null && prevSibling.getNode() != null) { + if (parent instanceof GrReferenceElement && prevSibling != null && prevSibling.getNode() != null) { ASTNode node = prevSibling.getNode(); return !GroovyTokenTypes.DOTS.contains(node.getElementType()); } else { return true; } } - if (PsiImplUtil.realPrevious(context.getParent().getPrevSibling()) instanceof GrModifierList) { + if (PsiImplUtil.realPrevious(parent.getPrevSibling()) instanceof GrModifierList) { return true; } if (PsiImplUtil.realPrevious(context.getPrevSibling()) instanceof GrModifierList) { return true; } - return context.getParent() instanceof GrExpression && - context.getParent().getParent() instanceof GroovyFile && - GroovyCompletionUtil.isNewStatement(context, false); + return parent instanceof GrExpression && + parent.getParent() instanceof GroovyFile && + GroovyCompletionUtil.isNewStatement(context, false); } public boolean isClassAcceptable(Class hintClass) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java index 2b7e14dd29f8..f3d48556d83c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java @@ -346,9 +346,14 @@ public class GroovyPsiElementFactoryImpl extends GroovyPsiElementFactory { public GrMethod createMethodFromText(@NotNull String methodText) { GroovyFileBase file = createDummyFile(methodText); - GrTopLevelDefintion defintion = file.getTopLevelDefinitions()[0]; - assert defintion != null && defintion instanceof GrMethod; - return ((GrMethod) defintion); + try { + GrTopLevelDefintion defintion = file.getTopLevelDefinitions()[0]; + assert defintion != null && defintion instanceof GrMethod; + return ((GrMethod)defintion); + } + catch (Error error) { + throw new IncorrectOperationException("Can't create method from text: '" + file.getText() + "'"); + } } @Override diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/surrounders/surroundersImpl/expressions/GroovyWithTypeCastSurrounder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/surrounders/surroundersImpl/expressions/GroovyWithTypeCastSurrounder.java index 4f082171c7c7..6724da5e03b6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/surrounders/surroundersImpl/expressions/GroovyWithTypeCastSurrounder.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/surrounders/surroundersImpl/expressions/GroovyWithTypeCastSurrounder.java @@ -29,7 +29,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement; public class GroovyWithTypeCastSurrounder extends GroovyExpressionSurrounder { protected TextRange surroundExpression(GrExpression expression) { GrParenthesizedExpression parenthesized = (GrParenthesizedExpression) GroovyPsiElementFactory.getInstance(expression.getProject()).createTopElementFromText("((Type)a)"); - parenthesized = (GrParenthesizedExpression) expression.replaceWithExpression(parenthesized, true); + parenthesized = (GrParenthesizedExpression) expression.replaceWithExpression(parenthesized, false); GrTypeCastExpression typeCast = (GrTypeCastExpression) parenthesized.getOperand(); replaceToOldExpression(typeCast.getOperand(), expression); GrTypeElement typeElement = typeCast.getCastTypeElement(); From bbe1515a2d31405b1d0478675377bf8c59d9cdee Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 20 May 2010 17:20:45 +0400 Subject: [PATCH 06/10] merge CodeStyleCustomizationsConsumer into LanguageCodeStyleSettingsProvider --- .../JavaCodeStyleOptionsCustomizer.java | 34 ------------------- ...JavaLanguageCodeStyleSettingsProvider.java | 12 +++++++ .../codeStyle/CodeStyleOptionsCustomizer.java | 31 ----------------- .../codeStyle/CodeStyleBlankLinesPanel.java | 5 ++- .../codeStyle/CodeStyleSpacesPanel.java | 5 ++- .../LanguageCodeStyleSettingsProvider.java | 7 ++++ .../src/META-INF/LangExtensionPoints.xml | 2 -- resources/src/META-INF/IdeaPlugin.xml | 2 -- 8 files changed, 23 insertions(+), 75 deletions(-) delete mode 100644 java/java-impl/src/com/intellij/application/options/JavaCodeStyleOptionsCustomizer.java delete mode 100644 platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleOptionsCustomizer.java diff --git a/java/java-impl/src/com/intellij/application/options/JavaCodeStyleOptionsCustomizer.java b/java/java-impl/src/com/intellij/application/options/JavaCodeStyleOptionsCustomizer.java deleted file mode 100644 index 058a9c9e44b6..000000000000 --- a/java/java-impl/src/com/intellij/application/options/JavaCodeStyleOptionsCustomizer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.application.options; - -import com.intellij.psi.codeStyle.CodeStyleCustomizationsConsumer; -import com.intellij.psi.codeStyle.CodeStyleOptionsCustomizer; - -/** - * @author yole - */ -public class JavaCodeStyleOptionsCustomizer extends CodeStyleOptionsCustomizer { - @Override - public void customizeSpacingOptions(CodeStyleCustomizationsConsumer consumer) { - consumer.showAllStandardOptions(); - } - - @Override - public void customizeBlankLinesOptions(CodeStyleCustomizationsConsumer consumer) { - consumer.showAllStandardOptions(); - } -} diff --git a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java index 823e663f284b..858faf1254c2 100644 --- a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java +++ b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java @@ -18,6 +18,7 @@ package com.intellij.ide; import com.intellij.application.options.codeStyle.LanguageCodeStyleSettingsProvider; import com.intellij.lang.Language; import com.intellij.lang.StdLanguages; +import com.intellij.psi.codeStyle.CodeStyleCustomizationsConsumer; import org.jetbrains.annotations.NotNull; /** @@ -44,6 +45,17 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett return GENERAL_CODE_SAMPLE; } + @Override + public void customizeSpacingOptions(CodeStyleCustomizationsConsumer consumer) { + consumer.showAllStandardOptions(); + } + + @Override + public void customizeBlankLinesOptions(CodeStyleCustomizationsConsumer consumer) { + consumer.showAllStandardOptions(); + } + + private static final String GENERAL_CODE_SAMPLE = "public class Foo {\n" + " public int[] X = new int[]{1, 3, 5 7, 9, 11};\n" + "\n" + diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleOptionsCustomizer.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleOptionsCustomizer.java deleted file mode 100644 index 43f52f822051..000000000000 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleOptionsCustomizer.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2000-2010 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.psi.codeStyle; - -import com.intellij.openapi.extensions.ExtensionPointName; - -/** - * @author yole - */ -public abstract class CodeStyleOptionsCustomizer { - public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.codeStyleOptionsCustomizer"); - - public void customizeSpacingOptions(CodeStyleCustomizationsConsumer consumer) { - } - - public void customizeBlankLinesOptions(CodeStyleCustomizationsConsumer consumer) { - } -} diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesPanel.java index 7c1286455774..b5c1e73da957 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesPanel.java @@ -20,7 +20,6 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.extensions.Extensions; import com.intellij.psi.PsiFile; import com.intellij.psi.codeStyle.CodeStyleCustomizationsConsumer; -import com.intellij.psi.codeStyle.CodeStyleOptionsCustomizer; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CustomCodeStyleSettings; import com.intellij.ui.OptionGroup; @@ -43,8 +42,8 @@ public class CodeStyleBlankLinesPanel extends MultilanguageCodeStyleAbstractPane public CodeStyleBlankLinesPanel(CodeStyleSettings settings) { super(settings); - for(CodeStyleOptionsCustomizer customizer: Extensions.getExtensions(CodeStyleOptionsCustomizer.EP_NAME)) { - customizer.customizeBlankLinesOptions(this); + for(LanguageCodeStyleSettingsProvider provider: Extensions.getExtensions(LanguageCodeStyleSettingsProvider.EP_NAME)) { + provider.customizeBlankLinesOptions(this); } myPanel diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java index cb0bd3cc03fb..abfd213b5cc4 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java @@ -18,7 +18,6 @@ package com.intellij.application.options.codeStyle; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.Trinity; -import com.intellij.psi.codeStyle.CodeStyleOptionsCustomizer; import com.intellij.psi.codeStyle.CodeStyleSettings; import com.intellij.psi.codeStyle.CustomCodeStyleSettings; import com.intellij.psi.codeStyle.CodeStyleCustomizationsConsumer; @@ -47,8 +46,8 @@ public class CodeStyleSpacesPanel extends OptionTreeWithPreviewPanel implements protected void initTables() { myAllowedOptions = new HashSet(); myCustomOptions = new MultiMap, String, String>>(); - for(CodeStyleOptionsCustomizer contributor: Extensions.getExtensions(CodeStyleOptionsCustomizer.EP_NAME)) { - contributor.customizeSpacingOptions(this); + for(LanguageCodeStyleSettingsProvider provider: Extensions.getExtensions(LanguageCodeStyleSettingsProvider.EP_NAME)) { + provider.customizeSpacingOptions(this); } initBooleanField("SPACE_BEFORE_METHOD_CALL_PARENTHESES", ApplicationBundle.message("checkbox.spaces.method.call.parentheses"), BEFORE_PARENTHESES); diff --git a/platform/lang-impl/src/com/intellij/application/options/codeStyle/LanguageCodeStyleSettingsProvider.java b/platform/lang-impl/src/com/intellij/application/options/codeStyle/LanguageCodeStyleSettingsProvider.java index d3529925cccf..fa500465c80a 100644 --- a/platform/lang-impl/src/com/intellij/application/options/codeStyle/LanguageCodeStyleSettingsProvider.java +++ b/platform/lang-impl/src/com/intellij/application/options/codeStyle/LanguageCodeStyleSettingsProvider.java @@ -18,6 +18,7 @@ package com.intellij.application.options.codeStyle; import com.intellij.lang.Language; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.extensions.Extensions; +import com.intellij.psi.codeStyle.CodeStyleCustomizationsConsumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,6 +42,12 @@ public abstract class LanguageCodeStyleSettingsProvider { public abstract String getCodeSample(@NotNull SettingsType settingsType); + public void customizeSpacingOptions(CodeStyleCustomizationsConsumer consumer) { + } + + public void customizeBlankLinesOptions(CodeStyleCustomizationsConsumer consumer) { + } + public static Language[] getLanguagesWithCodeStyleSettings() { ArrayList langs = new ArrayList(); for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) { diff --git a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml index b3792d05f479..8e40f85f82df 100644 --- a/platform/platform-resources/src/META-INF/LangExtensionPoints.xml +++ b/platform/platform-resources/src/META-INF/LangExtensionPoints.xml @@ -59,8 +59,6 @@ - diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index b9d570152642..dcdc083b16bd 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -720,8 +720,6 @@ - - From 9fa2a1323160bb79888693f13ed2f645db60fb15 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 20 May 2010 19:10:09 +0400 Subject: [PATCH 07/10] don't show empty Python code style settings page; fix Python preview text --- .../psi/codeStyle/CodeStyleSettingsProvider.java | 4 ++++ .../options/CodeStyleSchemesConfigurable.java | 12 +++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsProvider.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsProvider.java index 446067dec7ff..a154a764d6e1 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsProvider.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsProvider.java @@ -44,4 +44,8 @@ public abstract class CodeStyleSettingsProvider { public String getConfigurableDisplayName() { return null; } + + public boolean hasSettingsPage() { + return true; + } } diff --git a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java index def93b6a2a80..b63e5b5d7d6a 100644 --- a/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/CodeStyleSchemesConfigurable.java @@ -208,11 +208,13 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent. myPanels = new ArrayList(); for (final CodeStyleSettingsProvider provider : Extensions.getExtensions(CodeStyleSettingsProvider.EXTENSION_POINT_NAME)) { - myPanels.add(new CodeStyleConfigurableWrapper(provider, new CodeStyleSettingsPanelFactory() { - public NewCodeStyleSettingsPanel createPanel(final CodeStyleScheme scheme) { - return new NewCodeStyleSettingsPanel(provider.createSettingsPage(scheme.getCodeStyleSettings(), ensureModel().getCloneSettings(scheme))); - } - })); + if (provider.hasSettingsPage()) { + myPanels.add(new CodeStyleConfigurableWrapper(provider, new CodeStyleSettingsPanelFactory() { + public NewCodeStyleSettingsPanel createPanel(final CodeStyleScheme scheme) { + return new NewCodeStyleSettingsPanel(provider.createSettingsPage(scheme.getCodeStyleSettings(), ensureModel().getCloneSettings(scheme))); + } + })); + } } return myPanels.toArray(new Configurable[myPanels.size()]); From e3e6c98a04f973092ea420503c8ad655cba08520 Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 20 May 2010 19:19:13 +0400 Subject: [PATCH 08/10] app icon fixes --- .../compiler/progress/CompilerTask.java | 30 ++++++++++---- .../intellij/openapi/wm/AppIconScheme.java | 2 +- .../openapi/project/DumbServiceImpl.java | 21 +++++++--- .../src/com/intellij/ui/AppIcon.java | 41 ++++++++++++++----- 4 files changed, 67 insertions(+), 27 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java index 32f38b234cf1..8a77ac878006 100644 --- a/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java +++ b/java/compiler/impl/src/com/intellij/compiler/progress/CompilerTask.java @@ -58,6 +58,7 @@ import com.intellij.util.Alarm; import com.intellij.util.ArrayUtil; import com.intellij.util.messages.MessageBusConnection; import com.intellij.util.ui.MessageCategory; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -194,28 +195,39 @@ public class CompilerTask extends Task.Backgroundable { } private void stopAppIconProgress() { - AppIcon appIcon = AppIcon.getInstance(); - if (appIcon.hideProgress(APP_ICON_ID)) { - if (myErrorCount > 0) { - appIcon.setBadge(String.valueOf(myErrorCount)); - appIcon.requestAttention(true); - } else { - appIcon.setBadge(null); + UIUtil.invokeLaterIfNeeded(new Runnable() { + public void run() { + AppIcon appIcon = AppIcon.getInstance(); + if (appIcon.hideProgress(APP_ICON_ID)) { + if (myErrorCount > 0) { + appIcon.setBadge(String.valueOf(myErrorCount)); + appIcon.requestAttention(true); + } else { + appIcon.setBadge(null); + } + } } - } + }); } public void setText(final String text) { + super.setText(text); updateProgressText(); } public void setText2(final String text) { + super.setText2(text); updateProgressText(); } public void setFraction(final double fraction) { + super.setFraction(fraction); updateProgressText(); - AppIcon.getInstance().setProgress(APP_ICON_ID, AppIconScheme.Progress.BUILD, fraction, true); + UIUtil.invokeLaterIfNeeded(new Runnable() { + public void run() { + AppIcon.getInstance().setProgress(APP_ICON_ID, AppIconScheme.Progress.BUILD, fraction, true); + } + }); } protected void onProgressChange() { diff --git a/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java b/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java index 0ef08736f3b7..7b25e4ce14ff 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java @@ -33,7 +33,7 @@ public class AppIconScheme { static final Progress BUILD = new Progress() { public Color getOkColor() { - return Color.blue; + return new Color(51, 102, 255); } public Color getErrorColor() { diff --git a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java index 6919f5aa4359..c28d4cfdb9a6 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/DumbServiceImpl.java @@ -37,6 +37,7 @@ import com.intellij.util.concurrency.Semaphore; import com.intellij.util.containers.Queue; import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.messages.MessageBus; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -271,16 +272,24 @@ public class DumbServiceImpl extends DumbService { if (indicator instanceof ProgressIndicatorEx) { ((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() { @Override - public void setFraction(double fraction) { - AppIcon.getInstance().setProgress("indexUpdate", AppIconScheme.Progress.INDEXING, fraction, true); + public void setFraction(final double fraction) { + UIUtil.invokeLaterIfNeeded(new Runnable() { + public void run() { + AppIcon.getInstance().setProgress("indexUpdate", AppIconScheme.Progress.INDEXING, fraction, true); + } + }); } @Override public void finish(@NotNull TaskInfo task) { - AppIcon appIcon = AppIcon.getInstance(); - if (appIcon.hideProgress("indexUpdate")) { - appIcon.requestAttention(false); - } + UIUtil.invokeAndWaitIfNeeded(new Runnable() { + public void run() { + AppIcon appIcon = AppIcon.getInstance(); + if (appIcon.hideProgress("indexUpdate")) { + appIcon.requestAttention(false); + } + } + }); } }); } diff --git a/platform/platform-impl/src/com/intellij/ui/AppIcon.java b/platform/platform-impl/src/com/intellij/ui/AppIcon.java index 9881e73cd5ab..b4e4203468cd 100644 --- a/platform/platform-impl/src/com/intellij/ui/AppIcon.java +++ b/platform/platform-impl/src/com/intellij/ui/AppIcon.java @@ -15,6 +15,8 @@ */ package com.intellij.ui; +import com.intellij.openapi.application.Application; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.wm.AppIconScheme; @@ -63,6 +65,8 @@ public abstract class AppIcon { private double myLastValue; private BufferedImage getAppImage() { + assertIsDispatchThread(); + try { if (myAppImage != null) return myAppImage; @@ -91,6 +95,8 @@ public abstract class AppIcon { @Override public void setBadge(String text) { + assertIsDispatchThread(); + try { getAppMethod("setDockIconBadge", String.class).invoke(getApp(), text); } @@ -104,6 +110,8 @@ public abstract class AppIcon { @Override public void requestAttention(boolean critical) { + assertIsDispatchThread(); + try { getAppMethod("requestUserAttention", boolean.class).invoke(getApp(), critical); } @@ -117,6 +125,8 @@ public abstract class AppIcon { @Override public boolean hideProgress(Object processId) { + assertIsDispatchThread(); + if (getAppImage() == null) return false; if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return false; @@ -128,6 +138,8 @@ public abstract class AppIcon { } public boolean setProgress(Object processId, AppIconScheme.Progress scheme, double value, boolean isOk) { + assertIsDispatchThread(); + if (getAppImage() == null) return false; if (myCurrentProcessId != null && !myCurrentProcessId.equals(processId)) return false; @@ -136,10 +148,10 @@ public abstract class AppIcon { if (Math.abs(myLastValue - value) < 0.02d) return true; try { - int progressHeight = 20; - int xInset = 15; - int yInset = 10; - int bound = 2; + int progressHeight = (int)(myAppImage.getHeight() * 0.15); + int xInset = (int)(myAppImage.getWidth() * 0.05); + int yInset = (int)(myAppImage.getHeight() * 0.15); + int bound = (int)(myAppImage.getWidth() * 0.03); Rectangle progressRec = new Rectangle(new Point(xInset, myAppImage.getHeight() - progressHeight - yInset), new Dimension(myAppImage.getWidth() - xInset * 2, progressHeight)); @@ -147,23 +159,20 @@ public abstract class AppIcon { BufferedImage current = new BufferedImage(myAppImage.getWidth(), myAppImage.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = current.createGraphics(); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g.drawImage(getAppImage(), null, null); Rectangle bgRec = new Rectangle(progressRec.x - bound, progressRec.y - bound, progressRec.width + bound * 2, progressRec.height + bound * 2); g.setColor(Color.white); g.fillRect(bgRec.x, bgRec.y, bgRec.width, bgRec.height); - - - g.setColor(Color.black); - g.fillRect(progressRec.x, progressRec.y, progressRec.width, progressRec.height); - + g.setColor(isOk ? scheme.getOkColor() : scheme.getErrorColor()); int currentWidth = (int)Math.ceil(progressRec.width * value); - g.fillRect(progressRec.x, progressRec.y, currentWidth, progressRec.height); + g.setColor(Color.black); + g.drawRect(bgRec.x, bgRec.y, bgRec.width - 1, bgRec.height - 1); + setDockIcon(current); @@ -222,5 +231,15 @@ public abstract class AppIcon { } } + private static void assertIsDispatchThread() { + Application app = ApplicationManager.getApplication(); + if (app != null) { + if (!app.isUnitTestMode()) { + app.assertIsDispatchThread(); + } + } else { + assert EventQueue.isDispatchThread(); + } + } } From 75a0904058a4612a8dceda034bcbc9a0bfd290cd Mon Sep 17 00:00:00 2001 From: Kirill Kalishev Date: Thu, 20 May 2010 19:21:06 +0400 Subject: [PATCH 09/10] app icon fixes --- .../platform-api/src/com/intellij/openapi/wm/AppIconScheme.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java b/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java index 7b25e4ce14ff..759206f9b7a2 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/AppIconScheme.java @@ -43,7 +43,7 @@ public class AppIconScheme { static final Progress INDEXING = new Progress() { public Color getOkColor() { - return Color.yellow; + return new Color(255, 153, 0); } public Color getErrorColor() { From c8355f07ff526fbe61aa7d1612586b69cd979cef Mon Sep 17 00:00:00 2001 From: anna Date: Thu, 20 May 2010 19:25:11 +0400 Subject: [PATCH 10/10] revert --- .../openapi/roots/impl/LibraryOrderEntryBaseImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java index 68c9daa4f1d5..5de9a8c0ecd9 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/LibraryOrderEntryBaseImpl.java @@ -60,7 +60,7 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl { } return getRootFiles(OrderRootType.CLASSES); } - else if (type == OrderRootType.CLASSES_AND_OUTPUT || type == OrderRootType.CLASSES) { + else if (type == OrderRootType.CLASSES_AND_OUTPUT) { return myScope == DependencyScope.PROVIDED ? VirtualFile.EMPTY_ARRAY : getRootFiles(OrderRootType.CLASSES); } return getRootFiles(type); @@ -80,7 +80,7 @@ abstract class LibraryOrderEntryBaseImpl extends OrderEntryBaseImpl { } return rootProvider.getUrls(OrderRootType.CLASSES); } - else if (type == OrderRootType.CLASSES_AND_OUTPUT || type == OrderRootType.CLASSES) { + else if (type == OrderRootType.CLASSES_AND_OUTPUT) { return myScope == DependencyScope.PROVIDED ? ArrayUtil.EMPTY_STRING_ARRAY : rootProvider.getUrls(OrderRootType.CLASSES); } return rootProvider.getUrls(type);