diff options
author | Tor Norbye <tnorbye@google.com> | 2013-04-03 16:27:26 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-04-03 16:27:26 -0700 |
commit | d1a59a0799588a226d255d9b45c4825b19651554 (patch) | |
tree | c9759b94ddad742db08b6662f52a62e0401491c1 /plugins | |
parent | 2bd2b7c2623d4266384e890271869efc044aabff (diff) | |
download | idea-d1a59a0799588a226d255d9b45c4825b19651554.tar.gz |
Snapshot dc7fe9a777db5bc87a5b1ad4bfe40a547fc7d49a from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: Iae1c655b8958fc7603a78c675e4a4b942a1fccd4
Diffstat (limited to 'plugins')
73 files changed, 988 insertions, 379 deletions
diff --git a/plugins/ant/ant.iml b/plugins/ant/ant.iml index 9f7c99239c68..be08ab558305 100644 --- a/plugins/ant/ant.iml +++ b/plugins/ant/ant.iml @@ -25,6 +25,7 @@ <orderEntry type="module" module-name="lang-impl" /> <orderEntry type="module" module-name="platform-impl" /> <orderEntry type="module" module-name="ant-jps-plugin" /> + <orderEntry type="module" module-name="dom-impl" /> </component> <component name="copyright"> <Base> diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchWidget.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchWidget.java index 9dc52fe6db06..10f8de491587 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchWidget.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchWidget.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 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. @@ -110,6 +110,7 @@ public class GitBranchWidget extends EditorBasedWidget implements StatusBarWidge @NotNull @Override + @Deprecated public String getMaxValue() { return myMaxString; } diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index ba3405511934..1c42546c1216 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -189,7 +189,7 @@ <itemPresentationProvider forClass="org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl" implementationClass="org.jetbrains.plugins.groovy.findUsages.GrFileItemPresentationProvider"/> - <testFramework implementation="org.jetbrains.plugins.groovy.testIntegration.GroovyTestFramework"/> + <testFramework implementation="org.jetbrains.plugins.groovy.testIntegration.GroovyTestFramework" order="first"/> <testCreator language="Groovy" implementationClass="com.intellij.testIntegration.JavaTestCreator"/> <testGenerator language="Groovy" implementationClass="org.jetbrains.plugins.groovy.testIntegration.GroovyTestGenerator"/> <constructorBodyGenerator language="Groovy" diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java index 8f79de6736cf..72b88cdfaa95 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java @@ -36,6 +36,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass; +import org.jetbrains.plugins.groovy.refactoring.GroovyChangeContextUtil; import static org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil.isWhiteSpace; @@ -55,6 +56,13 @@ public class GroovyGenerationInfo<T extends PsiMember> extends PsiGenerationInfo @Override public void insert(@NotNull PsiClass aClass, @Nullable PsiElement anchor, boolean before) throws IncorrectOperationException { + + final T proto = getPsiMember(); + if (proto instanceof GrMethod) { + GroovyChangeContextUtil.encodeContextInfo(((GrMethod)proto).getParameterList()); + } + + super.insert(aClass, anchor, before); final T member = getPsiMember(); @@ -64,14 +72,24 @@ public class GroovyGenerationInfo<T extends PsiMember> extends PsiGenerationInfo final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(member.getProject()); final PsiElement prev = member.getPrevSibling(); - if (prev!=null && GroovyTokenTypes.mNLS == prev.getNode().getElementType()) { + if (prev != null && GroovyTokenTypes.mNLS == prev.getNode().getElementType()) { prev.replace(factory.createLineTerminator(1)); } + else if (prev instanceof PsiMember) { + member.getParent().getNode().addLeaf(GroovyTokenTypes.mNLS, "\n", member.getNode()); + } final PsiElement next = member.getNextSibling(); if (next != null && GroovyTokenTypes.mNLS == next.getNode().getElementType()) { next.replace(factory.createLineTerminator(1)); } + else if (next instanceof PsiMember) { + member.getParent().getNode().addLeaf(GroovyTokenTypes.mNLS, "\n", next.getNode()); + } + + if (member instanceof GrMethod) { + GroovyChangeContextUtil.decodeContextInfo(((GrMethod)member).getParameterList(), null, null); + } GrReferenceAdjuster.shortenReferences(member); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckInspection.java index b3a037cb2aca..9afa1cf2a6da 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckInspection.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -15,7 +15,6 @@ */ package org.jetbrains.plugins.groovy.codeInspection.bugs; -import com.intellij.codeInsight.generation.GenerateMembersUtil; import com.intellij.codeInsight.generation.OverrideImplementUtil; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.ide.fileTemplates.FileTemplate; @@ -46,7 +45,6 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMe import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement; import org.jetbrains.plugins.groovy.lang.psi.impl.GrRangeType; import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil; -import org.jetbrains.plugins.groovy.overrideImplement.GroovyOverrideImplementUtil; import java.io.IOException; import java.util.ArrayList; @@ -60,6 +58,7 @@ import java.util.Properties; public class GroovyRangeTypeCheckInspection extends BaseInspection { private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.codeInspection.bugs.GroovyRangeTypeCheckInspection"); + @NotNull @Override protected BaseInspectionVisitor buildVisitor() { return new MyVisitor(); @@ -80,7 +79,7 @@ public class GroovyRangeTypeCheckInspection extends BaseInspection { } @Override - protected GroovyFix buildFix(PsiElement location) { + protected GroovyFix buildFix(@NotNull PsiElement location) { final GrRangeExpression range = (GrRangeExpression)location; final PsiType type = range.getType(); final List<GroovyFix> fixes = new ArrayList<GroovyFix>(3); @@ -309,9 +308,7 @@ public class GroovyRangeTypeCheckInspection extends BaseInspection { } if (comparable != null && !myPsiClass.isInterface()) { final PsiMethod baseMethod = comparable.getMethods()[0]; - final GrMethod prototype = GroovyOverrideImplementUtil.generateMethodPrototype(myPsiClass, baseMethod, substitutor); - final PsiElement anchor = OverrideImplementUtil.getDefaultAnchorToOverrideOrImplement(myPsiClass, baseMethod, substitutor); - GenerateMembersUtil.insert(myPsiClass, prototype, anchor, true); + OverrideImplementUtil.overrideOrImplement(myPsiClass, baseMethod); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java index 8aebf825a629..4776586c78a1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/EquivalenceChecker.java @@ -172,7 +172,8 @@ public class EquivalenceChecker { } private static boolean assertStatementsAreEquivalent(GrAssertStatement statement1, GrAssertStatement statement2) { - return expressionsAreEquivalent(statement1.getAssertion(), statement2.getAssertion()); + return expressionsAreEquivalent(statement1.getAssertion(), statement2.getAssertion()) && + expressionsAreEquivalent(statement1.getErrorMessage(), statement2.getErrorMessage()); } private static boolean synchronizedStatementsAreEquivalent(GrSynchronizedStatement statement1, diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java index 723b59fb2b74..759d8c9c4fde 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/JavaStylePropertiesUtil.java @@ -62,7 +62,9 @@ public class JavaStylePropertiesUtil { String oldNameStr = refExpr.getReferenceNameElement().getText(); String newRefExpr = StringUtil.trimEnd(refExpr.getText(), oldNameStr) + name; final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(call.getProject()); - return (GrAssignmentExpression)factory.createStatementFromText(newRefExpr + " = " + value.getText(), call); + final GrAssignmentExpression assignment = (GrAssignmentExpression)factory.createStatementFromText(newRefExpr + " = xxx", call); + assignment.getRValue().replaceWithExpression(value, true); + return assignment; } private static GrExpression genRefForGetter(GrMethodCall call, String accessorName) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java index 894a5cd0f725..9972a658b9d4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyLiteralCopyPasteProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -96,8 +96,8 @@ public class GroovyLiteralCopyPasteProcessor extends StringLiteralCopyPasteProce @Override - protected String getLineBreaker(PsiElement token) { - final String text = token.getText(); + protected String getLineBreaker(@NotNull PsiElement token) { + final String text = token.getParent().getText(); if (text.contains("'''") || text.contains("\"\"\"")) { return "\n"; } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/InvertIfIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/InvertIfIntention.java index 422b3818de9b..c928dbe8f005 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/InvertIfIntention.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/control/InvertIfIntention.java @@ -1,24 +1,46 @@ +/* + * 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.groovy.intentions.control; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; -import com.intellij.psi.codeStyle.CodeStyleManager; +import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.ArrayUtilRt; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils; import org.jetbrains.plugins.groovy.intentions.base.Intention; import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate; +import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrBlockStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression; import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner; +import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction; +import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.IfEndInstruction; /** * @author Niels Harremoes @@ -64,50 +86,77 @@ public class InvertIfIntention extends Intention { GrStatement thenBranch = parentIf.getThenBranch(); - String newIfText = "if (" + negatedCondition.getText() + ") " + generateElseBranchTextAndRemoveTailStatements(parentIf); + final boolean thenIsNotEmpty = isNotEmpty(thenBranch); - boolean isThenEmpty = thenBranch == null || - (thenBranch instanceof GrBlockStatement) && ((GrBlockStatement)thenBranch).getBlock().getStatements().length == 0; - if (!isThenEmpty) { - newIfText += " else " + thenBranch.getText(); + String newIfText = "if (" + negatedCondition.getText() + ") {}"; + if (thenIsNotEmpty) { + newIfText += " else {}"; } GrIfStatement newIf = (GrIfStatement)groovyPsiElementFactory.createStatementFromText(newIfText, parentIf.getContext()); - parentIf.replace(CodeStyleManager.getInstance(project).reformat(newIf)); + generateElseBranchTextAndRemoveTailStatements(parentIf, newIf); + + if (thenIsNotEmpty) { + final GrStatement elseBranch = newIf.getElseBranch(); + assert elseBranch != null; + elseBranch.replaceWithStatement(thenBranch); + } + + parentIf.replace(newIf); } - private static String generateElseBranchTextAndRemoveTailStatements(GrIfStatement ifStatement) { + private static boolean isNotEmpty(@Nullable GrStatement thenBranch) { + return thenBranch != null && + !(thenBranch instanceof GrBlockStatement && ((GrBlockStatement)thenBranch).getBlock().getStatements().length == 0); + } + + private static void generateElseBranchTextAndRemoveTailStatements(@NotNull GrIfStatement ifStatement, @NotNull GrIfStatement newIf) { + final GrStatement thenBranch = newIf.getThenBranch(); + assert thenBranch != null; + GrStatement elseBranch = ifStatement.getElseBranch(); if (elseBranch != null) { - return elseBranch.getText(); + thenBranch.replaceWithStatement(elseBranch); + return; } PsiElement parent = ifStatement.getParent(); - if (!(parent instanceof GrStatementOwner)) { - return "{}"; - } + if (!(parent instanceof GrStatementOwner)) return; - String text = parent.getText(); - int start = ifStatement.getTextRange().getEndOffset() - parent.getTextRange().getStartOffset(); - PsiElement rbrace = parent instanceof GrCodeBlock ? ((GrCodeBlock)parent).getRBrace() : null; - int end = rbrace != null ? rbrace.getStartOffsetInParent() : text.length(); + if (!isTailAfterIf(ifStatement, ((GrStatementOwner)parent))) return; - String lastStatements = text.substring(start, end); + final PsiElement start = ifStatement.getNextSibling(); + PsiElement end = parent instanceof GrCodeBlock ? ((GrCodeBlock)parent).getRBrace().getPrevSibling() : parent.getLastChild(); - deleteLastStatements((GrStatementOwner)parent, ifStatement, rbrace); - return "{\n" + lastStatements.trim() + "\n}"; + final GrOpenBlock block = ((GrBlockStatement)thenBranch).getBlock(); + block.addRangeAfter(start, end, block.getLBrace()); + parent.deleteChildRange(start, end); } - private static void deleteLastStatements(GrStatementOwner statementOwner, GrIfStatement ifStatement, PsiElement rbrace) { - PsiElement next = ifStatement.getNextSibling(); - if (next == null) return; + private static boolean isTailAfterIf(@NotNull GrIfStatement ifStatement, @NotNull GrStatementOwner owner) { + final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(ifStatement); + if (flowOwner == null) return false; - if (rbrace == null) { - statementOwner.getNode().removeRange(next.getNode(), null); - } - else { - statementOwner.getNode().removeRange(next.getNode(), rbrace.getNode()); + final Instruction[] flow = flowOwner.getControlFlow(); + + final GrStatement[] statements = owner.getStatements(); + final int index = ArrayUtilRt.find(statements, ifStatement); + if (index == statements.length - 1) return false; + + final GrStatement then = ifStatement.getThenBranch(); + + for (Instruction i : flow) { + final PsiElement element = i.getElement(); + if (element == null || !PsiTreeUtil.isAncestor(then, element, true)) continue; + + for (Instruction succ : i.allSuccessors()) { + if (succ instanceof IfEndInstruction) { + return false; + } + } } + + return true; } @NotNull diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrScriptBindingVariable.groovy b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrScriptBindingVariable.groovy deleted file mode 100644 index 545b360fba73..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrScriptBindingVariable.groovy +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic - -/** - * @author Max Medvedev - */ -class GrScriptBindingVariable { -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/NotAndParenthesesSurrounder.groovy b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/NotAndParenthesesSurrounder.java index 535eccdec105..1712dbab9695 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/NotAndParenthesesSurrounder.groovy +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/surroundWith/NotAndParenthesesSurrounder.java @@ -13,30 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.lang.surroundWith +package org.jetbrains.plugins.groovy.lang.surroundWith; -import com.intellij.openapi.util.TextRange -import com.intellij.psi.PsiElement -import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression -import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression +import com.intellij.openapi.util.TextRange; +import com.intellij.psi.PsiElement; +import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression; /** * @author Max Medvedev */ -class NotAndParenthesesSurrounder extends GroovyExpressionSurrounder { +public class NotAndParenthesesSurrounder extends GroovyExpressionSurrounder { @Override protected TextRange surroundExpression(GrExpression expression, PsiElement context) { - GrUnaryExpression result = (GrUnaryExpression)GroovyPsiElementFactory.getInstance(expression.project).createExpressionFromText("!(a)", context) - replaceToOldExpression(((GrParenthesizedExpression)result.operand).operand, expression) + GrUnaryExpression result = (GrUnaryExpression)GroovyPsiElementFactory.getInstance(expression.getProject()).createExpressionFromText("!(a)", context); + GroovyExpressionSurrounder.replaceToOldExpression(((GrParenthesizedExpression)result.getOperand()).getOperand(), expression); result = (GrUnaryExpression)expression.replaceWithExpression(result, true); - return new TextRange(result.textRange.endOffset, result.textRange.endOffset); - + return new TextRange(result.getTextRange().getEndOffset(), result.getTextRange().getEndOffset()); } @Override - String getTemplateDescription() { - "!(expr)" + public String getTemplateDescription() { + return "!(expr)"; } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java index f5bdee288688..666ddb5dc0d2 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.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. @@ -27,13 +27,15 @@ import com.intellij.psi.util.PsiTypesUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster; import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory; +import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList; +import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation; import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock; import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement; +import org.jetbrains.plugins.groovy.refactoring.GroovyChangeContextUtil; import org.jetbrains.plugins.groovy.refactoring.convertToJava.ModifierListGenerator; import java.io.IOException; @@ -72,21 +74,54 @@ public class GroovyOverrideImplementUtil { String templName = isAbstract ? JavaTemplateUtil.TEMPLATE_IMPLEMENTED_METHOD_BODY : JavaTemplateUtil.TEMPLATE_OVERRIDDEN_METHOD_BODY; final FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(templName); final GrMethod result = createOverrideImplementMethodSignature(project, method, substitutor, aClass); - PsiModifierList modifierList = result.getModifierList(); - modifierList.setModifierProperty(PsiModifier.ABSTRACT, false); - modifierList.setModifierProperty(PsiModifier.NATIVE, false); + setupModifierList(result); setupOverridingMethodBody(project, method, result, template, substitutor); + + setupAnnotations(aClass, method, result); + + GroovyChangeContextUtil.encodeContextInfo(result); + return result; + } + + private static void setupAnnotations(@NotNull GrTypeDefinition aClass, @NotNull PsiMethod method, @NotNull GrMethod result) { if (OverrideImplementUtil.isInsertOverride(method, aClass)) { result.getModifierList().addAnnotation(JAVA_LANG_OVERRIDE); } - GrReferenceAdjuster.shortenReferences(result); - return result; + final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(method.getProject()); + + final PsiParameter[] originalParams = method.getParameterList().getParameters(); + + GrParameter[] parameters = result.getParameters(); + for (int i = 0; i < parameters.length; i++) { + GrParameter parameter = parameters[i]; + final PsiParameter original = originalParams[i]; + + for (PsiAnnotation annotation : original.getModifierList().getAnnotations()) { + final GrModifierList modifierList = parameter.getModifierList(); + if (annotation instanceof GrAnnotation) { + modifierList.add(annotation); + } + else { + modifierList.add(factory.createAnnotationFromText(annotation.getText())); + } + } + } + } + + private static void setupModifierList(GrMethod result) { + PsiModifierList modifierList = result.getModifierList(); + modifierList.setModifierProperty(PsiModifier.ABSTRACT, false); + modifierList.setModifierProperty(PsiModifier.NATIVE, false); } - private static GrMethod createOverrideImplementMethodSignature(Project project, PsiMethod superMethod, PsiSubstitutor substitutor, PsiClass aClass) { + @NotNull + private static GrMethod createOverrideImplementMethodSignature(@NotNull Project project, + @NotNull PsiMethod superMethod, + @NotNull PsiSubstitutor substitutor, + @NotNull PsiClass aClass) { StringBuilder buffer = new StringBuilder(); final boolean hasModifiers = ModifierListGenerator.writeModifiers(buffer, superMethod.getModifierList(), GROOVY_MODIFIERS, false); @@ -134,6 +169,9 @@ public class GroovyOverrideImplementUtil { for (int i = 0; i < parameters.length; i++) { if (i > 0) buffer.append(", "); PsiParameter parameter = parameters[i]; + + + if (!(parameter instanceof GrParameter && ((GrParameter)parameter).getTypeElementGroovy() == null)) { final PsiType parameterType = substitutor.substitute(parameter.getType()); buffer.append(parameterType.getCanonicalText()); @@ -150,31 +188,29 @@ public class GroovyOverrideImplementUtil { buffer.append(") "); final PsiReferenceList list = superMethod.getThrowsList(); - if (list != null) { - final PsiClassType[] types = list.getReferencedTypes(); - if (types.length > 0) { - buffer.append("throws "); - for (PsiClassType type : types) { - buffer.append(type.getCanonicalText()); - buffer.append(" ,"); - } - - buffer.delete(buffer.length() - 2, buffer.length()); + final PsiClassType[] types = list.getReferencedTypes(); + if (types.length > 0) { + buffer.append("throws "); + for (PsiClassType type : types) { + buffer.append(type.getCanonicalText()); + buffer.append(" ,"); } + + buffer.delete(buffer.length() - 2, buffer.length()); } buffer.append("{}"); final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project); if (isConstructor) { - return factory.createConstructorFromText(name, buffer.toString(), aClass); + return factory.createConstructorFromText(name, buffer.toString(), superMethod); } else { - return factory.createMethodFromText(buffer.toString(), aClass); + return factory.createMethodFromText(buffer.toString(), superMethod); } } @Nullable - private static PsiType getSuperReturnType(PsiMethod superMethod) { + private static PsiType getSuperReturnType(@NotNull PsiMethod superMethod) { if (superMethod instanceof GrMethod) { final GrTypeElement element = ((GrMethod)superMethod).getReturnTypeElementGroovy(); return element != null ? element.getType() : null; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java index 48cf405bcb18..98e2de75d35d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java @@ -21,6 +21,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.light.LightElement; +import com.intellij.psi.scope.BaseScopeProcessor; import com.intellij.psi.tree.IElementType; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; @@ -72,6 +73,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.ClosureSyntheticPara import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightLocalVariable; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass; import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.ClosureParameterEnhancer; +import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils; import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil; @@ -895,32 +897,37 @@ public class ExpressionGenerator extends Generator { public void visitLiteralExpression(GrLiteral literal) { final TypeConstraint[] constraints = GroovyExpectedTypesProvider.calculateTypeConstraints(literal); - final String text = literal.getText(); - final Object value; - if (text.startsWith("'''") || text.startsWith("\"\"\"")) { - String string = ((String)literal.getValue()); - LOG.assertTrue(string != null); - string = string.replace("\n", "\\n").replace("\r", "\\r"); - value = string; - } - else { - value = literal.getValue(); - } - boolean isChar = false; for (TypeConstraint constraint : constraints) { if (constraint instanceof SubtypeConstraint && TypesUtil.unboxPrimitiveTypeWrapper(constraint.getDefaultType()) == PsiType.CHAR) { isChar = true; } } - if (isChar) { - builder.append('\'').append(StringUtil.escapeQuotes(String.valueOf(value))).append('\''); + + final String text = literal.getText(); + final Object value; + if (text.startsWith("'''") || text.startsWith("\"\"\"")) { + String string = GrStringUtil.removeQuotes(text).replace("\n", "\\n").replace("\r", "\\r"); + builder.append('"').append(string).append('"'); } - else if (value instanceof String) { - builder.append('"').append(StringUtil.escapeQuotes((String)value)).append('"'); + else if (text.startsWith("'")) { + if (isChar) { + builder.append(text); + } + else { + builder.append('"').append(StringUtil.escapeQuotes(StringUtil.trimEnd(text.substring(1, text.length()), "'"))).append('"'); + } + } + else if (text.startsWith("\"")) { + if (isChar) { + builder.append('\'').append(StringUtil.escapeQuotes(StringUtil.trimEnd(text.substring(1, text.length()), "\""))).append('\''); + } + else { + builder.append(text); + } } else { - builder.append(value); + builder.append(text); } } @@ -1353,11 +1360,7 @@ public class ExpressionGenerator extends Generator { final boolean castNeeded = isCastNeeded(caller, method, this.context); if (castNeeded) { - builder.append('('); - final PsiType type = caller.getType(); - builder.append('('); - writeType(builder, type, context); - builder.append(')'); + writeCastForMethod(caller, method, context); } caller.accept(this); if (castNeeded) { @@ -1371,6 +1374,35 @@ public class ExpressionGenerator extends Generator { new ArgumentListGenerator(builder, this.context).generate(signature, exprs, namedArgs, closures, context); } + private void writeCastForMethod(@NotNull GrExpression caller, @NotNull PsiMethod method, @NotNull GroovyPsiElement context) { + final PsiType type = inferCastType(caller, method, context); + if (type == null) return; + + builder.append('('); + builder.append('('); + writeType(builder, type, context); + builder.append(')'); + } + + @Nullable + private static PsiType inferCastType(@NotNull GrExpression caller, @NotNull PsiMethod method, @NotNull GroovyPsiElement context) { + final PsiType type = caller.getType(); + if (type instanceof PsiIntersectionType) { + final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts(); + for (PsiType conjunct : conjuncts) { + final CheckProcessElement processor = new CheckProcessElement(method); + ResolveUtil.processAllDeclarationsSeparately(conjunct, processor, new BaseScopeProcessor() { + @Override + public boolean execute(@NotNull PsiElement element, ResolveState state) { + return false; + } + }, ResolveState.initial(), context); + if (processor.isFound()) return conjunct; + } + } + return type; + } + @Override public void visitListOrMap(GrListOrMap listOrMap) { diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java index 1d4982a8189a..2446b3afe5b8 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java @@ -21,6 +21,7 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocComment; +import com.intellij.psi.scope.BaseScopeProcessor; import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.tree.IElementType; import com.intellij.util.containers.HashMap; @@ -545,23 +546,49 @@ public class GenerationUtil { PsiType declared = getDeclaredType(qualifier, context); if (declared == null) return false; - final PsiManager manager = PsiManager.getInstance(context.project); - return ResolveUtil.processAllDeclarations(declared, new PsiScopeProcessor() { + final CheckProcessElement checker = new CheckProcessElement(member); + ResolveUtil.processAllDeclarationsSeparately(declared, checker, new BaseScopeProcessor() { @Override public boolean execute(@NotNull PsiElement element, ResolveState state) { - if (manager.areElementsEquivalent(element, member)) return false; - return true; + return false; } + }, ResolveState.initial(), qualifier); + return !checker.isFound(); + } - @Override - public <T> T getHint(@NotNull Key<T> hintKey) { - return null; - } + static class CheckProcessElement implements PsiScopeProcessor { - @Override - public void handleEvent(Event event, Object associated) { + private final PsiElement myMember; + private final PsiManager myManager; + + private boolean myResult = false; + + public CheckProcessElement(@NotNull PsiElement member) { + myMember = member; + myManager = member.getManager(); + } + + @Override + public boolean execute(@NotNull PsiElement element, ResolveState state) { + if (myManager.areElementsEquivalent(element, myMember)) { + myResult = true; + return false; } - }, ResolveState.initial(), qualifier); + return true; + } + + @Override + public <T> T getHint(@NotNull Key<T> hintKey) { + return null; + } + + @Override + public void handleEvent(Event event, Object associated) { + } + + public boolean isFound() { + return myResult; + } } @Nullable diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java index 06a777d4f042..8562a1ba283b 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -40,6 +40,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumTypeDe import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstantList; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration; import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil; import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass; @@ -126,21 +127,18 @@ public class GrIntroduceFieldHandler extends GrIntroduceHandlerBase<GrIntroduceF final GrEnumConstantList enumConstants = ((GrEnumTypeDefinition)targetClass).getEnumConstantList(); added = (GrVariableDeclaration)targetClass.addAfter(declaration, enumConstants); } + else if (targetClass instanceof GrTypeDefinition) { + PsiElement anchor = getAnchorAfter((GrTypeDefinition)targetClass); + added = (GrVariableDeclaration)targetClass.addAfter(declaration, anchor); + } else { - if (targetClass instanceof GrTypeDefinition) { - final PsiMethod[] methods = targetClass.getMethods(); - PsiElement anchor = getFirstElement(methods); - added = (GrVariableDeclaration)targetClass.addBefore(declaration, anchor); - } - else { - assert targetClass instanceof GroovyScriptClass; - final GroovyFile file = (GroovyFile)targetClass.getContainingFile(); - PsiElement[] elements = file.getMethods(); - if (elements.length == 0) elements = file.getStatements(); - final PsiElement anchor = getFirstElement(elements); - added = (GrVariableDeclaration)file.addBefore(declaration, anchor); + assert targetClass instanceof GroovyScriptClass; + final GroovyFile file = (GroovyFile)targetClass.getContainingFile(); + PsiElement[] elements = file.getMethods(); + if (elements.length == 0) elements = file.getStatements(); + final PsiElement anchor = getFirstElement(elements); + added = (GrVariableDeclaration)file.addBefore(declaration, anchor); // GrReferenceAdjuster.shortenReferences(added.getModifierList()); - } } final GrVariable field = added.getVariables()[0]; @@ -178,6 +176,18 @@ public class GrIntroduceFieldHandler extends GrIntroduceHandlerBase<GrIntroduceF return field; } + @Nullable + private static PsiElement getAnchorAfter(@NotNull GrTypeDefinition targetClass) { + PsiElement anchor = targetClass.getBody().getLBrace(); + + final GrMembersDeclaration[] declarations = targetClass.getMemberDeclarations(); + for (GrMembersDeclaration declaration : declarations) { + if (declaration instanceof GrVariableDeclaration) anchor = declaration; + if (!(declaration instanceof GrVariableDeclaration)) return anchor; + } + return anchor; + } + @Override protected PsiElement[] findOccurrences(GrExpression expression, PsiElement scope) { if (scope instanceof GroovyScriptClass) { diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy index f03bbc966f1b..bc53240531c8 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -41,8 +41,8 @@ class GroovyCopyPasteTest extends LightCodeInsightFixtureTestCase { super.tearDown(); } - private void doTest(String fromFileName, String fromText, String toText, String expected) { - myFixture.configureByText fromFileName, fromText + private void doTest(String fromText, String toText, String expected) { + myFixture.configureByText 'fromFileName.groovy', fromText myFixture.performEditorAction IdeActions.ACTION_COPY myFixture.configureByText 'b.groovy', toText myFixture.performEditorAction IdeActions.ACTION_PASTE @@ -50,45 +50,44 @@ class GroovyCopyPasteTest extends LightCodeInsightFixtureTestCase { } public void testEscapeSlashesInRegex() { - doTest 'a.groovy', '<selection>a/b</selection>', 'def x = /smth<caret>/', 'def x = /smtha\\/b<caret>/' + doTest '<selection>a/b</selection>', 'def x = /smth<caret>/', 'def x = /smtha\\/b<caret>/' } public void testEscapeSlashesInRegexFromRegex() { - doTest 'a.groovy', 'def x = / <selection>a\\/b</selection>/', 'def x = /smth<caret>/', 'def x = /smtha\\/b<caret>/' + doTest 'def x = / <selection>a\\/b</selection>/', 'def x = /smth<caret>/', 'def x = /smtha\\/b<caret>/' } void testDontEscapeSymbolsInRegex(){ - doTest 'a.groovy', '''def x = <selection>a/b</selection>''', 'def x = /<caret> /', '''def x = /a\\/b /''' + doTest '''def x = <selection>a/b</selection>''', 'def x = /<caret> /', '''def x = /a\\/b /''' } public void testEscapeDollarInGString() { - doTest 'a.groovy', '''def x = '<selection>$a</selection>b/''', 'def x = "smth<caret>h"', 'def x = "smth\\$a<caret>h"' + doTest '''def x = '<selection>$a</selection>b/''', 'def x = "smth<caret>h"', 'def x = "smth\\$a<caret>h"' } public void testRestoreImports() { myFixture.addClass("package foo; public class Foo {}") - doTest 'a.groovy', '''import foo.*; <selection>Foo f</selection>''', '<caret>', '''import foo.Foo + doTest '''import foo.*; <selection>Foo f</selection>''', '<caret>', '''import foo.Foo Foo f''' } public void testPasteMultilineIntoMultilineGString() throws Exception { - doTest 'a.txt', '<selection>a/b\nc/d</selection>', 'def x = """smth<caret>"""', 'def x = """smtha/b\nc/d<caret>"""' + doTest '<selection>a/b\nc/d</selection>', 'def x = """smth<caret>"""', 'def x = """smtha/b\nc/d<caret>"""' } public void testPasteMultilineIntoString() throws Exception { - doTest 'a.txt', '<selection>a\nd</selection>', "def x = 'smth<caret>'", "def x = 'smtha\\n' +\n 'd<caret>'" + doTest '<selection>a\nd</selection>', "def x = 'smth<caret>'", "def x = 'smtha\\n' +\n 'd<caret>'" } public void testPasteMultilineIntoGString() throws Exception { - doTest 'a.txt', '<selection>a\nd</selection>', 'def x = "smth<caret>"', 'def x = "smtha\\n" +\n "d<caret>"' + doTest '<selection>a\nd</selection>', 'def x = "smth<caret>"', 'def x = "smtha\\n" +\n "d<caret>"' } public void testGStringEolReplace() throws Exception { - doTest 'a.txt', - '''<selection>first + doTest '''<selection>first second </selection>''', '''def x = """ @@ -101,7 +100,21 @@ second } void testPasteInGStringContent() { - doTest 'a.groovy', 'def a = <selection>5\\6</selection>', 'def x = "<caret> "', 'def x = "5\\\\6 "' + doTest 'def a = <selection>5\\6</selection>', 'def x = "<caret> "', 'def x = "5\\\\6 "' } + void testPasteLFInGString() { + doTest '<selection>bar\nbaz</selection>', ''' +""" +$foo +<caret> +""" +''', ''' +""" +$foo +bar +baz<caret> +""" +''' + } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/InvertIfTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/InvertIfTest.groovy index 5cd2deb06cea..a86850982289 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/InvertIfTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/InvertIfTest.groovy @@ -1,3 +1,18 @@ +/* + * 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.groovy.intentions /** @@ -103,10 +118,11 @@ i<caret>f (a) { } nosuccess ''', '''i<caret>f (!a) { - nosuccess } else { succes -}''' +} +nosuccess +''' } public void testEmptyThenBlockIsRemoved() { @@ -120,4 +136,29 @@ i<caret>f (a) { } ''' } + + void testContinue() { + doTextTest('''\ +for (i in []) { + i<caret>f (2) { + print 2 + continue + } + + print 3 + print(3) +} +''', '''\ +for (i in []) { + if (!(2)) { + + print 3 + print(3) + } else { + print 2 + continue + } +} +''') + } }
\ No newline at end of file diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy index 7ab6e1056e24..ddd7f88c31eb 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/actions/generate/GroovyGenerateMembersTest.groovy @@ -338,6 +338,39 @@ class Inheritor extends Base { ''') } + void testGetterInTheEnd() { + myFixture.configureByText 'a.groovy', ''' +class GrImportStatementStub { + private final String myAlias; + private final String mySymbolName; + + protected GrImportStatementStub(String symbolName, String alias) { + } + <caret> +} +''' + generateGetter() + + myFixture.checkResult ''' +class GrImportStatementStub { + private final String myAlias; + private final String mySymbolName; + + protected GrImportStatementStub(String symbolName, String alias) { + } + + String getMyAlias() { + return myAlias + } + + String getMySymbolName() { + return mySymbolName + } +} +''' + + } + private void generateGetter() { //noinspection GroovyResultOfObjectAllocationIgnored new GroovyGenerateGetterSetterAction() //don't remove it!!! diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy index 897d1d4bb004..ac034e12badf 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy @@ -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. @@ -189,4 +189,6 @@ public final class Matcher { void testSelfNavigatingOperator() { doTest() } void testComparisonToNull() { doTest() } + + void testStringConverting() { doTest() } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/FileGenerationTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/FileGenerationTest.groovy index e422d76a54ba..0cb9e0f37ecc 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/FileGenerationTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/FileGenerationTest.groovy @@ -125,4 +125,6 @@ public enum A { void testReflectedMethodWithEllipsis() { doTest() } void testMapAccess2() { doTest() } + + void testMutualCasts() { doTest() } } diff --git a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy index 34b68dc84d3a..1106a1868530 100644 --- a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy +++ b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/All_after.groovy @@ -10,8 +10,8 @@ class Foo implements Comparable<Foo> { @Override int compareTo(Foo o) { - return 0 //To change body of implemented methods use File | Settings | File Templates. + <selection>return 0 //To change body of implemented methods use File | Settings | File Templates.</selection> } } -print new Foo().<caret>.new Foo()
\ No newline at end of file +print new Foo()..new Foo()
\ No newline at end of file diff --git a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy index d2dfad4b1cff..c34954dc3c1e 100644 --- a/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy +++ b/plugins/groovy/testdata/groovy/inspections/rangeTypeCheck/NotComparable_after.groovy @@ -4,12 +4,12 @@ class Foo implements Comparable<Foo> { @Override int compareTo(Foo o) { - return 0 //To change body of implemented methods use File | Settings | File Templates. + <selection>return 0 //To change body of implemented methods use File | Settings | File Templates.</selection> } } class X { def foo() { - final ObjectRange range = new Foo().<caret>.new Foo() + final ObjectRange range = new Foo()..new Foo() } } diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/stringConverting.groovy b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/stringConverting.groovy new file mode 100644 index 000000000000..e70d8c606eb8 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/stringConverting.groovy @@ -0,0 +1,12 @@ +print("a"); +print("v"); +char a = 'a'; +java.lang.String s = "b"; +java.lang.String x = "ab"; +print("a\t\nabc"); +print("a'b\tc"); +print("a\"b\tc"); +print(4); +print(4.5f); +print(4.5d); +print(-4.5d); diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/stringConverting.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/stringConverting.java new file mode 100644 index 000000000000..e70d8c606eb8 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/stringConverting.java @@ -0,0 +1,12 @@ +print("a"); +print("v"); +char a = 'a'; +java.lang.String s = "b"; +java.lang.String x = "ab"; +print("a\t\nabc"); +print("a'b\tc"); +print("a\"b\tc"); +print(4); +print(4.5f); +print(4.5d); +print(-4.5d); diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch3.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch3.java index b3e0f58ec920..b9bf0f879210 100644 --- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch3.java +++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch3.java @@ -1,4 +1,4 @@ -java.util.Date date = new java.util.Date(2011, 4, 9); +java.util.Date date = new java.util.Date(2011, 04, 09); if (org.codehaus.groovy.runtime.DefaultGroovyMethods.isCase(new java.util.Date(20, 11, 23), date)) { print("aaa"); print("bbb"); diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch4.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch4.java index f70673f58d36..86116da16b22 100644 --- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch4.java +++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch4.java @@ -1,4 +1,4 @@ -java.util.Date date = new java.util.Date(2011, 4, 9); +java.util.Date date = new java.util.Date(2011, 04, 09); if (org.codehaus.groovy.runtime.DefaultGroovyMethods.isCase(new java.util.Date(20, 11, 23), date)) { print("aaa"); print("bbb"); diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/mutualCasts.groovy b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/mutualCasts.groovy new file mode 100644 index 000000000000..952d9733ebfe --- /dev/null +++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/mutualCasts.groovy @@ -0,0 +1,14 @@ +class X { + void foo(List l) { + if (l instanceof String) { + if (l instanceof MyList) { + print l + String v = l.value + } + } + } +} + +class MyList { + String getValue() { '' } +} diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/mutualCasts.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/mutualCasts.java new file mode 100644 index 000000000000..a88e5a708423 --- /dev/null +++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/mutualCasts.java @@ -0,0 +1,17 @@ +public class X { +public void foo(java.util.List l) { +if (l instanceof java.lang.String){ +if (l instanceof MyList){ +org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, l); +java.lang.String v = ((MyList)l).getValue(); +} + +} + +} + +} +public class MyList { +public java.lang.String getValue() {return "";} + +} diff --git a/plugins/groovy/testdata/refactoring/introduceField/Anonymous2_after.groovy b/plugins/groovy/testdata/refactoring/introduceField/Anonymous2_after.groovy index cebc36fe407d..f7ccc4a47f5b 100644 --- a/plugins/groovy/testdata/refactoring/introduceField/Anonymous2_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceField/Anonymous2_after.groovy @@ -7,7 +7,6 @@ def a = new A() { f = 123 } int i - def f @Override diff --git a/plugins/groovy/testdata/refactoring/introduceField/Anonymous3_after.groovy b/plugins/groovy/testdata/refactoring/introduceField/Anonymous3_after.groovy index 84dd753e25d8..bc413dbeba86 100644 --- a/plugins/groovy/testdata/refactoring/introduceField/Anonymous3_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceField/Anonymous3_after.groovy @@ -4,12 +4,11 @@ interface A { def a = new A() { int i + def f { f = 123 } - def f - @Override void m1() { println <selection>f</selection> diff --git a/plugins/groovy/testdata/refactoring/introduceField/DeclareFinal_after.groovy b/plugins/groovy/testdata/refactoring/introduceField/DeclareFinal_after.groovy index 592c0d8d49f6..4dab8f017bce 100644 --- a/plugins/groovy/testdata/refactoring/introduceField/DeclareFinal_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceField/DeclareFinal_after.groovy @@ -1,6 +1,5 @@ class Foo { def bar = 5 - final f = bar + 5 def foo() { diff --git a/plugins/groovy/testdata/refactoring/introduceField/DontReplaceStaticOccurrences_after.groovy b/plugins/groovy/testdata/refactoring/introduceField/DontReplaceStaticOccurrences_after.groovy index 4363b4c6a8e7..7ca2367e5734 100644 --- a/plugins/groovy/testdata/refactoring/introduceField/DontReplaceStaticOccurrences_after.groovy +++ b/plugins/groovy/testdata/refactoring/introduceField/DontReplaceStaticOccurrences_after.groovy @@ -1,6 +1,5 @@ class Bar { static int x = 5 - final f = x + 2 def foo() { diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java index a5724010ba1e..198dbdba198c 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/status/ui/HgStatusWidget.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. @@ -104,6 +104,7 @@ public class HgStatusWidget extends EditorBasedWidget implements StatusBarWidget @NotNull @Override + @Deprecated public String getMaxPossibleText() { return MAX_STRING; } diff --git a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java index a36363116174..0f24a668a363 100644 --- a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java +++ b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/AbstractJavaFxPackager.java @@ -261,7 +261,8 @@ public abstract class AbstractJavaFxPackager { commands.add("-classpath"); commands.add(antHome + "/lib/ant.jar" + File.pathSeparator + antHome + "/lib/ant-launcher.jar" + File.pathSeparator + - javaHome + "/lib/ant-javafx.jar"); + javaHome + "/lib/ant-javafx.jar" + File.pathSeparator + + javaHome + "/jre/lib/jfxrt.jar"); commands.add("org.apache.tools.ant.launch.Launcher"); commands.add("-f"); try { @@ -335,4 +336,6 @@ public abstract class AbstractJavaFxPackager { public abstract String getPreloaderClass(); public abstract String getPreloaderJar(); + + public abstract boolean convertCss2Bin(); } diff --git a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java index 883dd8dba8ec..1e814429accf 100644 --- a/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java +++ b/plugins/javaFX/common-javaFX-plugin/src/org/jetbrains/plugins/javaFX/packaging/JavaFxAntGenerator.java @@ -39,6 +39,8 @@ public class JavaFxAntGenerator { final String preloaderJar = packager.getPreloaderJar(); final String preloaderClass = packager.getPreloaderClass(); String preloaderFiles = null; + String allButPreloader = null; + if (!StringUtil.isEmptyOrSpaces(preloaderJar) && !StringUtil.isEmptyOrSpaces(preloaderClass)) { preloaderFiles = artifactName + "_preloader_files"; topLevelTagsCollector.add(new SimpleTag("fx:fileset", @@ -46,8 +48,24 @@ public class JavaFxAntGenerator { new Pair<String, String>("requiredFor", "preloader"), new Pair<String, String>("dir", tempDirPath), new Pair<String, String>("includes", preloaderJar))); + + allButPreloader = "all_but_preloader_" + artifactName; + topLevelTagsCollector.add(new SimpleTag("fx:fileset", new Pair<String, String>("id", allButPreloader), + new Pair<String, String>("dir", tempDirPath), + new Pair<String, String>("excludes", preloaderJar), + new Pair<String, String>("includes", "*.jar"))); } + final String allButSelf = "all_but_" + artifactName; + final SimpleTag allButSelfAndPreloader = new SimpleTag("fx:fileset", new Pair<String, String>("id", allButSelf), + new Pair<String, String>("dir", tempDirPath), + new Pair<String, String>("includes", "*.jar")); + allButSelfAndPreloader.add(new SimpleTag("exclude", new Pair<String, String>("name", artifactFileName))); + if (preloaderJar != null) { + allButSelfAndPreloader.add(new SimpleTag("exclude", new Pair<String, String>("name", preloaderJar))); + } + topLevelTagsCollector.add(allButSelfAndPreloader); + //register application final String appId = artifactName + "_id"; Pair[] applicationParams = { @@ -67,6 +85,12 @@ public class JavaFxAntGenerator { topLevelTagsCollector.add(applicationTag); + if (packager.convertCss2Bin()) { + final SimpleTag css2binTag = new SimpleTag("fx:csstobin", new Pair<String, String>("outdir", tempDirPath)); + css2binTag.add(new SimpleTag("fileset", new Pair<String, String>("dir", tempDirPath), new Pair<String, String>("includes", "**/*.css"))); + topLevelTagsCollector.add(css2binTag); + } + //create jar task final SimpleTag createJarTag = new SimpleTag("fx:jar", new Pair<String, String>("destfile", tempDirPath + File.separator + artifactFileName)); @@ -77,7 +101,7 @@ public class JavaFxAntGenerator { fileset2Jar.add(new Pair<String, String>("excludes", "*.jar")); createJarTag.add(new SimpleTag("fileset", fileset2Jar.toArray(new Pair[fileset2Jar.size()]))); - createJarTag.add(createResourcesTag(tempDirPath, preloaderFiles, artifactFileName, preloaderJar, false)); + createJarTag.add(createResourcesTag(preloaderFiles, false, allButPreloader, allButSelf)); topLevelTagsCollector.add(createJarTag); @@ -97,29 +121,22 @@ public class JavaFxAntGenerator { if (!infoPairs.isEmpty()) { deployTag.add(new SimpleTag("fx:info", infoPairs.toArray(new Pair[infoPairs.size()]))); } - deployTag.add(createResourcesTag(tempDirPath, preloaderFiles, artifactFileName, preloaderJar, true)); + deployTag.add(createResourcesTag(preloaderFiles, true, allButPreloader, allButSelf)); topLevelTagsCollector.add(deployTag); return topLevelTagsCollector; } - private static SimpleTag createResourcesTag(String tempDirPath, String preloaderFiles, - String artifactFileName, - String preloaderJar, - boolean includeSelf) { + private static SimpleTag createResourcesTag(String preloaderFiles, + boolean includeSelf, + String allButPreloader, + String allButSelf) { final SimpleTag resourcesTag = new SimpleTag("fx:resources"); if (preloaderFiles != null) { resourcesTag.add(new SimpleTag("fx:fileset", new Pair<String, String>("refid", preloaderFiles))); - } - final File[] files = new File(tempDirPath).listFiles(); - if (files != null) { - for (File file : files) { - final String fileName = file.getName(); - if (!fileName.equals(preloaderJar) && (includeSelf || !fileName.equals(artifactFileName))) { - resourcesTag.add(new SimpleTag("fx:fileset", new Pair<String, String>("dir", tempDirPath), new Pair<String, String>("includes", fileName))); - } - - } + resourcesTag.add(new SimpleTag("fx:fileset", new Pair<String, String>("refid", includeSelf ? allButPreloader : allButSelf))); + } else if (!includeSelf) { + resourcesTag.add(new SimpleTag("fx:fileset", new Pair<String, String>("refid", allButSelf))); } return resourcesTag; } diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java index 7b5893da6b90..702f0aa0fbd5 100644 --- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java +++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFXRenameTest.java @@ -18,6 +18,7 @@ package org.jetbrains.plugins.javaFX.fxml; import com.intellij.codeInsight.TargetElementUtilBase; import com.intellij.codeInsight.daemon.DaemonAnalyzerTestCase; import com.intellij.openapi.application.PluginPathManager; +import com.intellij.psi.PsiClass; import com.intellij.psi.PsiElement; import com.intellij.refactoring.rename.RenameProcessor; import com.intellij.refactoring.rename.inplace.MemberInplaceRenameHandler; @@ -51,7 +52,15 @@ public class JavaFXRenameTest extends DaemonAnalyzerTestCase { public void testCustomComponentTag() throws Exception { doTest("Foo", true); } - + + public void testFromReference() throws Exception { + final String newName = "lbl1"; + doTest(newName); + final PsiClass controllerClass = findClass(getTestName(false)); + assertNotNull(controllerClass); + assertNotNull(controllerClass.findFieldByName(newName, false)); + } + public void testIdWithRefs() throws Exception { configureByFiles(null, getTestName(true) + ".fxml"); PsiElement element = TargetElementUtilBase diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java index c70899c98bdd..f5e9cb659645 100644 --- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java +++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/packaging/JavaFxAntTaskTest.java @@ -34,26 +34,36 @@ public class JavaFxAntTaskTest extends UsefulTestCase{ private static final String PRELOADER_JAR = "preloaderJar"; public void testJarDeployNoInfo() throws Exception { - doTest("<fx:application id=\"jarDeployNoInfo_id\" name=\"jarDeployNoInfo\" mainClass=\"Main\">\n" + - "</fx:application>\n" + - "<fx:jar destfile=\"temp\\jarDeployNoInfo.jar\">\n" + - "<fx:application refid=\"jarDeployNoInfo_id\">\n" + - "</fx:application>\n" + - "<fileset dir=\"temp\" excludes=\"*.jar\">\n" + - "</fileset>\n" + - "<fx:resources>\n" + - "</fx:resources>\n" + - "</fx:jar>\n" + - "<fx:deploy width=\"800\" height=\"400\" updatemode=\"background\" outdir=\"temp\\deploy\" outfile=\"jarDeployNoInfo\">\n" + - "<fx:application refid=\"jarDeployNoInfo_id\">\n" + - "</fx:application>\n" + - "<fx:resources>\n" + - "</fx:resources>\n" + - "</fx:deploy>\n", Collections.<String, String>emptyMap()); + doTest("<fx:fileset id=\"all_but_jarDeployNoInfo\" dir=\"temp\" includes=\"*.jar\">\n" + + "<exclude name=\"jarDeployNoInfo.jar\">\n" + + "</exclude>\n" + + "</fx:fileset>\n" + + "<fx:application id=\"jarDeployNoInfo_id\" name=\"jarDeployNoInfo\" mainClass=\"Main\">\n" + + "</fx:application>\n" + + "<fx:jar destfile=\"temp/jarDeployNoInfo.jar\">\n" + + "<fx:application refid=\"jarDeployNoInfo_id\">\n" + + "</fx:application>\n" + + "<fileset dir=\"temp\" excludes=\"*.jar\">\n" + + "</fileset>\n" + + "<fx:resources>\n" + + "<fx:fileset refid=\"all_but_jarDeployNoInfo\">\n" + + "</fx:fileset>\n" + + "</fx:resources>\n" + + "</fx:jar>\n" + + "<fx:deploy width=\"800\" height=\"400\" updatemode=\"background\" outdir=\"temp/deploy\" outfile=\"jarDeployNoInfo\">\n" + + "<fx:application refid=\"jarDeployNoInfo_id\">\n" + + "</fx:application>\n" + + "<fx:resources>\n" + + "</fx:resources>\n" + + "</fx:deploy>\n", Collections.<String, String>emptyMap()); } public void testJarDeployTitle() throws Exception { - doTest("<fx:application id=\"jarDeployTitle_id\" name=\"jarDeployTitle\" mainClass=\"Main\">\n" + + doTest("<fx:fileset id=\"all_but_jarDeployTitle\" dir=\"temp\" includes=\"*.jar\">\n" + + "<exclude name=\"jarDeployTitle.jar\">\n" + + "</exclude>\n" + + "</fx:fileset>\n" + + "<fx:application id=\"jarDeployTitle_id\" name=\"jarDeployTitle\" mainClass=\"Main\">\n" + "</fx:application>\n" + "<fx:jar destfile=\"temp/jarDeployTitle.jar\">\n" + "<fx:application refid=\"jarDeployTitle_id\">\n" + @@ -61,6 +71,8 @@ public class JavaFxAntTaskTest extends UsefulTestCase{ "<fileset dir=\"temp\" excludes=\"*.jar\">\n" + "</fileset>\n" + "<fx:resources>\n" + + "<fx:fileset refid=\"all_but_jarDeployTitle\">\n" + + "</fx:fileset>\n" + "</fx:resources>\n" + "</fx:jar>\n" + "<fx:deploy width=\"800\" height=\"400\" updatemode=\"background\" outdir=\"temp/deploy\" outfile=\"jarDeployTitle\">\n" + @@ -79,9 +91,17 @@ public class JavaFxAntTaskTest extends UsefulTestCase{ options.put(PRELOADER_JAR, "preloader.jar"); doTest("<fx:fileset id=\"jarDeployPreloader_preloader_files\" requiredFor=\"preloader\" dir=\"temp\" includes=\"preloader.jar\">\n" + "</fx:fileset>\n" + + "<fx:fileset id=\"all_but_preloader_jarDeployPreloader\" dir=\"temp\" excludes=\"preloader.jar\" includes=\"*.jar\">\n" + + "</fx:fileset>\n" + + "<fx:fileset id=\"all_but_jarDeployPreloader\" dir=\"temp\" includes=\"*.jar\">\n" + + "<exclude name=\"jarDeployPreloader.jar\">\n" + + "</exclude>\n" + + "<exclude name=\"preloader.jar\">\n" + + "</exclude>\n" + + "</fx:fileset>\n" + "<fx:application id=\"jarDeployPreloader_id\" name=\"jarDeployPreloader\" mainClass=\"Main\" preloaderClass=\"MyPreloader\">\n" + "</fx:application>\n" + - "<fx:jar destfile=\"temp\\jarDeployPreloader.jar\">\n" + + "<fx:jar destfile=\"temp/jarDeployPreloader.jar\">\n" + "<fx:application refid=\"jarDeployPreloader_id\">\n" + "</fx:application>\n" + "<fileset dir=\"temp\" excludes=\"*.jar\">\n" + @@ -89,14 +109,18 @@ public class JavaFxAntTaskTest extends UsefulTestCase{ "<fx:resources>\n" + "<fx:fileset refid=\"jarDeployPreloader_preloader_files\">\n" + "</fx:fileset>\n" + + "<fx:fileset refid=\"all_but_jarDeployPreloader\">\n" + + "</fx:fileset>\n" + "</fx:resources>\n" + "</fx:jar>\n" + - "<fx:deploy width=\"800\" height=\"400\" updatemode=\"background\" outdir=\"temp\\deploy\" outfile=\"jarDeployPreloader\">\n" + + "<fx:deploy width=\"800\" height=\"400\" updatemode=\"background\" outdir=\"temp/deploy\" outfile=\"jarDeployPreloader\">\n" + "<fx:application refid=\"jarDeployPreloader_id\">\n" + "</fx:application>\n" + "<fx:resources>\n" + "<fx:fileset refid=\"jarDeployPreloader_preloader_files\">\n" + "</fx:fileset>\n" + + "<fx:fileset refid=\"all_but_preloader_jarDeployPreloader\">\n" + + "</fx:fileset>\n" + "</fx:resources>\n" + "</fx:deploy>\n", options); } @@ -143,6 +167,7 @@ public class JavaFxAntTaskTest extends UsefulTestCase{ private String myParams; private String myPreloaderClass; private String myPreloaderJar; + private boolean myConvertCss2Bin; private MockJavaFxPackager(String outputPath) { myOutputPath = outputPath; @@ -279,5 +304,10 @@ public class JavaFxAntTaskTest extends UsefulTestCase{ public String getPreloaderJar() { return myPreloaderJar; } + + @Override + public boolean convertCss2Bin() { + return myConvertCss2Bin; + } } } diff --git a/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactBuildTaskProvider.java b/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactBuildTaskProvider.java index f26dcac10632..f252a2ea55d1 100644 --- a/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactBuildTaskProvider.java +++ b/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactBuildTaskProvider.java @@ -212,6 +212,11 @@ public class JpsJavaFxArtifactBuildTaskProvider extends ArtifactBuildTaskProvide return null; } + @Override + public boolean convertCss2Bin() { + return myProperties.myState.isConvertCss2Bin(); + } + private JpsArtifact getPreloaderArtifact() { for (JpsPackagingElement element : myArtifact.getRootElement().getChildren()) { if (element instanceof JpsArtifactOutputPackagingElement) { diff --git a/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactProperties.java b/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactProperties.java index fcb5ae582383..b58f6c6c8944 100644 --- a/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactProperties.java +++ b/plugins/javaFX/javaFX-jps-plugin/src/org/jetbrains/plugins/javaFX/JpsJavaFxArtifactProperties.java @@ -34,6 +34,7 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac myState.setKeypass(state.myKeypass); myState.setStorepass(state.myStorepass); myState.setAlias(state.myAlias); + myState.setConvertCss2Bin(state.myConvertCss2Bin); } @NotNull @@ -63,6 +64,7 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac private String myKeystore; private String myStorepass; private String myKeypass; + private boolean myConvertCss2Bin; public String getTitle() { return myTitle; @@ -183,5 +185,13 @@ public class JpsJavaFxArtifactProperties extends JpsElementBase<JpsJavaFxArtifac public void setKeypass(String keypass) { myKeypass = keypass; } + + public boolean isConvertCss2Bin() { + return myConvertCss2Bin; + } + + public void setConvertCss2Bin(boolean convertCss2Bin) { + myConvertCss2Bin = convertCss2Bin; + } } } diff --git a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml index ce37e7bf9534..ebe56efb50d1 100644 --- a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml +++ b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml @@ -42,6 +42,7 @@ <packaging.artifactPropertiesProvider implementation="org.jetbrains.plugins.javaFX.packaging.preloader.JavaFxPreloaderArtifactPropertiesProvider"/> <implicitUsageProvider implementation="org.jetbrains.plugins.javaFX.fxml.codeInsight.inspections.JavaFxImplicitUsageProvider"/> <referencesSearch implementation="org.jetbrains.plugins.javaFX.fxml.refs.JavaFxControllerFieldSearcher"/> + <renamePsiElementProcessor implementation="org.jetbrains.plugins.javaFX.JavaFxRenameAttributeProcessor" order="before xmlAttribute"/> </extensions> <actions> diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxFileReferenceProvider.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxFileReferenceProvider.java new file mode 100644 index 000000000000..e6a2669c955a --- /dev/null +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxFileReferenceProvider.java @@ -0,0 +1,36 @@ +package org.jetbrains.plugins.javaFX; + +import com.intellij.openapi.vfs.VirtualFileSystem; +import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem; +import com.intellij.psi.*; +import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; +import com.intellij.util.ProcessingContext; +import org.jetbrains.annotations.NotNull; + +import java.util.Collection; +import java.util.Collections; + +/** +* User: anna +* Date: 4/3/13 +*/ +public class JavaFxFileReferenceProvider extends PsiReferenceProvider { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull ProcessingContext context) { + final Object value = ((PsiLiteralExpression)element).getValue(); + final PsiDirectory directory = element.getContainingFile().getOriginalFile().getParent(); + if (!(value instanceof String) || directory == null) return PsiReference.EMPTY_ARRAY; + final VirtualFileSystem fs = directory.getVirtualFile().getFileSystem(); + return new FileReferenceSet((String)value, element, 1, null, ((NewVirtualFileSystem)fs).isCaseSensitive()) { + @NotNull + @Override + public Collection<PsiFileSystemItem> getDefaultContexts() { + if (!directory.isValid()) { + return super.getDefaultContexts(); + } + return Collections.<PsiFileSystemItem>singletonList(directory); + } + }.getAllReferences(); + } +} diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxIdsIndex.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxIdsIndex.java index ce51e924b6a6..3e4c63850118 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxIdsIndex.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxIdsIndex.java @@ -74,10 +74,23 @@ public class JavaFxIdsIndex extends FileBasedIndexExtension<String, Set<String>> } @NotNull - public static Collection<String> getAllRegisteredIds(Project project) { + public static Collection<String> getAllRegisteredIds(Project project, Set<String> fxmls) { CommonProcessors.CollectUniquesProcessor<String> processor = new CommonProcessors.CollectUniquesProcessor<String>(); FileBasedIndex.getInstance().processAllKeys(KEY, processor, project); - return processor.getResults(); + final Collection<String> results = new ArrayList<String>(processor.getResults()); + final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project); + for (Iterator<String> iterator = results.iterator(); iterator.hasNext(); ) { + final String id = iterator.next(); + final List<Set<String>> values = FileBasedIndex.getInstance().getValues(KEY, id, searchScope); + if (!values.isEmpty()) { + final Set<String> pathSet = values.get(0); + if (pathSet != null && !Collections.disjoint(pathSet, fxmls)) { + continue; + } + } + iterator.remove(); + } + return results; } @NotNull diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxRenameAttributeProcessor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxRenameAttributeProcessor.java new file mode 100644 index 000000000000..fd9945ebec50 --- /dev/null +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/JavaFxRenameAttributeProcessor.java @@ -0,0 +1,58 @@ +/* + * 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; + +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiField; +import com.intellij.psi.PsiReference; +import com.intellij.psi.search.SearchScope; +import com.intellij.psi.xml.XmlAttribute; +import com.intellij.psi.xml.XmlAttributeValue; +import com.intellij.refactoring.rename.RenameXmlAttributeProcessor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.javaFX.fxml.FxmlConstants; +import org.jetbrains.plugins.javaFX.fxml.JavaFxFileTypeFactory; + +import java.util.Map; + +/** + * User: anna + * Date: 4/2/13 + */ +public class JavaFxRenameAttributeProcessor extends RenameXmlAttributeProcessor { + @Override + public boolean canProcessElement(@NotNull PsiElement element) { + if (element instanceof XmlAttributeValue && JavaFxFileTypeFactory.isFxml(element.getContainingFile())) { + final PsiElement parent = element.getParent(); + return parent instanceof XmlAttribute && FxmlConstants.FX_ID.equals(((XmlAttribute)parent).getName()); + } + return false; + } + + @Override + public void prepareRenaming(PsiElement element, String newName, Map<PsiElement, String> allRenames, SearchScope scope) { + if (element instanceof XmlAttributeValue) { + final XmlAttributeValue refId = (XmlAttributeValue)element; + final PsiReference refIdReference = refId.getReference(); + if (refIdReference != null) { + final PsiElement resolveRefId = refIdReference.resolve(); + if (resolveRefId instanceof PsiField) { + allRenames.put(resolveRefId, newName); + } + } + } + } +} diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/actions/OpenInSceneBuilderAction.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/actions/OpenInSceneBuilderAction.java index f809cc9402e9..061e63714e7a 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/actions/OpenInSceneBuilderAction.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/actions/OpenInSceneBuilderAction.java @@ -16,7 +16,6 @@ package org.jetbrains.plugins.javaFX.actions; import com.intellij.CommonBundle; -import com.intellij.execution.ExecutionException; import com.intellij.execution.configurations.GeneralCommandLine; import com.intellij.execution.configurations.JavaParameters; import com.intellij.execution.configurations.PathEnvironmentVariableUtil; @@ -141,7 +140,7 @@ public class OpenInSceneBuilderAction extends AnAction { commandLine.addParameter(path); commandLine.createProcess(); } - catch (ExecutionException ex) { + catch (Exception ex) { Messages.showErrorDialog("Failed to start SceneBuilder: " + commandLine.getCommandLineString(), CommonBundle.getErrorTitle()); } } @@ -164,31 +163,12 @@ public class OpenInSceneBuilderAction extends AnAction { private static VirtualFile getPredefinedPath() { String path = null; if (SystemInfo.isWindows) { - String programFilesPath = null; - final String property = System.getProperty("java.home"); - if (property != null) { - final File jdkDir = new File(property).getParentFile(); - if (jdkDir != null) { - final File javaDir = jdkDir.getParentFile(); - if (javaDir != null) { - final File programFilesDir = javaDir.getParentFile(); - if (programFilesDir != null) { - programFilesPath = programFilesDir.getPath(); - } - } - } - } - final String sb11 = File.separator + "JavaFX Scene Builder 1.1" + File.separator + "JavaFX Scene Builder 1.1.exe"; - final String sb10 = File.separator + "JavaFX Scene Builder 1.0" + File.separator + "JavaFX Scene Builder 1.0.exe"; + final String sb10 = File.separator + "JavaFX Scene Builder 1.0" + File.separator + "bin" + File.separator + "scenebuilder.exe"; final List<String> suspiciousPaths = new ArrayList<String>(); - if (programFilesPath != null && new File(programFilesPath, ORACLE).isDirectory()) { - fillPaths(programFilesPath, sb11, sb10, suspiciousPaths); - } else { - final String programFiles = "C:\\Program Files"; - fillPaths(programFiles, sb11, sb10, suspiciousPaths); - fillPaths(programFiles + " (x86)", sb11, sb10, suspiciousPaths); - } + final String programFiles = "C:\\Program Files"; + fillPaths(programFiles, sb11, sb10, suspiciousPaths); + fillPaths(programFiles + " (x86)", sb11, sb10, suspiciousPaths); final File sb = FileUtil.findFirstThatExist(ArrayUtil.toStringArray(suspiciousPaths)); if (sb != null) { path = sb.getPath(); diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxReferencesContributor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxReferencesContributor.java index 059533aefee4..658e99aa051a 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxReferencesContributor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/fxml/refs/JavaFxReferencesContributor.java @@ -15,21 +15,14 @@ */ package org.jetbrains.plugins.javaFX.fxml.refs; -import com.intellij.openapi.vfs.VirtualFileSystem; -import com.intellij.openapi.vfs.newvfs.NewVirtualFileSystem; import com.intellij.psi.*; import com.intellij.psi.filters.ElementFilter; import com.intellij.psi.filters.position.FilterPattern; -import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; -import com.intellij.util.ProcessingContext; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.javaFX.JavaFxFileReferenceProvider; import org.jetbrains.plugins.javaFX.fxml.JavaFxCommonClassNames; -import java.util.Collection; -import java.util.Collections; - import static com.intellij.patterns.PsiJavaPatterns.literalExpression; /** @@ -79,25 +72,6 @@ public class JavaFxReferencesContributor extends PsiReferenceContributor { public boolean isClassAcceptable(Class hintClass) { return true; } - })), new PsiReferenceProvider() { - @NotNull - @Override - public PsiReference[] getReferencesByElement(@NotNull final PsiElement element, @NotNull ProcessingContext context) { - final Object value = ((PsiLiteralExpression)element).getValue(); - final PsiDirectory directory = element.getContainingFile().getParent(); - if (!(value instanceof String) || directory == null) return PsiReference.EMPTY_ARRAY; - final VirtualFileSystem fs = directory.getVirtualFile().getFileSystem(); - return new FileReferenceSet((String)value, element, 1, null, ((NewVirtualFileSystem)fs).isCaseSensitive()) { - @NotNull - @Override - public Collection<PsiFileSystemItem> getDefaultContexts() { - if (!directory.isValid()) { - return super.getDefaultContexts(); - } - return Collections.<PsiFileSystemItem>singletonList(directory); - } - }.getAllReferences(); - } - }); + })), new JavaFxFileReferenceProvider()); } } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactProperties.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactProperties.java index 67e295fbafb1..a81172de6525 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactProperties.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactProperties.java @@ -68,6 +68,7 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP private String myKeystore; private String myStorepass; private String myKeypass; + private boolean myConvertCss2Bin; @Override public void onBuildFinished(@NotNull final Artifact artifact, @NotNull final CompileContext compileContext) { @@ -249,6 +250,14 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP myKeypass = keypass; } + public boolean isConvertCss2Bin() { + return myConvertCss2Bin; + } + + public void setConvertCss2Bin(boolean convertCss2Bin) { + myConvertCss2Bin = convertCss2Bin; + } + public String getPreloaderClass(Artifact rootArtifact, Project project) { final Artifact artifact = getPreloaderArtifact(rootArtifact, project); if (artifact != null) { @@ -348,6 +357,11 @@ public class JavaFxArtifactProperties extends ArtifactProperties<JavaFxArtifactP } @Override + public boolean convertCss2Bin() { + return myProperties.isConvertCss2Bin(); + } + + @Override protected String prepareParam(String param) { return GeneralCommandLine.prepareCommand(param); } diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.form b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.form index 65c36ea983ec..2d0fb3b4c8c4 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.form +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.form @@ -8,7 +8,7 @@ <properties/> <border type="none"/> <children> - <grid id="ca833" layout-manager="GridLayoutManager" row-count="10" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <grid id="ca833" layout-manager="GridLayoutManager" row-count="11" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="0" left="0" bottom="0" right="0"/> <constraints> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> @@ -163,7 +163,7 @@ </component> <component id="b03bd" class="javax.swing.JCheckBox" binding="myEnableSigningCB"> <constraints> - <grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> </constraints> <properties> <text value="Enable &signing"/> @@ -172,7 +172,7 @@ <grid id="506ce" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="0" left="0" bottom="0" right="0"/> <constraints> - <grid row="9" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + <grid row="10" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> </constraints> <properties/> <border type="none"/> @@ -192,6 +192,14 @@ </hspacer> </children> </grid> + <component id="8bb5f" class="javax.swing.JCheckBox" binding="myConvertCssToBinCheckBox" default-binding="true"> + <constraints> + <grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + </constraints> + <properties> + <text value="Convert css to bin"/> + </properties> + </component> </children> </grid> <vspacer id="1a12e"> diff --git a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java index feaee5b4e41f..8060c8ff120b 100644 --- a/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java +++ b/plugins/javaFX/src/org/jetbrains/plugins/javaFX/packaging/JavaFxArtifactPropertiesEditor.java @@ -51,6 +51,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor { private JCheckBox myUpdateInBackgroundCB; private JCheckBox myEnableSigningCB; private JButton myEditSignCertificateButton; + private JCheckBox myConvertCssToBinCheckBox; private JavaFxEditCertificatesDialog myDialog; public JavaFxArtifactPropertiesEditor(JavaFxArtifactProperties properties, final Project project, Artifact artifact) { @@ -99,6 +100,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor { final boolean inBackground = Comparing.strEqual(myProperties.getUpdateMode(), JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND); if (inBackground != myUpdateInBackgroundCB.isSelected()) return true; if (myProperties.isEnabledSigning() != myEnableSigningCB.isSelected()) return true; + if (myProperties.isConvertCss2Bin() != myConvertCssToBinCheckBox.isSelected()) return true; if (myDialog != null) { if (isModified(myProperties.getAlias(), myDialog.myPanel.myAliasTF)) return true; if (isModified(myProperties.getKeystore(), myDialog.myPanel.myKeystore)) return true; @@ -132,6 +134,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor { myProperties.setUpdateMode(myUpdateInBackgroundCB.isSelected() ? JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND : JavaFxPackagerConstants.UPDATE_MODE_ALWAYS); myProperties.setEnabledSigning(myEnableSigningCB.isSelected()); + myProperties.setConvertCss2Bin(myConvertCssToBinCheckBox.isSelected()); if (myDialog != null) { myProperties.setSelfSigning(myDialog.myPanel.mySelfSignedRadioButton.isSelected()); myProperties.setAlias(myDialog.myPanel.myAliasTF.getText()); @@ -155,6 +158,7 @@ public class JavaFxArtifactPropertiesEditor extends ArtifactPropertiesEditor { setText(myParams, myProperties.getParamFile()); myUpdateInBackgroundCB.setSelected(Comparing.strEqual(myProperties.getUpdateMode(), JavaFxPackagerConstants.UPDATE_MODE_BACKGROUND)); myEnableSigningCB.setSelected(myProperties.isEnabledSigning()); + myConvertCssToBinCheckBox.setSelected(myProperties.isConvertCss2Bin()); myEditSignCertificateButton.setEnabled(myProperties.isEnabledSigning()); } diff --git a/plugins/javaFX/testData/rename/FromReference.java b/plugins/javaFX/testData/rename/FromReference.java new file mode 100644 index 000000000000..63a025eec6d5 --- /dev/null +++ b/plugins/javaFX/testData/rename/FromReference.java @@ -0,0 +1,4 @@ +import javafx.control.Label; +public class FromReference { + public Label lb; +}
\ No newline at end of file diff --git a/plugins/javaFX/testData/rename/fromReference.fxml b/plugins/javaFX/testData/rename/fromReference.fxml new file mode 100644 index 000000000000..0c7df76f5d20 --- /dev/null +++ b/plugins/javaFX/testData/rename/fromReference.fxml @@ -0,0 +1,8 @@ +<?import javafx.scene.control.Label?> +<?import javafx.layout.*?> +<GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="FromReference"> + <fx:define> + <Label fx:id="lb"/> + </fx:define> + <fx:reference source="l<caret>b"/> +</GridPane>
\ No newline at end of file diff --git a/plugins/javaFX/testData/rename/fromReference_after.fxml b/plugins/javaFX/testData/rename/fromReference_after.fxml new file mode 100644 index 000000000000..4fa09b02606d --- /dev/null +++ b/plugins/javaFX/testData/rename/fromReference_after.fxml @@ -0,0 +1,8 @@ +<?import javafx.scene.control.Label?> +<?import javafx.layout.*?> +<GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="FromReference"> + <fx:define> + <Label fx:id="lbl1"/> + </fx:define> + <fx:reference source="lbl1"/> +</GridPane>
\ No newline at end of file diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java index a3b3cd35e410..246897a2cb53 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/MavenDomProjectProcessorUtils.java @@ -315,27 +315,25 @@ public class MavenDomProjectProcessorUtils { SearchProcessor<MavenDomDependency, MavenDomDependencies> processor = new SearchProcessor<MavenDomDependency, MavenDomDependencies>() { @Override protected MavenDomDependency find(MavenDomDependencies mavenDomDependencies) { - if (!model.equals(mavenDomDependencies.getParentOfType(MavenDomProjectModel.class, true))) { - for (MavenDomDependency domDependency : mavenDomDependencies.getDependencies()) { - if (artifactId.equals(domDependency.getArtifactId().getStringValue()) && - groupId.equals(domDependency.getGroupId().getStringValue())) { - return domDependency; - } + for (MavenDomDependency domDependency : mavenDomDependencies.getDependencies()) { + if (artifactId.equals(domDependency.getArtifactId().getStringValue()) && + groupId.equals(domDependency.getGroupId().getStringValue())) { + return domDependency; + } - if ("import".equals(domDependency.getScope().getRawText())) { - GenericDomValue<String> version = domDependency.getVersion(); - if (version.getXmlElement() != null) { - GenericDomValueReference reference = new GenericDomValueReference(version); - PsiElement resolve = reference.resolve(); - - if (resolve instanceof XmlFile) { - MavenDomProjectModel dependModel = MavenDomUtil.getMavenDomModel((PsiFile)resolve, MavenDomProjectModel.class); - if (dependModel != null) { - for (MavenDomDependency dep : dependModel.getDependencyManagement().getDependencies().getDependencies()) { - if (artifactId.equals(dep.getArtifactId().getStringValue()) && - groupId.equals(dep.getGroupId().getStringValue())) { - return domDependency; - } + if ("import".equals(domDependency.getScope().getRawText())) { + GenericDomValue<String> version = domDependency.getVersion(); + if (version.getXmlElement() != null) { + GenericDomValueReference reference = new GenericDomValueReference(version); + PsiElement resolve = reference.resolve(); + + if (resolve instanceof XmlFile) { + MavenDomProjectModel dependModel = MavenDomUtil.getMavenDomModel((PsiFile)resolve, MavenDomProjectModel.class); + if (dependModel != null) { + for (MavenDomDependency dep : dependModel.getDependencyManagement().getDependencies().getDependencies()) { + if (artifactId.equals(dep.getArtifactId().getStringValue()) && + groupId.equals(dep.getGroupId().getStringValue())) { + return domDependency; } } } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java index 6e2b13848646..1c835789d6de 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/dom/converters/MavenArtifactCoordinatesConverter.java @@ -18,6 +18,8 @@ package org.jetbrains.idea.maven.dom.converters; import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.RecursionManager; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; @@ -25,15 +27,14 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.util.ArrayUtil; -import com.intellij.util.xml.ConvertContext; -import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomUtil; -import com.intellij.util.xml.ResolvingConverter; +import com.intellij.util.xml.*; +import com.intellij.util.xml.impl.GenericDomValueReference; import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.dom.MavenDomBundle; +import org.jetbrains.idea.maven.dom.MavenDomProjectProcessorUtils; import org.jetbrains.idea.maven.dom.MavenDomUtil; import org.jetbrains.idea.maven.dom.model.*; import org.jetbrains.idea.maven.indices.MavenProjectIndicesManager; @@ -79,7 +80,7 @@ public abstract class MavenArtifactCoordinatesConverter extends ResolvingConvert Project p = getProject(context); MavenId id = MavenArtifactCoordinatesHelper.getId(context); - PsiFile result = selectStrategy(context).resolve(p, id); + PsiFile result = selectStrategy(context).resolve(p, id, context); return result != null ? result : super.resolve(o, context); } @@ -178,7 +179,7 @@ public abstract class MavenArtifactCoordinatesConverter extends ResolvingConvert return doGetVariants(id, manager); } - public PsiFile resolve(Project project, MavenId id) { + public PsiFile resolve(Project project, MavenId id, ConvertContext context) { MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project); PsiManager psiManager = PsiManager.getInstance(project); @@ -224,7 +225,7 @@ public abstract class MavenArtifactCoordinatesConverter extends ResolvingConvert private class ProjectStrategy extends ConverterStrategy { @Override - public PsiFile resolve(Project project, MavenId id) { + public PsiFile resolve(Project project, MavenId id, ConvertContext context) { return null; } @@ -265,6 +266,31 @@ public abstract class MavenArtifactCoordinatesConverter extends ResolvingConvert } @Override + public PsiFile resolve(Project project, MavenId id, ConvertContext context) { + if (id.getVersion() == null && id.getGroupId() != null && id.getArtifactId() != null) { + DomElement parent = context.getInvocationElement().getParent(); + if (parent instanceof MavenDomDependency) { + MavenDomDependency managedDependency = MavenDomProjectProcessorUtils.searchManagingDependency((MavenDomDependency)parent); + if (managedDependency != null && !"import".equals(managedDependency.getScope().getStringValue())) { + final GenericDomValue<String> managedDependencyArtifactId = managedDependency.getArtifactId(); + PsiElement res = RecursionManager.doPreventingRecursion(managedDependencyArtifactId, false, new Computable<PsiElement>() { + @Override + public PsiElement compute() { + return new GenericDomValueReference(managedDependencyArtifactId).resolve(); + } + }); + + if (res instanceof PsiFile) { + return (PsiFile)res; + } + } + } + } + + return super.resolve(project, id, context); + } + + @Override public PsiFile resolveBySpecifiedPath() { return myDependency.getSystemPath().getValue(); } @@ -287,7 +313,7 @@ public abstract class MavenArtifactCoordinatesConverter extends ResolvingConvert private class ExclusionStrategy extends ConverterStrategy { @Override - public PsiFile resolve(Project project, MavenId id) { + public PsiFile resolve(Project project, MavenId id, ConvertContext context) { return null; } diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryAttachHandler.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryAttachHandler.java index 5fbef78c3498..4e3cf1854652 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryAttachHandler.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/library/RepositoryAttachHandler.java @@ -347,7 +347,9 @@ public class RepositoryAttachHandler { private static List<MavenRemoteRepository> convertRepositories(Collection<MavenRepositoryInfo> infos) { List<MavenRemoteRepository> result = new ArrayList<MavenRemoteRepository>(infos.size()); for (MavenRepositoryInfo each : infos) { - result.add(new MavenRemoteRepository(each.getId(), each.getName(), each.getUrl(), null, null, null)); + if (each.getUrl() != null) { + result.add(new MavenRemoteRepository(each.getId(), each.getName(), each.getUrl(), null, null, null)); + } } return result; } diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java index 48e8b72fcf83..9d7365241feb 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenDependencyCompletionAndResolutionTest.java @@ -29,6 +29,7 @@ import org.jetbrains.idea.maven.dom.intentions.ChooseFileIntentionAction; import org.jetbrains.idea.maven.dom.model.MavenDomDependency; import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel; +import java.io.File; import java.util.Arrays; import java.util.List; @@ -414,6 +415,33 @@ public class MavenDependencyCompletionAndResolutionTest extends MavenDomWithIndi assertResolved(myProjectPom, findPsiFile(f)); } + public void testResolveManagedDependency() throws Exception { + importProject("<groupId>test</groupId>" + + "<artifactId>project</artifactId>" + + "<version>1</version>" + + + "<dependencyManagement>" + + " <dependencies>" + + " <dependency>" + + " <groupId>junit</groupId>" + + " <artifactId>junit</artifactId>" + + " <version>4.0</version>" + + " </dependency>" + + " </dependencies>" + + "</dependencyManagement>" + + + "<dependencies>" + + " <dependency>" + + " <groupId>junit</groupId>" + + " <artifactId>junit<caret></artifactId>" + + " </dependency>" + + "</dependencies>"); + + String filePath = myIndicesFixture.getRepositoryHelper().getTestDataPath("local1/junit/junit/4.0/junit-4.0.pom"); + VirtualFile f = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath); + assertResolved(myProjectPom, findPsiFile(f)); + } + public void testResolutionIsTypeBased() throws Exception { createProjectPom("<groupId>test</groupId>" + "<artifactId>project</artifactId>" + diff --git a/plugins/properties/testData/propertiesFile/projectView/bundle/X.java b/plugins/properties/testData/propertiesFile/projectView/bundle/X.txt index e9d8ee4c9055..e9d8ee4c9055 100644 --- a/plugins/properties/testData/propertiesFile/projectView/bundle/X.java +++ b/plugins/properties/testData/propertiesFile/projectView/bundle/X.txt diff --git a/plugins/properties/testData/propertiesFile/projectView/sortByType/X.java b/plugins/properties/testData/propertiesFile/projectView/sortByType/X.txt index e9d8ee4c9055..e9d8ee4c9055 100644 --- a/plugins/properties/testData/propertiesFile/projectView/sortByType/X.java +++ b/plugins/properties/testData/propertiesFile/projectView/sortByType/X.txt diff --git a/plugins/properties/testData/propertiesFile/projectView/standAlone/X.java b/plugins/properties/testData/propertiesFile/projectView/standAlone/X.txt index e9d8ee4c9055..e9d8ee4c9055 100644 --- a/plugins/properties/testData/propertiesFile/projectView/standAlone/X.java +++ b/plugins/properties/testData/propertiesFile/projectView/standAlone/X.txt diff --git a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java index 2e44168b2e1b..1b2ffb9fb334 100644 --- a/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java +++ b/plugins/properties/testSrc/com/intellij/lang/properties/PropertiesProjectViewTest.java @@ -40,7 +40,7 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " xxx.properties\n" + " xxx_en.properties\n" + " xxx_ru_RU.properties\n" + - " X.java\n" + + " X.txt\n" + myStructure.getProjectFileRepresentation() + " External Libraries\n"; PlatformTestUtil.assertTreeEqual(pane.getTree(), structure); @@ -57,7 +57,7 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " xxx.properties\n" + " xxx2.properties\n" + " yyy.properties\n" + - " X.java\n" + + " X.txt\n" + myStructure.getProjectFileRepresentation() + " External Libraries\n"; @@ -77,7 +77,7 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " -Resource Bundle 'xxx'\n" + " xxx.properties\n" + " xxx_en.properties\n" + - " X.java\n" + + " X.txt\n" + myStructure.getProjectFileRepresentation() + " External Libraries\n"; @@ -89,7 +89,7 @@ public class PropertiesProjectViewTest extends LightPlatformCodeInsightFixtureTe " -PsiDirectory: src\n" + " -PsiDirectory: sortByType\n" + " a.properties\n" + - " X.java\n" + + " X.txt\n" + " -Resource Bundle 'xxx'\n" + " xxx.properties\n" + " xxx_en.properties\n" + diff --git a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/AuthenticationCallback.java b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/AuthenticationCallback.java index 0d3314f1ece5..bdc9c2deb03c 100644 --- a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/AuthenticationCallback.java +++ b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/AuthenticationCallback.java @@ -106,4 +106,6 @@ public interface AuthenticationCallback { * @return false if authentication was canceled or related calculations were unsuccessful */ boolean askProxyCredentials(File base); + + void reset(); } diff --git a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnCommand.java b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnCommand.java index a1e358b6f4a0..d6df6bae947e 100644 --- a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnCommand.java +++ b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnCommand.java @@ -118,15 +118,21 @@ public abstract class SvnCommand { /** * Wait for process termination + * @param timeout */ - public void waitFor() { + public boolean waitFor(int timeout) { checkStarted(); final OSProcessHandler handler; synchronized (myLock) { - if (myIsDestroyed) return; + if (myIsDestroyed) return true; handler = myHandler; } - handler.waitFor(); + if (timeout == -1) { + return handler.waitFor(); + } + else { + return handler.waitFor(timeout); + } } protected abstract void processTerminated(int exitCode); @@ -173,8 +179,10 @@ public abstract class SvnCommand { public void destroyProcess() { synchronized (myLock) { - myIsDestroyed = true; - myHandler.destroyProcess(); + if (! myIsDestroyed) { + myIsDestroyed = true; + myHandler.destroyProcess(); + } } } diff --git a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnLineCommand.java b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnLineCommand.java index 3554b1cd4d81..5821d7a5fb18 100644 --- a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnLineCommand.java +++ b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnLineCommand.java @@ -35,6 +35,7 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; import java.util.Iterator; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; /** @@ -101,8 +102,46 @@ public class SvnLineCommand extends SvnCommand { File configDir = null; - // for IDEA proxy case - if (authenticationCallback != null && authenticationCallback.haveDataForTmpConfig()) { + try { + // for IDEA proxy case + if (authenticationCallback != null) { + writeIdeaConfig2SubversionConfig(authenticationCallback, base); + configDir = authenticationCallback.getSpecialConfigDir(); + } + + while (true) { + final SvnLineCommand command = runCommand(exePath, commandName, listener, base, configDir, parameters); + if (command.myErr.length() > 0) { + final String errText = command.myErr.toString().trim(); + if (authenticationCallback != null) { + final AuthCallbackCase callback = createCallback(errText, authenticationCallback, base); + if (callback != null) { + cleanup(exePath, commandName, base); + if (callback.getCredentials(errText)) { + if (authenticationCallback.getSpecialConfigDir() != null) { + configDir = authenticationCallback.getSpecialConfigDir(); + } + continue; + } + } + } + throw new SvnBindException(errText); + } + final Integer exitCode = command.myExitCode.get(); + if (exitCode != 0) { + throw new SvnBindException("Svn process exited with error code: " + exitCode); + } + return; + } + } finally { + if (authenticationCallback != null) { + authenticationCallback.reset(); + } + } + } + + private static void writeIdeaConfig2SubversionConfig(@NotNull AuthenticationCallback authenticationCallback, @NotNull File base) throws SvnBindException { + if (authenticationCallback.haveDataForTmpConfig()) { try { if (! authenticationCallback.persistDataToTmpConfig(base)) { throw new SvnBindException("Can not persist " + ApplicationNamesInfo.getInstance().getProductName() + @@ -116,34 +155,7 @@ public class SvnLineCommand extends SvnCommand { throw new SvnBindException(e); } assert authenticationCallback.getSpecialConfigDir() != null; - configDir = authenticationCallback.getSpecialConfigDir(); } - - while (true) { - final SvnLineCommand command = runCommand(exePath, commandName, listener, base, configDir, parameters); - if (command.myErr.length() > 0) { - final String errText = command.myErr.toString().trim(); - if (authenticationCallback != null) { - final AuthCallbackCase callback = createCallback(errText, authenticationCallback, base); - if (callback != null) { - cleanup(exePath, commandName, base); - if (callback.getCredentials(errText)) { - if (authenticationCallback.getSpecialConfigDir() != null) { - configDir = authenticationCallback.getSpecialConfigDir(); - } - continue; - } - } - } - throw new SvnBindException(errText); - } - final Integer exitCode = command.myExitCode.get(); - if (exitCode != 0) { - throw new SvnBindException("Svn process exited with error code: " + exitCode); - } - return; - } - //ok } private static AuthCallbackCase createCallback(final String errText, final AuthenticationCallback callback, final File base) { @@ -269,6 +281,7 @@ public class SvnLineCommand extends SvnCommand { final LineCommandListener listener, File base, File configDir, String... parameters) throws SvnBindException { + final AtomicBoolean errorReceived = new AtomicBoolean(false); final SvnLineCommand command = new SvnLineCommand(base, commandName, exePath, configDir) { int myErrCnt = 0; @@ -285,6 +298,8 @@ public class SvnLineCommand extends SvnCommand { if (ProcessOutputTypes.STDERR.equals(outputType)) { ++ myErrCnt; final String trim = text.trim(); + // should end in 1 second + errorReceived.set(true); if (trim.startsWith(UNABLE_TO_CONNECT)) { // wait for 3 lines of text then if (myErrCnt >= 3) { @@ -337,7 +352,17 @@ public class SvnLineCommand extends SvnCommand { } }); command.start(); - command.waitFor(); + boolean finished; + do { + finished = command.waitFor(500); + if (!finished && errorReceived.get()) { + command.waitFor(1000); + command.destroyProcess(); + break; + } + } + while (!finished); + if (exceptionRef.get() != null) { throw new SvnBindException(exceptionRef.get()); } diff --git a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnSimpleCommand.java b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnSimpleCommand.java index da5df9e6d299..75c43befb6cb 100644 --- a/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnSimpleCommand.java +++ b/plugins/svn4idea/bindSvn/src/org/jetbrains/idea/svn/commandLine/SvnSimpleCommand.java @@ -87,7 +87,7 @@ public class SvnSimpleCommand extends SvnCommand { }); start(); if (isStarted()) {//if wasn't started, exception is stored into a field, don't wait for process - waitFor(); + waitFor(-1); } synchronized (myDataLock) { diff --git a/plugins/svn4idea/src/META-INF/plugin.xml b/plugins/svn4idea/src/META-INF/plugin.xml index fe90da5a24dc..cff125884e80 100644 --- a/plugins/svn4idea/src/META-INF/plugin.xml +++ b/plugins/svn4idea/src/META-INF/plugin.xml @@ -76,7 +76,7 @@ <reference id="Vcs.ShowTabbedFileHistory"/> <reference id="Vcs.ShowHistoryForBlock"/> <reference id="Annotate"/> - <action id="Subversion.Copy" class="org.jetbrains.idea.svn.actions.CopyAction"/> + <action id="Subversion.Copy" class="org.jetbrains.idea.svn.actions.CreateBranchOrTagAction"/> <separator/> <action id="Subversion.Lock" class="org.jetbrains.idea.svn.actions.LockAction"/> <action id="Subversion.Unlock" class="org.jetbrains.idea.svn.actions.UnlockAction"/> diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java index 8efa61780535..bb493b0c6619 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnAuthenticationManager.java @@ -499,8 +499,14 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im public ISVNProxyManager getProxyManager(SVNURL url) throws SVNException { SSLExceptionsHelper.addInfo("Accessing URL: " + url.toString()); - CommonProxy.getInstance().noProxy(url.getProtocol(), url.getHost(), url.getPort()); ourThreadLocalProvider.set(myProvider); + // in proxy creation, we need proxy information from common proxy. but then we should forbid common proxy to intercept + final ISVNProxyManager proxy = createProxy(url); + CommonProxy.getInstance().noProxy(url.getProtocol(), url.getHost(), url.getPort()); + return proxy; + } + + private ISVNProxyManager createProxy(SVNURL url) { // this code taken from default manager (changed for system properties reading) String host = url.getHost(); @@ -509,7 +515,7 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im if (getConfig().isIsUseDefaultProxy()) { // ! use common proxy if it is set try { - final List<Proxy> proxies = CommonProxy.getInstance().select(new URI(url.toString())); + final List<Proxy> proxies = HttpConfigurable.getInstance().getOnlyBySettingsSelector().select(new URI(url.toString())); if (proxies != null && ! proxies.isEmpty()) { for (Proxy proxy : proxies) { if (HttpConfigurable.isRealProxy(proxy) && Proxy.Type.HTTP.equals(proxy.type())) { @@ -528,28 +534,27 @@ public class SvnAuthenticationManager extends DefaultSVNAuthenticationManager im } return null; } - String proxyExceptions = getServersPropertyIdea(host, "http-proxy-exceptions"); - String proxyExceptionsSeparator = ","; - if (proxyExceptions == null) { - proxyExceptions = System.getProperty("http.nonProxyHosts"); - proxyExceptionsSeparator = "|"; - } - if (proxyExceptions != null) { - for(StringTokenizer exceptions = new StringTokenizer(proxyExceptions, proxyExceptionsSeparator); exceptions.hasMoreTokens();) { - String exception = exceptions.nextToken().trim(); - if (DefaultSVNOptions.matches(exception, host)) { - return null; - } - } + String proxyExceptions = getServersPropertyIdea(host, "http-proxy-exceptions"); + String proxyExceptionsSeparator = ","; + if (proxyExceptions == null) { + proxyExceptions = System.getProperty("http.nonProxyHosts"); + proxyExceptionsSeparator = "|"; + } + if (proxyExceptions != null) { + for(StringTokenizer exceptions = new StringTokenizer(proxyExceptions, proxyExceptionsSeparator); exceptions.hasMoreTokens();) { + String exception = exceptions.nextToken().trim(); + if (DefaultSVNOptions.matches(exception, host)) { + return null; + } } - String proxyPort = getServersPropertyIdea(host, HTTP_PROXY_PORT); - String proxyUser = getServersPropertyIdea(host, HTTP_PROXY_USERNAME); - String proxyPassword = getServersPropertyIdea(host, HTTP_PROXY_PASSWORD); - return new MySimpleProxyManager(proxyHost, proxyPort, proxyUser, proxyPassword); + } + String proxyPort = getServersPropertyIdea(host, HTTP_PROXY_PORT); + String proxyUser = getServersPropertyIdea(host, HTTP_PROXY_USERNAME); + String proxyPassword = getServersPropertyIdea(host, HTTP_PROXY_PASSWORD); + return new MySimpleProxyManager(proxyHost, proxyPort, proxyUser, proxyPassword); } - private static class MyPromptingProxyManager extends MySimpleProxyManager { private static final String ourPrompt = "Proxy authentication"; private final String myProtocol; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties index 0cf1b0a5eb25..b86ae6f4b00e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties @@ -654,4 +654,8 @@ Subversion will find not merged revisions using svn\:mergeinfo property recorded quick.merge.variants.quick.select.explanation=Shows all revisions from target branch, merged and not merged.\n\ For manual selection. Very quick. quick.merge.variants.pre.select.explanation=Finds where one of involved branches was copied from another.\n\ -Loads only not yet merged revisions for selection. Can take long time for execution.
\ No newline at end of file +Loads only not yet merged revisions for selection. Can take long time for execution. +dialog.create.branch.or.tag.from.working.copy.warning=<html>Use this variant to create branch <b>with local changes</b>.\ +<br/>In general, several items will be "added-with-history", not only target directory.\ +<br/><br/>Each file that have revision different than root will be copied separately.\ +<br/>It's recommended to update working copy before branch creation therefore.</html>
\ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CopyAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java index 5812f4e63244..99d80848bd19 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CopyAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java @@ -32,7 +32,7 @@ import com.intellij.openapi.wm.WindowManager; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnStatusUtil; import org.jetbrains.idea.svn.SvnVcs; -import org.jetbrains.idea.svn.dialogs.CopyDialog; +import org.jetbrains.idea.svn.dialogs.CreateBranchOrTagDialog; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNException; @@ -43,7 +43,7 @@ import java.io.File; import java.util.ArrayList; import java.util.List; -public class CopyAction extends BasicAction { +public class CreateBranchOrTagAction extends BasicAction { protected String getActionName(AbstractVcs vcs) { return SvnBundle.message("action.Subversion.Copy.text"); } @@ -65,7 +65,7 @@ public class CopyAction extends BasicAction { protected void perform(final Project project, final SvnVcs activeVcs, VirtualFile file, DataContext context) throws VcsException { - CopyDialog dialog = new CopyDialog(project, true, new File(file.getPath())); + CreateBranchOrTagDialog dialog = new CreateBranchOrTagDialog(project, true, new File(file.getPath())); dialog.show(); if (dialog.isOK()) { final String dstURL = dialog.getToURL(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaSvnkitBasedAuthenticationCallback.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaSvnkitBasedAuthenticationCallback.java index 618507117bee..995646f50d45 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaSvnkitBasedAuthenticationCallback.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaSvnkitBasedAuthenticationCallback.java @@ -60,9 +60,11 @@ public class IdeaSvnkitBasedAuthenticationCallback implements AuthenticationCall private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.checkin.IdeaSvnkitBasedAuthenticationCallback"); private File myTempDirectory; private boolean myProxyCredentialsWereReturned; + private SvnConfiguration myConfiguration; public IdeaSvnkitBasedAuthenticationCallback(SvnVcs vcs) { myVcs = vcs; + myConfiguration = SvnConfiguration.getInstance(myVcs.getProject()); } @Override @@ -174,6 +176,14 @@ public class IdeaSvnkitBasedAuthenticationCallback implements AuthenticationCall } if (authentication != null) { myProxyCredentialsWereReturned = true; + // for 'generic' proxy variant (suppose user defined proxy in Subversion config but no password) + try { + initTmpDir(SvnConfiguration.getInstance(myVcs.getProject())); + } + catch (IOException e) { + PopupUtil.showBalloonForActiveComponent("Failed to authenticate to proxy: " + e.getMessage(), MessageType.ERROR); + return false; + } return SvnConfiguration.putProxyCredentialsIntoServerFile(myTempDirectory, url.getHost(), authentication); } return false; @@ -570,7 +580,7 @@ public class IdeaSvnkitBasedAuthenticationCallback implements AuthenticationCall @Nullable @Override public File getSpecialConfigDir() { - return myTempDirectory; + return myTempDirectory != null ? myTempDirectory : new File(myConfiguration.getConfigurationDirectory()); } private String getFromType(SVNAuthentication authentication) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopyDialog.form b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.form index 9aa53e1a4124..1b8924b12e77 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopyDialog.form +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.form @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.svn.dialogs.CopyDialog"> +<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.svn.dialogs.CreateBranchOrTagDialog"> <grid id="9287c" binding="myTopPanel" layout-manager="GridBagLayout"> <constraints> - <xy x="10" y="10" width="561" height="430"/> + <xy x="10" y="10" width="561" height="470"/> </constraints> <properties/> <border type="none"/> @@ -26,7 +26,7 @@ </component> </children> </scrollpane> - <grid id="9317" layout-manager="GridLayoutManager" row-count="5" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <grid id="9317" layout-manager="GridLayoutManager" row-count="6" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="0" left="0" bottom="0" right="0"/> <constraints> <grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> @@ -55,7 +55,7 @@ </component> <component id="27881" class="javax.swing.JRadioButton" binding="myRepositoryRadioButton" default-binding="true"> <constraints> - <grid row="2" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> + <grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> </constraints> <properties> <text value="&Repository Location:"/> @@ -63,13 +63,13 @@ </component> <component id="d7ae0" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myRepositoryField"> <constraints> - <grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="0" fill="3" indent="2" use-parent-layout="false"/> + <grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="0" fill="3" indent="2" use-parent-layout="false"/> </constraints> <properties/> </component> <component id="675da" class="javax.swing.JLabel"> <constraints> - <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/> + <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/> </constraints> <properties> <text value="Re&vision:"/> @@ -77,17 +77,17 @@ </component> <nested-form id="23004" form-file="org/jetbrains/idea/svn/update/SvnRevisionPanel.form" binding="myRevisionPanel"> <constraints> - <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + <grid row="5" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> </constraints> </nested-form> <hspacer id="b36ab"> <constraints> - <grid row="4" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + <grid row="5" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/> </constraints> </hspacer> <component id="13071" class="javax.swing.JButton" binding="myProjectButton"> <constraints> - <grid row="3" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> + <grid row="4" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> </constraints> <properties> <margin top="2" left="2" bottom="2" right="2"/> @@ -95,6 +95,14 @@ <toolTipText value="Use project location"/> </properties> </component> + <component id="658a" class="javax.swing.JLabel" binding="myUseThisVariantToLabel"> + <constraints> + <grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/> + </constraints> + <properties> + <text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="dialog.create.branch.or.tag.from.working.copy.warning"/> + </properties> + </component> </children> </grid> <grid id="a6551" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopyDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java index 5b31c7b7b266..62fc918d8a92 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopyDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java @@ -28,6 +28,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.ComboboxWithBrowseButton; import com.intellij.ui.DocumentAdapter; import com.intellij.util.ArrayUtil; +import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.RootUrlInfo; @@ -58,7 +59,7 @@ import java.io.File; * Date: 05.07.2005 * Time: 23:35:12 */ -public class CopyDialog extends DialogWrapper { +public class CreateBranchOrTagDialog extends DialogWrapper { private static final Logger LOG = Logger.getInstance("org.jetbrains.idea.svn.dialogs.CopyDialog"); private final File mySrcFile; @@ -81,19 +82,21 @@ public class CopyDialog extends DialogWrapper { private JRadioButton myAnyLocationRadioButton; private JButton myProjectButton; private JLabel myErrorLabel; + private JLabel myUseThisVariantToLabel; @NonNls private static final String HELP_ID = "vcs.subversion.branch"; private SvnBranchConfigurationNew myBranchConfiguration; private final VirtualFile mySrcVirtualFile; private final String myWcRootUrl; - public CopyDialog(final Project project, boolean canBeParent, File file) throws VcsException { + public CreateBranchOrTagDialog(final Project project, boolean canBeParent, File file) throws VcsException { super(project, canBeParent); mySrcFile = file; myProject = project; setResizable(true); setTitle(SvnBundle.message("dialog.title.branch")); getHelpAction().setEnabled(true); + myUseThisVariantToLabel.setBorder(BorderFactory.createEmptyBorder(0,0,10,0)); myProjectButton.setIcon(AllIcons.Nodes.IdeaProject); myBranchTagBaseComboBox.setPreferredSize(new Dimension(myBranchTagBaseComboBox.getPreferredSize().width, myWorkingCopyField.getPreferredSize().height)); @@ -242,6 +245,7 @@ public class CopyDialog extends DialogWrapper { myBranchTagBaseComboBox.setEnabled(myBranchOrTagRadioButton.isSelected()); myBranchTextField.setEnabled(myBranchOrTagRadioButton.isSelected()); myToURLText.setEnabled(myAnyLocationRadioButton.isSelected()); + myUseThisVariantToLabel.setForeground(myWorkingCopyRadioButton.isSelected() ? UIUtil.getActiveTextColor() : UIUtil.getInactiveTextColor()); getOKAction().setEnabled(isOKActionEnabled()); } diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java index 6cf5f1e8f235..8245c9eb9500 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/generic/GenericRepository.java @@ -1,7 +1,9 @@ package com.intellij.tasks.generic; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.XmlElementFactory; import com.intellij.psi.xml.XmlTag; @@ -105,8 +107,15 @@ public class GenericRepository extends BaseRepositoryImpl { String id = matcher.group(placeholders.indexOf(ID_PLACEHOLDER) + 1); String summary = matcher.group(placeholders.indexOf(SUMMARY_PLACEHOLDER) + 1); if (myResponseType == ResponseType.XML && summary != null) { - XmlTag text = XmlElementFactory.getInstance(ProjectManager.getInstance().getDefaultProject()).createTagFromText("<a>" + summary + "</a>"); - summary = XmlUtil.decode(text.getValue().getTrimmedText()); + final String finalSummary = summary; + summary = ApplicationManager.getApplication().runReadAction(new Computable<String>() { + @Override + public String compute() { + XmlElementFactory factory = XmlElementFactory.getInstance(ProjectManager.getInstance().getDefaultProject()); + XmlTag text = factory.createTagFromText("<a>" + finalSummary + "</a>"); + return XmlUtil.decode(text.getValue().getTrimmedText()); + } + }); } tasks.add(new GenericTask(id, summary, this)); } diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/AssemblaIntegrationTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/AssemblaIntegrationTest.java index b7979309dbc4..1f26161bd222 100644 --- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/AssemblaIntegrationTest.java +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/AssemblaIntegrationTest.java @@ -63,6 +63,6 @@ public class AssemblaIntegrationTest extends TaskManagerTestCase { "</tickets>"); assertEquals(1, tasks.length); - assertEquals("Привет", tasks[0].getSummary()); + assertEquals("\u041F\u0440\u0438\u0432\u0435\u0442", tasks[0].getSummary()); } } diff --git a/plugins/ui-designer-core/src/com/intellij/designer/model/RadComponent.java b/plugins/ui-designer-core/src/com/intellij/designer/model/RadComponent.java index 3fedbbe03d5e..1a701775d42e 100644 --- a/plugins/ui-designer-core/src/com/intellij/designer/model/RadComponent.java +++ b/plugins/ui-designer-core/src/com/intellij/designer/model/RadComponent.java @@ -76,6 +76,10 @@ public abstract class RadComponent extends PropertiesContainer { return myParent; } + public final <T extends RadComponent> T getParent(Class<T> clazz) { + return (T)myParent; + } + public final void setParent(RadComponent parent) { myParent = parent; } |