diff options
Diffstat (limited to 'plugins')
1578 files changed, 7289 insertions, 48139 deletions
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml index 890da15b546b..164c690d4da3 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml @@ -408,6 +408,10 @@ key="class.name.differs.from.file.name.display.name" groupBundle="messages.InspectionsBundle" groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING" implementationClass="com.siyeh.ig.classlayout.ClassNameDiffersFromFileNameInspection"/> + <localInspection language="JAVA" shortName="ClassWithOnlyPrivateConstructors" bundle="com.siyeh.InspectionGadgetsBundle" + key="class.with.only.private.constructors.display.name" groupBundle="messages.InspectionsBundle" + groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING" + implementationClass="com.siyeh.ig.classlayout.ClassWithOnlyPrivateConstructorsInspection"/> <localInspection language="JAVA" shortName="ConstantDeclaredInAbstractClass" bundle="com.siyeh.InspectionGadgetsBundle" key="constant.declared.in.abstract.class.display.name" groupBundle="messages.InspectionsBundle" groupKey="group.names.class.structure" enabledByDefault="false" level="WARNING" diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties index efeb65889a93..f92925b33bc0 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties @@ -2096,3 +2096,5 @@ serializable.local.class.stores.non.serializable.problem.descriptor=Serializable serializable.anonymous.class.stores.non.serializable.problem.descriptor=Serializable anonymous class implicitly stores non-Serializable object of type ''{0}'' assignment.to.lambda.parameter.display.name=Assignment to lambda parameter assignment.to.lambda.parameter.problem.descriptor=Assignment to lambda parameter <code>#ref</code> #loc +class.with.only.private.constructors.display.name=Class with only 'private' constructors should be declared 'final' +class.with.only.private.constructors.problem.descriptor=Class <code>#ref</code> with only 'private' constructors should be declared 'final' diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseGlobalInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseGlobalInspection.java index b0f4a3633ad9..8d2e5049cdbc 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseGlobalInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/BaseGlobalInspection.java @@ -16,6 +16,7 @@ package com.siyeh.ig; import com.intellij.codeInspection.GlobalJavaBatchInspectionTool; +import com.intellij.codeInspection.InspectionProfileEntry; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -34,8 +35,7 @@ public abstract class BaseGlobalInspection extends GlobalJavaBatchInspectionTool assert name.endsWith(INSPECTION) : "class name must end with 'Inspection' to correctly" + " calculate the short name: " + name; - shortName = name.substring(name.lastIndexOf((int)'.') + 1, - name.length() - INSPECTION.length()); + shortName = InspectionProfileEntry.getShortName(getClass().getSimpleName()); } return shortName; } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentToMethodParameterInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentToMethodParameterInspection.java index 56dbecc83d6b..5fb2f2b8ff5e 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentToMethodParameterInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/assignment/AssignmentToMethodParameterInspection.java @@ -26,9 +26,6 @@ import javax.swing.*; public class AssignmentToMethodParameterInspection extends BaseAssignmentToParameterInspection { - @SuppressWarnings({"PublicField"}) - public boolean ignoreTransformationOfOriginalParameter = false; - @Override @NotNull public String getDisplayName() { diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspectionBase.java new file mode 100644 index 000000000000..6d091699ce82 --- /dev/null +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspectionBase.java @@ -0,0 +1,91 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.classlayout; + +import com.intellij.psi.PsiClass; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiModifier; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; +import com.siyeh.ig.BaseInspectionVisitor; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author Bas Leijdekkers + */ +public class ClassWithOnlyPrivateConstructorsInspectionBase extends BaseInspection { + @Nls + @NotNull + @Override + public String getDisplayName() { + return InspectionGadgetsBundle.message("class.with.only.private.constructors.display.name"); + } + + @NotNull + @Override + protected String buildErrorString(Object... infos) { + return InspectionGadgetsBundle.message("class.with.only.private.constructors.problem.descriptor"); + } + + @Override + public BaseInspectionVisitor buildVisitor() { + return new ClassWithOnlyPrivateConstructorsVisitor(); + } + + private static class ClassWithOnlyPrivateConstructorsVisitor extends BaseInspectionVisitor { + + @Override + public void visitClass(PsiClass aClass) { + super.visitClass(aClass); + final PsiMethod[] constructors = aClass.getConstructors(); + if (constructors.length == 0) { + return; + } + for (PsiMethod constructor : constructors) { + if (constructor.hasModifierProperty(PsiModifier.FINAL)) { + return; + } + } + final PsiClass[] innerClasses = aClass.getInnerClasses(); + for (PsiClass innerClass : innerClasses) { + if (isExtendedByInnerClass(innerClass, aClass, new HashSet<PsiClass>())) { + return; + } + } + registerClassError(aClass, aClass); + } + + private static boolean isExtendedByInnerClass(PsiClass innerClass, PsiClass superClass, Set<PsiClass> visited) { + if (!visited.add(innerClass)) { + return false; + } + if (innerClass.isInheritor(superClass, false)) { + return true; + } + final PsiClass[] innerClasses = innerClass.getInnerClasses(); + for (PsiClass aClass : innerClasses) { + if (isExtendedByInnerClass(aClass, superClass, visited)) { + return true; + } + } + return false; + } + } +} diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspection.java index 755a4c349e21..0b7524de01a4 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspection.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2014 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,12 +17,15 @@ package com.siyeh.ig.controlflow; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Ref; import com.intellij.psi.*; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.refactoring.extractMethod.InputVariables; +import com.intellij.refactoring.util.duplicates.ConditionalReturnStatementValue; import com.intellij.refactoring.util.duplicates.DuplicatesFinder; import com.intellij.refactoring.util.duplicates.Match; +import com.intellij.refactoring.util.duplicates.ReturnValue; import com.intellij.util.IncorrectOperationException; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; @@ -158,12 +161,10 @@ public class IfStatementWithIdenticalBranchesInspection return new IfStatementWithIdenticalBranchesVisitor(); } - private static class IfStatementWithIdenticalBranchesVisitor - extends BaseInspectionVisitor { + private static class IfStatementWithIdenticalBranchesVisitor extends BaseInspectionVisitor { @Override - public void visitIfStatement( - @NotNull PsiIfStatement ifStatement) { + public void visitIfStatement(@NotNull PsiIfStatement ifStatement) { super.visitIfStatement(ifStatement); final PsiStatement elseBranch = ifStatement.getElseBranch(); final PsiStatement thenBranch = ifStatement.getThenBranch(); @@ -179,14 +180,18 @@ public class IfStatementWithIdenticalBranchesInspection inputVariables, null, Collections.<PsiVariable>emptyList()); if (elseBranch instanceof PsiIfStatement) { - final PsiIfStatement statement = - (PsiIfStatement)elseBranch; + final PsiIfStatement statement = (PsiIfStatement)elseBranch; final PsiStatement branch = statement.getThenBranch(); if (branch == null) { return; } final Match match = finder.isDuplicate(branch, true); - if (match != null && match.getReturnValue() == null) { + if (match != null) { + final ReturnValue matchReturnValue = match.getReturnValue(); + if (matchReturnValue instanceof ConditionalReturnStatementValue && + !matchReturnValue.isEquivalent(buildReturnValue(thenBranch))) { + return; + } registerStatementError(ifStatement, statement); return; } @@ -197,11 +202,37 @@ public class IfStatementWithIdenticalBranchesInspection else { final Match match = finder.isDuplicate(elseBranch, true); if (match != null) { + final ReturnValue matchReturnValue = match.getReturnValue(); + if (matchReturnValue instanceof ConditionalReturnStatementValue && + !matchReturnValue.isEquivalent(buildReturnValue(thenBranch))) { + return; + } registerStatementError(ifStatement); } } } + @Nullable + private ReturnValue buildReturnValue(PsiElement element) { + final Ref<PsiReturnStatement> result = Ref.create(null); + element.accept(new JavaRecursiveElementWalkingVisitor() { + @Override + public void visitReturnStatement(PsiReturnStatement statement) { + super.visitReturnStatement(statement); + result.set(statement); + } + }); + final PsiReturnStatement returnStatement = result.get(); + if (returnStatement == null) { + return null; + } + final PsiExpression expression = returnStatement.getReturnValue(); + if (expression == null) { + return null; + } + return new ConditionalReturnStatementValue(expression); + } + private void checkIfStatementWithoutElseBranch( PsiIfStatement ifStatement) { final PsiStatement thenBranch = ifStatement.getThenBranch(); diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspectionBase.java index ad4273156865..0bc871664bfd 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspectionBase.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/dataflow/UnnecessaryLocalVariableInspectionBase.java @@ -97,11 +97,6 @@ public class UnnecessaryLocalVariableInspectionBase extends BaseInspection { } @Override - protected boolean buildQuickFixesOnlyForOnTheFlyErrors() { - return true; - } - - @Override public BaseInspectionVisitor buildVisitor() { return new UnnecessaryLocalVariableVisitor(); } diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/PointlessArithmeticExpressionInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/PointlessArithmeticExpressionInspection.java index bebf5a559d15..023b4bc9f949 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/PointlessArithmeticExpressionInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/numeric/PointlessArithmeticExpressionInspection.java @@ -105,7 +105,7 @@ public class PointlessArithmeticExpressionInspection fromTarget = (i == length - 1) ? polyadicExpression.getTokenBeforeOperand(operand) : operand; break; } - else if ((tokenType.equals(JavaTokenType.MINUS) || tokenType.equals(JavaTokenType.DIV)) && + else if ((tokenType.equals(JavaTokenType.MINUS) && i == 1 || tokenType.equals(JavaTokenType.DIV)) && EquivalenceChecker.expressionsAreEquivalent(previousOperand, operand)) { fromTarget = previousOperand; untilTarget = operand; @@ -229,9 +229,10 @@ public class PointlessArithmeticExpressionInspection private boolean subtractionExpressionIsPointless(PsiExpression[] expressions) { PsiExpression previousExpression = null; - for (PsiExpression expression : expressions) { + for (int i = 0; i < expressions.length; i++) { + PsiExpression expression = expressions[i]; if (previousExpression != null && - (isZero(expression) || EquivalenceChecker.expressionsAreEquivalent(previousExpression, expression))) { + (isZero(expression) || i == 1 && EquivalenceChecker.expressionsAreEquivalent(previousExpression, expression))) { return true; } previousExpression = expression; diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspection.java deleted file mode 100644 index 997e57ba0cda..000000000000 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspection.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.siyeh.ig.performance; - -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.psi.search.searches.OverridingMethodsSearch; -import com.intellij.psi.util.PropertyUtil; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.Query; -import com.siyeh.InspectionGadgetsBundle; -import com.siyeh.ig.BaseInspection; -import com.siyeh.ig.BaseInspectionVisitor; -import com.siyeh.ig.InspectionGadgetsFix; -import com.siyeh.ig.PsiReplacementUtil; -import com.siyeh.ig.psiutils.ClassUtils; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -public class CallToSimpleGetterInClassInspection extends BaseInspection { - - @SuppressWarnings("UnusedDeclaration") - public boolean ignoreGetterCallsOnOtherObjects = false; - - @SuppressWarnings("UnusedDeclaration") - public boolean onlyReportPrivateGetter = false; - - @Override - @NotNull - public String getID() { - return "CallToSimpleGetterFromWithinClass"; - } - - @Override - @NotNull - public String getDisplayName() { - return InspectionGadgetsBundle.message("call.to.simple.getter.in.class.display.name"); - } - - @Override - @NotNull - public String buildErrorString(Object... infos) { - return InspectionGadgetsBundle.message("call.to.simple.getter.in.class.problem.descriptor"); - } - - @Override - @Nullable - public JComponent createOptionsPanel() { - final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this); - optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.simple.getter.in.class.ignore.option"), - "ignoreGetterCallsOnOtherObjects"); - optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.private.simple.getter.in.class.option"), - "onlyReportPrivateGetter"); - return optionsPanel; - } - - @Override - public InspectionGadgetsFix buildFix(Object... infos) { - return new InlineCallFix(); - } - - private static class InlineCallFix extends InspectionGadgetsFix { - @NotNull - @Override - public String getFamilyName() { - return getName(); - } - - @Override - @NotNull - public String getName() { - return InspectionGadgetsBundle.message("call.to.simple.getter.in.class.inline.quickfix"); - } - - @Override - public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { - final PsiElement methodIdentifier = descriptor.getPsiElement(); - final PsiReferenceExpression methodExpression = (PsiReferenceExpression)methodIdentifier.getParent(); - if (methodExpression == null) { - return; - } - final PsiMethodCallExpression call = (PsiMethodCallExpression)methodExpression.getParent(); - if (call == null) { - return; - } - final PsiMethod method = call.resolveMethod(); - if (method == null) { - return; - } - final PsiCodeBlock body = method.getBody(); - if (body == null) { - return; - } - final PsiStatement[] statements = body.getStatements(); - final PsiReturnStatement returnStatement = (PsiReturnStatement)statements[0]; - final PsiExpression returnValue = returnStatement.getReturnValue(); - if (!(returnValue instanceof PsiReferenceExpression)) { - return; - } - final PsiReferenceExpression referenceExpression = (PsiReferenceExpression)returnValue; - final PsiField field = (PsiField)referenceExpression.resolve(); - if (field == null) { - return; - } - final String fieldName = field.getName(); - if (fieldName == null) { - return; - } - final PsiExpression qualifier = methodExpression.getQualifierExpression(); - if (qualifier == null) { - final JavaPsiFacade facade = JavaPsiFacade.getInstance(call.getProject()); - final PsiResolveHelper resolveHelper = facade.getResolveHelper(); - final PsiVariable variable = resolveHelper.resolveReferencedVariable(fieldName, call); - if (variable == null) { - return; - } - if (variable.equals(field)) { - PsiReplacementUtil.replaceExpression(call, fieldName); - } - else { - PsiReplacementUtil.replaceExpression(call, "this." + fieldName); - } - } - else { - PsiReplacementUtil.replaceExpression(call, qualifier.getText() + '.' + fieldName); - } - } - } - - @Override - public BaseInspectionVisitor buildVisitor() { - return new CallToSimpleGetterInClassVisitor(); - } - - private class CallToSimpleGetterInClassVisitor extends BaseInspectionVisitor { - - @Override - public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { - super.visitMethodCallExpression(call); - final PsiClass containingClass = ClassUtils.getContainingClass(call); - if (containingClass == null) { - return; - } - final PsiMethod method = call.resolveMethod(); - if (method == null) { - return; - } - if (!containingClass.equals(method.getContainingClass())) { - return; - } - final PsiReferenceExpression methodExpression = call.getMethodExpression(); - final PsiExpression qualifier = methodExpression.getQualifierExpression(); - if (qualifier != null && !(qualifier instanceof PsiThisExpression)) { - if (ignoreGetterCallsOnOtherObjects) { - return; - } - final PsiType type = qualifier.getType(); - if (!(type instanceof PsiClassType)) { - return; - } - final PsiClassType classType = (PsiClassType)type; - final PsiClass qualifierClass = classType.resolve(); - if (!containingClass.equals(qualifierClass)) { - return; - } - } - if (!PropertyUtil.isSimpleGetter(method)) { - return; - } - if (onlyReportPrivateGetter && !method.hasModifierProperty(PsiModifier.PRIVATE)) { - return; - } - final Query<PsiMethod> query = OverridingMethodsSearch.search(method, true); - final PsiMethod overridingMethod = query.findFirst(); - if (overridingMethod != null) { - return; - } - registerMethodCallError(call); - } - } -}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspectionBase.java new file mode 100644 index 000000000000..f21fd50918da --- /dev/null +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspectionBase.java @@ -0,0 +1,103 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.performance; + +import com.intellij.psi.*; +import com.intellij.psi.search.searches.OverridingMethodsSearch; +import com.intellij.psi.util.PropertyUtil; +import com.intellij.util.Query; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; +import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.psiutils.ClassUtils; +import org.jetbrains.annotations.NotNull; + +public class CallToSimpleGetterInClassInspectionBase extends BaseInspection { + @SuppressWarnings("UnusedDeclaration") + public boolean ignoreGetterCallsOnOtherObjects = false; + @SuppressWarnings("UnusedDeclaration") + public boolean onlyReportPrivateGetter = false; + + @Override + @NotNull + public String getID() { + return "CallToSimpleGetterFromWithinClass"; + } + + @Override + @NotNull + public String getDisplayName() { + return InspectionGadgetsBundle.message("call.to.simple.getter.in.class.display.name"); + } + + @Override + @NotNull + public String buildErrorString(Object... infos) { + return InspectionGadgetsBundle.message("call.to.simple.getter.in.class.problem.descriptor"); + } + + @Override + public BaseInspectionVisitor buildVisitor() { + return new CallToSimpleGetterInClassVisitor(); + } + + private class CallToSimpleGetterInClassVisitor extends BaseInspectionVisitor { + + @Override + public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { + super.visitMethodCallExpression(call); + final PsiClass containingClass = ClassUtils.getContainingClass(call); + if (containingClass == null) { + return; + } + final PsiMethod method = call.resolveMethod(); + if (method == null) { + return; + } + if (!containingClass.equals(method.getContainingClass())) { + return; + } + final PsiReferenceExpression methodExpression = call.getMethodExpression(); + final PsiExpression qualifier = methodExpression.getQualifierExpression(); + if (qualifier != null && !(qualifier instanceof PsiThisExpression)) { + if (ignoreGetterCallsOnOtherObjects) { + return; + } + final PsiType type = qualifier.getType(); + if (!(type instanceof PsiClassType)) { + return; + } + final PsiClassType classType = (PsiClassType)type; + final PsiClass qualifierClass = classType.resolve(); + if (!containingClass.equals(qualifierClass)) { + return; + } + } + if (!PropertyUtil.isSimpleGetter(method)) { + return; + } + if (onlyReportPrivateGetter && !method.hasModifierProperty(PsiModifier.PRIVATE)) { + return; + } + final Query<PsiMethod> query = OverridingMethodsSearch.search(method, true); + final PsiMethod overridingMethod = query.findFirst(); + if (overridingMethod != null) { + return; + } + registerMethodCallError(call); + } + } +} diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspection.java deleted file mode 100644 index bfcf47cd0465..000000000000 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspection.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.siyeh.ig.performance; - -import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.psi.search.searches.OverridingMethodsSearch; -import com.intellij.psi.util.PropertyUtil; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.Query; -import com.siyeh.InspectionGadgetsBundle; -import com.siyeh.ig.BaseInspection; -import com.siyeh.ig.BaseInspectionVisitor; -import com.siyeh.ig.InspectionGadgetsFix; -import com.siyeh.ig.PsiReplacementUtil; -import com.siyeh.ig.psiutils.ClassUtils; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; - -public class CallToSimpleSetterInClassInspection extends BaseInspection { - - @SuppressWarnings("UnusedDeclaration") - public boolean ignoreSetterCallsOnOtherObjects = false; - - @SuppressWarnings("UnusedDeclaration") - public boolean onlyReportPrivateSetter = false; - - @Override - @NotNull - public String getID() { - return "CallToSimpleSetterFromWithinClass"; - } - - @Override - @NotNull - public String getDisplayName() { - return InspectionGadgetsBundle.message("call.to.simple.setter.in.class.display.name"); - } - - @Override - @NotNull - public String buildErrorString(Object... infos) { - return InspectionGadgetsBundle.message("call.to.simple.setter.in.class.problem.descriptor"); - } - - @Override - @Nullable - public JComponent createOptionsPanel() { - final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this); - optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.simple.setter.in.class.ignore.option"), - "ignoreSetterCallsOnOtherObjects"); - optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.private.setter.in.class.option"), - "onlyReportPrivateSetter"); - return optionsPanel; - } - - @Override - public InspectionGadgetsFix buildFix(Object... infos) { - return new InlineCallFix(); - } - - private static class InlineCallFix extends InspectionGadgetsFix { - - @Override - @NotNull - public String getName() { - return InspectionGadgetsBundle.message("call.to.simple.setter.in.class.inline.quickfix"); - } - - @NotNull - @Override - public String getFamilyName() { - return getName(); - } - - @Override - public void doFix(Project project, ProblemDescriptor descriptor) - throws IncorrectOperationException { - final PsiElement methodIdentifier = descriptor.getPsiElement(); - final PsiReferenceExpression methodExpression = (PsiReferenceExpression)methodIdentifier.getParent(); - if (methodExpression == null) { - return; - } - final PsiMethodCallExpression call = (PsiMethodCallExpression)methodExpression.getParent(); - if (call == null) { - return; - } - final PsiExpressionList argumentList = call.getArgumentList(); - final PsiExpression[] arguments = argumentList.getExpressions(); - final PsiExpression argument = arguments[0]; - final PsiMethod method = call.resolveMethod(); - if (method == null) { - return; - } - final PsiCodeBlock body = method.getBody(); - if (body == null) { - return; - } - final PsiStatement[] statements = body.getStatements(); - final PsiExpressionStatement assignmentStatement = (PsiExpressionStatement)statements[0]; - final PsiAssignmentExpression assignment = (PsiAssignmentExpression)assignmentStatement.getExpression(); - final PsiExpression qualifier = methodExpression.getQualifierExpression(); - final PsiReferenceExpression lhs = (PsiReferenceExpression)assignment.getLExpression(); - final PsiField field = (PsiField)lhs.resolve(); - if (field == null) { - return; - } - final String fieldName = field.getName(); - if (qualifier == null) { - final JavaPsiFacade manager = JavaPsiFacade.getInstance(call.getProject()); - final PsiResolveHelper resolveHelper = manager.getResolveHelper(); - final PsiVariable variable = resolveHelper.resolveReferencedVariable(fieldName, call); - if (variable == null) { - return; - } - @NonNls final String newExpression; - if (variable.equals(field)) { - newExpression = fieldName + " = " + argument.getText(); - } - else { - newExpression = "this." + fieldName + " = " + argument.getText(); - } - PsiReplacementUtil.replaceExpression(call, newExpression); - } - else { - final String newExpression = qualifier.getText() + '.' + fieldName + " = " + argument.getText(); - PsiReplacementUtil.replaceExpression(call, newExpression); - } - } - } - - @Override - public BaseInspectionVisitor buildVisitor() { - return new CallToSimpleSetterInClassVisitor(); - } - - private class CallToSimpleSetterInClassVisitor extends BaseInspectionVisitor { - - @Override - public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { - super.visitMethodCallExpression(call); - final PsiClass containingClass = ClassUtils.getContainingClass(call); - if (containingClass == null) { - return; - } - final PsiMethod method = call.resolveMethod(); - if (method == null) { - return; - } - if (!containingClass.equals(method.getContainingClass())) { - return; - } - final PsiReferenceExpression methodExpression = call.getMethodExpression(); - final PsiExpression qualifier = methodExpression.getQualifierExpression(); - if (qualifier != null && !(qualifier instanceof PsiThisExpression)) { - if (ignoreSetterCallsOnOtherObjects) { - return; - } - final PsiType type = qualifier.getType(); - if (!(type instanceof PsiClassType)) { - return; - } - final PsiClassType classType = (PsiClassType)type; - final PsiClass qualifierClass = classType.resolve(); - if (!containingClass.equals(qualifierClass)) { - return; - } - } - if (!PropertyUtil.isSimpleSetter(method)) { - return; - } - if (onlyReportPrivateSetter && !method.hasModifierProperty(PsiModifier.PRIVATE)) { - return; - } - final Query<PsiMethod> query = OverridingMethodsSearch.search(method, true); - final PsiMethod overridingMethod = query.findFirst(); - if (overridingMethod != null) { - return; - } - registerMethodCallError(call); - } - } -}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspectionBase.java new file mode 100644 index 000000000000..6e6512a8866a --- /dev/null +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspectionBase.java @@ -0,0 +1,103 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.performance; + +import com.intellij.psi.*; +import com.intellij.psi.search.searches.OverridingMethodsSearch; +import com.intellij.psi.util.PropertyUtil; +import com.intellij.util.Query; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.BaseInspection; +import com.siyeh.ig.BaseInspectionVisitor; +import com.siyeh.ig.psiutils.ClassUtils; +import org.jetbrains.annotations.NotNull; + +public class CallToSimpleSetterInClassInspectionBase extends BaseInspection { + @SuppressWarnings("UnusedDeclaration") + public boolean ignoreSetterCallsOnOtherObjects = false; + @SuppressWarnings("UnusedDeclaration") + public boolean onlyReportPrivateSetter = false; + + @Override + @NotNull + public String getID() { + return "CallToSimpleSetterFromWithinClass"; + } + + @Override + @NotNull + public String getDisplayName() { + return InspectionGadgetsBundle.message("call.to.simple.setter.in.class.display.name"); + } + + @Override + @NotNull + public String buildErrorString(Object... infos) { + return InspectionGadgetsBundle.message("call.to.simple.setter.in.class.problem.descriptor"); + } + + @Override + public BaseInspectionVisitor buildVisitor() { + return new CallToSimpleSetterInClassVisitor(); + } + + private class CallToSimpleSetterInClassVisitor extends BaseInspectionVisitor { + + @Override + public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) { + super.visitMethodCallExpression(call); + final PsiClass containingClass = ClassUtils.getContainingClass(call); + if (containingClass == null) { + return; + } + final PsiMethod method = call.resolveMethod(); + if (method == null) { + return; + } + if (!containingClass.equals(method.getContainingClass())) { + return; + } + final PsiReferenceExpression methodExpression = call.getMethodExpression(); + final PsiExpression qualifier = methodExpression.getQualifierExpression(); + if (qualifier != null && !(qualifier instanceof PsiThisExpression)) { + if (ignoreSetterCallsOnOtherObjects) { + return; + } + final PsiType type = qualifier.getType(); + if (!(type instanceof PsiClassType)) { + return; + } + final PsiClassType classType = (PsiClassType)type; + final PsiClass qualifierClass = classType.resolve(); + if (!containingClass.equals(qualifierClass)) { + return; + } + } + if (!PropertyUtil.isSimpleSetter(method)) { + return; + } + if (onlyReportPrivateSetter && !method.hasModifierProperty(PsiModifier.PRIVATE)) { + return; + } + final Query<PsiMethod> query = OverridingMethodsSearch.search(method, true); + final PsiMethod overridingMethod = query.findFirst(); + if (overridingMethod != null) { + return; + } + registerMethodCallError(call); + } + } +} diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ImportUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ImportUtils.java index 712449655cdd..375e0f6a8017 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ImportUtils.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/ImportUtils.java @@ -388,6 +388,14 @@ public class ImportUtils { } final PsiImportStatementBase existingImportStatement = importList.findSingleImportStatement(memberName); if (existingImportStatement != null) { + if (existingImportStatement instanceof PsiImportStaticStatement) { + final PsiImportStaticStatement importStaticStatement = (PsiImportStaticStatement)existingImportStatement; + if (!memberName.equals(importStaticStatement.getReferenceName())) { + return false; + } + final PsiClass targetClass = importStaticStatement.resolveTargetClass(); + return targetClass != null && qualifierClass.equals(targetClass.getQualifiedName()); + } return false; } final PsiImportStaticStatement onDemandImportStatement = findOnDemandImportStaticStatement(importList, qualifierClass); diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryInterfaceModifierInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryInterfaceModifierInspection.java index 0a4b57e8543b..310cc20c30b6 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryInterfaceModifierInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/style/UnnecessaryInterfaceModifierInspection.java @@ -19,6 +19,7 @@ import com.intellij.codeInspection.CleanupLocalInspectionTool; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.openapi.project.Project; import com.intellij.psi.*; +import com.intellij.psi.util.PsiUtil; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.BaseInspection; import com.siyeh.ig.BaseInspectionVisitor; @@ -121,8 +122,10 @@ public class UnnecessaryInterfaceModifierInspection extends BaseInspection imple } modifierList = (PsiModifierList)parent; } - modifierList.setModifierProperty(PsiModifier.STATIC, false); final PsiElement modifierOwner = modifierList.getParent(); + if (!(modifierOwner instanceof PsiMethod && PsiUtil.isLanguageLevel8OrHigher(modifierList))) { + modifierList.setModifierProperty(PsiModifier.STATIC, false); + } assert modifierOwner != null; if (modifierOwner instanceof PsiClass) { final PsiClass aClass = (PsiClass)modifierOwner; diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspection.java new file mode 100644 index 000000000000..3aeebcd724e8 --- /dev/null +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspection.java @@ -0,0 +1,33 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.classlayout; + +import com.intellij.psi.PsiClass; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.MakeClassFinalFix; +import org.jetbrains.annotations.Nullable; + +/** + * @author Bas Leijdekkers + */ +public class ClassWithOnlyPrivateConstructorsInspection extends ClassWithOnlyPrivateConstructorsInspectionBase { + + @Nullable + @Override + protected InspectionGadgetsFix buildFix(Object... infos) { + return new MakeClassFinalFix((PsiClass)infos[0]); + } +} diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineCallFix.java b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineCallFix.java index 43e57741bbe3..b9503e220c68 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineCallFix.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/fixes/InlineCallFix.java @@ -16,52 +16,54 @@ package com.siyeh.ig.fixes; import com.intellij.codeInspection.ProblemDescriptor; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiMethodCallExpression; import com.intellij.psi.PsiReferenceExpression; -import com.intellij.refactoring.JavaRefactoringActionHandlerFactory; -import com.intellij.refactoring.RefactoringActionHandler; +import com.intellij.refactoring.JavaRefactoringSettings; +import com.intellij.refactoring.inline.InlineMethodProcessor; import com.siyeh.InspectionGadgetsBundle; import com.siyeh.ig.InspectionGadgetsFix; import org.jetbrains.annotations.NotNull; public class InlineCallFix extends InspectionGadgetsFix { - @Override - @NotNull - public String getFamilyName() { - return getName(); - } + private String myName; + + public InlineCallFix(String name) { + myName = name; + } + + public InlineCallFix() { + this(InspectionGadgetsBundle.message("inline.call.quickfix")); + } + + @Override + @NotNull + public String getFamilyName() { + return myName; + } @Override @NotNull public String getName() { - return InspectionGadgetsBundle.message("inline.call.quickfix"); + return getFamilyName(); } @Override public void doFix(final Project project, ProblemDescriptor descriptor) { final PsiElement nameElement = descriptor.getPsiElement(); - final PsiReferenceExpression methodExpression = - (PsiReferenceExpression)nameElement.getParent(); - assert methodExpression != null; - final PsiMethodCallExpression methodCallExpression = - (PsiMethodCallExpression)methodExpression.getParent(); - final JavaRefactoringActionHandlerFactory factory = - JavaRefactoringActionHandlerFactory.getInstance(); - final RefactoringActionHandler inlineHandler = factory.createInlineHandler(); - final Runnable runnable = new Runnable() { - @Override - public void run() { - inlineHandler.invoke(project, new PsiElement[]{methodCallExpression}, null); - } - }; - if (ApplicationManager.getApplication().isUnitTestMode()) { - runnable.run(); - } - else { - ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed()); - } + final PsiReferenceExpression methodExpression = (PsiReferenceExpression)nameElement.getParent(); + if (methodExpression == null) return; + final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)methodExpression.getParent(); + final PsiMethod method = methodCallExpression.resolveMethod(); + if (method == null) return; + inline(project, methodExpression, method); + } + + protected void inline(Project project, PsiReferenceExpression methodExpression, PsiMethod method) { + new InlineMethodProcessor(project, method, methodExpression, null, true, + JavaRefactoringSettings.getInstance().RENAME_SEARCH_IN_COMMENTS_FOR_METHOD, + JavaRefactoringSettings.getInstance().RENAME_SEARCH_FOR_TEXT_FOR_METHOD).inlineMethodCall(methodExpression); } } diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspection.java new file mode 100644 index 000000000000..c550093cef63 --- /dev/null +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/performance/CallToSimpleGetterInClassInspection.java @@ -0,0 +1,63 @@ +/* + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.performance; + +import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiExpressionStatement; +import com.intellij.psi.PsiMethod; +import com.intellij.psi.PsiReferenceExpression; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.InlineCallFix; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +public class CallToSimpleGetterInClassInspection extends CallToSimpleGetterInClassInspectionBase { + @Override + @Nullable + public JComponent createOptionsPanel() { + final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this); + optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.simple.getter.in.class.ignore.option"), + "ignoreGetterCallsOnOtherObjects"); + optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.private.simple.getter.in.class.option"), + "onlyReportPrivateGetter"); + return optionsPanel; + } + + @Override + public InspectionGadgetsFix buildFix(Object... infos) { + return new InlineOrDeleteCallFix(InspectionGadgetsBundle.message("call.to.simple.getter.in.class.inline.quickfix")); + } + + private static class InlineOrDeleteCallFix extends InlineCallFix { + public InlineOrDeleteCallFix(String name) { + super(name); + } + + @Override + protected void inline(Project project, PsiReferenceExpression methodExpression, PsiMethod method) { + final PsiElement statement = methodExpression.getParent().getParent(); + if (statement instanceof PsiExpressionStatement) { + statement.delete(); + } else { + super.inline(project, methodExpression, method); + } + } + } +}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspection.java new file mode 100644 index 000000000000..652a8e89ea98 --- /dev/null +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/performance/CallToSimpleSetterInClassInspection.java @@ -0,0 +1,43 @@ +/* + * Copyright 2003-2011 Dave Griffith, Bas Leijdekkers + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.performance; + +import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel; +import com.siyeh.InspectionGadgetsBundle; +import com.siyeh.ig.InspectionGadgetsFix; +import com.siyeh.ig.fixes.InlineCallFix; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +public class CallToSimpleSetterInClassInspection extends CallToSimpleSetterInClassInspectionBase { + + @Override + @Nullable + public JComponent createOptionsPanel() { + final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this); + optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.simple.setter.in.class.ignore.option"), + "ignoreSetterCallsOnOtherObjects"); + optionsPanel.addCheckbox(InspectionGadgetsBundle.message("call.to.private.setter.in.class.option"), + "onlyReportPrivateSetter"); + return optionsPanel; + } + + @Override + public InspectionGadgetsFix buildFix(Object... infos) { + return new InlineCallFix(InspectionGadgetsBundle.message("call.to.simple.setter.in.class.inline.quickfix")); + } +}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithOnlyPrivateConstructors.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithOnlyPrivateConstructors.html new file mode 100644 index 000000000000..87122815ae53 --- /dev/null +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithOnlyPrivateConstructors.html @@ -0,0 +1,9 @@ +<html> +<body> +Reports classes with only <b>private</b> constructors that are not extended by any nested class. +Such classes can not be extended and should be declared <b>final</b>. +<!-- tooltip end --> +<p> +<small>New in 14</small> +</body> +</html>
\ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html index 24229c1d262b..184a994f90cd 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutConstructor.html @@ -1,6 +1,6 @@ <html> <body> -Reports a classes without constructors. Some coding standards prohibit such classes. +Reports classes without constructors. Some coding standards prohibit such classes. <!-- tooltip end --> <p> diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html index fbc102e8154c..0ce4bbb23575 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ClassWithoutNoArgConstructor.html @@ -1,6 +1,6 @@ <html> <body> -Reports a classes without a no-argument constructor. +Reports classes without a no-argument constructor. Such constructors are necessary in some contexts if a class is to be created reflexively. <!-- tooltip end --> <p> diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java index 377e50fa8a21..666651d71e21 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/IfStatementWithIdenticalBranches.java @@ -7,20 +7,20 @@ import java.util.Set; public class IfStatementWithIdenticalBranches { void one() { - if (true) { + <warning descr="'if' statement with identical branches">if</warning> (true) { } else { } - if (false) { + <warning descr="'if' statement with identical branches">if</warning> (false) { System.out.println(); return; } System.out.println(); } - int two() { - if (true) { + int two() { + <warning descr="'if' statement with identical branches">if</warning> (true) { int i = 2; return i; } else { @@ -41,7 +41,7 @@ public class IfStatementWithIdenticalBranches { void four() { if (true) { - if (false) { + <warning descr="'if' statement with identical branches">if</warning> (false) { System.out.println(); return; } @@ -61,7 +61,7 @@ public class IfStatementWithIdenticalBranches { void six() { if (true) { - if (false) { + <warning descr="'if' statement with identical branches">if</warning> (false) { System.out.println(); System.out.println(); return; @@ -93,11 +93,11 @@ public class IfStatementWithIdenticalBranches { } void nine() { - if (true) { + <warning descr="'if' statement with identical branches">if</warning> (true) { - } else if (true) { + } else <warning descr="'if' statement with identical branches">if</warning> (true) { - } else if (true) { + } else <warning descr="'if' statement with identical branches">if</warning> (true) { } else { @@ -105,7 +105,7 @@ public class IfStatementWithIdenticalBranches { } void blocks() { - if (true) { + <warning descr="'if' statement with identical branches">if</warning> (true) { System.out.println(); return; } @@ -135,4 +135,31 @@ class NotADup { return null; } + public static String calculate(int someNumber) { + if (someNumber == 0 ) { + try { + return placeOrder(3, null); + } + catch( Exception e ) { + System.out.println("e = " + e); + } + } + else if (someNumber == 1) { + try { + return placeOrder(3, someNumber, null); + } + catch(Exception e ) { + System.out.println("e = " + e); + } + } + return null; + } + + private static String placeOrder(int i, int someNumber, Object o) { + return null; + } + + private static String placeOrder(int i, Object o) { + return null; + } } diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/expected.xml deleted file mode 100644 index c85bba14ea3b..000000000000 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/if_statement_with_identical_branches/expected.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<problems> - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>10</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>15</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>23</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>44</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>64</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>96</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>98</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>100</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> - - <problem> - <file>IfStatementWithIdenticalBranches.java</file> - <line>108</line> - <problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">'if' statement with identical branches</problem_class> - <description><code>if</code> statement with identical branches #loc</description> - </problem> -</problems>
\ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/pointless_arithmetic_expression/PointlessArithmeticExpression.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/pointless_arithmetic_expression/PointlessArithmeticExpression.java index 019805adcf17..4ba7a97033ad 100644 --- a/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/pointless_arithmetic_expression/PointlessArithmeticExpression.java +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/numeric/pointless_arithmetic_expression/PointlessArithmeticExpression.java @@ -124,4 +124,5 @@ class Expanded {{ long g = 8L / 8L; long h = 9L * 0L; int a = 8 * 0 * 8 * ; // don't warn + int minus = 2 - 1 - 1; }}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspectionTest.java new file mode 100644 index 000000000000..a177242537d2 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/classlayout/ClassWithOnlyPrivateConstructorsInspectionTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.classlayout; + +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; + +public class ClassWithOnlyPrivateConstructorsInspectionTest extends LightInspectionTestCase { + + public void testSimple() { + doTest("class /*Class 'X' with only 'private' constructors should be declared 'final'*/X/**/ {" + + " private X() {}" + + " private X(int i) {}" + + "}"); + } + + public void testExtendingInnerClass() { + doTest("class X {\n" + + " private X() {}\n" + + " class Y {\n" + + " class Z extends X{}\n" + + " }\n" + + "}"); + } + + public void testNoConstructors() { + doTest("class X {}"); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new ClassWithOnlyPrivateConstructorsInspection(); + } +}
\ No newline at end of file diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspectionTest.java index 1562b8c9053c..e3e2f9c8a857 100644 --- a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspectionTest.java +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/IfStatementWithIdenticalBranchesInspectionTest.java @@ -1,12 +1,18 @@ package com.siyeh.ig.controlflow; -import com.siyeh.ig.IGInspectionTestCase; +import com.intellij.codeInspection.InspectionProfileEntry; +import com.siyeh.ig.LightInspectionTestCase; +import org.jetbrains.annotations.Nullable; -public class IfStatementWithIdenticalBranchesInspectionTest - extends IGInspectionTestCase { +public class IfStatementWithIdenticalBranchesInspectionTest extends LightInspectionTestCase { - public void test() throws Exception { - doTest("com/siyeh/igtest/controlflow/if_statement_with_identical_branches", - new IfStatementWithIdenticalBranchesInspection()); + public void testIfStatementWithIdenticalBranches() throws Exception { + doTest(); + } + + @Nullable + @Override + protected InspectionProfileEntry getInspection() { + return new IfStatementWithIdenticalBranchesInspection(); } }
\ No newline at end of file diff --git a/plugins/IntelliLang/java-support/resources/javaInjections.xml b/plugins/IntelliLang/java-support/resources/javaInjections.xml index 7bbd374ae8b1..4b66c8b13713 100644 --- a/plugins/IntelliLang/java-support/resources/javaInjections.xml +++ b/plugins/IntelliLang/java-support/resources/javaInjections.xml @@ -115,5 +115,21 @@ <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("selectNodes").withParameters("java.lang.Object", "java.lang.String").definedInClass("org.jdom.xpath.XPath"))]]></place> <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("selectSingleNode").withParameters("java.lang.Object", "java.lang.String").definedInClass("org.jdom.xpath.XPath"))]]></place> </injection> + <injection language="encoding-reference" injector-id="java"> + <display-name>Charset Name</display-name> + <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("forName").withParameters("java.lang.String").definedInClass("java.nio.charset.Charset"))]]></place> + <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("isSupported").withParameters("java.lang.String").definedInClass("java.nio.charset.Charset"))]]></place> + <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("getBytes").withParameters("java.lang.String").definedInClass("java.lang.String"))]]></place> + <place><![CDATA[psiParameter().ofMethod(3, psiMethod().withName("String").withParameters("byte[]", "int", "int", "java.lang.String").definedInClass("java.lang.String"))]]></place> + <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("String").withParameters("byte[]", "java.lang.String").definedInClass("java.lang.String"))]]></place> + <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("InputStreamReader").withParameters("java.io.InputStream", "java.lang.String").definedInClass("java.io.InputStreamReader"))]]></place> + <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("OutputStreamWriter").withParameters("java.io.OutputStream", "java.lang.String").definedInClass("java.io.OutputStreamWriter"))]]></place> + <place><![CDATA[psiParameter().ofMethod(0, psiMethod().withName("toString").withParameters("java.lang.String").definedInClass("java.io.ByteArrayOutputStream"))]]></place> + <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("PrintStream").withParameters("java.io.File", "java.lang.String").definedInClass("java.io.PrintStream"))]]></place> + <place><![CDATA[psiParameter().ofMethod(2, psiMethod().withName("PrintStream").withParameters("java.io.OutputStream", "boolean", "java.lang.String").definedInClass("java.io.PrintStream"))]]></place> + <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("PrintStream").withParameters("java.lang.String", "java.lang.String").definedInClass("java.io.PrintStream"))]]></place> + <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("encode").withParameters("java.lang.String", "java.lang.String").definedInClass("java.net.URLEncoder"))]]></place> + <place><![CDATA[psiParameter().ofMethod(1, psiMethod().withName("decode").withParameters("java.lang.String", "java.lang.String").definedInClass("java.net.URLDecoder"))]]></place> + </injection> </component> diff --git a/plugins/IntelliLang/src/META-INF/plugin.xml b/plugins/IntelliLang/src/META-INF/plugin.xml index a7f600958250..8f8806a8b2ec 100644 --- a/plugins/IntelliLang/src/META-INF/plugin.xml +++ b/plugins/IntelliLang/src/META-INF/plugin.xml @@ -45,7 +45,7 @@ <highlightErrorFilter implementation="org.intellij.plugins.intelliLang.inject.FrankensteinErrorFilter"/> <daemon.highlightInfoFilter implementation="org.intellij.plugins.intelliLang.inject.FrankensteinErrorFilter"/> - <projectConfigurable displayName="Language Injections" dynamic="true" instance="org.intellij.plugins.intelliLang.InjectionsSettingsUI" nonDefaultProject="true"/> + <projectConfigurable groupId="editor" displayName="Language Injections" dynamic="true" instance="org.intellij.plugins.intelliLang.InjectionsSettingsUI" nonDefaultProject="true"/> <multiHostInjector implementation="org.intellij.plugins.intelliLang.inject.CommentLanguageInjector"/> <multiHostInjector implementation="org.intellij.plugins.intelliLang.inject.TemporaryPlacesInjector"/> diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java index 4211fdf53a74..48ee3b51fac2 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectorUtils.java @@ -16,6 +16,7 @@ package org.intellij.plugins.intelliLang.inject; +import com.intellij.codeInsight.completion.CompletionUtil; import com.intellij.lang.Language; import com.intellij.lang.injection.MultiHostRegistrar; import com.intellij.openapi.extensions.Extensions; @@ -25,12 +26,16 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.impl.source.tree.injected.MultiHostRegistrarImpl; import com.intellij.psi.impl.source.tree.injected.Place; +import com.intellij.psi.util.CachedValueProvider; +import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ArrayUtil; -import com.intellij.util.NullableFunction; import com.intellij.util.ObjectUtils; -import com.intellij.util.SmartList; +import com.intellij.util.Producer; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.text.CharArrayUtil; +import com.intellij.util.text.StringSearcher; +import gnu.trove.TIntArrayList; import org.intellij.plugins.intelliLang.Configuration; import org.intellij.plugins.intelliLang.inject.config.BaseInjection; import org.jetbrains.annotations.NotNull; @@ -220,18 +225,117 @@ public class InjectorUtils { return true; } + @Nullable public static BaseInjection findCommentInjection(PsiElement context, final String supportId, final Ref<PsiElement> causeRef) { - return findNearestComment(context, new NullableFunction<PsiComment, BaseInjection>() { + PsiElement target = CompletionUtil.getOriginalOrSelf(context); + PsiFile file = target.getContainingFile(); + TreeMap<TextRange, BaseInjection> map = getInjectionMap(file); + Map.Entry<TextRange, BaseInjection> entry = map == null ? null : map.lowerEntry(target.getTextRange()); + if (entry == null) return null; + + PsiComment psiComment = PsiTreeUtil.findElementOfClassAtOffset(file, entry.getKey().getStartOffset(), PsiComment.class, false); + if (psiComment == null) return null; + TextRange r0 = psiComment.getTextRange(); + + // calulate topmost siblings & heights + PsiElement commonParent = PsiTreeUtil.findCommonParent(psiComment, target); + int h1 = 0, h2 = 0; + PsiElement e1 = psiComment, e2 = target; + for (PsiElement e = e1; e != commonParent; e1 = e, e = e.getParent(), h1++); + for (PsiElement e = e2; e != commonParent; e2 = e, e = e.getParent(), h2++); + + // make sure comment is close enough and ... + int off1 = r0.getEndOffset(); + int off2 = e2.getTextRange().getStartOffset(); + if (off2 - off1 > 120) return null; + if (off2 - off1 > 2) { + // ... there's nothing in between on the top level and ... + for (PsiElement e = e1; e != e2; e = e.getNextSibling()) { + if (!isWhitespaceCommentOrBlank(e)) return null; + } + // ... there's no non-empty host in the left (comment) subtree + Producer<PsiElement> producer = prevWalker(PsiTreeUtil.getDeepestLast(e1), e1); + PsiElement e; + while ( (e = producer.produce()) != null && e != psiComment) { + if (e instanceof PsiLanguageInjectionHost && !StringUtil.isEmptyOrSpaces(e.getText())) { + return null; + } + } + } + if (causeRef != null) { + causeRef.set(psiComment); + } + return new BaseInjection(supportId).copyFrom(entry.getValue()); + } + + protected static boolean isWhitespaceCommentOrBlank(PsiElement e) { + return e instanceof PsiWhiteSpace || e instanceof PsiComment || + e instanceof PsiLanguageInjectionHost && StringUtil.isEmptyOrSpaces(e.getText()); + } + + protected static TreeMap<TextRange, BaseInjection> getInjectionMap(final PsiFile file) { + return CachedValuesManager.getCachedValue(file, new CachedValueProvider<TreeMap<TextRange, BaseInjection>>() { @Nullable @Override - public BaseInjection fun(PsiComment comment) { - if (causeRef != null) causeRef.set(comment); - String text = ElementManipulators.getValueText(comment).trim(); - return detectInjectionFromText(supportId, text); + public Result<TreeMap<TextRange, BaseInjection>> compute() { + TreeMap<TextRange, BaseInjection> map = calcInjections(file); + return Result.create(map.isEmpty() ? null : map, file); } }); } + @NotNull + protected static TreeMap<TextRange, BaseInjection> calcInjections(PsiFile file) { + final TreeMap<TextRange, BaseInjection> injectionMap = new TreeMap<TextRange, BaseInjection>(RANGE_COMPARATOR); + + TIntArrayList ints = new TIntArrayList(); + StringSearcher searcher = new StringSearcher("language=", true, true, false); + CharSequence contents = file.getViewProvider().getContents(); + final char[] contentsArray = CharArrayUtil.fromSequenceWithoutCopying(contents); + + //long time = System.currentTimeMillis(); + + int s0 = 0, s1 = contents.length(); + for (int idx = searcher.scan(contents, contentsArray, s0, s1); + idx != -1; + idx = searcher.scan(contents, contentsArray, idx + 1, s1)) { + ints.add(idx); + PsiComment element = PsiTreeUtil.findElementOfClassAtOffset(file, idx, PsiComment.class, false); + if (element != null) { + String str = ElementManipulators.getValueText(element).trim(); + BaseInjection injection = detectInjectionFromText("", str); + if (injection != null) { + injectionMap.put(element.getTextRange(), injection); + } + } + } + + //VirtualFile virtualFile = file.getVirtualFile(); + //Document document = FileDocumentManager.getInstance().getDocument(virtualFile); + //EditorHighlighter highlighter = EditorHighlighterCache.getEditorHighlighterForCachesBuilding(document); + // + //ParserDefinition definition = LanguageParserDefinitions.INSTANCE.forLanguage(file.getLanguage()); + //TokenSet commentTokens = definition.getCommentTokens(); + //HighlighterIterator it = highlighter != null && PlatformIdTableBuilding.checkCanUseCachedEditorHighlighter(contents, highlighter) ? + // highlighter.createIterator(0) : null; + // + //do { + // if (it != null) { + // while (!it.atEnd() && !commentTokens.contains(it.getTokenType())) it.advance(); + // if (it.atEnd()) break; + // } + // int s0 = it == null ? 0 : it.getStart(); + // int s1 = it == null ? contents.length() : it.getEnd(); + // + // for () { .. } + // + // if (it != null && !it.atEnd()) it.advance(); + //} while (it != null && !it.atEnd()); + + //System.out.println(Thread.currentThread().getName() + ": " + file.getName() + "@" + file.hashCode() + " indexed: " + (System.currentTimeMillis() - time)); + return injectionMap; + } + private static final Pattern MAP_ENTRY_PATTERN = Pattern.compile("([\\S&&[^=]]+)=(\"(?:[^\"]|\\\\\")*\"|\\S*)"); public static Map<String, String> decodeMap(CharSequence charSequence) { if (StringUtil.isEmpty(charSequence)) return Collections.emptyMap(); @@ -259,68 +363,30 @@ public class InjectorUtils { return injection; } - @Nullable - public static <T> T findNearestComment(PsiElement element, NullableFunction<PsiComment, T> processor) { - if (element instanceof PsiComment) return null; - PsiFile containingFile = element.getContainingFile(); - - List<PsiLanguageInjectionHost> otherHosts = new SmartList<PsiLanguageInjectionHost>(); - - boolean commentOrSpaces = false; - - PsiElement prev = element, e = prevOrParent(element, containingFile); - for (int counter = 0; e != null && counter < 100; prev = e, e = prevOrParent(e, containingFile), counter ++) { - if (e instanceof PsiComment) { - commentOrSpaces = true; - PsiComment comment = (PsiComment)e; - if (!checkDepth(otherHosts, element, comment)) continue; - T value = processor.fun(comment); - if (value != null) return value; - } - else if (e instanceof PsiWhiteSpace) { - commentOrSpaces = true; - } - else if (e instanceof PsiLanguageInjectionHost) { - commentOrSpaces = StringUtil.isEmptyOrSpaces(e.getText()); // check getText only for hosts (XmlText) - if (!commentOrSpaces) otherHosts.add((PsiLanguageInjectionHost)e); - } - else { - commentOrSpaces = false; - } - } - if (commentOrSpaces) { // allow several comments - for (e = prevOrParent(prev, containingFile); e != null; e = e.getPrevSibling()) { - if (e instanceof PsiComment) { - PsiComment comment = (PsiComment)e; - if (!checkDepth(otherHosts, element, comment)) continue; - T value = processor.fun(comment); - if (value != null) return value; + private static Producer<PsiElement> prevWalker(final PsiElement element, final PsiElement scope) { + return new Producer<PsiElement>() { + PsiElement e = element; + + @Nullable + @Override + public PsiElement produce() { + if (e == null || e == scope) return null; + PsiElement prev = e.getPrevSibling(); + if (prev != null) { + e = prev; + while (true) { + PsiElement lastChild = e.getLastChild(); + if (lastChild == null) break; + e = lastChild; + } + return e; } - else if (!(e instanceof PsiWhiteSpace)) { - break; + else { + PsiElement parent = e.getParent(); + e = parent == scope || parent instanceof PsiFile ? null : parent; + return e; } } - } - return null; - } - - // allow java-like multi variable commenting: String s = "s", t = "t" - // a comment should cover all hosts in a subtree - private static boolean checkDepth(List<PsiLanguageInjectionHost> hosts, PsiElement element, PsiComment comment) { - if (hosts.isEmpty()) return true; - PsiElement parent = PsiTreeUtil.findCommonParent(comment, element); - for (PsiLanguageInjectionHost host : hosts) { - if (!PsiTreeUtil.isAncestor(parent, PsiTreeUtil.findCommonParent(host, element), true)) return false; - } - return true; - } - - @Nullable - public static PsiElement prevOrParent(PsiElement e, PsiElement scope) { - if (e == null || e == scope) return null; - PsiElement prev = e.getPrevSibling(); - if (prev != null) return PsiTreeUtil.getDeepestLast(prev); - PsiElement parent = e.getParent(); - return parent == scope || parent instanceof PsiFile ? null : parent; + }; } } diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java index d3a8d4cefc7b..d331042244a6 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/FlipAssertLiteralIntention.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2014 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ */ package com.siyeh.ipp.junit; -import com.intellij.codeInsight.AnnotationUtil; import com.intellij.psi.*; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; import com.siyeh.IntentionPowerPackBundle; import com.siyeh.ig.PsiReplacementUtil; @@ -67,11 +67,10 @@ public class FlipAssertLiteralIntention extends MutablyNamedIntention { @NonNls final StringBuilder newCall = new StringBuilder(); final PsiElement qualifier = methodExpression.getQualifier(); if (qualifier == null) { - final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(call, PsiMethod.class); - if (containingMethod != null && AnnotationUtil.isAnnotated(containingMethod, "org.junit.Test", true)) { - if (!ImportUtils.addStaticImport("org.junit.Assert", toMethodName, element)) { - newCall.append("org.junit.Assert."); - } + final PsiClass containingClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); + if (!InheritanceUtil.isInheritor(containingClass, "junit.framework.Assert") && + !ImportUtils.addStaticImport("org.junit.Assert", toMethodName, element)) { + newCall.append("org.junit.Assert."); } } else { @@ -88,6 +87,6 @@ public class FlipAssertLiteralIntention extends MutablyNamedIntention { newCall.append(BoolUtils.getNegatedExpressionText(arguments[1])); } newCall.append(')'); - PsiReplacementUtil.replaceExpression(call, newCall.toString()); + PsiReplacementUtil.replaceExpressionAndShorten(call, newCall.toString()); } }
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertEqualsWithAssertLiteralIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertEqualsWithAssertLiteralIntention.java index cb27659e0cc2..e972b18665ae 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertEqualsWithAssertLiteralIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertEqualsWithAssertLiteralIntention.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2014 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ */ package com.siyeh.ipp.junit; -import com.intellij.codeInsight.AnnotationUtil; import com.intellij.psi.*; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; import com.siyeh.IntentionPowerPackBundle; import com.siyeh.ig.PsiReplacementUtil; @@ -86,11 +86,10 @@ public class ReplaceAssertEqualsWithAssertLiteralIntention extends MutablyNamedI final PsiElement qualifier = expression.getQualifier(); @NonNls final StringBuilder newExpression = new StringBuilder(); if (qualifier == null) { - final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(call, PsiMethod.class); - if (containingMethod != null && AnnotationUtil.isAnnotated(containingMethod, "org.junit.Test", true)) { - if (!ImportUtils.addStaticImport("org.junit.Assert", assertString, element)) { - newExpression.append("org.junit.Assert."); - } + final PsiClass containingClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); + if (!InheritanceUtil.isInheritor(containingClass, "junit.framework.Assert") && + !ImportUtils.addStaticImport("org.junit.Assert", assertString, element)) { + newExpression.append("org.junit.Assert."); } } else { diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertLiteralWithAssertEqualsIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertLiteralWithAssertEqualsIntention.java index 7bc8b2beec90..a3e318e5196a 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertLiteralWithAssertEqualsIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/junit/ReplaceAssertLiteralWithAssertEqualsIntention.java @@ -1,5 +1,5 @@ /* - * Copyright 2003-2013 Dave Griffith, Bas Leijdekkers + * Copyright 2003-2014 Dave Griffith, Bas Leijdekkers * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ */ package com.siyeh.ipp.junit; -import com.intellij.codeInsight.AnnotationUtil; import com.intellij.psi.*; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.InheritanceUtil; import com.intellij.psi.util.PsiTreeUtil; import com.siyeh.IntentionPowerPackBundle; import com.siyeh.ig.PsiReplacementUtil; @@ -73,11 +73,10 @@ public class ReplaceAssertLiteralWithAssertEqualsIntention extends MutablyNamedI @NonNls final StringBuilder newExpression = new StringBuilder(); final PsiElement qualifier = methodExpression.getQualifier(); if (qualifier == null) { - final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(call, PsiMethod.class); - if (containingMethod != null && AnnotationUtil.isAnnotated(containingMethod, "org.junit.Test", true)) { - if (!ImportUtils.addStaticImport("org.junit.Assert", "assertEquals", element)) { - newExpression.append("org.junit.Assert."); - } + final PsiClass containingClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); + if (!InheritanceUtil.isInheritor(containingClass, "junit.framework.Assert") && + !ImportUtils.addStaticImport("org.junit.Assert", "assertEquals", element)) { + newExpression.append("org.junit.Assert."); } } else { diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java index 8ffc5eebfbe0..f26a41771228 100644 --- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java +++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceMethodRefWithLambdaIntention.java @@ -19,6 +19,7 @@ import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; import com.intellij.psi.codeStyle.JavaCodeStyleManager; +import com.intellij.psi.codeStyle.SuggestedNameInfo; import com.intellij.psi.codeStyle.VariableKind; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; @@ -45,24 +46,38 @@ public class ReplaceMethodRefWithLambdaIntention extends Intention { protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException { final PsiMethodReferenceExpression referenceExpression = PsiTreeUtil.getParentOfType(element, PsiMethodReferenceExpression.class); LOG.assertTrue(referenceExpression != null); + final PsiElement resolve = referenceExpression.resolve(); + final boolean isReceiver = resolve instanceof PsiMethod && PsiMethodReferenceUtil.hasReceiver(referenceExpression, (PsiMethod)resolve); + final PsiParameter[] psiParameters = resolve instanceof PsiMethod ? ((PsiMethod)resolve).getParameterList().getParameters() : null; final PsiType functionalInterfaceType = referenceExpression.getFunctionalInterfaceType(); final PsiClassType.ClassResolveResult functionalInterfaceResolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType); final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType); + LOG.assertTrue(interfaceMethod != null); + final PsiSubstitutor psiSubstitutor = LambdaUtil.getSubstitutor(interfaceMethod, functionalInterfaceResolveResult); final StringBuilder buf = new StringBuilder("("); LOG.assertTrue(functionalInterfaceType != null); buf.append(functionalInterfaceType.getCanonicalText()).append(")("); - LOG.assertTrue(interfaceMethod != null); - final PsiParameter[] parameters = interfaceMethod.getParameterList().getParameters(); + final PsiParameterList parameterList = interfaceMethod.getParameterList(); + final PsiParameter[] parameters = parameterList.getParameters(); final Map<PsiParameter, String> map = new HashMap<PsiParameter, String>(); final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(element.getProject()); final String paramsString = StringUtil.join(parameters, new Function<PsiParameter, String>() { @Override public String fun(PsiParameter parameter) { - String parameterName = parameter.getName(); - if (parameterName != null) { - final String baseName = codeStyleManager.variableNameToPropertyName(parameterName, VariableKind.PARAMETER); - parameterName = codeStyleManager.suggestUniqueVariableName(baseName, referenceExpression, true); + final int parameterIndex = parameterList.getParameterIndex(parameter); + String baseName; + if (isReceiver && parameterIndex == 0) { + final SuggestedNameInfo nameInfo = codeStyleManager.suggestVariableName(VariableKind.PARAMETER, null, null, psiSubstitutor.substitute(parameter.getType())); + baseName = nameInfo.names.length > 0 ? nameInfo.names[0] : parameter.getName(); + } + else { + final String initialName = psiParameters != null ? psiParameters[parameterIndex - (isReceiver ? 1 : 0)].getName() : parameter.getName(); + baseName = codeStyleManager.variableNameToPropertyName(initialName, VariableKind.PARAMETER); + } + + if (baseName != null) { + String parameterName = codeStyleManager.suggestUniqueVariableName(baseName, referenceExpression, true); map.put(parameter, parameterName); return parameterName; } @@ -92,11 +107,10 @@ public class ReplaceMethodRefWithLambdaIntention extends Intention { final boolean onArrayRef = JavaPsiFacade.getElementFactory(element.getProject()).getArrayClass(PsiUtil.getLanguageLevel(element)) == containingClass; - boolean isReceiver = PsiMethodReferenceUtil.isReceiverType(functionalInterfaceType, containingClass, resolveElement instanceof PsiMethod ? (PsiMethod)resolveElement : null); final PsiElement referenceNameElement = referenceExpression.getReferenceNameElement(); if (isReceiver){ - buf.append(parameters[0].getName()).append("."); + buf.append(map.get(parameters[0])).append("."); } else { if (!(referenceNameElement instanceof PsiKeyword)) { if (qualifier instanceof PsiTypeElement) { diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/ExistingStaticImport.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/ExistingStaticImport.java new file mode 100644 index 000000000000..96be19ed47a7 --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/ExistingStaticImport.java @@ -0,0 +1,11 @@ +import org.junit.Test; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +class X { + @Test + void t() { + <caret>assertTrue(true); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/ExistingStaticImport_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/ExistingStaticImport_after.java new file mode 100644 index 000000000000..8eccf08eb0ad --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/ExistingStaticImport_after.java @@ -0,0 +1,11 @@ +import org.junit.Test; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +class X { + @Test + void t() { + assertFalse(!true); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/StaticImportWithoutTestMethod.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/StaticImportWithoutTestMethod.java new file mode 100644 index 000000000000..369c92ea185f --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/StaticImportWithoutTestMethod.java @@ -0,0 +1,8 @@ +import static org.junit.Assert.assertTrue; + +class StaticImportWithoutTestMethod { + + void t() { + <caret>assertTrue(false); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/StaticImportWithoutTestMethod_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/StaticImportWithoutTestMethod_after.java new file mode 100644 index 000000000000..5bf7c4d7c1fb --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/flip_assert_literal/StaticImportWithoutTestMethod_after.java @@ -0,0 +1,9 @@ +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +class StaticImportWithoutTestMethod { + + void t() { + assertFalse(!false); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_equals_with_assert_literal/OutsideTestMethod.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_equals_with_assert_literal/OutsideTestMethod.java new file mode 100644 index 000000000000..5af128b5478b --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_equals_with_assert_literal/OutsideTestMethod.java @@ -0,0 +1,8 @@ +import static org.junit.Assert.assertEquals; + +class OutsideTestMethod { + + void m() { + <caret>assertEquals("asdf", null); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_equals_with_assert_literal/OutsideTestMethod_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_equals_with_assert_literal/OutsideTestMethod_after.java new file mode 100644 index 000000000000..e3291d9d271f --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_equals_with_assert_literal/OutsideTestMethod_after.java @@ -0,0 +1,9 @@ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +class OutsideTestMethod { + + void m() { + assertNull("asdf"); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_literal_with_assert_equals/OutsideTestMethod.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_literal_with_assert_equals/OutsideTestMethod.java new file mode 100644 index 000000000000..34c98500412e --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_literal_with_assert_equals/OutsideTestMethod.java @@ -0,0 +1,8 @@ +import static org.junit.Assert.assertNull; + +class OutsideTestMethod { + + void m() { + <caret>assertNull("asdf"); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_literal_with_assert_equals/OutsideTestMethod_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_literal_with_assert_equals/OutsideTestMethod_after.java new file mode 100644 index 000000000000..0d6315f93c7b --- /dev/null +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/junit/replace_assert_literal_with_assert_equals/OutsideTestMethod_after.java @@ -0,0 +1,9 @@ +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +class OutsideTestMethod { + + void m() { + assertEquals(null, "asdf"); + } +}
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Ambiguity_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Ambiguity_after.java index b0e14f13dad8..2d27aef15301 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Ambiguity_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Ambiguity_after.java @@ -14,6 +14,6 @@ public class MyTest { static void call(int i, I2 s) {} public static void main(String[] args) { - call(1, (x) -> MyTest.m(x)); + call(1, (i) -> MyTest.m(i)); } } diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/ArrayMethodRef_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/ArrayMethodRef_after.java index 65a55a55e8aa..94c8d2f42151 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/ArrayMethodRef_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/ArrayMethodRef_after.java @@ -1,6 +1,6 @@ public class Foo { static void foo() { - Cln j = (p) -> p.clone(); + Cln j = (ints) -> ints.clone(); } interface Cln { diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference1_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference1_after.java index b61947e47488..bd874395a9f5 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference1_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference1_after.java @@ -10,8 +10,8 @@ public class MyTest { static void m(I s) {} static { - m((s) -> { - new Foo<Integer>(s); + m((x) -> { + new Foo<Integer>(x); }); } } diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference_after.java index 22e5bef35348..cd937894625e 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInference_after.java @@ -11,6 +11,6 @@ public class MyTest<X> { } static { - I<String> s = (z) -> new MyTest<String>(z); + I<String> s = (x) -> new MyTest<String>(x); } }
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInnerClass_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInnerClass_after.java index 600af263857a..0d1106d8e4b6 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInnerClass_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsInnerClass_after.java @@ -8,6 +8,6 @@ class MyTest { } static { - I i1 = (receiver) -> new Inner(receiver); + I i1 = (mt) -> new Inner(mt); } } diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsStaticInnerClass_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsStaticInnerClass_after.java index fdce48211ed4..c26cd8a6d244 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsStaticInnerClass_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/NewRefsStaticInnerClass_after.java @@ -10,6 +10,6 @@ class MyTest { static { - I i1 = (receiver) -> new Inner(receiver); + I i1 = (outer) -> new Inner(outer); } } diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Receiver_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Receiver_after.java index 9f5bcafa929d..5b3eaf82c2b9 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Receiver_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Receiver_after.java @@ -11,6 +11,6 @@ public class MyTest { } static { - I i = (I) (receiver) -> receiver.m(); + I i = (I) (myTest) -> myTest.m(); } } diff --git a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Subst_after.java b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Subst_after.java index c719ccefa15b..2ff6feee03b9 100644 --- a/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Subst_after.java +++ b/plugins/IntentionPowerPak/test/com/siyeh/ipp/types/methodRefs2lambda/Subst_after.java @@ -5,5 +5,5 @@ class Bar { } class Test { - Comparator<Bar> comparator = (o1, o2) -> o1.xxx(o2); + Comparator<Bar> comparator = (bar, p) -> bar.xxx(p); }
\ No newline at end of file diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java index 98371872da52..4bd28a435688 100644 --- a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/FlipAssertLiteralIntentionTest.java @@ -10,6 +10,8 @@ import com.siyeh.ipp.IPPTestCase; public class FlipAssertLiteralIntentionTest extends IPPTestCase { public void testMessage() { doTest(); } + public void testExistingStaticImport() { doTest(); } + public void testStaticImportWithoutTestMethod() { doTest(); } @Override protected void setUp() throws Exception { @@ -18,6 +20,10 @@ public class FlipAssertLiteralIntentionTest extends IPPTestCase { "class Assert {" + " public static void assertTrue(java.lang.String message, boolean condition) {}" + "}"); + myFixture.addClass("package org.junit;" + + "@Retention(RetentionPolicy.RUNTIME)" + + "@Target({ElementType.METHOD})" + + "public @interface Test {}"); } @Override diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/ReplaceAssertEqualsWithAssertLiteralIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/ReplaceAssertEqualsWithAssertLiteralIntentionTest.java new file mode 100644 index 000000000000..529beaa1c348 --- /dev/null +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/ReplaceAssertEqualsWithAssertLiteralIntentionTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ipp.junit; + +import com.siyeh.IntentionPowerPackBundle; +import com.siyeh.ipp.IPPTestCase; + +/** + * @see ReplaceAssertEqualsWithAssertLiteralIntention + * @author Bas Leijdekkers + */ +public class ReplaceAssertEqualsWithAssertLiteralIntentionTest extends IPPTestCase { + + public void testOutsideTestMethod() { doTest(); } + + @Override + protected void setUp() throws Exception { + super.setUp(); + myFixture.addClass("package org.junit;" + + "class Assert {" + + " static public void assertEquals(Object expected, Object actual) {}" + + "}"); + } + + @Override + protected String getRelativePath() { + return "junit/replace_assert_equals_with_assert_literal"; + } + + @Override + protected String getIntentionName() { + return IntentionPowerPackBundle.message("replace.assert.equals.with.assert.literal.intention.name", "assertNull"); + } +} diff --git a/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/ReplaceAssertLiteralWithAssertEqualsIntentionTest.java b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/ReplaceAssertLiteralWithAssertEqualsIntentionTest.java new file mode 100644 index 000000000000..00be3ec3e87f --- /dev/null +++ b/plugins/IntentionPowerPak/testSrc/com/siyeh/ipp/junit/ReplaceAssertLiteralWithAssertEqualsIntentionTest.java @@ -0,0 +1,47 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ipp.junit; + +import com.siyeh.IntentionPowerPackBundle; +import com.siyeh.ipp.IPPTestCase; + +/** + * @see com.siyeh.ipp.junit.ReplaceAssertLiteralWithAssertEqualsIntention + * @author Bas Leijdekkers + */ +public class ReplaceAssertLiteralWithAssertEqualsIntentionTest extends IPPTestCase { + + public void testOutsideTestMethod() { doTest(); } + + @Override + protected void setUp() throws Exception { + super.setUp(); + myFixture.addClass("package org.junit;" + + "class Assert {" + + " static public void assertNull(Object actual) {}" + + "}"); + } + + @Override + protected String getRelativePath() { + return "junit/replace_assert_literal_with_assert_equals"; + } + + @Override + protected String getIntentionName() { + return IntentionPowerPackBundle.message("replace.assert.literal.with.assert.equals.intention.name", "assertNull", "null"); + } +} diff --git a/plugins/copyright/src/META-INF/plugin.xml b/plugins/copyright/src/META-INF/plugin.xml index ea667615982f..8d0c4b038d85 100644 --- a/plugins/copyright/src/META-INF/plugin.xml +++ b/plugins/copyright/src/META-INF/plugin.xml @@ -11,7 +11,7 @@ <depends optional="true" config-file="java.xml">com.intellij.modules.java</depends> <extensions defaultExtensionNs="com.intellij"> - <projectConfigurable instance="com.maddyhome.idea.copyright.ui.CopyrightProjectConfigurable"/> + <projectConfigurable groupId="editor" dynamic="true" displayName="Copyright" instance="com.maddyhome.idea.copyright.ui.CopyrightProjectConfigurable"/> <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/> <checkinHandlerFactory implementation="com.maddyhome.idea.copyright.actions.UpdateCopyrightCheckinHandlerFactory"/> <applicationService serviceInterface="com.maddyhome.idea.copyright.util.FileTypeUtil" diff --git a/plugins/coverage-common/src/META-INF/coverage-common-plugin.xml b/plugins/coverage-common/src/META-INF/coverage-common-plugin.xml index dcc83cecb41c..028b043cf6d0 100644 --- a/plugins/coverage-common/src/META-INF/coverage-common-plugin.xml +++ b/plugins/coverage-common/src/META-INF/coverage-common-plugin.xml @@ -8,7 +8,7 @@ <extensions defaultExtensionNs="com.intellij"> <testActionProvider implementation="com.intellij.coverage.actions.TrackCoverageActionProvider"/> <projectViewNodeDecorator implementation="com.intellij.coverage.CoverageProjectViewDirectoryNodeDecorator"/> - <projectConfigurable instance="com.intellij.coverage.CoverageOptionsConfigurable" id="coverage" displayName="Coverage" /> + <projectConfigurable groupId="build" instance="com.intellij.coverage.CoverageOptionsConfigurable" id="coverage" displayName="Coverage" /> <projectService serviceImplementation="com.intellij.coverage.CoverageOptionsProvider"/> <projectService serviceImplementation="com.intellij.coverage.view.CoverageViewManager"/> <executor implementation="com.intellij.coverage.CoverageExecutor" /> diff --git a/plugins/coverage/src/com/intellij/execution/configurations/coverage/JavaCoverageEnabledConfiguration.java b/plugins/coverage/src/com/intellij/execution/configurations/coverage/JavaCoverageEnabledConfiguration.java index f8d3c14ace28..6a2ca1ff2f18 100644 --- a/plugins/coverage/src/com/intellij/execution/configurations/coverage/JavaCoverageEnabledConfiguration.java +++ b/plugins/coverage/src/com/intellij/execution/configurations/coverage/JavaCoverageEnabledConfiguration.java @@ -23,6 +23,7 @@ import com.intellij.coverage.JavaCoverageRunner; import com.intellij.execution.configurations.RunConfigurationBase; import com.intellij.execution.configurations.SimpleJavaParameters; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.util.DefaultJDOMExternalizer; import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.WriteExternalException; import com.intellij.ui.classFilter.ClassFilter; @@ -116,6 +117,7 @@ public class JavaCoverageEnabledConfiguration extends CoverageEnabledConfigurati myCoveragePatterns = coveragePatterns; } + @Override public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); @@ -126,14 +128,13 @@ public class JavaCoverageEnabledConfiguration extends CoverageEnabledConfigurati mySuiteToMergeWith = element.getAttributeValue(COVERAGE_MERGE_SUITE_ATT_NAME); // coverage patters - final List children = element.getChildren(COVERAGE_PATTERN_ELEMENT_NAME); + List<Element> children = element.getChildren(COVERAGE_PATTERN_ELEMENT_NAME); if (children.size() > 0) { myCoveragePatterns = new ClassFilter[children.size()]; for (int i = 0; i < children.size(); i++) { - myCoveragePatterns[i] = new ClassFilter(); - @NonNls final Element e = (Element)children.get(i); - myCoveragePatterns[i].readExternal(e); - final String val = e.getAttributeValue("value"); + Element e = children.get(i); + myCoveragePatterns[i] = createClassFilter(e); + String val = e.getAttributeValue("value"); if (val != null) { myCoveragePatterns[i].setPattern(val); } @@ -141,6 +142,13 @@ public class JavaCoverageEnabledConfiguration extends CoverageEnabledConfigurati } } + public static ClassFilter createClassFilter(Element element) throws InvalidDataException { + ClassFilter filter = new ClassFilter(); + DefaultJDOMExternalizer.readExternal(filter, element); + return filter; + } + + @Override public void writeExternal(Element element) throws WriteExternalException { // just for backward compatibility with settings format before "Huge Coverage Refactoring" // see [IDEA-56800] ProjectRunConfigurationManager component: "coverage" extension: "merge" attribute is misplaced @@ -187,12 +195,13 @@ public class JavaCoverageEnabledConfiguration extends CoverageEnabledConfigurati if (myCoveragePatterns != null) { for (ClassFilter pattern : myCoveragePatterns) { @NonNls final Element patternElement = new Element(COVERAGE_PATTERN_ELEMENT_NAME); - pattern.writeExternal(patternElement); + DefaultJDOMExternalizer.writeExternal(pattern, patternElement); element.addContent(patternElement); } } } + @Override @Nullable public String getCoverageFilePath() { if (myCoverageFilePath != null ) { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsstatuses/CvsChangeProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsstatuses/CvsChangeProvider.java index ee82d0874566..a2e055b7b283 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsstatuses/CvsChangeProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsstatuses/CvsChangeProvider.java @@ -169,7 +169,7 @@ public class CvsChangeProvider implements ChangeProvider { for (VirtualFile file : children) { progress.checkCanceled(); if (file.isDirectory()) { - final boolean isIgnored = myFileIndex.isIgnored(file); + final boolean isIgnored = myFileIndex.isExcluded(file); if (!isIgnored) { processEntriesIn(file, scope, builder, true, progress); } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportTree.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportTree.java index 99f038430b9b..3877a78a0d35 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportTree.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/ui/experts/importToCvs/ImportTree.java @@ -151,11 +151,11 @@ public class ImportTree extends NodeRenderer { return; } final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); - if (!fileIndex.isIgnored(selectedFile)) { + if (!fileIndex.isExcluded(selectedFile)) { return; } final VirtualFile parent = selectedFile.getParent(); - if (parent != null && fileIndex.isIgnored(parent)) { + if (parent != null && fileIndex.isExcluded(parent)) { return; } for (final VirtualFile excludedFile : myExcludedFiles) { @@ -183,11 +183,11 @@ public class ImportTree extends NodeRenderer { continue; } final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); - if (!fileIndex.isIgnored(selectedFile)) { + if (!fileIndex.isExcluded(selectedFile)) { continue; } final VirtualFile parent = selectedFile.getParent(); - if (parent == null || fileIndex.isIgnored(parent) || myExcludedFiles.contains(parent)) { + if (parent == null || fileIndex.isExcluded(parent) || myExcludedFiles.contains(parent)) { continue; } if (!myIncludedFiles.contains(selectedFile)) { @@ -211,7 +211,7 @@ public class ImportTree extends NodeRenderer { return true; } } - if (myProject == null || !ProjectRootManager.getInstance(myProject).getFileIndex().isIgnored(file)) { + if (myProject == null || !ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(file)) { return false; } for (VirtualFile includedFile : myIncludedFiles) { @@ -242,7 +242,7 @@ public class ImportTree extends NodeRenderer { if (FileTypeManager.getInstance().isFileIgnored(abstractFileObject.getName())) return true; if (myProject != null && !includedFiles.contains(file)) { final VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(file); - if (vFile != null && ProjectRootManager.getInstance(myProject).getFileIndex().isIgnored(vFile)) { + if (vFile != null && ProjectRootManager.getInstance(myProject).getFileIndex().isExcluded(vFile)) { return true; } } diff --git a/plugins/devkit/resources/META-INF/plugin.xml b/plugins/devkit/resources/META-INF/plugin.xml index d92839c2df6c..9bb838c8e02c 100644 --- a/plugins/devkit/resources/META-INF/plugin.xml +++ b/plugins/devkit/resources/META-INF/plugin.xml @@ -27,7 +27,6 @@ <junitPatcher implementation="org.jetbrains.idea.devkit.run.JUnitDevKitPatcher"/> <antBuildGen implementation="org.jetbrains.idea.devkit.build.ant.ChunkBuildPluginExtension"/> - <compiler.buildParticipantProvider implementation="org.jetbrains.idea.devkit.build.PluginBuildParticipantProvider"/> <compiler.buildTargetScopeProvider implementation="org.jetbrains.idea.devkit.build.PluginModuleBuildScopeProvider"/> <dom.fileDescription implementation="org.jetbrains.idea.devkit.dom.impl.PluginXmlDomFileDescription"/> @@ -46,6 +45,7 @@ <dom.implementation interfaceClass="org.jetbrains.idea.devkit.dom.Extensions" implementationClass="org.jetbrains.idea.devkit.dom.impl.ExtensionsImpl"/> <useScopeEnlarger implementation="org.jetbrains.idea.devkit.DevKitUseScopeEnlarger"/> + <properties.implicitPropertyUsageProvider implementation="org.jetbrains.idea.devkit.references.RegistryImplicitPropertyUsageProvider"/> <configurationType implementation="org.jetbrains.idea.devkit.run.PluginConfigurationType"/> <moduleType id="PLUGIN_MODULE" implementationClass="org.jetbrains.idea.devkit.module.PluginModuleType" classpathProvider="true"/> diff --git a/plugins/devkit/src/build/PluginBuildConfiguration.java b/plugins/devkit/src/build/PluginBuildConfiguration.java index 3604b0f0d13a..1155402e3f39 100644 --- a/plugins/devkit/src/build/PluginBuildConfiguration.java +++ b/plugins/devkit/src/build/PluginBuildConfiguration.java @@ -54,13 +54,11 @@ public class PluginBuildConfiguration implements ModuleComponent, JDOMExternaliz @NonNls private static final String MANIFEST_ATTR = "manifest"; @NonNls private static final String META_INF = "META-INF"; @NonNls private static final String PLUGIN_XML = "plugin.xml"; - private final PluginBuildParticipant myBuildParticipant; public PluginBuildConfiguration(Module module) { myModule = module; myPluginXmlContainer = ConfigFileFactory.getInstance().createSingleFileContainer(myModule.getProject(), PluginDescriptorConstants.META_DATA); Disposer.register(module, myPluginXmlContainer); - myBuildParticipant = new PluginBuildParticipant(module, this); } @Nullable @@ -203,8 +201,4 @@ public class PluginBuildConfiguration implements ModuleComponent, JDOMExternaliz public void setUseUserManifest(final boolean useUserManifest) { myUseUserManifest = useUserManifest; } - - public PluginBuildParticipant getBuildParticipant() { - return myBuildParticipant; - } } diff --git a/plugins/devkit/src/build/PluginBuildParticipant.java b/plugins/devkit/src/build/PluginBuildParticipant.java deleted file mode 100644 index 75f6c7cf3046..000000000000 --- a/plugins/devkit/src/build/PluginBuildParticipant.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.devkit.build; - -import com.intellij.openapi.compiler.CompileContext; -import com.intellij.openapi.compiler.CompilerMessageCategory; -import com.intellij.openapi.compiler.make.BuildParticipant; -import com.intellij.openapi.deployment.DeploymentUtil; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.roots.ModuleRootManager; -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.libraries.Library; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.JarFileSystem; -import com.intellij.openapi.vfs.VfsUtil; -import com.intellij.openapi.vfs.VfsUtilCore; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.packaging.artifacts.Artifact; -import com.intellij.packaging.elements.ArtifactRootElement; -import com.intellij.packaging.elements.CompositePackagingElement; -import com.intellij.packaging.elements.PackagingElement; -import com.intellij.packaging.elements.PackagingElementFactory; -import com.intellij.packaging.impl.artifacts.ArtifactImpl; -import com.intellij.packaging.impl.artifacts.PlainArtifactType; -import com.intellij.psi.xml.XmlDocument; -import com.intellij.psi.xml.XmlFile; -import com.intellij.psi.xml.XmlTag; -import com.intellij.util.descriptors.ConfigFile; -import com.intellij.util.xml.DomElement; -import com.intellij.util.xml.DomManager; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.idea.devkit.DevKitBundle; -import org.jetbrains.idea.devkit.dom.Dependency; -import org.jetbrains.idea.devkit.dom.IdeaPlugin; -import org.jetbrains.idea.devkit.module.PluginModuleType; -import org.jetbrains.idea.devkit.projectRoots.IdeaJdk; -import org.jetbrains.idea.devkit.util.DescriptorUtil; - -import java.util.HashSet; -import java.util.List; - -/** - * @author peter -*/ -public class PluginBuildParticipant extends BuildParticipant { - @NonNls private static final String CLASSES = "/classes"; - @NonNls private static final String LIB = "/lib/"; - @NonNls private static final String LIB_DIRECTORY = "lib"; - private final Module myModule; - private final PluginBuildConfiguration myPluginBuildConfiguration; - - public PluginBuildParticipant(final Module module, final PluginBuildConfiguration pluginBuildConfiguration) { - super(); - myModule = module; - myPluginBuildConfiguration = pluginBuildConfiguration; - } - - @Override - public Artifact createArtifact(CompileContext context) { - Sdk sdk = IdeaJdk.findIdeaJdk(ModuleRootManager.getInstance(myModule).getSdk()); - if (sdk != null && IdeaJdk.isFromIDEAProject(sdk.getHomePath())) { - return null; - } - - if (sdk == null) { - context.addMessage(CompilerMessageCategory.ERROR, DevKitBundle.message("sdk.type.incorrect", myModule.getName()), null, -1, -1); - return null; - } - - final String outputPath = PluginBuildUtil.getPluginExPath(myModule); - if (outputPath == null) { - return null; - } - - if (!checkDependencies(context)) { - return null; - } - - - final PackagingElementFactory factory = PackagingElementFactory.getInstance(); - final ArtifactRootElement<?> root = factory.createArtifactRootElement(); - - ConfigFile configFile = myPluginBuildConfiguration.getPluginXML(); - if (configFile != null) { - DeploymentUtil.getInstance().checkConfigFile(configFile, context, myModule); - factory.addFileCopy(root, "META-INF/", VfsUtil.urlToPath(configFile.getUrl())); - - final XmlFile xmlFile = configFile.getXmlFile(); - if (xmlFile != null) { - final XmlDocument document = xmlFile.getDocument(); - if (document != null) { - final DomElement domElement = DomManager.getDomManager(xmlFile.getProject()).getDomElement(document.getRootTag()); - if (domElement instanceof IdeaPlugin) { - for(Dependency dependency: ((IdeaPlugin)domElement).getDependencies()) { - final String file = dependency.getConfigFile().getStringValue(); - if (file != null) { - final VirtualFile virtualFile = configFile.getVirtualFile(); - assert virtualFile != null; - final VirtualFile parent = virtualFile.getParent(); - assert parent != null; - final String url = parent.getUrl(); - factory.addFileCopy(root, "META-INF/", VfsUtil.urlToPath(url) + "/" + file); - } - } - } - } - } - } - - HashSet<Module> modules = new HashSet<Module>(); - PluginBuildUtil.getDependencies(myModule, modules); - - final CompositePackagingElement<?> classesDir = factory.getOrCreateDirectory(root, CLASSES); - for (Module dep : modules) { - classesDir.addOrFindChild(factory.createModuleOutput(dep)); - } - classesDir.addOrFindChild(factory.createModuleOutput(myModule)); - - HashSet<Library> libs = new HashSet<Library>(); - PluginBuildUtil.getLibraries(myModule, libs); - for (Module dependentModule : modules) { - PluginBuildUtil.getLibraries(dependentModule, libs); - } - - - // libraries - final VirtualFile libDir = sdk.getHomeDirectory().findFileByRelativePath(LIB_DIRECTORY); - for (Library library : libs) { - boolean hasDirsOnly = true; - VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); - for (VirtualFile file : files) { - if (file.getFileSystem() instanceof JarFileSystem) { - hasDirsOnly = false; - file = ((JarFileSystem)file.getFileSystem()).getVirtualFileForJar(file); - } - if (libDir != null && file != null && VfsUtilCore.isAncestor(libDir, file, false)) { - context.addMessage(CompilerMessageCategory.ERROR, DevKitBundle.message("dont.add.idea.libs.to.classpath", file.getName()), null, - -1, -1); - } - } - - final List<? extends PackagingElement<?>> elements = factory.createLibraryElements(library); - if (hasDirsOnly) { - //todo split one lib into 2 separate libs if there are jars and dirs - classesDir.addOrFindChildren(elements); - } - else { - factory.getOrCreateDirectory(root, LIB).addOrFindChildren(elements); - } - } - - return new ArtifactImpl(getArtifactName(), PlainArtifactType.getInstance(), false, root, FileUtil.toSystemIndependentName(outputPath)); - } - - private String getArtifactName() { - return myModule.getName() + ":plugin"; - } - - private boolean checkDependencies(CompileContext context) { - final Module[] wrongSetDependencies = PluginBuildUtil.getWrongSetDependencies(myModule); - if (wrongSetDependencies.length != 0) { - boolean realProblems = false; - final String pluginId = DescriptorUtil.getPluginId(myModule); - - for (Module dependency : wrongSetDependencies) { - if (!PluginModuleType.isOfType(dependency)) { - realProblems = true; - context.addMessage(CompilerMessageCategory.ERROR, - DevKitBundle.message("incorrect.dependency.non-plugin-module", dependency.getName(), myModule.getName()), null, - -1, -1); - } - else { - final XmlFile pluginXml = PluginModuleType.getPluginXml(dependency); - boolean isDeclared = false; - if (pluginXml != null) { - final XmlTag rootTag = pluginXml.getDocument().getRootTag(); - final XmlTag[] dependencies = rootTag != null ? rootTag.findSubTags("depends") : XmlTag.EMPTY; - for (XmlTag dep : dependencies) { - if (dep.getValue().getTrimmedText().equals(pluginId)) { - isDeclared = true; - break; - } - } - } - if (!isDeclared) { - // make this a warning instead? - realProblems = true; - context.addMessage(CompilerMessageCategory.ERROR, - DevKitBundle.message("incorrect.dependency.not-declared", dependency.getName(), myModule.getName()), null, -1, - -1); - } - } - } - if (realProblems) return false; - } - return true; - } - -} diff --git a/plugins/devkit/src/build/PluginBuildParticipantProvider.java b/plugins/devkit/src/build/PluginBuildParticipantProvider.java deleted file mode 100644 index b8a35d377a96..000000000000 --- a/plugins/devkit/src/build/PluginBuildParticipantProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.idea.devkit.build; - -import com.intellij.openapi.compiler.make.BuildParticipantProvider; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleType; -import org.jetbrains.idea.devkit.module.PluginModuleType; - -import java.util.Collection; -import java.util.Collections; - -/** - * @author nik - */ -public class PluginBuildParticipantProvider extends BuildParticipantProvider { - public Collection<PluginBuildParticipant> getParticipants(final Module module) { - if (ModuleType.get(module) != PluginModuleType.getInstance()) { - return Collections.emptyList(); - } - - final PluginBuildConfiguration configuration = PluginBuildConfiguration.getInstance(module); - return configuration != null ? Collections.singletonList(configuration.getBuildParticipant()) - : Collections.<PluginBuildParticipant>emptyList(); - } -} diff --git a/plugins/devkit/src/references/RegistryImplicitPropertyUsageProvider.java b/plugins/devkit/src/references/RegistryImplicitPropertyUsageProvider.java new file mode 100644 index 000000000000..d40f100e4111 --- /dev/null +++ b/plugins/devkit/src/references/RegistryImplicitPropertyUsageProvider.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.devkit.references; + +import com.intellij.codeInspection.unused.ImplicitPropertyUsageProvider; +import com.intellij.lang.properties.psi.Property; +import com.intellij.psi.PsiFile; +import org.jetbrains.idea.devkit.util.PsiUtil; + +/** + * @author Konstantin Bulenkov + */ +public class RegistryImplicitPropertyUsageProvider extends ImplicitPropertyUsageProvider { + @Override + protected boolean isUsed(Property property) { + if (PsiUtil.isIdeaProject(property.getProject())) { + final PsiFile file = property.getContainingFile(); + if (file != null && file.getName().equals("registry.properties")) { + final String name = property.getName(); + return name.endsWith(".description") || name.endsWith(".restartRequired"); + } + } + return false; + } +} diff --git a/plugins/devkit/src/testAssistant/TestDataGuessByExistingFilesUtil.java b/plugins/devkit/src/testAssistant/TestDataGuessByExistingFilesUtil.java index e37fb720c25a..b5763cc663c7 100644 --- a/plugins/devkit/src/testAssistant/TestDataGuessByExistingFilesUtil.java +++ b/plugins/devkit/src/testAssistant/TestDataGuessByExistingFilesUtil.java @@ -34,6 +34,7 @@ import com.intellij.psi.codeStyle.NameUtil; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.testIntegration.TestFramework; import com.intellij.util.PathUtil; +import com.intellij.util.Processor; import com.intellij.util.containers.ConcurrentHashMap; import com.intellij.util.containers.HashSet; import com.intellij.util.containers.LinkedMultiMap; @@ -389,17 +390,21 @@ public class TestDataGuessByExistingFilesUtil { return new TestDataDescriptor(descriptors); } - private static synchronized MultiMap<String, Trinity<Matcher, String, String>> getAllFileNames(List<Trinity<Matcher, String, String>> input, + private static MultiMap<String, Trinity<Matcher, String, String>> getAllFileNames(final List<Trinity<Matcher, String, String>> input, final GotoFileModel model) { - LinkedMultiMap<String, Trinity<Matcher, String, String>> map = new LinkedMultiMap<String, Trinity<Matcher, String, String>>(); - for (String name : model.getNames(false)) { - ProgressManager.checkCanceled(); - for (Trinity<Matcher, String, String> trinity : input) { - if (trinity.first.matches(name)) { - map.putValue(name, trinity); + final LinkedMultiMap<String, Trinity<Matcher, String, String>> map = new LinkedMultiMap<String, Trinity<Matcher, String, String>>(); + model.processNames(new Processor<String>() { + @Override + public boolean process(String name) { + ProgressManager.checkCanceled(); + for (Trinity<Matcher, String, String> trinity : input) { + if (trinity.first.matches(name)) { + map.putValue(name, trinity); + } } + return true; } - } + }, false); return map; } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java index c5a23e1b1d43..a29672091751 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EPathUtil.java @@ -149,7 +149,7 @@ public class EPathUtil { return collapse2eclipsePathRelative2Module(file, module); } else { //should check all modules then final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); - if (fileIndex.isIgnored(file) || fileIndex.isInLibraryClasses(file)) { + if (fileIndex.isExcluded(file) || fileIndex.isInLibraryClasses(file)) { for (Module aModule : ModuleManager.getInstance(project).getModules()) { final String path = collapse2eclipsePathRelative2Module(file, aModule); if (path != null) { diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java index ffd71fd6ef76..4541cf57f7a7 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java @@ -451,7 +451,7 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module != null) { return appendRelatedToModule(element, classesUrl, rootName, file, module); - } else if (ProjectRootManager.getInstance(project).getFileIndex().isIgnored(file)) { + } else if (ProjectRootManager.getInstance(project).getFileIndex().isExcluded(file)) { for (Module aModule : ModuleManager.getInstance(project).getModules()) { if (appendRelatedToModule(element, classesUrl, rootName, file, aModule)) return true; } diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java index 20fe160cb399..1f8f93accd89 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepBase.java @@ -16,6 +16,7 @@ package com.intellij.remoteServer.util.importProject; import com.intellij.ide.util.projectWizard.ModuleWizardStep; +import com.intellij.ide.util.projectWizard.WizardContext; import com.intellij.openapi.module.Module; import com.intellij.openapi.options.ConfigurationException; import com.intellij.remoteServer.ServerType; @@ -25,11 +26,12 @@ import com.intellij.remoteServer.util.CloudDeploymentNameConfiguration; import com.intellij.remoteServer.util.CloudGitDeploymentDetector; import javax.swing.*; +import java.util.Collections; /** * @author michael.golubev */ -public abstract class CloudGitChooseAccountStepBase extends ModuleWizardStep { +public class CloudGitChooseAccountStepBase extends ModuleWizardStep { private JPanel myAccountSelectionPanelPlaceHolder; private JPanel myMainPanel; @@ -38,14 +40,15 @@ public abstract class CloudGitChooseAccountStepBase extends ModuleWizardStep { private CloudAccountSelectionEditor myEditor; private final CloudGitDeploymentDetector myDeploymentDetector; + private final WizardContext myContext; - public CloudGitChooseAccountStepBase(CloudGitDeploymentDetector deploymentDetector) { + public CloudGitChooseAccountStepBase(CloudGitDeploymentDetector deploymentDetector, WizardContext context) { myDeploymentDetector = deploymentDetector; + myContext = context; ServerType cloudType = deploymentDetector.getCloudType(); myTitleLabel.setText(CloudBundle.getText("choose.account.title", cloudType.getPresentableName())); - myEditor = new CloudAccountSelectionEditor(cloudType); + myEditor = new CloudAccountSelectionEditor(Collections.<ServerType<?>>singletonList(cloudType)); myAccountSelectionPanelPlaceHolder.add(myEditor.getMainPanel()); - myEditor.initUI(); } protected CloudGitDeploymentDetector getDeploymentDetector() { @@ -63,6 +66,11 @@ public abstract class CloudGitChooseAccountStepBase extends ModuleWizardStep { return super.validate(); } + @Override + public void updateDataModel() { + myEditor.setAccountOnContext(myContext); + } + public void createRunConfiguration(Module module, String applicationName) { CloudDeploymentNameConfiguration deploymentConfiguration = myDeploymentDetector.createDeploymentConfiguration(); @@ -72,6 +80,6 @@ public abstract class CloudGitChooseAccountStepBase extends ModuleWizardStep { deploymentConfiguration.setDeploymentName(applicationName); } - myEditor.createRunConfiguration(module, deploymentConfiguration); + CloudAccountSelectionEditor.createRunConfiguration(myContext, myDeploymentDetector.getCloudType(), module, deploymentConfiguration); } } diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java index 74f4d22e32c3..1de4eff05368 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitChooseAccountStepImpl.java @@ -55,7 +55,7 @@ public class CloudGitChooseAccountStepImpl extends CloudGitChooseAccountStepBase CloudGitProjectStructureDetector structureDetector, ProjectFromSourcesBuilder builder, ProjectDescriptor projectDescriptor) { - super(deploymentDetector); + super(deploymentDetector, builder.getContext()); myBuilder = builder; myProjectDescriptor = projectDescriptor; @@ -82,6 +82,7 @@ public class CloudGitChooseAccountStepImpl extends CloudGitChooseAccountStepBase @Override public void updateDataModel() { + super.updateDataModel(); final MultiMap<CloudGitProjectRoot, DetectedSourceRoot> project2sourceRoots = new MultiMap<CloudGitProjectRoot, DetectedSourceRoot>(); new RootIterator() { diff --git a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java index f253a3de2894..704ced7f3d05 100644 --- a/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java +++ b/plugins/git4idea/remote-servers-git/src/com/intellij/remoteServer/util/importProject/CloudGitRemoteDetector.java @@ -34,6 +34,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.MessageType; +import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.remoteServer.ServerType; @@ -258,20 +259,14 @@ public class CloudGitRemoteDetector extends AbstractProjectComponent implements ImportModuleAction.createFromWizard(myProject, wizard); } else { - final CloudGitChooseAccountStepBase chooseAccountStep - = new CloudGitChooseAccountStepBase(myDeploymentDetector) { - - @Override - public void updateDataModel() { - - } - }; - + final Ref<CloudGitChooseAccountStepBase> chooseAccountStepRef = new Ref<CloudGitChooseAccountStepBase>(); if (!new AbstractProjectWizard(CloudBundle.getText("choose.account.wizzard.title", myCloudName), myProject, (String)null) { final StepSequence myStepSequence; { + CloudGitChooseAccountStepBase chooseAccountStep = new CloudGitChooseAccountStepBase(myDeploymentDetector, myWizardContext); + chooseAccountStepRef.set(chooseAccountStep); myStepSequence = new StepSequence(chooseAccountStep); addStep(chooseAccountStep); init(); @@ -284,7 +279,7 @@ public class CloudGitRemoteDetector extends AbstractProjectComponent implements }.showAndGet()) { return; } - chooseAccountStep.createRunConfiguration(targetModule, myApplicationName); + chooseAccountStepRef.get().createRunConfiguration(targetModule, myApplicationName); } } } diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index 4286aee1536b..5f56de5674e1 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -18,6 +18,8 @@ package git4idea; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Collections2; +import com.intellij.ide.file.BatchFileChangeListener; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressIndicator; @@ -43,6 +45,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Consumer; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.io.storage.HeavyProcessLatch; import com.intellij.util.ui.UIUtil; import com.intellij.vcsUtil.VcsFileUtil; import com.intellij.vcsUtil.VcsUtil; @@ -1010,4 +1013,15 @@ public class GitUtil { builder.setTitle(title); builder.show(); } + + public static void workingTreeChangeStarted(@NotNull Project project) { + HeavyProcessLatch.INSTANCE.processStarted(); + ApplicationManager.getApplication().getMessageBus().syncPublisher(BatchFileChangeListener.TOPIC).batchChangeStarted(project); + } + + public static void workingTreeChangeFinished(@NotNull Project project) { + HeavyProcessLatch.INSTANCE.processFinished(); + ApplicationManager.getApplication().getMessageBus().syncPublisher(BatchFileChangeListener.TOPIC).batchChangeCompleted(project); + } + } diff --git a/plugins/git4idea/src/git4idea/actions/GitMergeAction.java b/plugins/git4idea/src/git4idea/actions/GitMergeAction.java index 1d46335cc1b1..e8bc37929a0d 100644 --- a/plugins/git4idea/src/git4idea/actions/GitMergeAction.java +++ b/plugins/git4idea/src/git4idea/actions/GitMergeAction.java @@ -81,27 +81,34 @@ abstract class GitMergeAction extends GitRepositoryAction { final Git git = ServiceManager.getService(Git.class); final GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = new GitLocalChangesWouldBeOverwrittenDetector(selectedRoot, MERGE); - final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = + final GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(selectedRoot); - GitCommandResult result = git.runCommand(new Computable<GitLineHandler>() { - @Override - public GitLineHandler compute() { - GitLineHandler handler = handlerProvider.compute(); - handler.addLineListener(localChangesDetector); - handler.addLineListener(untrackedFilesDetector); - return handler; - } - }); - affectedRoots.add(selectedRoot); - GitRepository repository = repositoryManager.getRepositoryForRoot(selectedRoot); - assert repository != null : "Repository can't be null for root " + selectedRoot; - String revision = repository.getCurrentRevision(); - if (revision == null) { - return; + GitUtil.workingTreeChangeStarted(project); + try { + GitCommandResult result = git.runCommand(new Computable<GitLineHandler>() { + @Override + public GitLineHandler compute() { + GitLineHandler handler = handlerProvider.compute(); + handler.addLineListener(localChangesDetector); + handler.addLineListener(untrackedFilesDetector); + return handler; + } + }); + affectedRoots.add(selectedRoot); + + GitRepository repository = repositoryManager.getRepositoryForRoot(selectedRoot); + assert repository != null : "Repository can't be null for root " + selectedRoot; + String revision = repository.getCurrentRevision(); + if (revision == null) { + return; + } + final GitRevisionNumber currentRev = new GitRevisionNumber(revision); + handleResult(result, project, localChangesDetector, untrackedFilesDetector, repository, currentRev, affectedRoots, beforeLabel); + } + finally { + GitUtil.workingTreeChangeFinished(project); } - final GitRevisionNumber currentRev = new GitRevisionNumber(revision); - handleResult(result, project, localChangesDetector, untrackedFilesDetector, repository, currentRev, affectedRoots, beforeLabel); } }.queue(); diff --git a/plugins/git4idea/src/git4idea/actions/GitRebaseAbort.java b/plugins/git4idea/src/git4idea/actions/GitRebaseAbort.java index 5b56884400ab..a3c4497e4dce 100644 --- a/plugins/git4idea/src/git4idea/actions/GitRebaseAbort.java +++ b/plugins/git4idea/src/git4idea/actions/GitRebaseAbort.java @@ -20,6 +20,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; +import git4idea.GitUtil; import git4idea.commands.GitCommand; import git4idea.commands.GitHandlerUtil; import git4idea.commands.GitSimpleHandler; @@ -74,7 +75,13 @@ public class GitRebaseAbort extends GitRepositoryAction { GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REBASE); h.setStdoutSuppressed(false); h.addParameters("--abort"); - GitHandlerUtil.doSynchronously(h, getActionName(), h.printableCommandLine()); + GitUtil.workingTreeChangeStarted(project); + try { + GitHandlerUtil.doSynchronously(h, getActionName(), h.printableCommandLine()); + } + finally { + GitUtil.workingTreeChangeFinished(project); + } } /** diff --git a/plugins/git4idea/src/git4idea/actions/GitRebaseActionBase.java b/plugins/git4idea/src/git4idea/actions/GitRebaseActionBase.java index c69bfb6c7547..912dd0ba350f 100644 --- a/plugins/git4idea/src/git4idea/actions/GitRebaseActionBase.java +++ b/plugins/git4idea/src/git4idea/actions/GitRebaseActionBase.java @@ -64,11 +64,17 @@ public abstract class GitRebaseActionBase extends GitRepositoryAction { task.executeInBackground(false, new GitTaskResultHandlerAdapter() { @Override protected void run(GitTaskResult taskResult) { - editor.close(); - GitRepositoryManager manager = GitUtil.getRepositoryManager(project); - manager.updateRepository(root); - root.refresh(false, true); - notifyAboutErrorResult(taskResult, resultListener, exceptions, project); + GitUtil.workingTreeChangeStarted(project); + try { + editor.close(); + GitRepositoryManager manager = GitUtil.getRepositoryManager(project); + manager.updateRepository(root); + root.refresh(false, true); + notifyAboutErrorResult(taskResult, resultListener, exceptions, project); + } + finally { + GitUtil.workingTreeChangeFinished(project); + } } }); } diff --git a/plugins/git4idea/src/git4idea/actions/GitResetHead.java b/plugins/git4idea/src/git4idea/actions/GitResetHead.java index d2278a2ed511..fd186b80e9e1 100644 --- a/plugins/git4idea/src/git4idea/actions/GitResetHead.java +++ b/plugins/git4idea/src/git4idea/actions/GitResetHead.java @@ -56,7 +56,13 @@ public class GitResetHead extends GitRepositoryAction { } GitLineHandler h = d.handler(); affectedRoots.add(d.getGitRoot()); - GitHandlerUtil.doSynchronously(h, GitBundle.getString("resetting.title"), h.printableCommandLine()); + GitUtil.workingTreeChangeStarted(project); + try { + GitHandlerUtil.doSynchronously(h, GitBundle.getString("resetting.title"), h.printableCommandLine()); + } + finally { + GitUtil.workingTreeChangeFinished(project); + } GitRepositoryManager manager = GitUtil.getRepositoryManager(project); manager.updateRepository(d.getGitRoot()); } diff --git a/plugins/git4idea/src/git4idea/actions/GitStash.java b/plugins/git4idea/src/git4idea/actions/GitStash.java index f23169708f38..b16c948b61c2 100644 --- a/plugins/git4idea/src/git4idea/actions/GitStash.java +++ b/plugins/git4idea/src/git4idea/actions/GitStash.java @@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.VirtualFile; import git4idea.GitPlatformFacade; +import git4idea.GitUtil; import git4idea.commands.GitHandlerUtil; import git4idea.commands.GitLineHandler; import git4idea.i18n.GitBundle; @@ -53,7 +54,13 @@ public class GitStash extends GitRepositoryAction { VirtualFile root = d.getGitRoot(); affectedRoots.add(root); final GitLineHandler h = d.handler(); - GitHandlerUtil.doSynchronously(h, GitBundle.getString("stashing.title"), h.printableCommandLine()); + GitUtil.workingTreeChangeStarted(project); + try { + GitHandlerUtil.doSynchronously(h, GitBundle.getString("stashing.title"), h.printableCommandLine()); + } + finally { + GitUtil.workingTreeChangeFinished(project); + } ServiceManager.getService(project, GitPlatformFacade.class).hardRefresh(root); } diff --git a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java index d49dc15827b7..2441bf7d46cf 100644 --- a/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitCheckoutOperation.java @@ -64,40 +64,46 @@ class GitCheckoutOperation extends GitBranchOperation { protected void execute() { saveAllDocuments(); boolean fatalErrorHappened = false; - while (hasMoreRepositories() && !fatalErrorHappened) { - final GitRepository repository = next(); - - VirtualFile root = repository.getRoot(); - GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = - new GitLocalChangesWouldBeOverwrittenDetector(root, GitLocalChangesWouldBeOverwrittenDetector.Operation.CHECKOUT); - GitSimpleEventDetector unmergedFiles = new GitSimpleEventDetector(GitSimpleEventDetector.Event.UNMERGED_PREVENTING_CHECKOUT); - GitUntrackedFilesOverwrittenByOperationDetector untrackedOverwrittenByCheckout = - new GitUntrackedFilesOverwrittenByOperationDetector(root); - - GitCommandResult result = myGit.checkout(repository, myStartPointReference, myNewBranch, false, - localChangesDetector, unmergedFiles, untrackedOverwrittenByCheckout); - if (result.success()) { - refresh(repository); - markSuccessful(repository); - } - else if (unmergedFiles.hasHappened()) { - fatalUnmergedFilesError(); - fatalErrorHappened = true; - } - else if (localChangesDetector.wasMessageDetected()) { - boolean smartCheckoutSucceeded = smartCheckoutOrNotify(repository, localChangesDetector); - if (!smartCheckoutSucceeded) { + GitUtil.workingTreeChangeStarted(myProject); + try { + while (hasMoreRepositories() && !fatalErrorHappened) { + final GitRepository repository = next(); + + VirtualFile root = repository.getRoot(); + GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = + new GitLocalChangesWouldBeOverwrittenDetector(root, GitLocalChangesWouldBeOverwrittenDetector.Operation.CHECKOUT); + GitSimpleEventDetector unmergedFiles = new GitSimpleEventDetector(GitSimpleEventDetector.Event.UNMERGED_PREVENTING_CHECKOUT); + GitUntrackedFilesOverwrittenByOperationDetector untrackedOverwrittenByCheckout = + new GitUntrackedFilesOverwrittenByOperationDetector(root); + + GitCommandResult result = myGit.checkout(repository, myStartPointReference, myNewBranch, false, + localChangesDetector, unmergedFiles, untrackedOverwrittenByCheckout); + if (result.success()) { + refresh(repository); + markSuccessful(repository); + } + else if (unmergedFiles.hasHappened()) { + fatalUnmergedFilesError(); + fatalErrorHappened = true; + } + else if (localChangesDetector.wasMessageDetected()) { + boolean smartCheckoutSucceeded = smartCheckoutOrNotify(repository, localChangesDetector); + if (!smartCheckoutSucceeded) { + fatalErrorHappened = true; + } + } + else if (untrackedOverwrittenByCheckout.wasMessageDetected()) { + fatalUntrackedFilesError(repository.getRoot(), untrackedOverwrittenByCheckout.getRelativeFilePaths()); + fatalErrorHappened = true; + } + else { + fatalError(getCommonErrorTitle(), result.getErrorOutputAsJoinedString()); fatalErrorHappened = true; } } - else if (untrackedOverwrittenByCheckout.wasMessageDetected()) { - fatalUntrackedFilesError(repository.getRoot(), untrackedOverwrittenByCheckout.getRelativeFilePaths()); - fatalErrorHappened = true; - } - else { - fatalError(getCommonErrorTitle(), result.getErrorOutputAsJoinedString()); - fatalErrorHappened = true; - } + } + finally { + GitUtil.workingTreeChangeFinished(myProject); } if (!fatalErrorHappened) { diff --git a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java index e90d1eb808ef..89a50cfd6054 100644 --- a/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java +++ b/plugins/git4idea/src/git4idea/branch/GitMergeOperation.java @@ -72,76 +72,82 @@ class GitMergeOperation extends GitBranchOperation { saveAllDocuments(); boolean fatalErrorHappened = false; int alreadyUpToDateRepositories = 0; - while (hasMoreRepositories() && !fatalErrorHappened) { - final GitRepository repository = next(); - LOG.info("next repository: " + repository); - - VirtualFile root = repository.getRoot(); - GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = - new GitLocalChangesWouldBeOverwrittenDetector(root, GitLocalChangesWouldBeOverwrittenDetector.Operation.MERGE); - GitSimpleEventDetector unmergedFiles = new GitSimpleEventDetector(GitSimpleEventDetector.Event.UNMERGED_PREVENTING_MERGE); - GitUntrackedFilesOverwrittenByOperationDetector untrackedOverwrittenByMerge = - new GitUntrackedFilesOverwrittenByOperationDetector(root); - GitSimpleEventDetector mergeConflict = new GitSimpleEventDetector(GitSimpleEventDetector.Event.MERGE_CONFLICT); - GitSimpleEventDetector alreadyUpToDateDetector = new GitSimpleEventDetector(GitSimpleEventDetector.Event.ALREADY_UP_TO_DATE); - - GitCommandResult result = myGit.merge(repository, myBranchToMerge, Collections.<String>emptyList(), - localChangesDetector, unmergedFiles, untrackedOverwrittenByMerge, mergeConflict, - alreadyUpToDateDetector); - if (result.success()) { - LOG.info("Merged successfully"); - refresh(repository); - markSuccessful(repository); - if (alreadyUpToDateDetector.hasHappened()) { - alreadyUpToDateRepositories += 1; + GitUtil.workingTreeChangeStarted(myProject); + try { + while (hasMoreRepositories() && !fatalErrorHappened) { + final GitRepository repository = next(); + LOG.info("next repository: " + repository); + + VirtualFile root = repository.getRoot(); + GitLocalChangesWouldBeOverwrittenDetector localChangesDetector = + new GitLocalChangesWouldBeOverwrittenDetector(root, GitLocalChangesWouldBeOverwrittenDetector.Operation.MERGE); + GitSimpleEventDetector unmergedFiles = new GitSimpleEventDetector(GitSimpleEventDetector.Event.UNMERGED_PREVENTING_MERGE); + GitUntrackedFilesOverwrittenByOperationDetector untrackedOverwrittenByMerge = + new GitUntrackedFilesOverwrittenByOperationDetector(root); + GitSimpleEventDetector mergeConflict = new GitSimpleEventDetector(GitSimpleEventDetector.Event.MERGE_CONFLICT); + GitSimpleEventDetector alreadyUpToDateDetector = new GitSimpleEventDetector(GitSimpleEventDetector.Event.ALREADY_UP_TO_DATE); + + GitCommandResult result = myGit.merge(repository, myBranchToMerge, Collections.<String>emptyList(), + localChangesDetector, unmergedFiles, untrackedOverwrittenByMerge, mergeConflict, + alreadyUpToDateDetector); + if (result.success()) { + LOG.info("Merged successfully"); + refresh(repository); + markSuccessful(repository); + if (alreadyUpToDateDetector.hasHappened()) { + alreadyUpToDateRepositories += 1; + } } - } - else if (unmergedFiles.hasHappened()) { - LOG.info("Unmerged files error!"); - fatalUnmergedFilesError(); - fatalErrorHappened = true; - } - else if (localChangesDetector.wasMessageDetected()) { - LOG.info("Local changes would be overwritten by merge!"); - boolean smartMergeSucceeded = proposeSmartMergePerformAndNotify(repository, localChangesDetector); - if (!smartMergeSucceeded) { + else if (unmergedFiles.hasHappened()) { + LOG.info("Unmerged files error!"); + fatalUnmergedFilesError(); + fatalErrorHappened = true; + } + else if (localChangesDetector.wasMessageDetected()) { + LOG.info("Local changes would be overwritten by merge!"); + boolean smartMergeSucceeded = proposeSmartMergePerformAndNotify(repository, localChangesDetector); + if (!smartMergeSucceeded) { + fatalErrorHappened = true; + } + } + else if (mergeConflict.hasHappened()) { + LOG.info("Merge conflict"); + myConflictedRepositories.put(repository, Boolean.FALSE); + refresh(repository); + markSuccessful(repository); + } + else if (untrackedOverwrittenByMerge.wasMessageDetected()) { + LOG.info("Untracked files would be overwritten by merge!"); + fatalUntrackedFilesError(repository.getRoot(), untrackedOverwrittenByMerge.getRelativeFilePaths()); + fatalErrorHappened = true; + } + else { + LOG.info("Unknown error. " + result); + fatalError(getCommonErrorTitle(), result.getErrorOutputAsJoinedString()); fatalErrorHappened = true; } } - else if (mergeConflict.hasHappened()) { - LOG.info("Merge conflict"); - myConflictedRepositories.put(repository, Boolean.FALSE); - refresh(repository); - markSuccessful(repository); - } - else if (untrackedOverwrittenByMerge.wasMessageDetected()) { - LOG.info("Untracked files would be overwritten by merge!"); - fatalUntrackedFilesError(repository.getRoot(), untrackedOverwrittenByMerge.getRelativeFilePaths()); - fatalErrorHappened = true; + + if (fatalErrorHappened) { + notifyAboutRemainingConflicts(); } else { - LOG.info("Unknown error. " + result); - fatalError(getCommonErrorTitle(), result.getErrorOutputAsJoinedString()); - fatalErrorHappened = true; + boolean allConflictsResolved = resolveConflicts(); + if (allConflictsResolved) { + if (alreadyUpToDateRepositories < getRepositories().size()) { + notifySuccess(); + } + else { + notifySuccess("Already up-to-date"); + } + } } - } - if (fatalErrorHappened) { - notifyAboutRemainingConflicts(); + restoreLocalChanges(); } - else { - boolean allConflictsResolved = resolveConflicts(); - if (allConflictsResolved) { - if (alreadyUpToDateRepositories < getRepositories().size()) { - notifySuccess(); - } - else { - notifySuccess("Already up-to-date"); - } - } + finally { + GitUtil.workingTreeChangeFinished(myProject); } - - restoreLocalChanges(); } private void notifyAboutRemainingConflicts() { diff --git a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java index 2eb0219485b6..3bb008a2f95f 100644 --- a/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java +++ b/plugins/git4idea/src/git4idea/checkin/GitCheckinEnvironment.java @@ -601,8 +601,8 @@ public class GitCheckinEnvironment implements CheckinEnvironment { c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; - final List<String> usersList = getUsersList(project); - final Set<String> authors = new HashSet<String>(usersList); + + Set<String> authors = new HashSet<String>(getUsersList(project)); ContainerUtil.addAll(authors, mySettings.getCommitAuthors()); List<String> list = new ArrayList<String>(authors); Collections.sort(list); diff --git a/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java b/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java index 831f833e0db5..40865a0b3f13 100644 --- a/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java +++ b/plugins/git4idea/src/git4idea/checkout/GitCloneDialog.java @@ -21,37 +21,25 @@ import com.intellij.dvcs.ui.DvcsBundle; import com.intellij.openapi.project.Project; import git4idea.GitUtil; import git4idea.GitVcs; -import git4idea.commands.GitCommand; -import git4idea.commands.GitLineHandlerPasswordRequestAware; -import git4idea.commands.GitTask; -import git4idea.commands.GitTaskResult; +import git4idea.commands.*; import git4idea.remote.GitRememberedInputs; import org.jetbrains.annotations.NotNull; import java.io.File; -/** - * @author Nadya Zabrodina - */ public class GitCloneDialog extends CloneDvcsDialog { public GitCloneDialog(@NotNull Project project) { super(project, GitVcs.NAME, GitUtil.DOT_GIT); } - /* - * We have a hack here: if http response asked for a password, then the url is at least valid and existent, and we consider - * that the test passed. - */ protected boolean test(@NotNull String url) { - final GitLineHandlerPasswordRequestAware handler = - new GitLineHandlerPasswordRequestAware(myProject, new File("."), GitCommand.LS_REMOTE); + final GitLineHandler handler = new GitLineHandler(myProject, new File("."), GitCommand.LS_REMOTE); handler.setUrl(url); handler.addParameters(url, "master"); GitTask task = new GitTask(myProject, handler, DvcsBundle.message("clone.testing", url)); GitTaskResult result = task.executeModal(); - boolean authFailed = handler.hadAuthRequest(); - return result.isOK() || authFailed; + return result.isOK(); } @NotNull diff --git a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java index bd8635db89be..033b1fd106fc 100644 --- a/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java +++ b/plugins/git4idea/src/git4idea/cherrypick/GitCherryPicker.java @@ -33,6 +33,7 @@ import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import com.intellij.vcs.log.VcsFullCommitDetails; import git4idea.GitPlatformFacade; +import git4idea.GitUtil; import git4idea.commands.Git; import git4idea.commands.GitCommandResult; import git4idea.commands.GitSimpleEventDetector; @@ -80,15 +81,21 @@ public class GitCherryPicker { public void cherryPick(@NotNull Map<GitRepository, List<VcsFullCommitDetails>> commitsInRoots) { List<GitCommitWrapper> successfulCommits = new ArrayList<GitCommitWrapper>(); - for (Map.Entry<GitRepository, List<VcsFullCommitDetails>> entry : commitsInRoots.entrySet()) { - GitRepository repository = entry.getKey(); - boolean result = cherryPick(repository, entry.getValue(), successfulCommits); - repository.update(); - if (!result) { - return; + GitUtil.workingTreeChangeStarted(myProject); + try { + for (Map.Entry<GitRepository, List<VcsFullCommitDetails>> entry : commitsInRoots.entrySet()) { + GitRepository repository = entry.getKey(); + boolean result = cherryPick(repository, entry.getValue(), successfulCommits); + repository.update(); + if (!result) { + return; + } } + notifySuccess(successfulCommits); + } + finally { + GitUtil.workingTreeChangeFinished(myProject); } - notifySuccess(successfulCommits); } // return true to continue with other roots, false to break execution diff --git a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java index 5b3a2422254f..e0312e5471fc 100644 --- a/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java +++ b/plugins/git4idea/src/git4idea/commands/GitHttpGuiAuthenticator.java @@ -87,7 +87,7 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { return ""; } url = adjustUrl(url); - Pair<GitHttpAuthDataProvider, AuthData> authData = findBestAuthData(url); + Pair<GitHttpAuthDataProvider, AuthData> authData = findBestAuthData(url, myModalityState); if (authData != null && authData.second.getPassword() != null) { String password = authData.second.getPassword(); myDataProvider = authData.first; @@ -114,7 +114,7 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { @NotNull public String askUsername(@NotNull String url) { url = adjustUrl(url); - Pair<GitHttpAuthDataProvider, AuthData> authData = findBestAuthData(url); + Pair<GitHttpAuthDataProvider, AuthData> authData = findBestAuthData(url, myModalityState); String login = null; String password = null; if (authData != null) { @@ -223,10 +223,10 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { // return the first that knows username + password; otherwise return the first that knows just the username @Nullable - private Pair<GitHttpAuthDataProvider, AuthData> findBestAuthData(@NotNull String url) { + private Pair<GitHttpAuthDataProvider, AuthData> findBestAuthData(@NotNull String url, @Nullable ModalityState modalityState) { Pair<GitHttpAuthDataProvider, AuthData> candidate = null; for (GitHttpAuthDataProvider provider : getProviders()) { - AuthData data = provider.getAuthData(url); + AuthData data = provider.getAuthData(url, modalityState); if (data != null) { Pair<GitHttpAuthDataProvider, AuthData> pair = Pair.create(provider, data); if (data.getPassword() != null) { @@ -268,12 +268,12 @@ class GitHttpGuiAuthenticator implements GitHttpAuthenticator { @Nullable @Override - public AuthData getAuthData(@NotNull String url) { + public AuthData getAuthData(@NotNull String url, @Nullable ModalityState modalityState) { String userName = getUsername(url); String key = makeKey(url, userName); final PasswordSafe passwordSafe = PasswordSafe.getInstance(); try { - String password = passwordSafe.getPassword(myProject, PASS_REQUESTER, key); + String password = passwordSafe.getPassword(myProject, PASS_REQUESTER, key, modalityState); return new AuthData(StringUtil.notNullize(userName), password); } catch (PasswordSafeException e) { diff --git a/plugins/git4idea/src/git4idea/commands/GitImpl.java b/plugins/git4idea/src/git4idea/commands/GitImpl.java index 3e14a6414704..c873e71ff94b 100644 --- a/plugins/git4idea/src/git4idea/commands/GitImpl.java +++ b/plugins/git4idea/src/git4idea/commands/GitImpl.java @@ -138,7 +138,7 @@ public class GitImpl implements Git { return run(new Computable<GitLineHandler>() { @Override public GitLineHandler compute() { - GitLineHandlerPasswordRequestAware handler = new GitLineHandlerPasswordRequestAware(project, parentDirectory, GitCommand.CLONE); + GitLineHandler handler = new GitLineHandler(project, parentDirectory, GitCommand.CLONE); handler.setStdoutSuppressed(false); handler.setUrl(url); handler.addParameters("--progress"); @@ -376,8 +376,7 @@ public class GitImpl implements Git { return runCommand(new Computable<GitLineHandler>() { @Override public GitLineHandler compute() { - final GitLineHandlerPasswordRequestAware h = new GitLineHandlerPasswordRequestAware(repository.getProject(), repository.getRoot(), - GitCommand.PUSH); + final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitCommand.PUSH); h.setUrl(url); h.setSilent(false); h.setStdoutSuppressed(false); @@ -454,8 +453,7 @@ public class GitImpl implements Git { return runCommand(new Computable<GitLineHandler>() { @Override public GitLineHandler compute() { - final GitLineHandlerPasswordRequestAware h = new GitLineHandlerPasswordRequestAware(repository.getProject(), repository.getRoot(), - GitCommand.FETCH); + final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitCommand.FETCH); h.setUrl(url); h.addParameters(remote); h.addParameters(params); @@ -520,13 +518,7 @@ public class GitImpl implements Git { }); handler.runInCurrentThread(null); - authFailed = handler.hasHttpAuthFailed(); - - if (handler instanceof GitLineHandlerPasswordRequestAware && ((GitLineHandlerPasswordRequestAware)handler).hadAuthRequest()) { - errorOutput.add("Authentication failed"); - } - success = !startFailed.get() && errorOutput.isEmpty() && (handler.isIgnoredErrorCode(exitCode.get()) || exitCode.get() == 0); } while (authFailed && authAttempt++ < 2); diff --git a/plugins/git4idea/src/git4idea/commands/GitLineHandlerPasswordRequestAware.java b/plugins/git4idea/src/git4idea/commands/GitLineHandlerPasswordRequestAware.java deleted file mode 100644 index b117b2092946..000000000000 --- a/plugins/git4idea/src/git4idea/commands/GitLineHandlerPasswordRequestAware.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2000-2011 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 git4idea.commands; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.vfs.VirtualFile; -import org.jetbrains.annotations.NotNull; - -import java.io.File; - -/** - * {@link GitLineHandler} that listens to Git output and kills itself if "username" or "password" is queried throughout the prompt. - * We can't pass the data to the prompt anyway, so better to kill the process and show an error message, than to hang the task. - * - * @author Kirill Likhodedov - */ -public class GitLineHandlerPasswordRequestAware extends GitLineHandler { - - private boolean myAuthRequest; - - public GitLineHandlerPasswordRequestAware(@NotNull Project project, @NotNull VirtualFile vcsRoot, @NotNull GitCommand command) { - super(project, vcsRoot, command); - } - - public GitLineHandlerPasswordRequestAware(@NotNull Project project, @NotNull File directory, @NotNull GitCommand clone) { - super(project, directory, clone); - } - - @Override - protected void onTextAvailable(String text, Key outputType) { - super.onTextAvailable(text, outputType); - if (text.toLowerCase().startsWith("password") || text.toLowerCase().startsWith("username")) { - myAuthRequest = true; - destroyProcess(); - } - } - - public boolean hadAuthRequest() { - return myAuthRequest; - } -} diff --git a/plugins/git4idea/src/git4idea/log/GitRefManager.java b/plugins/git4idea/src/git4idea/log/GitRefManager.java index 5b60076f68e7..eb9e79c69767 100644 --- a/plugins/git4idea/src/git4idea/log/GitRefManager.java +++ b/plugins/git4idea/src/git4idea/log/GitRefManager.java @@ -69,23 +69,31 @@ public class GitRefManager implements VcsLogRefManager { return typeComparison; } + //noinspection UnnecessaryLocalVariable VcsRefType type = type1; // common type + + String name1 = ref1.getName(); + String name2 = ref2.getName(); + if (name1.equals(name2)) { + return 0; + } + if (type == LOCAL_BRANCH) { - if (ref1.getName().equals(MASTER)) { + if (name1.equals(MASTER)) { return -1; } - if (ref2.getName().equals(MASTER)) { + if (name2.equals(MASTER)) { return 1; } - return ref1.getName().compareTo(ref2.getName()); + return name1.compareTo(name2); } if (type == REMOTE_BRANCH) { - if (ref1.getName().equals(ORIGIN_MASTER)) { + if (name1.equals(ORIGIN_MASTER)) { return -1; } - if (ref2.getName().equals(ORIGIN_MASTER)) { + if (name2.equals(ORIGIN_MASTER)) { return 1; } if (hasTrackingBranch(ref1) && !hasTrackingBranch(ref2)) { @@ -94,10 +102,10 @@ public class GitRefManager implements VcsLogRefManager { if (!hasTrackingBranch(ref1) && hasTrackingBranch(ref2)) { return 1; } - return ref1.getName().compareTo(ref2.getName()); + return name1.compareTo(name2); } - return ref1.getName().compareTo(ref2.getName()); + return name1.compareTo(name2); } }; @@ -121,10 +129,8 @@ public class GitRefManager implements VcsLogRefManager { @NotNull @Override - public List<VcsRef> sort(Collection<VcsRef> refs) { - ArrayList<VcsRef> list = new ArrayList<VcsRef>(refs); - Collections.sort(list, REF_COMPARATOR); - return list; + public Comparator<VcsRef> getComparator() { + return REF_COMPARATOR; } @NotNull @@ -314,7 +320,7 @@ public class GitRefManager implements VcsLogRefManager { @NotNull @Override public List<VcsRef> getRefs() { - return sort(myBranches); + return ContainerUtil.sorted(myBranches, getComparator()); } @NotNull diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java index a85a328fc114..aabf913fbf61 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaser.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaser.java @@ -63,10 +63,6 @@ public class GitRebaser { mySkippedCommits = new ArrayList<GitRebaseUtils.CommitInfo>(); } - public void setProgressIndicator(@Nullable ProgressIndicator progressIndicator) { - myProgressIndicator = progressIndicator; - } - public GitUpdateResult rebase(@NotNull VirtualFile root, @NotNull List<String> parameters, @Nullable final Runnable onCancel, @@ -89,28 +85,34 @@ public class GitRebaser { rebaseTask.setProgressAnalyzer(new GitStandardProgressAnalyzer()); final AtomicReference<GitUpdateResult> updateResult = new AtomicReference<GitUpdateResult>(); final AtomicBoolean failure = new AtomicBoolean(); - rebaseTask.executeInBackground(true, new GitTaskResultHandlerAdapter() { - @Override - protected void onSuccess() { - updateResult.set(GitUpdateResult.SUCCESS); - } + try { + GitUtil.workingTreeChangeStarted(myProject); + rebaseTask.executeInBackground(true, new GitTaskResultHandlerAdapter() { + @Override + protected void onSuccess() { + updateResult.set(GitUpdateResult.SUCCESS); + } - @Override - protected void onCancel() { - if (onCancel != null) { - onCancel.run(); + @Override + protected void onCancel() { + if (onCancel != null) { + onCancel.run(); + } + updateResult.set(GitUpdateResult.CANCEL); } - updateResult.set(GitUpdateResult.CANCEL); - } - @Override - protected void onFailure() { - failure.set(true); - } - }); + @Override + protected void onFailure() { + failure.set(true); + } + }); - if (failure.get()) { - updateResult.set(handleRebaseFailure(root, rebaseHandler, rebaseConflictDetector, untrackedFilesDetector)); + if (failure.get()) { + updateResult.set(handleRebaseFailure(rebaseHandler, root, rebaseConflictDetector, untrackedFilesDetector)); + } + } + finally { + GitUtil.workingTreeChangeFinished(myProject); } return updateResult.get(); } @@ -119,26 +121,6 @@ public class GitRebaser { return new GitLineHandler(myProject, root, GitCommand.REBASE); } - public GitUpdateResult handleRebaseFailure(VirtualFile root, GitLineHandler pullHandler, - GitRebaseProblemDetector rebaseConflictDetector, - GitMessageWithFilesDetector untrackedWouldBeOverwrittenDetector) { - if (rebaseConflictDetector.isMergeConflict()) { - LOG.info("handleRebaseFailure merge conflict"); - final boolean allMerged = new MyConflictResolver(myProject, myGit, root, this).merge(); - return allMerged ? GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS : GitUpdateResult.INCOMPLETE; - } else if (untrackedWouldBeOverwrittenDetector.wasMessageDetected()) { - LOG.info("handleRebaseFailure: untracked files would be overwritten by checkout"); - UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy(myProject, root, - untrackedWouldBeOverwrittenDetector.getRelativeFilePaths(), "rebase", null); - return GitUpdateResult.ERROR; - } else { - LOG.info("handleRebaseFailure error " + pullHandler.errors()); - GitUIUtil.notifyImportantError(myProject, "Rebase error", GitUIUtil.stringifyErrors(pullHandler.errors())); - return GitUpdateResult.ERROR; - } - } - - public void abortRebase(@NotNull VirtualFile root) { LOG.info("abortRebase " + root); final GitLineHandler rh = new GitLineHandler(myProject, root, GitCommand.REBASE); @@ -158,11 +140,17 @@ public class GitRebaser { * @return true if rebase successfully finished. */ public boolean continueRebase(@NotNull Collection<VirtualFile> rebasingRoots) { - boolean success = true; - for (VirtualFile root : rebasingRoots) { - success &= continueRebase(root); + GitUtil.workingTreeChangeStarted(myProject); + try { + boolean success = true; + for (VirtualFile root : rebasingRoots) { + success &= continueRebase(root); + } + return success; + } + finally { + GitUtil.workingTreeChangeFinished(myProject); } - return success; } // start operation may be "--continue" or "--skip" depending on the situation. @@ -330,34 +318,6 @@ public class GitRebaser { "You also may <b>abort rebase</b> to restore the original branch and stop rebasing."); } - private static class MyConflictResolver extends GitConflictResolver { - private final GitRebaser myRebaser; - private final VirtualFile myRoot; - - public MyConflictResolver(Project project, @NotNull Git git, VirtualFile root, GitRebaser rebaser) { - super(project, git, ServiceManager.getService(GitPlatformFacade.class), Collections.singleton(root), makeParams()); - myRebaser = rebaser; - myRoot = root; - } - - private static Params makeParams() { - Params params = new Params(); - params.setReverse(true); - params.setMergeDescription("Merge conflicts detected. Resolve them before continuing rebase."); - params.setErrorNotificationTitle("Can't continue rebase"); - params.setErrorNotificationAdditionalDescription("Then you may <b>continue rebase</b>. <br/> You also may <b>abort rebase</b> to restore the original branch and stop rebasing."); - return params; - } - - @Override protected boolean proceedIfNothingToMerge() throws VcsException { - return myRebaser.continueRebase(myRoot); - } - - @Override protected boolean proceedAfterAllMerged() throws VcsException { - return myRebaser.continueRebase(myRoot); - } - } - public static class TrivialEditor extends GitInteractiveRebaseEditorHandler{ public TrivialEditor(@NotNull GitRebaseEditorService service, @NotNull Project project, diff --git a/plugins/git4idea/src/git4idea/remote/GitHttpAuthDataProvider.java b/plugins/git4idea/src/git4idea/remote/GitHttpAuthDataProvider.java index 6c0860ccf20a..281d69b772c3 100644 --- a/plugins/git4idea/src/git4idea/remote/GitHttpAuthDataProvider.java +++ b/plugins/git4idea/src/git4idea/remote/GitHttpAuthDataProvider.java @@ -15,6 +15,7 @@ */ package git4idea.remote; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.util.AuthData; import org.jetbrains.annotations.NotNull; @@ -31,7 +32,7 @@ public interface GitHttpAuthDataProvider { ExtensionPointName<GitHttpAuthDataProvider> EP_NAME = ExtensionPointName.create("Git4Idea.GitHttpAuthDataProvider"); @Nullable - AuthData getAuthData(@NotNull String url); + AuthData getAuthData(@NotNull String url, @Nullable ModalityState modalityState); void forgetPassword(@NotNull String url); diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java index 5109d0600b69..576f326a8ea3 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java @@ -416,7 +416,7 @@ class GitRepositoryReader { LOG.info(".git/HEAD has not standard format: [" + headContent + "]. We've parsed branch [" + matcher.group(1) + "]"); return new Head(true, matcher.group(1)); } - throw new RepoStateException("Invalid format of the .git/HEAD file: \n" + headContent); + throw new RepoStateException("Invalid format of the .git/HEAD file: [" + headContent + "]"); } /** diff --git a/plugins/git4idea/src/git4idea/rollback/GitRollbackEnvironment.java b/plugins/git4idea/src/git4idea/rollback/GitRollbackEnvironment.java index 00f1830e6255..e255598e2046 100644 --- a/plugins/git4idea/src/git4idea/rollback/GitRollbackEnvironment.java +++ b/plugins/git4idea/src/git4idea/rollback/GitRollbackEnvironment.java @@ -141,15 +141,21 @@ public class GitRollbackEnvironment implements RollbackEnvironment { } } // revert files from HEAD - for (Map.Entry<VirtualFile, List<FilePath>> entry : toRevert.entrySet()) { - listener.accept(entry.getValue()); - try { - revert(entry.getKey(), entry.getValue()); - } - catch (VcsException e) { - exceptions.add(e); + GitUtil.workingTreeChangeStarted(myProject); + try { + for (Map.Entry<VirtualFile, List<FilePath>> entry : toRevert.entrySet()) { + listener.accept(entry.getValue()); + try { + revert(entry.getKey(), entry.getValue()); + } + catch (VcsException e) { + exceptions.add(e); + } } } + finally { + GitUtil.workingTreeChangeFinished(myProject); + } LocalFileSystem lfs = LocalFileSystem.getInstance(); HashSet<File> filesToRefresh = new HashSet<File>(); for (Change c : changes) { diff --git a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java index 3c8d7100c50c..9b13bb6cdb65 100644 --- a/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java +++ b/plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java @@ -413,25 +413,31 @@ public class GitUnstashDialog extends DialogWrapper { GitUntrackedFilesOverwrittenByOperationDetector untrackedFilesDetector = new GitUntrackedFilesOverwrittenByOperationDetector(root); h.addLineListener(untrackedFilesDetector); - final Ref<GitCommandResult> result = Ref.create(); - ProgressManager.getInstance().run(new Task.Modal(h.project(), GitBundle.getString("unstash.unstashing"), false) { - public void run(@NotNull final ProgressIndicator indicator) { - h.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(indicator, h, "stash", false)); - Git git = ServiceManager.getService(Git.class); - result.set(git.runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(h))); - } - }); + GitUtil.workingTreeChangeStarted(myProject); + try { + final Ref<GitCommandResult> result = Ref.create(); + ProgressManager.getInstance().run(new Task.Modal(h.project(), GitBundle.getString("unstash.unstashing"), false) { + public void run(@NotNull final ProgressIndicator indicator) { + h.addLineListener(new GitHandlerUtil.GitLineHandlerListenerProgress(indicator, h, "stash", false)); + Git git = ServiceManager.getService(Git.class); + result.set(git.runCommand(new Computable.PredefinedValueComputable<GitLineHandler>(h))); + } + }); - ServiceManager.getService(myProject, GitPlatformFacade.class).hardRefresh(root); - GitCommandResult res = result.get(); - if (conflict.get()) { - boolean conflictsResolved = new UnstashConflictResolver(myProject, root, getSelectedStash()).merge(); - LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved); - } else if (untrackedFilesDetector.wasMessageDetected()) { - UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy(myProject, root, untrackedFilesDetector.getRelativeFilePaths(), - "unstash", null); - } else if (!res.success()) { - GitUIUtil.showOperationErrors(myProject, h.errors(), h.printableCommandLine()); + ServiceManager.getService(myProject, GitPlatformFacade.class).hardRefresh(root); + GitCommandResult res = result.get(); + if (conflict.get()) { + boolean conflictsResolved = new UnstashConflictResolver(myProject, root, getSelectedStash()).merge(); + LOG.info("loadRoot " + root + ", conflictsResolved: " + conflictsResolved); + } else if (untrackedFilesDetector.wasMessageDetected()) { + UntrackedFilesNotifier.notifyUntrackedFilesOverwrittenBy(myProject, root, untrackedFilesDetector.getRelativeFilePaths(), + "unstash", null); + } else if (!res.success()) { + GitUIUtil.showOperationErrors(myProject, h.errors(), h.printableCommandLine()); + } + } + finally { + GitUtil.workingTreeChangeFinished(myProject); } super.doOKAction(); } diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index bc13ab8f7c36..e78039ef9d71 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -132,7 +132,13 @@ public class GitUpdateProcess { GitComplexProcess.Operation updateOperation = new GitComplexProcess.Operation() { @Override public void run(ContinuationContext continuationContext) { - myResult = updateImpl(updateMethod, continuationContext); + GitUtil.workingTreeChangeStarted(myProject); + try { + myResult = updateImpl(updateMethod, continuationContext); + } + finally { + GitUtil.workingTreeChangeFinished(myProject); + } } }; GitComplexProcess.execute(myProject, "update", updateOperation); diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java index 9625505e779f..2db213ca1a30 100644 --- a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java +++ b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java @@ -65,7 +65,6 @@ import java.util.concurrent.atomic.AtomicReference; import static com.intellij.openapi.vcs.Executor.cd; import static com.intellij.openapi.vcs.Executor.mkdir; -import static org.junit.Assume.assumeTrue; /** * <p>The container of test environment variables which should be visible from any step definition script.</p> @@ -149,7 +148,7 @@ public class GitCucumberWorld { AbstractVcs vcs = vcsManager.findVcsByName("Git"); Assert.assertEquals(1, vcsManager.getRootsUnderVcs(vcs).length); - assumeSupportedGitVersion(); + GitTestUtil.assumeSupportedGitVersion(myVcs); LOG.info(getStartTestMarker()); } @@ -157,10 +156,6 @@ public class GitCucumberWorld { return "Starting " + myTestName; } - private static void assumeSupportedGitVersion() { - assumeTrue(myVcs.getVersion().isSupported()); - } - // TODO should take actual feature name once we migrate to more recent cucumber lib private String createTestName() { return getClass().getName() + "-" + new Random().nextInt(); diff --git a/plugins/git4idea/tests/git4idea/log/GitLogRefSorterTest.java b/plugins/git4idea/tests/git4idea/log/GitRefManagerTest.java index 7346852bab68..707e97265267 100644 --- a/plugins/git4idea/tests/git4idea/log/GitLogRefSorterTest.java +++ b/plugins/git4idea/tests/git4idea/log/GitRefManagerTest.java @@ -21,10 +21,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; -/** - * @author Kirill Likhodedov - */ -public class GitLogRefSorterTest extends UsefulTestCase { +public class GitRefManagerTest extends UsefulTestCase { public static final MockVirtualFile MOCK_VIRTUAL_FILE = new MockVirtualFile("mockFile"); @@ -77,10 +74,10 @@ public class GitLogRefSorterTest extends UsefulTestCase { expect("HEAD", "master", "release", "origin/master", "origin/great_feature", "tag/v1")); } - @Override - protected void setUp() throws Exception { - super.setUp(); - + // may happen e.g. in multi-repo case + public void testTwoMasters() { + check(given("master", "master"), + expect("master", "master")); } private static Collection<VcsRef> given(String... refs) { @@ -205,7 +202,7 @@ public class GitLogRefSorterTest extends UsefulTestCase { return infos; } }); - return new GitRefManager(manager).sort(refs); + return ContainerUtil.sorted(refs, new GitRefManager(manager).getComparator()); } // TODO either use the real GitRepository, or move upwards and make more generic implementation diff --git a/plugins/git4idea/tests/git4idea/test/GitPlatformTest.java b/plugins/git4idea/tests/git4idea/test/GitPlatformTest.java index ecef2b2cdcf5..ef3f963c9c7e 100644 --- a/plugins/git4idea/tests/git4idea/test/GitPlatformTest.java +++ b/plugins/git4idea/tests/git4idea/test/GitPlatformTest.java @@ -29,6 +29,7 @@ import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.fixtures.IdeaProjectTestFixture; import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory; import com.intellij.testFramework.vcs.AbstractVcsTestCase; +import com.intellij.util.ObjectUtils; import git4idea.DialogManager; import git4idea.GitPlatformFacade; import git4idea.GitUtil; @@ -57,6 +58,7 @@ public abstract class GitPlatformTest extends UsefulTestCase { @NotNull protected GitVcsSettings myGitSettings; @NotNull protected GitPlatformFacade myPlatformFacade; @NotNull protected Git myGit; + @NotNull protected GitVcs myVcs; @NotNull protected TestDialogManager myDialogManager; @NotNull protected TestVcsNotifier myVcsNotifier; @@ -97,7 +99,10 @@ public abstract class GitPlatformTest extends UsefulTestCase { myGitRepositoryManager = GitUtil.getRepositoryManager(myProject); myPlatformFacade = ServiceManager.getService(myProject, GitPlatformFacade.class); myGit = ServiceManager.getService(myProject, Git.class); + myVcs = ObjectUtils.assertNotNull(GitVcs.getInstance(myProject)); + myVcs.doActivate(); + GitTestUtil.assumeSupportedGitVersion(myVcs); initChangeListManager(); addSilently(); removeSilently(); diff --git a/plugins/git4idea/tests/git4idea/test/GitTestUtil.java b/plugins/git4idea/tests/git4idea/test/GitTestUtil.java index a6a8f0cd79f5..842b1b1a2bae 100644 --- a/plugins/git4idea/tests/git4idea/test/GitTestUtil.java +++ b/plugins/git4idea/tests/git4idea/test/GitTestUtil.java @@ -31,6 +31,7 @@ import java.io.File; import static com.intellij.openapi.vcs.Executor.*; import static git4idea.test.GitExecutor.git; import static junit.framework.Assert.assertNotNull; +import static org.junit.Assume.assumeTrue; public class GitTestUtil { @@ -108,4 +109,8 @@ public class GitTestUtil { public static void setDefaultBuiltInServerPort() { System.setProperty(BuiltInServerManagerImpl.PROPERTY_RPC_PORT, "64463"); } + + public static void assumeSupportedGitVersion(@NotNull GitVcs vcs) { + assumeTrue(vcs.getVersion().isSupported()); + } } diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java index a733674f220e..714191d06b98 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubRebaseAction.java @@ -43,7 +43,6 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.github.api.GithubApiUtil; import org.jetbrains.plugins.github.api.GithubFullPath; import org.jetbrains.plugins.github.api.GithubRepoDetailed; -import org.jetbrains.plugins.github.exceptions.GithubOperationCanceledException; import org.jetbrains.plugins.github.util.*; import java.io.IOException; @@ -196,7 +195,7 @@ public class GithubRebaseAction extends DumbAwareAction { } try { - return GithubUtil.runTask(project, GithubAuthDataHolder.createFromSettings(), indicator, + return GithubUtil.runTask(project, GithubAuthDataHolder.createFromSettings(indicator.getModalityState()), indicator, new ThrowableConvertor<GithubAuthData, GithubRepoDetailed, IOException>() { @NotNull @Override @@ -227,6 +226,7 @@ public class GithubRebaseAction extends DumbAwareAction { @NotNull final ProgressIndicator indicator) { final Git git = ServiceManager.getService(project, Git.class); final GitPlatformFacade facade = ServiceManager.getService(project, GitPlatformFacade.class); + GitUtil.workingTreeChangeStarted(project); GitPreservingProcess process = new GitPreservingProcess(project, facade, git, Collections.singletonList(gitRepository), "Rebasing", "upstream/master", indicator, new Runnable() { @@ -237,6 +237,7 @@ public class GithubRebaseAction extends DumbAwareAction { } ); process.execute(); + GitUtil.workingTreeChangeFinished(project); } private static void doRebaseCurrentBranch(@NotNull final Project project, diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index 9431b91f3b2f..7c18b3bf7ffc 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -125,7 +125,7 @@ public class GithubShareAction extends DumbAwareAction { externalRemoteDetected = !gitRepository.getRemotes().isEmpty(); } - final GithubAuthDataHolder authHolder = GithubAuthDataHolder.createFromSettings(); + final GithubAuthDataHolder authHolder = GithubAuthDataHolder.createFromSettings(null); // get available GitHub repos with modal progress final GithubInfo githubInfo = loadGithubInfoWithModal(authHolder, project); diff --git a/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java b/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java index 6b3f73f5f8be..115258d9bee2 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java +++ b/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubCheckoutProvider.java @@ -61,7 +61,7 @@ public class GithubCheckoutProvider implements CheckoutProvider { @NotNull @Override public List<GithubRepo> convert(ProgressIndicator indicator) throws IOException { - return GithubUtil.runTask(project, GithubAuthDataHolder.createFromSettings(), indicator, + return GithubUtil.runTask(project, GithubAuthDataHolder.createFromSettings(indicator.getModalityState()), indicator, new ThrowableConvertor<GithubAuthData, List<GithubRepo>, IOException>() { @NotNull @Override diff --git a/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubHttpAuthDataProvider.java b/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubHttpAuthDataProvider.java index 5a7daf94a9fd..47d3edcb3de5 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubHttpAuthDataProvider.java +++ b/plugins/github/src/org/jetbrains/plugins/github/extensions/GithubHttpAuthDataProvider.java @@ -15,6 +15,7 @@ */ package org.jetbrains.plugins.github.extensions; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.AuthData; import git4idea.remote.GitHttpAuthDataProvider; @@ -31,7 +32,7 @@ public class GithubHttpAuthDataProvider implements GitHttpAuthDataProvider { @Nullable @Override - public AuthData getAuthData(@NotNull String url) { + public AuthData getAuthData(@NotNull String url, @Nullable ModalityState modalityState) { if (!GithubUrlUtil.isGithubUrl(url)) { return null; } @@ -47,7 +48,7 @@ public class GithubHttpAuthDataProvider implements GitHttpAuthDataProvider { return null; } - GithubAuthData auth = settings.getAuthData(); + GithubAuthData auth = settings.getAuthData(modalityState); switch (auth.getAuthType()) { case BASIC: GithubAuthData.BasicAuth basicAuth = auth.getBasicAuth(); diff --git a/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java b/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java index 5333d82e3baf..9cf3cdf4b4fe 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java +++ b/plugins/github/src/org/jetbrains/plugins/github/tasks/GithubRepositoryEditor.java @@ -125,7 +125,8 @@ public class GithubRepositoryEditor extends BaseRepositoryEditor<GithubRepositor @Override public String convert(ProgressIndicator indicator) throws IOException { return GithubUtil - .runTaskWithBasicAuthForHost(myProject, GithubAuthDataHolder.createFromSettings(), indicator, getHost(), + .runTaskWithBasicAuthForHost(myProject, GithubAuthDataHolder.createFromSettings(indicator.getModalityState()), + indicator, getHost(), new ThrowableConvertor<GithubAuthData, String, IOException>() { @NotNull @Override diff --git a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java index 7de0dae30d69..229170e29ead 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java +++ b/plugins/github/src/org/jetbrains/plugins/github/ui/GithubSettingsPanel.java @@ -130,7 +130,8 @@ public class GithubSettingsPanel { @NotNull @Override public String convert(ProgressIndicator indicator) throws IOException { - return GithubUtil.runTaskWithBasicAuthForHost(project, GithubAuthDataHolder.createFromSettings(), indicator, getHost(), + return GithubUtil.runTaskWithBasicAuthForHost(project, GithubAuthDataHolder.createFromSettings(indicator.getModalityState()), + indicator, getHost(), new ThrowableConvertor<GithubAuthData, String, IOException>() { @NotNull @Override @@ -262,7 +263,7 @@ public class GithubSettingsPanel { @NotNull public GithubAuthData getAuthData() { if (!myCredentialsModified) { - return mySettings.getAuthData(); + return mySettings.getAuthData(null); } Object selected = myAuthTypeComboBox.getSelectedItem(); if (AUTH_PASSWORD.equals(selected)) return GithubAuthData.createBasicAuth(getHost(), getLogin(), getPassword()); @@ -290,7 +291,7 @@ public class GithubSettingsPanel { public void apply() { if (myCredentialsModified) { - mySettings.setAuthData(getAuthData(), true); + mySettings.setAuthData(getAuthData(), true, null); } mySettings.setConnectionTimeout(getConnectionTimeout()); resetCredentialsModification(); diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java index f11044422154..d7981b261d7c 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthData.java @@ -15,6 +15,7 @@ */ package org.jetbrains.plugins.github.util; +import com.intellij.openapi.application.ModalityState; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.github.api.GithubApiUtil; @@ -52,8 +53,8 @@ public class GithubAuthData { myUseProxy = useProxy; } - public static GithubAuthData createFromSettings() { - return GithubSettings.getInstance().getAuthData(); + public static GithubAuthData createFromSettings(@Nullable ModalityState state) { + return GithubSettings.getInstance().getAuthData(state); } public static GithubAuthData createAnonymous() { diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthDataHolder.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthDataHolder.java index 695dfe734c34..24303a34d240 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthDataHolder.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubAuthDataHolder.java @@ -15,8 +15,10 @@ */ package org.jetbrains.plugins.github.util; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.util.ThrowableComputable; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class GithubAuthDataHolder { @@ -40,7 +42,7 @@ public class GithubAuthDataHolder { myAuthData = task.compute(); } - public static GithubAuthDataHolder createFromSettings() { - return new GithubAuthDataHolder(GithubSettings.getInstance().getAuthData()); + public static GithubAuthDataHolder createFromSettings(@Nullable ModalityState state) { + return new GithubAuthDataHolder(GithubSettings.getInstance().getAuthData(state)); } } diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java index 3523e412a95e..a2bdca59bbe4 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubSettings.java @@ -19,6 +19,7 @@ import com.intellij.ide.passwordSafe.PasswordSafe; import com.intellij.ide.passwordSafe.PasswordSafeException; import com.intellij.ide.passwordSafe.config.PasswordSafeSettings; import com.intellij.ide.passwordSafe.impl.PasswordSafeImpl; +import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.text.StringUtil; @@ -151,10 +152,10 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S } @NotNull - private String getPassword() { + private String getPassword(@Nullable ModalityState state) { String password; try { - password = PasswordSafe.getInstance().getPassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY); + password = PasswordSafe.getInstance().getPassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, state); } catch (PasswordSafeException e) { LOG.info("Couldn't get password for key [" + GITHUB_SETTINGS_PASSWORD_KEY + "]", e); @@ -164,10 +165,10 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S return StringUtil.notNullize(password); } - private void setPassword(@NotNull String password, boolean rememberPassword) { + private void setPassword(@NotNull String password, boolean rememberPassword, @Nullable ModalityState state) { try { if (rememberPassword) { - PasswordSafe.getInstance().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, password); + PasswordSafe.getInstance().storePassword(null, GithubSettings.class, GITHUB_SETTINGS_PASSWORD_KEY, password, state); } else { final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance(); @@ -196,13 +197,13 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S } @NotNull - public GithubAuthData getAuthData() { + public GithubAuthData getAuthData(@Nullable ModalityState state) { switch (getAuthType()) { case BASIC: //noinspection ConstantConditions - return GithubAuthData.createBasicAuth(getHost(), getLogin(), getPassword()); + return GithubAuthData.createBasicAuth(getHost(), getLogin(), getPassword(state)); case TOKEN: - return GithubAuthData.createTokenAuth(getHost(), getPassword()); + return GithubAuthData.createTokenAuth(getHost(), getPassword(state)); case ANONYMOUS: return GithubAuthData.createAnonymous(); default: @@ -210,7 +211,7 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S } } - public void setAuthData(@NotNull GithubAuthData auth, boolean rememberPassword) { + public void setAuthData(@NotNull GithubAuthData auth, boolean rememberPassword, @Nullable ModalityState state) { setValidGitAuth(isValidGitAuth(auth)); setAuthType(auth.getAuthType()); @@ -220,16 +221,16 @@ public class GithubSettings implements PersistentStateComponent<GithubSettings.S case BASIC: assert auth.getBasicAuth() != null; setLogin(auth.getBasicAuth().getLogin()); - setPassword(auth.getBasicAuth().getPassword(), rememberPassword); + setPassword(auth.getBasicAuth().getPassword(), rememberPassword, state); break; case TOKEN: assert auth.getTokenAuth() != null; setLogin(null); - setPassword(auth.getTokenAuth().getToken(), rememberPassword); + setPassword(auth.getTokenAuth().getToken(), rememberPassword, state); break; case ANONYMOUS: setLogin(null); - setPassword("", rememberPassword); + setPassword("", rememberPassword, state); break; default: throw new IllegalStateException("GithubSettings: setAuthData - wrong AuthType: " + auth.getAuthType()); diff --git a/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.java b/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.java index edd12ab85ab6..e4af54f84639 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.java +++ b/plugins/github/src/org/jetbrains/plugins/github/util/GithubUtil.java @@ -161,7 +161,7 @@ public class GithubUtil { if (ok[0]) { authData[0] = dialog.getAuthData(); - GithubSettings.getInstance().setAuthData(authData[0], dialog.isSavePasswordSelected()); + GithubSettings.getInstance().setAuthData(authData[0], dialog.isSavePasswordSelected(), indicator.getModalityState()); } } }, indicator.getModalityState()); @@ -195,7 +195,7 @@ public class GithubUtil { final GithubSettings settings = GithubSettings.getInstance(); if (settings.getAuthType() != GithubAuthData.AuthType.TOKEN) { - GithubSettings.getInstance().setAuthData(authData[0], dialog.isSavePasswordSelected()); + GithubSettings.getInstance().setAuthData(authData[0], dialog.isSavePasswordSelected(), indicator.getModalityState()); } } } @@ -247,7 +247,7 @@ public class GithubUtil { @NotNull public static GithubAuthDataHolder getValidAuthDataHolderFromConfig(@NotNull Project project, @NotNull ProgressIndicator indicator) throws IOException { - GithubAuthData auth = GithubAuthData.createFromSettings(); + GithubAuthData auth = GithubAuthData.createFromSettings(indicator.getModalityState()); GithubAuthDataHolder authHolder = new GithubAuthDataHolder(auth); try { checkAuthData(project, authHolder, indicator); diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTestBase.java b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTestBase.java index b54bd8c62b4e..d313398548a5 100644 --- a/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTestBase.java +++ b/plugins/github/test/org/jetbrains/plugins/github/GithubCreateGistTestBase.java @@ -54,12 +54,12 @@ public abstract class GithubCreateGistTestBase extends GithubTest { @NotNull protected GithubAuthDataHolder getAuthDataHolder() { - return new GithubAuthDataHolder(myGitHubSettings.getAuthData()); + return new GithubAuthDataHolder(myGitHubSettings.getAuthData(null)); } protected void deleteGist() throws IOException { if (GIST_ID != null) { - GithubApiUtil.deleteGist(myGitHubSettings.getAuthData(), GIST_ID); + GithubApiUtil.deleteGist(myGitHubSettings.getAuthData(null), GIST_ID); GIST = null; GIST_ID = null; } @@ -82,7 +82,7 @@ public abstract class GithubCreateGistTestBase extends GithubTest { if (GIST == null) { try { - GIST = GithubApiUtil.getGist(myGitHubSettings.getAuthData(), GIST_ID); + GIST = GithubApiUtil.getGist(myGitHubSettings.getAuthData(null), GIST_ID); } catch (IOException e) { System.err.println(e.getMessage()); diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java index 4fec0d1c7a5c..97b34aa7b26c 100644 --- a/plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java +++ b/plugins/github/test/org/jetbrains/plugins/github/GithubRequestPagingTest.java @@ -36,7 +36,7 @@ public class GithubRequestPagingTest extends GithubTest { public void testAvailableRepos() throws Throwable { - List<GithubRepo> availableRepos = GithubApiUtil.getUserRepos(myGitHubSettings.getAuthData(), myLogin2); + List<GithubRepo> availableRepos = GithubApiUtil.getUserRepos(myGitHubSettings.getAuthData(null), myLogin2); List<String> realData = new ArrayList<String>(); for (GithubRepo info : availableRepos) { realData.add(info.getName()); diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java index c4063629cbbe..e6da326777c5 100644 --- a/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java +++ b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTest.java @@ -99,7 +99,7 @@ public class GithubShareProjectTest extends GithubShareProjectTestBase { } protected void checkGithubExists() throws IOException { - GithubAuthData auth = myGitHubSettings.getAuthData(); + GithubAuthData auth = myGitHubSettings.getAuthData(null); GithubRepoDetailed githubInfo = GithubApiUtil.getDetailedRepoInfo(auth, myLogin1, PROJECT_NAME); assertNotNull("GitHub repository does not exist", githubInfo); } diff --git a/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java index abfb5ece3819..f146b37f4208 100644 --- a/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java +++ b/plugins/github/test/org/jetbrains/plugins/github/GithubShareProjectTestBase.java @@ -48,7 +48,7 @@ public abstract class GithubShareProjectTestBase extends GithubTest { } protected void deleteGithubRepo() throws IOException { - GithubApiUtil.deleteGithubRepository(myGitHubSettings.getAuthData(), myLogin1, PROJECT_NAME); + GithubApiUtil.deleteGithubRepository(myGitHubSettings.getAuthData(null), myLogin1, PROJECT_NAME); } protected void registerDefaultShareDialogHandler() { diff --git a/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java b/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java index 3d3d8201e03a..b728913aeacb 100644 --- a/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java +++ b/plugins/github/test/org/jetbrains/plugins/github/test/GithubTest.java @@ -172,7 +172,7 @@ public abstract class GithubTest extends GitPlatformTest { myAuth = GithubAuthData.createBasicAuth(host, login1, password); myGitHubSettings = GithubSettings.getInstance(); - myGitHubSettings.setAuthData(myAuth, false); + myGitHubSettings.setAuthData(myAuth, false, null); myHttpAuthService = (GitHttpAuthTestService)ServiceManager.getService(GitHttpAuthService.class); diff --git a/plugins/gradle/src/META-INF/plugin.xml b/plugins/gradle/src/META-INF/plugin.xml index 67ca15f5d679..de6937c18c6c 100644 --- a/plugins/gradle/src/META-INF/plugin.xml +++ b/plugins/gradle/src/META-INF/plugin.xml @@ -83,7 +83,7 @@ <moduleBuilder builderClass="org.jetbrains.plugins.gradle.service.project.wizard.GradleModuleBuilder"/> <internalFileTemplate name="Gradle Build Script"/> <internalFileTemplate name="Gradle Build Script with wrapper"/> - <projectConfigurable id="reference.settingsdialog.project.gradle" + <projectConfigurable groupId="build" id="reference.settingsdialog.project.gradle" instance="org.jetbrains.plugins.gradle.service.settings.GradleConfigurable" key="gradle.name" bundle="i18n.GradleBundle"/> <library.presentationProvider implementation="org.jetbrains.plugins.gradle.config.GradleLibraryPresentationProvider" order="last"/> diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java index e7795a0621d2..d17b9fdea764 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java @@ -261,9 +261,14 @@ public class GradleScriptType extends GroovyRunnableScriptType { final String scriptPath = configuration.getScriptPath(); if (scriptPath == null) { - throw new CantRunException("Target script is undefined"); + throw new CantRunException("Target script or gradle project path is undefined"); + } + + if(new File(scriptPath).isFile()) { + params.getProgramParametersList().add("--build-file"); + } else { + params.getProgramParametersList().add("--project-dir"); } - params.getProgramParametersList().add("--project-dir"); params.getProgramParametersList().add(FileUtil.toSystemDependentName(scriptPath)); params.getProgramParametersList().addParametersString(configuration.getProgramParameters()); params.getProgramParametersList().addParametersString(scriptParameters); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java index 5993480333e5..f4dec6283300 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java @@ -107,7 +107,8 @@ public class TestMethodGradleConfigurationProducer extends RunConfigurationProdu if (!configuration.getSettings().getTaskNames().containsAll(TASKS_TO_RUN)) return false; final String scriptParameters = configuration.getSettings().getScriptParameters() + ' '; - return scriptParameters.contains(String.format("--tests %s.%s ", containingClass.getQualifiedName(), psiMethod.getName())); + final String testFilter = creatTestFilter(containingClass, psiMethod); + return scriptParameters.contains(testFilter); } @Override @@ -163,11 +164,16 @@ public class TestMethodGradleConfigurationProducer extends RunConfigurationProdu StringBuilder buf = new StringBuilder(); for (PsiClass aClass : containingClasses) { - buf.append(String.format("--tests %s.%s ", aClass.getQualifiedName(), psiMethod.getName())); + buf.append(creatTestFilter(aClass, psiMethod)); } - configuration.getSettings().setScriptParameters(buf.toString()); + configuration.getSettings().setScriptParameters(buf.toString().trim()); configuration.setName(psiMethod.getName()); return true; } + + private static String creatTestFilter(@NotNull PsiClass aClass, @NotNull PsiMethod psiMethod) { + String testFilterPattern = aClass.getQualifiedName() + '.' + psiMethod.getName(); + return String.format("--tests \"%s\" ", StringUtil.replaceChar(testFilterPattern, '\"', '*')); + } } diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java index dd723557b37e..f59ccee38658 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java @@ -62,7 +62,6 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes private static final int GRADLE_DAEMON_TTL_MS = 10000; - public static final Pattern TEST_METHOD_NAME_PATTERN = Pattern.compile("(.*)\\[(\\d*: with Gradle-.*)\\]"); @Rule public TestName name = new TestName(); @NotNull @@ -91,12 +90,7 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes @Override public String getName() { - String methodName = name.getMethodName(); - Matcher m = TEST_METHOD_NAME_PATTERN.matcher(methodName); - if (m.matches()) { - methodName = m.group(1); - } - return methodName; + return name.getMethodName() == null ? super.getName() : FileUtil.sanitizeFileName(name.getMethodName()); } @Parameterized.Parameters(name = "{index}: with Gradle-{0}") diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java index be28ee0a95fd..5e6e8ff3a8d8 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/BaseInspection.java @@ -16,9 +16,9 @@ package org.jetbrains.plugins.groovy.codeInspection; import com.intellij.codeInspection.InspectionManager; +import com.intellij.codeInspection.InspectionProfileEntry; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.codeInspection.ProblemsHolder; -import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; @@ -26,8 +26,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase; public abstract class BaseInspection extends GroovySuppressableInspectionTool { - - private final String m_shortName = StringUtil.trimEnd(getClass().getSimpleName(), "Inspection"); + private final String m_shortName = InspectionProfileEntry.getShortName(getClass().getSimpleName()); public static final String ASSIGNMENT_ISSUES = "Assignment issues"; public static final String CONFUSING_CODE_CONSTRUCTS = "Potentially confusing code constructs"; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java index 6dcdb2a25ccc..309f7f43a1f1 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java @@ -200,7 +200,11 @@ public class GrLightMethodBuilder extends LightElement implements GrMethod, Ori @Override public GrTypeElement getReturnTypeElementGroovy() { - return null; + PsiType returnType = getReturnType(); + if (returnType == null) { + return null; + } + return new GrLightTypeElement(returnType, getManager()); } @Override diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameterListBuilder.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameterListBuilder.java index 409ab4df9d9c..425b4a898599 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameterListBuilder.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightParameterListBuilder.java @@ -64,9 +64,9 @@ public class GrLightParameterListBuilder extends LightElement implements GrParam return myCachedParameters; } - public void copyParameters(@NotNull PsiMethod method, PsiSubstitutor substitutor) { + public void copyParameters(@NotNull PsiMethod method, PsiSubstitutor substitutor, PsiMethod scope) { for (PsiParameter parameter : method.getParameterList().getParameters()) { - GrLightParameter p = new GrLightParameter(StringUtil.notNullize(parameter.getName()), substitutor.substitute(parameter.getType()), this); + GrLightParameter p = new GrLightParameter(StringUtil.notNullize(parameter.getName()), substitutor.substitute(parameter.getType()), scope); if (parameter instanceof GrParameter) { p.setOptional(((GrParameter)parameter).isOptional()); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java index 44da8f27928a..90605135e261 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java @@ -43,7 +43,7 @@ public class GrMethodWrapper extends GrLightMethodBuilder implements PsiMirrorEl getModifierList().copyModifiers(method); - getParameterList().copyParameters(method, substitutor); + getParameterList().copyParameters(method, substitutor, this); if (method instanceof OriginInfoAwareElement) { setOriginInfo(((OriginInfoAwareElement)method).getOriginInfo()); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java index cd516c6a02c6..8ccfe21915f8 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java @@ -44,6 +44,7 @@ public class GrStubFileElementType extends IStubFileElementType<GrFileStub> { @Override public StubBuilder getBuilder() { return new DefaultStubBuilder() { + @NotNull @Override protected StubElement createStubForFile(@NotNull final PsiFile file) { if (file instanceof GroovyFile) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java index 797ff3bc573d..b7b27df6e86d 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java @@ -44,7 +44,7 @@ public class GrFullClassNameIndex extends IntStubIndexExtension<PsiClass> { } @Override - public Collection<PsiClass> get(final Integer integer, final Project project, final GlobalSearchScope scope) { + public Collection<PsiClass> get(@NotNull final Integer integer, @NotNull final Project project, @NotNull final GlobalSearchScope scope) { return StubIndex.getElements(getKey(), integer, project, new GrSourceFilterScope(scope), PsiClass.class); } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/FromStringHintProcessor.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/FromStringHintProcessor.java index 6ca36c5bb70f..1af99c7647dd 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/FromStringHintProcessor.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/FromStringHintProcessor.java @@ -15,10 +15,7 @@ */ package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiMethod; -import com.intellij.psi.PsiSubstitutor; -import com.intellij.psi.PsiType; +import com.intellij.psi.*; import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import com.intellij.util.containers.ContainerUtil; @@ -49,7 +46,9 @@ public class FromStringHintProcessor extends SignatureHintProcessor { @Override public PsiType fun(String param) { try { - PsiType original = JavaPsiFacade.getElementFactory(method.getProject()).createTypeFromText(param, method); + PsiTypeParameterList typeParameterList = method.getTypeParameterList(); + PsiElement context = typeParameterList != null ? typeParameterList : method; + PsiType original = JavaPsiFacade.getElementFactory(method.getProject()).createTypeFromText(param, context); return substitutor.substitute(original); } catch (IncorrectOperationException e) { diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml index f16d2c195482..8e3d7103e250 100644 --- a/plugins/groovy/src/META-INF/plugin.xml +++ b/plugins/groovy/src/META-INF/plugin.xml @@ -25,7 +25,6 @@ <depends optional="true" config-file="intellilang-groovy-support.xml">org.intellij.intelliLang</depends> <depends optional="true">AntSupport</depends> <depends optional="true" config-file="groovy-byte-code-viewer.xml">ByteCodeViewer</depends> - <depends optional="true" config-file="structuralsearch.xml">Structural Search</depends> <extensionPoints> <extensionPoint name="methodComparator" interface="org.jetbrains.plugins.groovy.lang.resolve.GrMethodComparator"/> @@ -42,7 +41,6 @@ <extensionPoint name="positionManagerDelegate" interface="org.jetbrains.plugins.groovy.extensions.debugger.ScriptPositionManagerHelper"/> - <extensionPoint name="compilerExtension" interface="org.jetbrains.plugins.groovy.compiler.GroovyCompilerExtension"/> <extensionPoint name="scriptTypeDetector" interface="org.jetbrains.plugins.groovy.extensions.GroovyScriptTypeDetector"/> <extensionPoint name="namedArgumentProvider" interface="org.jetbrains.plugins.groovy.extensions.GroovyNamedArgumentProvider"/> @@ -275,7 +273,7 @@ <fileTypeFactory implementation="org.jetbrains.plugins.groovy.GroovyFileTypeLoader"/> <fileTypeFactory implementation="org.jetbrains.plugins.groovy.dgm.DGMFileTypeFactory"/> - <projectConfigurable instance="org.jetbrains.plugins.groovy.gant.GantConfigurable" id="reference.settingsdialog.project.gant" + <projectConfigurable groupId="build" instance="org.jetbrains.plugins.groovy.gant.GantConfigurable" id="reference.settingsdialog.project.gant" displayName="Gant"/> <library.presentationProvider implementation="org.jetbrains.plugins.groovy.config.GroovyLibraryPresentationProvider"/> @@ -404,6 +402,8 @@ <refactoring.helper implementation="org.jetbrains.plugins.groovy.refactoring.GroovyImportOptimizerRefactoringHelper"/> <codeInsight.lineMarkerProvider language="Groovy" implementationClass="org.jetbrains.plugins.groovy.codeInsight.GroovyLineMarkerProvider"/> + <codeInsight.lineMarkerProvider language="Groovy" + implementationClass="com.intellij.codeInsight.ExternalAnnotationsLineMarkerProvider"/> <codeInsight.gotoSuper language="Groovy" implementationClass="org.jetbrains.plugins.groovy.codeInsight.navigation.actions.GroovyGotoSuperHandler"/> <lookup.charFilter implementation="org.jetbrains.plugins.groovy.lang.completion.GroovyReferenceCharFilter"/> @@ -445,13 +445,13 @@ <weigher key="proximity" implementationClass="org.jetbrains.plugins.groovy.lang.completion.weighers.GrReferenceListWeigher" id="groovyReferenceListWeigher" order="before openedInEditor"/> - <debuggerClassFilterProvider implementation="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerClassFilterProvider"/> + <debuggerClassFilterProvider implementation="org.jetbrains.plugins.groovy.debugger.GroovyDebuggerClassFilterProvider"/> <useScopeEnlarger implementation="org.jetbrains.plugins.groovy.lang.psi.impl.search.GrPrivateFieldScopeEnlarger"/> <debuggerEditorTextProvider language="Groovy" implementationClass="org.jetbrains.plugins.groovy.debugger.GroovyEditorTextProvider"/> - <xdebugger.settings implementation="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettings"/> + <xdebugger.settings implementation="org.jetbrains.plugins.groovy.debugger.GroovyDebuggerSettings"/> <langCodeStyleSettingsProvider implementation="org.jetbrains.plugins.groovy.codeStyle.GroovyLanguageCodeStyleSettingsProvider"/> <codeStyleSettingsProvider implementation="org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettingsProvider"/> @@ -1515,6 +1515,8 @@ implementationClass="org.jetbrains.plugins.groovy.refactoring.memberPullUp.GrPullUpHelperFactory"/> <classTypePointerFactory implementation="org.jetbrains.plugins.groovy.lang.psi.impl.smartPointers.GrClassReferenceTypePointerFactory"/> <hierarchy.referenceProcessor implementation="org.jetbrains.plugins.groovy.hierarchy.call.GrCallReferenceProcessor"/> + <structuralsearch.profile implementation="com.intellij.structuralsearch.GroovyStructuralSearchProfile"/> + <equivalenceDescriptorProvider implementation="com.intellij.structuralsearch.GroovyEquivalenceDescriptorProvider"/> </extensions> <extensions defaultExtensionNs="com.intellij.debugger"> diff --git a/plugins/groovy/src/META-INF/structuralsearch.xml b/plugins/groovy/src/META-INF/structuralsearch.xml deleted file mode 100644 index b3b6193771de..000000000000 --- a/plugins/groovy/src/META-INF/structuralsearch.xml +++ /dev/null @@ -1,6 +0,0 @@ -<idea-plugin url="http://www.jetbrains.com/idea"> - <extensions defaultExtensionNs="com.intellij"> - <structuralsearch.profile implementation="com.intellij.structuralsearch.GroovyStructuralSearchProfile"/> - </extensions> -</idea-plugin> -
\ No newline at end of file diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java index e23254da8d1a..3fcf1c337b86 100644 --- a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java +++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java @@ -19,7 +19,7 @@ import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.progress.EmptyProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.ModificationTracker; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.patterns.compiler.PatternClassBean; import com.intellij.patterns.compiler.PatternCompilerFactory; import com.intellij.psi.*; @@ -30,14 +30,13 @@ import com.intellij.psi.scope.PsiScopeProcessor; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.TextOccurenceProcessor; import com.intellij.psi.search.UsageSearchContext; -import com.intellij.psi.util.CachedValue; -import com.intellij.psi.util.CachedValueProvider; -import com.intellij.psi.util.CachedValuesManager; -import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.psi.util.*; import com.intellij.psi.xml.XmlTag; import com.intellij.psi.xml.XmlText; +import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.SoftFactoryMap; import com.intellij.util.text.StringSearcher; import org.intellij.plugins.intelliLang.inject.InjectorUtils; import org.intellij.plugins.intelliLang.inject.config.BaseInjection; @@ -46,86 +45,74 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.GroovyFileType; import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor; -import java.util.Collections; import java.util.List; +import java.util.Set; /** * @author Gregory.Shrago */ public class PatternEditorContextMembersProvider extends NonCodeMembersContributor { - public static final Key<CachedValue<List<PsiElement>>> INJECTION_PARSED_CONTEXT = Key.create("INJECTION_PARSED_CONTEXT"); + private static final Key<SoftFactoryMap<Class[], PsiFile>> PATTERN_INJECTION_CONTEXT = Key.create("PATTERN_INJECTION_CONTEXT"); + private static final Key<CachedValue<Set<String>>> PATTERN_CLASSES = Key.create("PATTERN_CLASSES"); @Override public void processDynamicElements(@NotNull PsiType qualifierType, - @NotNull PsiScopeProcessor processor, - @NotNull PsiElement place, - @NotNull ResolveState state) { + @NotNull final PsiScopeProcessor scopeProcessor, + @NotNull final PsiElement place, + @NotNull final ResolveState state) { final PsiFile file = place.getContainingFile().getOriginalFile(); - CachedValue<List<PsiElement>> value = file.getUserData(INJECTION_PARSED_CONTEXT); - if (value == null) { - final BaseInjection injection = file.getUserData(BaseInjection.INJECTION_KEY); - final CachedValueProvider<List<PsiElement>> provider; - if (injection == null) { - provider = createDevProvider(file); - } - else { - provider = createPatternProvider(injection, file); + final BaseInjection injection = file.getUserData(BaseInjection.INJECTION_KEY); + Processor<PsiElement> processor = new Processor<PsiElement>() { + @Override + public boolean process(PsiElement element) { + return element.processDeclarations(scopeProcessor, state, null, place); } - if (provider == null) return; - file.putUserData(INJECTION_PARSED_CONTEXT, - value = CachedValuesManager.getManager(file.getProject()).createCachedValue(provider, false)); + }; + if (injection == null) { + processDevContext(file, processor); } - final List<PsiElement> roots = value.getValue(); - for (PsiElement root : roots) { - if (!root.processDeclarations(processor, state, null, place)) return; + else { + processPatternContext(injection, file, processor); } } - private static CachedValueProvider<List<PsiElement>> createPatternProvider(final BaseInjection injection, final PsiFile file) { - return new CachedValueProvider<List<PsiElement>>() { - @Override - public Result<List<PsiElement>> compute() { - return new Result<List<PsiElement>>(Collections.<PsiElement>singletonList( - getRootByClasses(InjectorUtils.getPatternClasses(injection.getSupportId()), file.getProject())), - ModificationTracker.NEVER_CHANGED); - } - }; + private static boolean processPatternContext(@NotNull BaseInjection injection, + @NotNull PsiFile file, + @NotNull Processor<PsiElement> processor) { + return processor.process(getRootByClasses(file, InjectorUtils.getPatternClasses(injection.getSupportId()))); } - private static PsiFile getRootByClasses(Class[] classes, Project project) { - final String text = PatternCompilerFactory.getFactory().getPatternCompiler(classes).dumpContextDeclarations(); - return PsiFileFactory.getInstance(project).createFileFromText("context.groovy", GroovyFileType.GROOVY_FILE_TYPE, text); + @NotNull + private static PsiFile getRootByClasses(@NotNull PsiFile file, @NotNull Class[] classes) { + final Project project = file.getProject(); + SoftFactoryMap<Class[], PsiFile> map = project.getUserData(PATTERN_INJECTION_CONTEXT); + if (map == null) { + map = new SoftFactoryMap<Class[], PsiFile>() { + + @Override + protected PsiFile create(Class[] key) { + String text = PatternCompilerFactory.getFactory().getPatternCompiler(key).dumpContextDeclarations(); + return PsiFileFactory.getInstance(project).createFileFromText("context.groovy", GroovyFileType.GROOVY_FILE_TYPE, text); + } + }; + project.putUserData(PATTERN_INJECTION_CONTEXT, map); + } + return map.get(classes); } - @Nullable - private static CachedValueProvider<List<PsiElement>> createDevProvider(final PsiFile file) { + private static boolean processDevContext(final PsiFile file, Processor<PsiElement> processor) { final XmlTag tag = getTagByInjectedFile(file); final XmlTag parentTag = tag == null ? null : tag.getParentTag(); final String parentTagName = parentTag == null ? null : parentTag.getName(); final String name = tag == null ? null : tag.getName(); - if ("place".equals(name) && "injection".equals(parentTagName) && parentTag != null) { - return new CachedValueProvider<List<PsiElement>>() { - @Override - public Result<List<PsiElement>> compute() { - final XmlTag tag = getTagByInjectedFile(file); - final XmlTag parentTag = tag == null ? null : tag.getParentTag(); - if (parentTag == null) return Result.create(Collections.<PsiElement>emptyList(), file); - return new Result<List<PsiElement>>(getRootsByClassNames(file, parentTag.getAttributeValue("injector-id")), parentTag.getContainingFile()); - } - }; + if ("place".equals(name) && "injection".equals(parentTagName)) { + return processRootsByClassNames(file, parentTag.getAttributeValue("injector-id"), processor); } else if ("pattern".equals(name) && parentTag != null) { - return new CachedValueProvider<List<PsiElement>>() { - @Override - public Result<List<PsiElement>> compute() { - final XmlTag tag = getTagByInjectedFile(file); - if (tag == null) return Result.create(Collections.<PsiElement>emptyList(), file); - return new Result<List<PsiElement>>(getRootsByClassNames(file, tag.getAttributeValue("type")), tag.getContainingFile()); - } - }; + return processRootsByClassNames(file, tag.getAttributeValue("type"), processor); } - else return null; + return true; } @Nullable @@ -135,22 +122,48 @@ public class PatternEditorContextMembersProvider extends NonCodeMembersContribut return element instanceof XmlText ? ((XmlText)element).getParentTag() : null; } - private static List<PsiElement> getRootsByClassNames(PsiFile file, String type) { - final List<PsiElement> roots = ContainerUtil.createLockFreeCopyOnWriteList(); + private static boolean processRootsByClassNames(@NotNull PsiFile file, @Nullable String type, @NotNull Processor<PsiElement> processor) { + Project project = file.getProject(); + Set<String> classNames = collectDevPatternClassNames(project); + if (!classNames.isEmpty()) { + JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); + for (String className : classNames) { + PsiClass patternClass = psiFacade.findClass(className, GlobalSearchScope.allScope(project)); + if (patternClass != null && !processor.process(patternClass)) return false; + } + } + Class[] classes = StringUtil.isEmpty(type) ? ArrayUtil.EMPTY_CLASS_ARRAY : PatternCompilerFactory.getFactory().getPatternClasses(type); + return classes.length == 0 || processor.process(getRootByClasses(file, classes)); + } + + private static Set<String> collectDevPatternClassNames(@NotNull final Project project) { + CachedValue<Set<String>> cachedValue = project.getUserData(PATTERN_CLASSES); + if (cachedValue == null) { + cachedValue = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<Set<String>>() { + @Nullable + @Override + public Result<Set<String>> compute() { + return Result.create(calcDevPatternClassNames(project), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT); + } + }, false); + project.putUserData(PATTERN_CLASSES, cachedValue); + } + return cachedValue.getValue(); + } - final Project project = file.getProject(); - final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); - final PsiClass beanClass = psiFacade.findClass(PatternClassBean.class.getName(), GlobalSearchScope.allScope(project)); + private static Set<String> calcDevPatternClassNames(@NotNull final Project project) { + final List<String> roots = ContainerUtil.createLockFreeCopyOnWriteList(); + JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); + PsiClass beanClass = psiFacade.findClass(PatternClassBean.class.getName(), GlobalSearchScope.allScope(project)); if (beanClass != null) { - final GlobalSearchScope scope = - GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), StdFileTypes.XML); + GlobalSearchScope scope = GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), StdFileTypes.XML); final TextOccurenceProcessor occurenceProcessor = new TextOccurenceProcessor() { @Override public boolean execute(@NotNull PsiElement element, int offsetInElement) { - final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class); - final String className = tag == null ? null : tag.getAttributeValue("className"); - if (className != null && tag.getLocalName().endsWith("patternClass")) { - ContainerUtil.addIfNotNull(psiFacade.findClass(className, GlobalSearchScope.allScope(project)), roots); + XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class); + String className = tag == null ? null : tag.getAttributeValue("className"); + if (StringUtil.isNotEmpty(className) && tag.getLocalName().endsWith("patternClass")) { + roots.add(className); } return true; } @@ -159,17 +172,13 @@ public class PatternEditorContextMembersProvider extends NonCodeMembersContribut CacheManager.SERVICE.getInstance(beanClass.getProject()).processFilesWithWord(new Processor<PsiFile>() { @Override public boolean process(PsiFile psiFile) { - LowLevelSearchUtil - .processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true, new EmptyProgressIndicator()); + LowLevelSearchUtil.processElementsContainingWordInElement(occurenceProcessor, psiFile, searcher, true, + new EmptyProgressIndicator()); return true; } }, searcher.getPattern(), UsageSearchContext.IN_FOREIGN_LANGUAGES, scope, searcher.isCaseSensitive()); } - final Class[] classes = PatternCompilerFactory.getFactory().getPatternClasses(type); - if (classes.length != 0) { - roots.add(getRootByClasses(classes, project)); - } - return roots; + return ContainerUtil.newHashSet(roots); } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerConfigurable.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerConfigurable.java index f273be1b3d6e..2db660e1cf04 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerConfigurable.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerConfigurable.java @@ -67,7 +67,7 @@ public class GroovyCompilerConfigurable implements SearchableConfigurable, Confi final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { - return super.isFileVisible(file, showHiddenFiles) && !index.isIgnored(file); + return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file); } }; descriptor.setRoots(ContainerUtil.concat( diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerExtension.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerExtension.java deleted file mode 100644 index 8d84f9f5b531..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompilerExtension.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2000-2009 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.plugins.groovy.compiler; - -import com.intellij.compiler.impl.javaCompiler.ModuleChunk; -import com.intellij.util.PathsList; -import com.intellij.openapi.extensions.ExtensionPointName; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -/** - * @author peter - */ -public abstract class GroovyCompilerExtension { - public static final ExtensionPointName<GroovyCompilerExtension> EP_NAME = ExtensionPointName.create("org.intellij.groovy.compilerExtension"); - - public abstract void enhanceCompilationClassPath(@NotNull ModuleChunk chunk, @NotNull PathsList classPath); - - @NotNull public abstract List<String> getCompilationUnitPatchers(@NotNull ModuleChunk chunk); - -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/TopLevelDependencyValidityState.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/TopLevelDependencyValidityState.java deleted file mode 100644 index 4c673957c36a..000000000000 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/generator/TopLevelDependencyValidityState.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2000-2014 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.compiler.generator; - -import com.intellij.openapi.compiler.ValidityState; -import com.intellij.openapi.diagnostic.Logger; - -import java.io.*; -import java.util.ArrayList; -import java.util.List; - -/** - * User: Dmitry.Krasilschikov - * Date: 20.08.2007 - */ -class TopLevelDependencyValidityState implements ValidityState { - private final long myTimestamp; - private final List<String> myMembers; //fields - - private static final Logger LOG = Logger.getInstance("org.jetbrains.plugins.groovy.compiler.generator.TopLevelDependencyValidityState"); - - TopLevelDependencyValidityState(long timestamp, List<String> members) { -// use signature of method and access modifiers - this.myMembers = members; - myTimestamp = timestamp; - } - - @Override - public boolean equalsTo(ValidityState validityState) { - if (!(validityState instanceof TopLevelDependencyValidityState)) return false; - - return ((TopLevelDependencyValidityState) validityState).myTimestamp == this.myTimestamp - && myMembers.equals(((TopLevelDependencyValidityState) validityState).myMembers); - } - - @Override - public void save(DataOutput out) throws IOException { - out.writeLong(myTimestamp); - out.writeChar('\n'); - - for (String member : myMembers) { - out.writeChar('\n'); - out.writeUTF(member); - } - } - - public static TopLevelDependencyValidityState load(DataInputStream is) throws IOException { - long timestamp = -1; - - Reader reader = new InputStreamReader(is); - StreamTokenizer tokenizer = new StreamTokenizer(reader); -// tokenizer.whitespaceChars(' ', ' '); -// tokenizer.whitespaceChars('\t', '\t'); -// tokenizer.whitespaceChars('\f', '\f'); -// tokenizer.whitespaceChars('\n', '\n'); -// tokenizer.whitespaceChars('\r', '\r'); - - List<String> members = new ArrayList<String>(); - while (true) { - int ttype = tokenizer.nextToken(); - switch (ttype) { - case StreamTokenizer.TT_NUMBER: { - try { - timestamp = (long) tokenizer.nval; - } catch (NumberFormatException e) { - LOG.error(e); - } - break; - } - case StreamTokenizer.TT_WORD: { - members.add(tokenizer.sval); - break; - } - case StreamTokenizer.TT_EOL: - break; - case StreamTokenizer.TT_EOF: - default: - break; - } - if (ttype == StreamTokenizer.TT_EOF) - break; - } - return new TopLevelDependencyValidityState(timestamp, members); - } -} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerClassFilterProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerClassFilterProvider.java index 34830b9a8988..7b734a4654b5 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerClassFilterProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerClassFilterProvider.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.debugger.filters; +package org.jetbrains.plugins.groovy.debugger; import com.intellij.ui.classFilter.ClassFilter; import com.intellij.ui.classFilter.DebuggerClassFilterProvider; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerSettings.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettings.java index dbadd515c140..273fd4cb8531 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerSettings.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettings.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.debugger.filters; +package org.jetbrains.plugins.groovy.debugger; import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; @@ -23,6 +23,7 @@ import com.intellij.openapi.util.registry.Registry; import com.intellij.util.xmlb.XmlSerializerUtil; import com.intellij.xdebugger.settings.XDebuggerSettings; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author ilyas @@ -35,7 +36,6 @@ import org.jetbrains.annotations.NotNull; )} ) public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSettings> { - public Boolean DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS = true; public boolean ENABLE_GROOVY_HOTSWAP = Registry.is("enable.groovy.hotswap"); @@ -49,6 +49,15 @@ public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSett return new GroovyDebuggerSettingsConfigurable(this); } + @Nullable + @Override + public Configurable createConfigurable(@NotNull Category category) { + if (category == Category.STEPPING) { + return new GroovySteppingConfigurable(); + } + return null; + } + @Override public GroovyDebuggerSettings getState() { return this; @@ -62,5 +71,4 @@ public class GroovyDebuggerSettings extends XDebuggerSettings<GroovyDebuggerSett public static GroovyDebuggerSettings getInstance() { return getInstance(GroovyDebuggerSettings.class); } - -} +}
\ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerSettingsConfigurable.form b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.form index a91ac8c1dae7..171170b00571 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerSettingsConfigurable.form +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.form @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> -<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettingsConfigurable"> - <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> +<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.GroovyDebuggerSettingsConfigurable"> + <grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="0" left="0" bottom="0" right="0"/> <constraints> <xy x="20" y="20" width="661" height="400"/> @@ -8,22 +8,14 @@ <properties/> <border type="none"/> <children> - <component id="84a2f" class="javax.swing.JCheckBox" binding="myIgnoreGroovyMethods"> - <constraints> - <grid row="0" 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 resource-bundle="org/jetbrains/plugins/groovy/GroovyBundle" key="groovy.debug.disable.specific.methods"/> - </properties> - </component> <vspacer id="30909"> <constraints> - <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> </constraints> </vspacer> <component id="908a2" class="com.intellij.ui.components.JBLabel"> <constraints> - <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="3" use-parent-layout="false"/> </constraints> <properties> <componentStyle value="SMALL"/> @@ -33,7 +25,7 @@ <grid id="bd4f0" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> <margin top="2" left="0" bottom="0" right="0"/> <constraints> - <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> + <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"/> </constraints> <properties/> <border type="none"/> diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerSettingsConfigurable.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.java index 4638aca4bdc9..8f143d9a5fd1 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerSettingsConfigurable.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyDebuggerSettingsConfigurable.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jetbrains.plugins.groovy.debugger.filters; +package org.jetbrains.plugins.groovy.debugger; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.options.SearchableConfigurable; @@ -29,7 +29,6 @@ import java.awt.event.ActionListener; * @author ilyas */ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurable { - private JCheckBox myIgnoreGroovyMethods; private JPanel myPanel; private JCheckBox myEnableHotSwap; private boolean isModified = false; @@ -37,19 +36,13 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl public GroovyDebuggerSettingsConfigurable(final GroovyDebuggerSettings settings) { mySettings = settings; - final Boolean flag = settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS; - myIgnoreGroovyMethods.setSelected(flag == null || flag.booleanValue()); - myIgnoreGroovyMethods.setSelected(mySettings.ENABLE_GROOVY_HOTSWAP); - ActionListener listener = new ActionListener() { + myEnableHotSwap.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - isModified = mySettings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS.booleanValue() != myIgnoreGroovyMethods.isSelected() || - mySettings.ENABLE_GROOVY_HOTSWAP != myEnableHotSwap.isSelected(); + isModified = mySettings.ENABLE_GROOVY_HOTSWAP != myEnableHotSwap.isSelected(); } - }; - myIgnoreGroovyMethods.addActionListener(listener); - myEnableHotSwap.addActionListener(listener); + }); } @Override @@ -59,6 +52,7 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl } @Override + @NotNull public String getHelpTopic() { return "reference.idesettings.debugger.groovy"; } @@ -87,7 +81,6 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl @Override public void apply() throws ConfigurationException { if (isModified) { - mySettings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS = myIgnoreGroovyMethods.isSelected(); mySettings.ENABLE_GROOVY_HOTSWAP = myEnableHotSwap.isSelected(); } isModified = false; @@ -95,8 +88,6 @@ public class GroovyDebuggerSettingsConfigurable implements SearchableConfigurabl @Override public void reset() { - final Boolean flag = mySettings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS; - myIgnoreGroovyMethods.setSelected(flag == null || flag.booleanValue()); myEnableHotSwap.setSelected(mySettings.ENABLE_GROOVY_HOTSWAP); } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java index bd0398bf5dd1..95b93362c14d 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java @@ -41,7 +41,6 @@ import com.intellij.psi.util.PsiModificationTracker; import com.intellij.util.PathUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.groovy.GroovyFileType; -import org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettings; import java.io.File; import java.io.IOException; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurable.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurable.java new file mode 100644 index 000000000000..0e5d99552d47 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurable.java @@ -0,0 +1,37 @@ +package org.jetbrains.plugins.groovy.debugger; + +import com.intellij.openapi.options.ConfigurableBase; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.plugins.groovy.GroovyBundle; + +class GroovySteppingConfigurable extends ConfigurableBase<GroovySteppingConfigurableUi, GroovyDebuggerSettings> { + @Override + protected GroovyDebuggerSettings getSettings() { + return GroovyDebuggerSettings.getInstance(); + } + + @Override + protected GroovySteppingConfigurableUi createUi() { + return new GroovySteppingConfigurableUi(); + } + + @NotNull + @Override + public String getId() { + return "debugger.stepping.groovy"; + } + + @Nls + @Override + public String getDisplayName() { + return GroovyBundle.message("groovy.debug.caption"); + } + + @Nullable + @Override + public String getHelpTopic() { + return "reference.idesettings.debugger.groovy"; + } +}
\ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.form b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.form new file mode 100644 index 000000000000..ac93a675fc77 --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.form @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.groovy.debugger.GroovySteppingConfigurableUi"> + <grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> + <margin top="0" left="0" bottom="0" right="0"/> + <constraints> + <xy x="20" y="20" width="500" height="400"/> + </constraints> + <properties/> + <border type="none"/> + <children> + <component id="821e8" class="javax.swing.JCheckBox" binding="ignoreGroovyMethods"> + <constraints> + <grid row="0" 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 resource-bundle="org/jetbrains/plugins/groovy/GroovyBundle" key="groovy.debug.disable.specific.methods"/> + </properties> + </component> + <vspacer id="209fe"> + <constraints> + <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> + </constraints> + </vspacer> + </children> + </grid> +</form> diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.java new file mode 100644 index 000000000000..d0e9e9e766cb --- /dev/null +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovySteppingConfigurableUi.java @@ -0,0 +1,33 @@ +package org.jetbrains.plugins.groovy.debugger; + +import com.intellij.openapi.options.ConfigurableUi; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +class GroovySteppingConfigurableUi implements ConfigurableUi<GroovyDebuggerSettings> { + private JCheckBox ignoreGroovyMethods; + private JPanel rootPanel; + + @Override + public void reset(@NotNull GroovyDebuggerSettings settings) { + Boolean flag = settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS; + ignoreGroovyMethods.setSelected(flag == null || flag.booleanValue()); + } + + @Override + public boolean isModified(@NotNull GroovyDebuggerSettings settings) { + return settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS.booleanValue() != ignoreGroovyMethods.isSelected(); + } + + @Override + public void apply(@NotNull GroovyDebuggerSettings settings) { + settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS = ignoreGroovyMethods.isSelected(); + } + + @NotNull + @Override + public JComponent getComponent() { + return rootPanel; + } +}
\ No newline at end of file diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GrMethodMergingContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GrMethodMergingContributor.java index e84361b0f57d..2c05dd7a3589 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GrMethodMergingContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GrMethodMergingContributor.java @@ -21,7 +21,6 @@ import com.intellij.codeInsight.lookup.LookupItem; import com.intellij.psi.PsiMethod; import com.intellij.psi.PsiParameter; import com.intellij.psi.PsiType; -import com.intellij.psi.ResolveResult; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil; import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames; @@ -46,13 +45,9 @@ public class GrMethodMergingContributor extends CompletionContributor { final LookupElement[] items = context.getItems(); if (items.length > 1) { String commonName = null; - LookupElement best = null; final ArrayList<PsiMethod> allMethods = new ArrayList<PsiMethod>(); for (LookupElement item : items) { - Object o = item.getObject(); - if (o instanceof ResolveResult) { - o = ((ResolveResult)o).getElement(); - } + Object o = item.getPsiElement(); if (item.getUserData(LookupItem.FORCE_SHOW_SIGNATURE_ATTR) != null || !(o instanceof PsiMethod)) { return AutoCompletionDecision.SHOW_LOOKUP; } @@ -76,17 +71,11 @@ public class GrMethodMergingContributor extends CompletionContributor { return AutoCompletionDecision.SHOW_LOOKUP; } - if (best == null && method.getParameterList().getParametersCount() > 0) { - best = item; - } commonName = name; allMethods.add(method); item.putUserData(JavaCompletionUtil.ALL_METHODS_ATTRIBUTE, allMethods); } - if (best == null) { - best = items[0]; - } - return AutoCompletionDecision.insertItem(best); + return AutoCompletionDecision.insertItem(JavaMethodMergingContributor.findBestOverload(items)); } return super.handleAutoCompletionPossibility(context); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/providers/GroovyReferenceContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/providers/GroovyReferenceContributor.java index e25c490f87cd..626983ab635a 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/providers/GroovyReferenceContributor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/providers/GroovyReferenceContributor.java @@ -34,5 +34,6 @@ public class GroovyReferenceContributor extends PsiReferenceContributor { registrar.registerReferenceProvider(GroovyPatterns.stringLiteral().withParent(GrAnnotationNameValuePair.class), new SpockUnrollReferenceProvider()); + } } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureUtil.java index e21a367eac62..2bfa261f420c 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureUtil.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureUtil.java @@ -143,9 +143,15 @@ public class MvcModuleStructureUtil { } public static void removeSrcFolderFromRoots(final VirtualFile file, - List<Consumer<ContentEntry>> actions, - Map<VirtualFile, JpsModuleSourceRootType<?>> sourceRoots) { - if (sourceRoots.containsKey(file)) { + @NotNull List<Consumer<ContentEntry>> actions, + @NotNull Map<VirtualFile, JpsModuleSourceRootType<?>> sourceRoots) { + removeSrcFolderFromRoots(file, actions, sourceRoots.keySet()); + } + + public static void removeSrcFolderFromRoots(final VirtualFile file, + @NotNull List<Consumer<ContentEntry>> actions, + @NotNull Collection<VirtualFile> sourceRoots) { + if (sourceRoots.contains(file)) { actions.add(new Consumer<ContentEntry>() { @Override public void consume(ContentEntry contentEntry) { @@ -163,7 +169,7 @@ public class MvcModuleStructureUtil { @Nullable public static Consumer<ModifiableRootModel> addJarDirectory(VirtualFile root, Module module, final String libName) { final VirtualFile libDir = root.findFileByRelativePath("lib"); - if (libDir == null || !libDir.isDirectory() || ProjectRootManager.getInstance(module.getProject()).getFileIndex().isIgnored(libDir)) { + if (libDir == null || !libDir.isDirectory() || ProjectRootManager.getInstance(module.getProject()).getFileIndex().isExcluded(libDir)) { return null; } @@ -350,16 +356,17 @@ public class MvcModuleStructureUtil { private static void removeInvalidSourceRoots(List<Consumer<ModifiableRootModel>> actions, MvcProjectStructure structure) { final Set<SourceFolder> toRemove = ContainerUtil.newTroveSet(); - final Set<ContentEntry> toRemoveContent = ContainerUtil.newTroveSet(); + final Set<String> toRemoveContent = ContainerUtil.newTroveSet(); for (ContentEntry entry : ModuleRootManager.getInstance(structure.myModule).getContentEntries()) { final VirtualFile file = entry.getFile(); if (file == null || !structure.isValidContentRoot(file)) { - toRemoveContent.add(entry); + toRemoveContent.add(entry.getUrl()); } - - for (SourceFolder folder : entry.getSourceFolders()) { - if (folder.getFile() == null) { - toRemove.add(folder); + else { + for (SourceFolder folder : entry.getSourceFolders()) { + if (folder.getFile() == null) { + toRemove.add(folder); + } } } } @@ -368,14 +375,15 @@ public class MvcModuleStructureUtil { actions.add(new Consumer<ModifiableRootModel>() { @Override public void consume(ModifiableRootModel model) { - for (final ContentEntry entry : toRemoveContent) { - model.removeContentEntry(entry); - } - for (ContentEntry entry : model.getContentEntries()) { - for (SourceFolder folder : entry.getSourceFolders()) { - if (toRemove.remove(folder)) { - entry.removeSourceFolder(folder); + if (toRemoveContent.remove(entry.getUrl())) { + model.removeContentEntry(entry); + } + else { + for (SourceFolder folder : entry.getSourceFolders()) { + if (toRemove.remove(folder)) { + entry.removeSourceFolder(folder); + } } } } diff --git a/plugins/groovy/structuralsearch-groovy/src/com/intellij/structuralsearch/GroovyEquivalenceDescriptorProvider.java b/plugins/groovy/structuralsearch-groovy/src/com/intellij/structuralsearch/GroovyEquivalenceDescriptorProvider.java new file mode 100644 index 000000000000..3637b97c111d --- /dev/null +++ b/plugins/groovy/structuralsearch-groovy/src/com/intellij/structuralsearch/GroovyEquivalenceDescriptorProvider.java @@ -0,0 +1,99 @@ +package com.intellij.structuralsearch; + +import com.intellij.dupLocator.equivalence.EquivalenceDescriptor; +import com.intellij.dupLocator.equivalence.EquivalenceDescriptorBuilder; +import com.intellij.dupLocator.equivalence.EquivalenceDescriptorProvider; +import com.intellij.psi.PsiElement; +import com.intellij.psi.tree.TokenSet; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.plugins.groovy.GroovyLanguage; +import org.jetbrains.plugins.groovy.lang.lexer.TokenSets; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClause; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod; +import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner; + +/** + * @author Eugene.Kudelevsky + */ +public class GroovyEquivalenceDescriptorProvider extends EquivalenceDescriptorProvider { + private static final TokenSet IGNORED_TOKENS = TokenSet.orSet(TokenSets.WHITE_SPACES_OR_COMMENTS, TokenSets.SEPARATORS); + + @Override + public boolean isMyContext(@NotNull PsiElement context) { + return context.getLanguage().isKindOf(GroovyLanguage.INSTANCE); + } + + @Override + public EquivalenceDescriptor buildDescriptor(@NotNull PsiElement e) { + final EquivalenceDescriptorBuilder builder = new EquivalenceDescriptorBuilder(); + + if (e instanceof GrVariableDeclaration) { + return builder.elements(((GrVariableDeclaration)e).getVariables()); + } + else if (e instanceof GrParameter) { + final GrParameter p = (GrParameter)e; + return builder + .element(p.getNameIdentifierGroovy()) + .optionally(p.getTypeElementGroovy()) + .optionallyInPattern(p.getInitializerGroovy()); + } + else if (e instanceof GrVariable) { + final GrVariable v = (GrVariable)e; + return builder + .element(v.getNameIdentifierGroovy()) + .optionally(v.getTypeElementGroovy()) + .optionallyInPattern(v.getInitializerGroovy()); + } + else if (e instanceof GrMethod) { + final GrMethod m = (GrMethod)e; + return builder + .element(m.getNameIdentifierGroovy()) + .elements(m.getParameters()) + .optionally(m.getReturnTypeElementGroovy()) + .optionallyInPattern(m.getBlock()); + } + else if (e instanceof GrTypeDefinitionBody) { + final GrTypeDefinitionBody b = (GrTypeDefinitionBody)e; + return builder + .inAnyOrder(b.getFields()) + .inAnyOrder(b.getMethods()) + .inAnyOrder(b.getInitializers()) + .inAnyOrder(b.getInnerClasses()); + } + else if (e instanceof GrTypeDefinition) { + GrTypeDefinition d = (GrTypeDefinition)e; + return builder.element(d.getNameIdentifierGroovy()) + .optionallyInPattern(d.getExtendsClause()) + .optionallyInPattern(d.getImplementsClause()) + .optionallyInPattern(d.getBody()); + } + else if (e instanceof GrForInClause) { + final GrForInClause f = (GrForInClause)e; + return builder + .element(f.getDeclaredVariable()) + .element(f.getIteratedExpression()); + } + else if (e instanceof GrReferenceList) { + return builder.inAnyOrder(((GrReferenceList)e).getReferenceElementsGroovy()); + } + else if (e instanceof GrCodeBlock) { + return builder.codeBlock(((GrStatementOwner)e).getStatements()); + } + + // todo: support 'object method()' <-> 'object.method()' + + return null; + } + + @Override + public TokenSet getIgnoredTokens() { + return IGNORED_TOKENS; + } +} diff --git a/plugins/groovy/structuralsearch-groovy/structuralsearch-groovy.iml b/plugins/groovy/structuralsearch-groovy/structuralsearch-groovy.iml index dbde3887908d..44183f613d0f 100644 --- a/plugins/groovy/structuralsearch-groovy/structuralsearch-groovy.iml +++ b/plugins/groovy/structuralsearch-groovy/structuralsearch-groovy.iml @@ -15,7 +15,7 @@ <orderEntry type="module" module-name="lang-impl" /> <orderEntry type="module" module-name="structuralsearch-tests" scope="TEST" /> <orderEntry type="module" module-name="testFramework-java" scope="TEST" /> - <orderEntry type="module" module-name="duplicates-analysis" scope="TEST" /> + <orderEntry type="module" module-name="duplicates-analysis" /> </component> </module> diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java index 42404baeec57..ec2d50c94355 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java @@ -17,6 +17,7 @@ package org.jetbrains.plugins.groovy; import com.intellij.TestAll; import com.intellij.TestCaseLoader; +import com.intellij.openapi.externalSystem.test.ExternalSystemTestCase; import junit.framework.Test; import junit.framework.TestSuite; import org.jetbrains.plugins.groovy.compiler.GroovyCompilerTest; @@ -45,7 +46,7 @@ public class FastGroovyTestSuite { private static boolean isSlow(Class aClass) { return aClass.equals(GroovyDebuggerTest.class) || aClass.equals(GroovyStressPerformanceTest.class) || - aClass.getName().startsWith(GroovyCompilerTest.class.getName()); + aClass.getName().startsWith(GroovyCompilerTest.class.getName()) || + ExternalSystemTestCase.class.isAssignableFrom(aClass); } - } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy index af16cc4ccb21..b6584bef6345 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GrCommentTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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,11 +15,11 @@ */ package org.jetbrains.plugins.groovy -import com.intellij.codeInsight.actions.CodeInsightAction import com.intellij.codeInsight.generation.actions.CommentByBlockCommentAction import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction import com.intellij.ide.DataManager import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.DataContext import org.jetbrains.annotations.NotNull @@ -100,7 +100,7 @@ print 2 doTest(before, after, new CommentByBlockCommentAction()) } - private void doTest(@NotNull String before, @NotNull String after, final CodeInsightAction action) { + private void doTest(@NotNull String before, @NotNull String after, final AnAction action) { myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, before) final DataContext dataContext = DataManager.instance.dataContextFromFocus.result action.actionPerformed(new AnActionEvent(null, dataContext, "", action.templatePresentation, ActionManager.instance, 0)); diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy index d6293f2e01d5..061f941ea1a0 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy @@ -1923,4 +1923,10 @@ var.<caret> ''', '', CompletionType.BASIC, CompletionResult.contain, 1, 'A__foo', 'bar') } + void testCharsetName() { + myFixture.addClass("package java.nio.charset; public class Charset { public static boolean isSupported(String s) {} }") + doVariantableTest('import java.nio.charset.*; Charset.isSupported("<caret>")', '', CompletionType.BASIC, CompletionResult.contain, 1, 'UTF-8') + } + + }
\ No newline at end of file diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/findUsages/FindUsagesTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/findUsages/FindUsagesTest.groovy index abc454f356e5..6ee91ef2581f 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/findUsages/FindUsagesTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/findUsages/FindUsagesTest.groovy @@ -429,7 +429,7 @@ print a<caret>a } void testTraitField() { - doTest(6, ''' + doTest(4, ''' trait T { public int fi<caret>eld = 4 @@ -439,16 +439,16 @@ trait T { } } -class C extends T { - def abc { - print field +class C implements T { + def abc() { + print field //unresolved print T__field } } new C().T__field -new C().field +new C().field //unresolved ''') } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInference2_3Test.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInference2_3Test.groovy index 7382469e50e4..e6882d70258b 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInference2_3Test.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInference2_3Test.groovy @@ -15,6 +15,7 @@ */ package org.jetbrains.plugins.groovy.lang.resolve +import com.intellij.psi.PsiMethod import com.intellij.testFramework.LightProjectDescriptor import org.jetbrains.plugins.groovy.GroovyLightProjectDescriptor @@ -205,4 +206,15 @@ class Thing { } + void testClosureParamsUsingGenerics() { + doTest("""\ + import groovy.transform.CompileStatic + + @CompileStatic + class Idea { + public static void main(String[] args) { + ["bc", "a", ].sort { i<caret>t.size() } + } + }""", "java.lang.String") + } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java index 14f6c981777b..1d41cdc688f9 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgCommandAuthenticator.java @@ -35,7 +35,7 @@ import org.zmlx.hg4idea.HgVcsMessages; class HgCommandAuthenticator { private static final Logger LOG = Logger.getInstance(HgCommandAuthenticator.class.getName()); - + private GetPasswordRunnable myGetPassword; private final Project myProject; private boolean myForceAuthorization; @@ -71,7 +71,7 @@ class HgCommandAuthenticator { } public boolean promptForAuthentication(Project project, String proposedLogin, String uri, String path, @Nullable ModalityState state) { - GetPasswordRunnable runnable = new GetPasswordRunnable(project, proposedLogin, uri, path, myForceAuthorization); + GetPasswordRunnable runnable = new GetPasswordRunnable(project, proposedLogin, uri, path, myForceAuthorization, state); ApplicationManager.getApplication().invokeAndWait(runnable, state == null ? ModalityState.defaultModalityState() : state); myGetPassword = runnable; return runnable.isOk(); @@ -96,14 +96,21 @@ class HgCommandAuthenticator { @Nullable private String myURL; private boolean myRememberPassword; private boolean myForceAuthorization; - - public GetPasswordRunnable(Project project, String proposedLogin, String uri, String path, boolean forceAuthorization) { + @Nullable private ModalityState myState; + + public GetPasswordRunnable(Project project, + String proposedLogin, + String uri, + String path, + boolean forceAuthorization, + @Nullable ModalityState state) { this.myProject = project; this.myProposedLogin = proposedLogin; this.myURL = uri + path; this.myForceAuthorization = forceAuthorization; + myState = state; } - + public void run() { // find if we've already been here @@ -128,11 +135,9 @@ class HgCommandAuthenticator { final String key = keyForUrlAndLogin(myURL, login); try { final PasswordSafeImpl passwordSafe = (PasswordSafeImpl)PasswordSafe.getInstance(); - password = passwordSafe.getMemoryProvider().getPassword(myProject, HgCommandAuthenticator.class, key); - if (password == null) { - password = passwordSafe.getPassword(myProject, HgCommandAuthenticator.class, key); - } - } catch (PasswordSafeException e) { + password = passwordSafe.getPassword(myProject, HgCommandAuthenticator.class, key, myState); + } + catch (PasswordSafeException e) { LOG.info("Couldn't get password for key [" + key + "]", e); } } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java index 9fa266e560a1..8a5949140d23 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/log/HgRefManager.java @@ -90,17 +90,10 @@ public class HgRefManager implements VcsLogRefManager { } }; -/* - public HgRefManager(@NotNull RepositoryManager<HgRepository> repositoryManager) { - myRepositoryManager = repositoryManager; - }*/ - @NotNull @Override - public List<VcsRef> sort(Collection<VcsRef> refs) { - ArrayList<VcsRef> list = new ArrayList<VcsRef>(refs); - Collections.sort(list, REF_COMPARATOR); - return list; + public Comparator<VcsRef> getComparator() { + return REF_COMPARATOR; } @NotNull @@ -114,6 +107,11 @@ public class HgRefManager implements VcsLogRefManager { }); } + @NotNull + private Collection<VcsRef> sort(@NotNull Collection<VcsRef> refs) { + return ContainerUtil.sorted(refs, getComparator()); + } + private static class SimpleRefType implements VcsRefType { private final boolean myIsBranch; @NotNull private final Color myColor; diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java index 4052b34a60d5..038c1c24121f 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/update/HgUpdateEnvironment.java @@ -99,7 +99,7 @@ public class HgUpdateEnvironment implements UpdateEnvironment { } public String getHelpTopic() { - return null; + return "reference.VersionControl.Mercurial.UpdateProject"; } public JComponent createComponent() { diff --git a/plugins/java-decompiler/lib/fernflower.jar b/plugins/java-decompiler/lib/fernflower.jar Binary files differindex 85b1c40002b5..d8589afbb097 100644 --- a/plugins/java-decompiler/lib/fernflower.jar +++ b/plugins/java-decompiler/lib/fernflower.jar diff --git a/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java b/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java index bf0454fd6670..f57ea6a4087b 100644 --- a/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java +++ b/plugins/java-decompiler/src/org/jetbrains/java/decompiler/IdeaDecompiler.java @@ -138,7 +138,9 @@ public class IdeaDecompiler extends ClassFileDecompilers.Light { } }, ClassReader.SKIP_CODE); } - catch (IOException ignore) { } + catch (Exception e) { + throw new RuntimeException("corrupted file: " + file.getUrl(), e); + } if (isGroovy.get()) { LOG.info("skipped Groovy class: " + file.getUrl()); return false; diff --git a/plugins/java-decompiler/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java b/plugins/java-decompiler/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java index 9367fc066f30..060b269789e3 100644 --- a/plugins/java-decompiler/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java +++ b/plugins/java-decompiler/test/org/jetbrains/java/decompiler/IdeaDecompilerTest.java @@ -40,10 +40,7 @@ public class IdeaDecompilerTest extends LightCodeInsightFixtureTestCase { VirtualFile file = StandardFileSystems.jar().findFileByPath(path); assertNotNull(path, file); - CharSequence text = new IdeaDecompiler().getText(file); - assertNotNull(text); - - String decompiled = text.toString(); + String decompiled = new IdeaDecompiler().getText(file).toString(); assertTrue(decompiled, decompiled.contains("public final class String")); assertTrue(decompiled, decompiled.contains("@deprecated")); assertTrue(decompiled, decompiled.contains("private static class CaseInsensitiveComparator")); @@ -57,6 +54,7 @@ public class IdeaDecompilerTest extends LightCodeInsightFixtureTestCase { public void testParameters() { doTestDecompiler(); } public void testConstants() { doTestDecompiler(); } public void testAnonymous() { doTestDecompiler(); } + public void testCodeConstructs() { doTestDecompiler(); } private void doTestDecompiler() { String name = PluginPathManager.getPluginHomePath("java-decompiler") + "/testData/" + getName().substring(4); @@ -103,7 +101,6 @@ public class IdeaDecompilerTest extends LightCodeInsightFixtureTestCase { VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() { @Override public boolean visitFile(@NotNull VirtualFile file) { - if (file.getName().equals("Jps.class")) return true; // temp. fix if (!file.isDirectory() && file.getFileType() == StdFileTypes.CLASS && !file.getName().contains("$")) { PsiFile clsFile = getPsiManager().findFile(file); assertNotNull(file.getPath(), clsFile); diff --git a/plugins/java-decompiler/testData/CodeConstructs.class b/plugins/java-decompiler/testData/CodeConstructs.class Binary files differnew file mode 100644 index 000000000000..bcac6685eb01 --- /dev/null +++ b/plugins/java-decompiler/testData/CodeConstructs.class diff --git a/plugins/java-decompiler/testData/CodeConstructs.java b/plugins/java-decompiler/testData/CodeConstructs.java new file mode 100644 index 000000000000..d0c2e35311c8 --- /dev/null +++ b/plugins/java-decompiler/testData/CodeConstructs.java @@ -0,0 +1,5 @@ +class CodeConstructs { + void expressions() { + new String().hashCode(); + } +}
\ No newline at end of file diff --git a/plugins/java-decompiler/testData/CodeConstructs.txt b/plugins/java-decompiler/testData/CodeConstructs.txt new file mode 100644 index 000000000000..59bc71849dd6 --- /dev/null +++ b/plugins/java-decompiler/testData/CodeConstructs.txt @@ -0,0 +1,15 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by Fernflower decompiler) +// + + +class CodeConstructs { + + CodeConstructs() { + } + + void expressions() { + (new String()).hashCode(); + } +} diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/duplicateStringLiteral/DuplicateStringLiteralInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/duplicateStringLiteral/DuplicateStringLiteralInspection.java index ce785c3df593..4efa0639e645 100644 --- a/plugins/java-i18n/src/com/intellij/codeInspection/duplicateStringLiteral/DuplicateStringLiteralInspection.java +++ b/plugins/java-i18n/src/com/intellij/codeInspection/duplicateStringLiteral/DuplicateStringLiteralInspection.java @@ -20,6 +20,7 @@ import com.intellij.codeInsight.daemon.GroupNames; import com.intellij.codeInspection.*; import com.intellij.codeInspection.ex.BaseLocalInspectionTool; import com.intellij.codeInspection.i18n.JavaI18nUtil; +import com.intellij.lang.java.JavaLanguage; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.progress.ProgressIndicator; @@ -133,13 +134,19 @@ public class DuplicateStringLiteralInspection extends BaseLocalInspectionTool { } if (resultFiles.isEmpty()) return; } + if (resultFiles == null || resultFiles.isEmpty()) return; final List<PsiExpression> foundExpr = new ArrayList<PsiExpression>(); + for (PsiFile file : resultFiles) { progress.checkCanceled(); - CharSequence text = file.getViewProvider().getContents(); + FileViewProvider viewProvider = file.getViewProvider(); + // important: skip non-java files with given word in literal (IDEA-126201) + if (viewProvider.getPsi(JavaLanguage.INSTANCE) == null) continue; + CharSequence text = viewProvider.getContents(); final char[] textArray = CharArrayUtil.fromSequenceWithoutCopying(text); StringSearcher searcher = new StringSearcher(stringToFind, true, true); + for (int offset = LowLevelSearchUtil.searchWord(text, textArray, 0, text.length(), searcher, progress); offset >= 0; offset = LowLevelSearchUtil.searchWord(text, textArray, offset + searcher.getPattern().length(), text.length(), searcher, progress) diff --git a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml index c03a5f4bff9c..1256121f509f 100644 --- a/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml +++ b/plugins/javaFX/src/META-INF/common-javaFX-plugin.xml @@ -25,7 +25,7 @@ enabledByDefault="true" level="WARNING" displayName="JavaFX unused imports" groupName="JavaFX"/> <applicationService serviceInterface="org.jetbrains.plugins.javaFX.JavaFxSettings" serviceImplementation="org.jetbrains.plugins.javaFX.JavaFxSettings"/> - <applicationConfigurable instance="org.jetbrains.plugins.javaFX.JavaFxSettingsConfigurable"/> + <applicationConfigurable groupId="language" displayName="JavaFX" instance="org.jetbrains.plugins.javaFX.JavaFxSettingsConfigurable"/> <fileBasedIndex implementation="org.jetbrains.plugins.javaFX.JavaFxControllerClassIndex"/> <fileBasedIndex implementation="org.jetbrains.plugins.javaFX.JavaFxIdsIndex"/> <fileBasedIndex implementation="org.jetbrains.plugins.javaFX.JavaFxCustomComponentsIndex"/> diff --git a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java index d1ff8d5a9792..07e578bae6c8 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java +++ b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurable.java @@ -394,7 +394,7 @@ public class JUnitConfigurable extends SettingsEditor<JUnitConfiguration> implem @Override public Visibility isDeclarationVisible(PsiElement declaration, PsiElement place) { try { - if (declaration instanceof PsiClass && classBrowser.getFilter().isAccepted(((PsiClass)declaration))) { + if (declaration instanceof PsiClass && (classBrowser.getFilter().isAccepted(((PsiClass)declaration)) || classBrowser.findClass(((PsiClass)declaration).getQualifiedName()) != null && place.getParent() != null)) { return Visibility.VISIBLE; } } diff --git a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurationModel.java b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurationModel.java index 38a3ff9915e3..fe5a13181ab9 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurationModel.java +++ b/plugins/junit/src/com/intellij/execution/junit2/configuration/JUnitConfigurationModel.java @@ -172,7 +172,7 @@ public class JUnitConfigurationModel { final JUnitConfiguration.Data data = configuration.getPersistentData(); setTestType(data.TEST_OBJECT); setJUnitTextValue(ALL_IN_PACKAGE, data.getPackageName()); - setJUnitTextValue(CLASS, data.getMainClassName()); + setJUnitTextValue(CLASS, data.getMainClassName().replaceAll("\\$", "\\.")); setJUnitTextValue(METHOD, data.getMethodName()); setJUnitTextValue(PATTERN, data.getPatternPresentation()); setJUnitTextValue(DIR, data.getDirName()); diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml index 960cb1c5df24..0261f132277c 100644 --- a/plugins/maven/src/main/resources/META-INF/plugin.xml +++ b/plugins/maven/src/main/resources/META-INF/plugin.xml @@ -46,7 +46,7 @@ <applicationService serviceImplementation="org.jetbrains.idea.maven.indices.MavenIndicesManager"/> <applicationService serviceImplementation="org.jetbrains.idea.maven.services.MavenRepositoryServicesManager"/> - <projectConfigurable instance="org.jetbrains.idea.maven.utils.MavenSettings" id="MavenSettings" displayName="Maven" order="last"> + <projectConfigurable groupId="build" instance="org.jetbrains.idea.maven.utils.MavenSettings" id="MavenSettings" displayName="Maven" order="last"> <configurable instance="org.jetbrains.idea.maven.project.MavenImportingConfigurable" id="reference.settings.project.maven.importing" key="maven.tab.importing" bundle="ProjectBundle"/> <configurable instance="org.jetbrains.idea.maven.project.MavenIgnoredFilesConfigurable" diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/unused/UnusedPropertyInspection.java b/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/unused/UnusedPropertyInspection.java index 53e241ef24bd..603833887b38 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/unused/UnusedPropertyInspection.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/codeInspection/unused/UnusedPropertyInspection.java @@ -20,9 +20,7 @@ import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.lang.ASTNode; -import com.intellij.lang.properties.PropertiesBundle; -import com.intellij.lang.properties.PropertiesQuickFixFactory; -import com.intellij.lang.properties.PropertySuppressableInspectionBase; +import com.intellij.lang.properties.*; import com.intellij.lang.properties.findUsages.PropertySearcher; import com.intellij.lang.properties.psi.Property; import com.intellij.openapi.extensions.Extensions; @@ -30,6 +28,7 @@ import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleUtilCore; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; +import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.PsiFile; @@ -39,6 +38,10 @@ import com.intellij.psi.search.searches.ReferencesSearch; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.FilteringIterator; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.Set; /** * @author cdr @@ -56,18 +59,44 @@ public class UnusedPropertyInspection extends PropertySuppressableInspectionBase return "UnusedProperty"; } + @Nullable + private static GlobalSearchScope getWidestUseScope(@Nullable String key, @NotNull Project project, @NotNull Module ownModule) { + if (key == null) return null; + + Set<Module> modules = ContainerUtil.newLinkedHashSet(); + for (IProperty property : PropertiesImplUtil.findPropertiesByKey(project, key)) { + Module module = ModuleUtilCore.findModuleForPsiElement(property.getPsiElement()); + if (module == null) { + return GlobalSearchScope.allScope(project); + } + if (module != ownModule) { + modules.add(module); + } + } + if (modules.isEmpty()) return null; + + List<Module> list = ContainerUtil.newArrayList(modules); + GlobalSearchScope result = GlobalSearchScope.moduleWithDependentsScope(list.get(0)); + for (int i = 1; i < list.size(); i++) { + result = result.uniteWith(GlobalSearchScope.moduleWithDependentsScope(list.get(i))); + } + return result; + } + @NotNull @Override public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull final LocalInspectionToolSession session) { final PsiFile file = session.getFile(); - Module module = ModuleUtilCore.findModuleForPsiElement(file); + final Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module == null) return super.buildVisitor(holder, isOnTheFly, session); + + final GlobalSearchScope ownUseScope = GlobalSearchScope.moduleWithDependentsScope(module); + Object[] extensions = Extensions.getExtensions("com.intellij.referencesSearch"); final PropertySearcher searcher = (PropertySearcher)ContainerUtil.find(extensions, new FilteringIterator.InstanceOf<PropertySearcher>(PropertySearcher.class)); - final GlobalSearchScope searchScope = GlobalSearchScope.moduleWithDependentsScope(module); final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(file.getProject()); return new PsiElementVisitor() { @Override @@ -90,13 +119,10 @@ public class UnusedPropertyInspection extends PropertySuppressableInspectionBase if (name == null) return; } - PsiSearchHelper.SearchCostResult cheapEnough = searchHelper.isCheapEnoughToSearch(name, searchScope, file, original); - if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return; + if (mayHaveUsages(property, original, name, ownUseScope)) return; - if (cheapEnough != PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES && - ReferencesSearch.search(property, searchScope, false).findFirst() != null) { - return; - } + final GlobalSearchScope widerScope = getWidestUseScope(property.getKey(), element.getProject(), module); + if (widerScope != null && mayHaveUsages(property, original, name, widerScope)) return; final ASTNode propertyNode = property.getNode(); assert propertyNode != null; @@ -108,6 +134,17 @@ public class UnusedPropertyInspection extends PropertySuppressableInspectionBase LocalQuickFix fix = PropertiesQuickFixFactory.getInstance().createRemovePropertyLocalFix(); holder.registerProblem(key, description, ProblemHighlightType.LIKE_UNUSED_SYMBOL, fix); } + + private boolean mayHaveUsages(Property property, ProgressIndicator original, String name, GlobalSearchScope searchScope) { + PsiSearchHelper.SearchCostResult cheapEnough = searchHelper.isCheapEnoughToSearch(name, searchScope, file, original); + if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return true; + + if (cheapEnough != PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES && + ReferencesSearch.search(property, searchScope, false).findFirst() != null) { + return true; + } + return false; + } }; } } diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java index 5908219098b7..b29fc4f78141 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/PropertiesImplUtil.java @@ -28,13 +28,14 @@ import com.intellij.psi.PsiDirectory; import com.intellij.psi.PsiFile; import com.intellij.psi.PsiManager; import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.indexing.FileBasedIndex; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * @author Konstantin Bulenkov @@ -64,7 +65,7 @@ public class PropertiesImplUtil extends PropertiesUtil { if (baseName.equals(getBaseName(psiFile))) { final PropertiesFile propertiesFile = getPropertiesFile(psiFile); if (propertiesFile != null) { - if (defaultPropertiesFile == null || defaultPropertiesFile.getName().compareTo(propertiesFile.getName()) < 0) { + if (defaultPropertiesFile == null || defaultPropertiesFile.getName().compareTo(propertiesFile.getName()) > 0) { defaultPropertiesFile = propertiesFile; } } @@ -91,7 +92,7 @@ public class PropertiesImplUtil extends PropertiesUtil { } @NotNull - public static List<IProperty> findPropertiesByKey(final Project project, final String key) { + public static List<IProperty> findPropertiesByKey(@NotNull final Project project, @NotNull final String key) { final GlobalSearchScope scope = GlobalSearchScope.allScope(project); final ArrayList<IProperty> properties = new ArrayList<IProperty>(PropertyKeyIndex.getInstance().get(key, project, scope)); diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java index 00c21d8d3811..58932d1fd4c5 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleEditorViewElement.java @@ -25,6 +25,6 @@ import org.jetbrains.annotations.NotNull; */ public interface ResourceBundleEditorViewElement { - PsiElement[] getPsiElements(@NotNull Project project); + PsiElement[] getPsiElements(); } diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.java index 25220d35311a..ee3e22b7079d 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundleFileStructureViewElement.java @@ -25,7 +25,6 @@ import com.intellij.lang.properties.IProperty; import com.intellij.lang.properties.ResourceBundle; import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.navigation.ItemPresentation; -import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; @@ -88,7 +87,7 @@ public class ResourceBundleFileStructureViewElement implements StructureViewTree } @Override - public PsiElement[] getPsiElements(@NotNull Project project) { + public PsiElement[] getPsiElements() { final List<PropertiesFile> propertiesFiles = getValue().getPropertiesFiles(); return ContainerUtil.map2Array(propertiesFiles, new PsiElement[propertiesFiles.size()], new Function<PropertiesFile, PsiElement>() { @Override diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java index 8b387e802597..ed660536d052 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/editor/ResourceBundlePropertyStructureViewElement.java @@ -29,7 +29,6 @@ import com.intellij.navigation.ItemPresentation; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; -import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.util.PlatformIcons; import org.jetbrains.annotations.NotNull; @@ -61,7 +60,7 @@ public class ResourceBundlePropertyStructureViewElement implements StructureView } @Override - public PsiElement[] getPsiElements(final @NotNull Project project) { + public PsiElement[] getPsiElements() { return new PsiElement[] {getProperty().getPsiElement()}; } diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.java index 432739c9df96..2e6c87b9d7a3 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesFileStructureViewElement.java @@ -22,7 +22,6 @@ import com.intellij.lang.properties.editor.ResourceBundleEditorViewElement; import com.intellij.lang.properties.psi.Property; import com.intellij.lang.properties.psi.impl.PropertiesFileImpl; import com.intellij.navigation.ItemPresentation; -import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; @@ -52,7 +51,7 @@ public class PropertiesFileStructureViewElement extends PsiTreeElementBase<Prope } @Override - public PsiElement[] getPsiElements(@NotNull Project project) { + public PsiElement[] getPsiElements() { return new PsiElement[] {getValue()}; } diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java index 8aedbcbbd85d..61b3c0202619 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesPrefixGroup.java @@ -22,11 +22,9 @@ import com.intellij.lang.properties.IProperty; import com.intellij.lang.properties.editor.ResourceBundleEditorViewElement; import com.intellij.lang.properties.editor.ResourceBundlePropertyStructureViewElement; import com.intellij.navigation.ItemPresentation; -import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; -import com.intellij.util.Function; import com.intellij.util.NullableFunction; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; @@ -137,7 +135,7 @@ public class PropertiesPrefixGroup implements Group, ResourceBundleEditorViewEle } @Override - public PsiElement[] getPsiElements(final @NotNull Project project) { + public PsiElement[] getPsiElements() { final List<PsiElement> elements = ContainerUtil.mapNotNull(getChildren(), new NullableFunction<TreeElement, PsiElement>() { @Nullable @Override @@ -148,7 +146,7 @@ public class PropertiesPrefixGroup implements Group, ResourceBundleEditorViewEle return property.getPsiElement(); } else if (treeElement instanceof ResourceBundlePropertyStructureViewElement) { - return ((ResourceBundlePropertyStructureViewElement)treeElement).getPsiElements(project)[0]; + return ((ResourceBundlePropertyStructureViewElement)treeElement).getPsiElements()[0]; } return null; } diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java index 2af033735706..d73fd376782d 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/structureView/PropertiesStructureViewElement.java @@ -19,7 +19,6 @@ import com.intellij.ide.structureView.StructureViewTreeElement; import com.intellij.lang.properties.editor.ResourceBundleEditorViewElement; import com.intellij.lang.properties.psi.Property; import com.intellij.navigation.ItemPresentation; -import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; @@ -58,7 +57,7 @@ public class PropertiesStructureViewElement implements StructureViewTreeElement, } @Override - public PsiElement[] getPsiElements(@NotNull Project project) { + public PsiElement[] getPsiElements() { return new PsiElement[] {getValue()}; } diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java index 0176aa38fc6e..e9eb9e9f72d2 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleEditor.java @@ -123,30 +123,40 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit myStructureViewPanel.add(myStructureViewComponent, BorderLayout.CENTER); myStructureViewComponent.getTree().getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { - private String selectedPropertyName; + private IProperty selectedProperty; private PropertiesFile selectedPropertiesFile; @Override public void valueChanged(TreeSelectionEvent e) { // filter out temp unselect/select events - if (getSelectedPropertyName() == null) return; - if (!Comparing.strEqual(selectedPropertyName, getSelectedPropertyName()) || + if (getSelectedProperty() == null) return; + if (!arePropertiesEquivalent(selectedProperty, getSelectedProperty()) || !Comparing.equal(selectedPropertiesFile, getSelectedPropertiesFile())) { if (e.getOldLeadSelectionPath() != null) { for (Map.Entry<PropertiesFile, Editor> entry : myEditors.entrySet()) { if (entry.getValue() == mySelectedEditor) { - writeEditorPropertyValue(mySelectedEditor, entry.getKey(), selectedPropertyName); + writeEditorPropertyValue(mySelectedEditor, entry.getKey(), selectedProperty.getName()); break; } } } - selectedPropertyName = getSelectedPropertyName(); + selectedProperty = getSelectedProperty(); selectedPropertiesFile = getSelectedPropertiesFile(); selectionChanged(); } } + + private boolean arePropertiesEquivalent(@Nullable IProperty p1, @Nullable IProperty p2) { + if (p1 == p2) { + return true; + } + if (p1 == null || p2 == null) { + return false; + } + return p1.getPsiElement().isEquivalentTo(p2.getPsiElement()); + } }); installPropertiesChangeListeners(); @@ -233,7 +243,10 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit DefaultMutableTreeNode nodeToSelect = null; while (!toCheck.isEmpty()) { DefaultMutableTreeNode node = toCheck.pop(); - String value = getNodeValue(node); + final ResourceBundleEditorViewElement element = getSelectedElement(node); + String value = element instanceof ResourceBundlePropertyStructureViewElement + ? ((ResourceBundlePropertyStructureViewElement)element).getValue() + : null; if (propertyName.equals(value)) { nodeToSelect = node; break; @@ -279,13 +292,6 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit } @Nullable - private static String getNodeValue(@NotNull DefaultMutableTreeNode node) { - final ResourceBundleEditorViewElement element = getSelectedElement(node); - return element instanceof ResourceBundlePropertyStructureViewElement ? ((ResourceBundlePropertyStructureViewElement)element).getValue() - : null; - } - - @Nullable private static ResourceBundleEditorViewElement getSelectedElement(@NotNull DefaultMutableTreeNode node) { Object userObject = node.getUserObject(); if (!(userObject instanceof AbstractTreeNode)) return null; @@ -296,8 +302,9 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit private void writeEditorPropertyValue(final Editor editor, final PropertiesFile propertiesFile, final @Nullable String propertyName) { final String currentValue = editor.getDocument().getText(); final String currentSelectedProperty = propertyName == null ? getSelectedPropertyName() : propertyName; - - assert currentSelectedProperty != null; + if (currentSelectedProperty == null) { + return; + } ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override @@ -564,21 +571,41 @@ public class ResourceBundleEditor extends UserDataHolderBase implements FileEdit } @Nullable - public String getSelectedPropertyName() { + private DefaultMutableTreeNode getSelectedNode() { JTree tree = myStructureViewComponent.getTree(); if (tree == null) return null; TreePath selected = tree.getSelectionModel().getSelectionPath(); if (selected == null) return null; - return getNodeValue((DefaultMutableTreeNode)selected.getLastPathComponent()); + return (DefaultMutableTreeNode)selected.getLastPathComponent(); + } + + @Nullable + private String getSelectedPropertyName() { + final IProperty selectedProperty = getSelectedProperty(); + return selectedProperty == null ? null : selectedProperty.getName(); + } + + @Nullable + private IProperty getSelectedProperty() { + final DefaultMutableTreeNode selectedNode = getSelectedNode(); + if (selectedNode == null) { + return null; + } + final ResourceBundleEditorViewElement element = getSelectedElement(selectedNode); + return element instanceof ResourceBundlePropertyStructureViewElement ? ((ResourceBundlePropertyStructureViewElement)element).getProperty() + : null; } @Nullable public ResourceBundleEditorViewElement getSelectedElement() { - JTree tree = myStructureViewComponent.getTree(); - if (tree == null) return null; - TreePath selected = tree.getSelectionModel().getSelectionPath(); - if (selected == null) return null; - return getSelectedElement((DefaultMutableTreeNode)selected.getLastPathComponent()); + final DefaultMutableTreeNode selectedNode = getSelectedNode(); + if (selectedNode == null) { + return null; + } + Object userObject = selectedNode.getUserObject(); + if (!(userObject instanceof AbstractTreeNode)) return null; + Object value = ((AbstractTreeNode)userObject).getValue(); + return value instanceof ResourceBundleEditorViewElement ? (ResourceBundleEditorViewElement) value : null; } @Override diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java index ee8e47a446e4..0985f35a5e12 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/ResourceBundleStructureViewComponent.java @@ -29,14 +29,11 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.util.PsiUtilBase; import com.intellij.psi.util.PsiUtilCore; import com.intellij.refactoring.safeDelete.SafeDeleteHandler; import com.intellij.ui.PopupHandler; import com.intellij.usages.UsageTarget; import com.intellij.usages.UsageView; -import com.intellij.util.Function; -import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import java.awt.datatransfer.StringSelection; @@ -79,13 +76,7 @@ class ResourceBundleStructureViewComponent extends PropertiesGroupingStructureVi } else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) { final ResourceBundleEditorViewElement selectedElement = ((ResourceBundleEditor)getFileEditor()).getSelectedElement(); if (selectedElement != null) { - final Project project = CommonDataKeys.PROJECT.getData(this); - if (project != null) { - final PsiElement[] psiElements = selectedElement.getPsiElements(project); - if (psiElements != null) { - return psiElements; - } - } + return selectedElement.getPsiElements(); } } else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) { final PsiElement[] psiElements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(this); diff --git a/plugins/properties/testSrc/com/intellij/lang/properties/ResourceBundleRenameTest.java b/plugins/properties/testSrc/com/intellij/lang/properties/ResourceBundleTest.java index f8c435817ea4..00d4adadaef1 100644 --- a/plugins/properties/testSrc/com/intellij/lang/properties/ResourceBundleRenameTest.java +++ b/plugins/properties/testSrc/com/intellij/lang/properties/ResourceBundleTest.java @@ -15,6 +15,7 @@ */ package com.intellij.lang.properties; +import com.intellij.lang.properties.psi.PropertiesFile; import com.intellij.lang.properties.refactoring.rename.ResourceBundleRenamerFactory; import com.intellij.openapi.extensions.Extensions; import com.intellij.psi.PsiFile; @@ -25,7 +26,16 @@ import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCa /** * @author Dmitry Batkovich */ -public class ResourceBundleRenameTest extends LightPlatformCodeInsightFixtureTestCase { +public class ResourceBundleTest extends LightPlatformCodeInsightFixtureTestCase { + + public void testDefaultPropertyFile() { + final PsiFile rawDefault = myFixture.addFileToProject("p.properties", ""); + myFixture.addFileToProject("p_en.properties", ""); + final PropertiesFile defaultFile = PropertiesImplUtil.getPropertiesFile(rawDefault); + assertNotNull(defaultFile); + final PropertiesFile file = defaultFile.getResourceBundle().getDefaultPropertiesFile(); + assertTrue(file.getContainingFile().isEquivalentTo(defaultFile.getContainingFile())); + } public void testRenameResourceBundleEntryFile() { final PsiFile toRenameFile = myFixture.addFileToProject("old_p.properties", ""); diff --git a/plugins/structuralsearch/build.xml b/plugins/structuralsearch/build.xml deleted file mode 100644 index 942281dbfbb1..000000000000 --- a/plugins/structuralsearch/build.xml +++ /dev/null @@ -1,53 +0,0 @@ -<project name="StructuralSearchPlugin" default="jar_plugin" basedir="."> - <property name="plugname" value="StructuralSearchPlugin"/> - <property name="releasePlugname" value="SS"/> - <property name="build.path" value="${project.path}/build_out"/> - <property name="version" value="0.7.0.1"/> - <property name="description" value="This is experimental yet useful plugin for searching source code - in terms of java syntax (query code by example :-). It is intended to be used for: - &lt;LI&gt;understanding new libraries, finding highlevel code patterns (singletons, serialization implementation, - Struts actions, ejbs, servlets, filters, source metadata, etc), analyzing - opportunities for aspect refactoring (finding exception handling, methods with - specific signatures and structure, etc). For instance, for exploring source code of JDK 1.5 with Aurora - one could use search to find added entities (classes, methods, etc), generic classes, methods and declarations or just - parameterized symbols. Note, that the plugin could miss some generic stuff that is not supported by Aurora (e.g. anonymous typed vars). - &lt;LI&gt; finding expressions, statements or group of statements regardsless of particular whitespace indentation. - This could be useful e.g. after applying extract method refactoring to find the other occurences the such extracted code. - &lt;LI&gt;Find code fragments (symbols, references, constants) like given pattern. - &lt;BR&gt;Warning, the plugin is PSI dependent, works with 1156 and 706" /> - <target name="clean"> - <delete includeEmptyDirs="true" failonerror="false"> - <fileset dir="${build.path}" includes="**/*.class,**/*.html,META-INF/*.xml,META-INF/*.txt"/> - </delete> - <mkdir dir="${build.path}"/> - </target> - <target name="copy_files"> - <copy todir="${build.path}/META-INF" > - <fileset dir="${project.path}/META-INF" includes="plugin.xml,version.txt"/> - </copy> - <copy todir="${build.path}/resources"> - <fileset dir="${project.path}/resources"/> - </copy> - <copy todir="${build.path}"> - <fileset dir="${project.path}/classes" includes="**/*.class"> - </fileset> - </copy> - </target> - - <target name="version" depends="copy_files"> - <replace dir="${build.path}" includes="**/*.xml **/*.html **/*.txt"> - <replacefilter token="@PLUGIN.VERSION@" value="${version}"/> - <replacefilter token="@PLUGIN.DESCRIPTION@" value="${description}"/> - </replace> - </target> - <target name="jar_plugin" depends="clean,copy_files,version" > - - <jar jarfile="${build.path}/${plugname}.jar" basedir="${build.path}" - excludes="${plugname}.jar" - /> - - <copy todir="${idea.path}/debug/plugins"> - <fileset dir="${build.path}" includes="*.jar" /> - </copy> - </target> -</project> diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/DocumentBasedReplaceHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/DocumentBasedReplaceHandler.java deleted file mode 100644 index 1f319b8f15e5..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/DocumentBasedReplaceHandler.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.RangeMarker; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementInfoImpl; -import com.intellij.util.containers.HashMap; - -import java.util.Map; - -/** - * @author Eugene.Kudelevsky - */ -public class DocumentBasedReplaceHandler extends StructuralReplaceHandler { - private final Project myProject; - private final Map<ReplacementInfo, RangeMarker> myRangeMarkers = new HashMap<ReplacementInfo, RangeMarker>(); - - DocumentBasedReplaceHandler(Project project) { - myProject = project; - } - - public void replace(ReplacementInfo info, ReplaceOptions options) { - if (info.getMatchesCount() == 0) return; - assert info instanceof ReplacementInfoImpl; - PsiElement element = info.getMatch(0); - if (element == null) return; - PsiFile file = element instanceof PsiFile ? (PsiFile)element : element.getContainingFile(); - assert file != null; - RangeMarker rangeMarker = myRangeMarkers.get(info); - Document document = rangeMarker.getDocument(); - document.replaceString(rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), info.getReplacement()); - PsiDocumentManager.getInstance(element.getProject()).commitDocument(document); - } - - @Override - public void prepare(ReplacementInfo info) { - assert info instanceof ReplacementInfoImpl; - MatchResult result = ((ReplacementInfoImpl)info).getMatchResult(); - PsiElement element = result.getMatch(); - PsiFile file = element instanceof PsiFile ? (PsiFile)element : element.getContainingFile(); - Document document = PsiDocumentManager.getInstance(myProject).getDocument(file); - TextRange textRange = result.getMatchRef().getElement().getTextRange(); - assert textRange != null; - RangeMarker rangeMarker = document.createRangeMarker(textRange); - rangeMarker.setGreedyToLeft(true); - rangeMarker.setGreedyToRight(true); - myRangeMarkers.put(info, rangeMarker); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/MalformedPatternException.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/MalformedPatternException.java deleted file mode 100644 index e73eddc19550..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/MalformedPatternException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.intellij.structuralsearch; - -import org.jetbrains.annotations.NonNls; - -/** - * Class to indicate incorrect pattern - */ -public class MalformedPatternException extends RuntimeException { - public MalformedPatternException() {} - public MalformedPatternException(String msg) { super(msg); } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchOptions.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchOptions.java deleted file mode 100644 index fb22f39990fa..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchOptions.java +++ /dev/null @@ -1,334 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.psi.search.SearchScope; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; - -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * match options - */ -public class MatchOptions implements JDOMExternalizable, Cloneable { - @NonNls private static final String TEXT_ATTRIBUTE_NAME = "text"; - - private boolean looseMatching; - private boolean distinct; - private boolean recursiveSearch; - private boolean caseSensitiveMatch; - private boolean resultIsContextMatch = false; - private FileType myFileType = StructuralSearchUtil.getDefaultFileType(); - private Language myDialect = null; - private int maxMatches = Integer.MAX_VALUE; - - private SearchScope scope; - private SearchScope downUpMatchScope; - private String searchCriteria = ""; - private Map<String,MatchVariableConstraint> variableConstraints; - - private String myPatternContext; - - @NonNls private static final String DISTINCT_ATTRIBUTE_NAME = "distinct"; - @NonNls private static final String RECURSIVE_ATTRIBUTE_NAME = "recursive"; - @NonNls private static final String CASESENSITIVE_ATTRIBUTE_NAME = "caseInsensitive"; - //private static final String SCOPE_ATTRIBUTE_NAME = "scope"; - @NonNls private static final String CONSTRAINT_TAG_NAME = "constraint"; - @NonNls private static final String FILE_TYPE_ATTR_NAME = "type"; - @NonNls private static final String DIALECT_ATTR_NAME = "dialect"; - @NonNls public static final String INSTANCE_MODIFIER_NAME = "Instance"; - @NonNls public static final String MODIFIER_ANNOTATION_NAME = "Modifier"; - - //private static final String UNDEFINED_SCOPE = "undefined"; - - public void addVariableConstraint(MatchVariableConstraint constraint) { - if (variableConstraints==null) { - variableConstraints = new LinkedHashMap<String,MatchVariableConstraint>(); - } - variableConstraints.put( constraint.getName(), constraint ); - } - - public boolean hasVariableConstraints() { - return variableConstraints!=null; - } - - public void clearVariableConstraints() { - variableConstraints=null; - } - - public MatchVariableConstraint getVariableConstraint(String name) { - if (variableConstraints!=null) { - return variableConstraints.get(name); - } - return null; - } - - public Iterator<String> getVariableConstraintNames() { - if (variableConstraints==null) return null; - return variableConstraints.keySet().iterator(); - } - - public void setCaseSensitiveMatch(boolean caseSensitiveMatch) { - this.caseSensitiveMatch = caseSensitiveMatch; - } - - public boolean isCaseSensitiveMatch() { - return caseSensitiveMatch; - } - - @SuppressWarnings({"HardCodedStringLiteral"}) - public String toString() { - StringBuffer result = new StringBuffer(); - - result.append("match options:\n"); - result.append("search pattern:\n"); - result.append(searchCriteria); - result.append("\nsearch scope:\n"); - - // @TODO print scope - //result.append((scopeHandler!=null)?scopeHandler.toString():"undefined scope"); - - result.append("\nrecursive:"); - result.append(recursiveSearch); - - result.append("\ndistinct:"); - result.append(distinct); - - result.append("\ncasesensitive:"); - result.append(caseSensitiveMatch); - - return result.toString(); - } - - public boolean isDistinct() { - return distinct; - } - - public void setDistinct(boolean distinct) { - this.distinct = distinct; - } - - public boolean isRecursiveSearch() { - return recursiveSearch; - } - - public void setRecursiveSearch(boolean recursiveSearch) { - this.recursiveSearch = recursiveSearch; - } - - public boolean isLooseMatching() { - return looseMatching; - } - - public void setLooseMatching(boolean looseMatching) { - this.looseMatching = looseMatching; - } - - public void setSearchPattern(String text) { - searchCriteria = text; - } - - public String getSearchPattern() { - return searchCriteria; - } - - public int getMaxMatchesCount() { - return maxMatches; - } - - public boolean isResultIsContextMatch() { - return resultIsContextMatch; - } - - public void setResultIsContextMatch(boolean resultIsContextMatch) { - this.resultIsContextMatch = resultIsContextMatch; - } - - public SearchScope getScope() { - return scope; - } - - public void setScope(SearchScope scope) { - this.scope = scope; - } - - public SearchScope getDownUpMatchScope() { - return downUpMatchScope; - } - - public void setDownUpMatchScope(final SearchScope downUpMatchScope) { - this.downUpMatchScope = downUpMatchScope; - } - - public void writeExternal(Element element) { - element.setAttribute(TEXT_ATTRIBUTE_NAME,getSearchPattern()); - element.setAttribute(RECURSIVE_ATTRIBUTE_NAME,String.valueOf(recursiveSearch)); - if (distinct) element.setAttribute(DISTINCT_ATTRIBUTE_NAME,String.valueOf(distinct)); - element.setAttribute(CASESENSITIVE_ATTRIBUTE_NAME,String.valueOf(caseSensitiveMatch)); - - //@TODO serialize scope! - - //if (myFileType != StdFileTypes.JAVA) { - element.setAttribute(FILE_TYPE_ATTR_NAME, myFileType.getName()); - //} - - if (myDialect != null) { - element.setAttribute(DIALECT_ATTR_NAME, myDialect.getID()); - } - - if (variableConstraints!=null) { - for (final MatchVariableConstraint matchVariableConstraint : variableConstraints.values()) { - if (matchVariableConstraint.isArtificial()) continue; - final Element infoElement = new Element(CONSTRAINT_TAG_NAME); - element.addContent(infoElement); - matchVariableConstraint.writeExternal(infoElement); - } - } - } - - public void readExternal(Element element) { - setSearchPattern(element.getAttribute(TEXT_ATTRIBUTE_NAME).getValue()); - - Attribute attr = element.getAttribute(RECURSIVE_ATTRIBUTE_NAME); - if (attr!=null) { - try { - recursiveSearch = attr.getBooleanValue(); - } catch(DataConversionException ignored) {} - } - - attr = element.getAttribute(DISTINCT_ATTRIBUTE_NAME); - if (attr!=null) { - try { - distinct = attr.getBooleanValue(); - } catch(DataConversionException ignored) {} - } - - attr = element.getAttribute(CASESENSITIVE_ATTRIBUTE_NAME); - if (attr!=null) { - try { - caseSensitiveMatch = attr.getBooleanValue(); - } catch(DataConversionException ignored) {} - } - - attr = element.getAttribute(FILE_TYPE_ATTR_NAME); - if (attr!=null) { - String value = attr.getValue(); - myFileType = getFileTypeByName(value); - } - - attr = element.getAttribute(DIALECT_ATTR_NAME); - if (attr != null) { - myDialect = Language.findLanguageByID(attr.getValue()); - } - - // @TODO deserialize scope - - List<Element> elements = element.getChildren(CONSTRAINT_TAG_NAME); - if (elements!=null && !elements.isEmpty()) { - for (final Element element1 : elements) { - final MatchVariableConstraint constraint = new MatchVariableConstraint(); - constraint.readExternal(element1); - addVariableConstraint(constraint); - } - } - } - - private static FileType getFileTypeByName(String value) { - if (value != null) { - for (FileType type : StructuralSearchUtil.getSuitableFileTypes()) { - if (value.equals(type.getName())) { - return type; - } - } - } - - return StructuralSearchUtil.getDefaultFileType(); - } - - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof MatchOptions)) return false; - - final MatchOptions matchOptions = (MatchOptions)o; - - if (caseSensitiveMatch != matchOptions.caseSensitiveMatch) return false; - if (distinct != matchOptions.distinct) return false; - //if (enableAutoIdentifySearchTarget != matchOptions.enableAutoIdentifySearchTarget) return false; - if (looseMatching != matchOptions.looseMatching) return false; - if (recursiveSearch != matchOptions.recursiveSearch) return false; - // @TODO support scope - - if (searchCriteria != null ? !searchCriteria.equals(matchOptions.searchCriteria) : matchOptions.searchCriteria != null) return false; - if (variableConstraints != null ? !variableConstraints.equals(matchOptions.variableConstraints) : matchOptions.variableConstraints != - null) { - return false; - } - if (myFileType != matchOptions.myFileType) { - return false; - } - - if (myDialect != null ? !myDialect.equals(matchOptions.myDialect) : matchOptions.myDialect != null) { - return false; - } - - if (myPatternContext != null ? !myPatternContext.equals(matchOptions.myPatternContext) : matchOptions.myPatternContext != null) { - return false; - } - - return true; - } - - public int hashCode() { - int result; - result = (looseMatching ? 1 : 0); - result = 29 * result + (distinct ? 1 : 0); - result = 29 * result + (recursiveSearch ? 1 : 0); - result = 29 * result + (caseSensitiveMatch ? 1 : 0); - // @TODO support scope - result = 29 * result + (searchCriteria != null ? searchCriteria.hashCode() : 0); - result = 29 * result + (variableConstraints != null ? variableConstraints.hashCode() : 0); - if (myFileType != null) result = 29 * result + myFileType.hashCode(); - if (myDialect != null) result = 29 * result + myDialect.hashCode(); - return result; - } - - public void setFileType(FileType fileType) { - myFileType = fileType; - } - - public FileType getFileType() { - return myFileType; - } - - public Language getDialect() { - return myDialect; - } - - public void setDialect(Language dialect) { - myDialect = dialect; - } - - public String getPatternContext() { - return myPatternContext; - } - - public void setPatternContext(String patternContext) { - myPatternContext = patternContext; - } - - public MatchOptions clone() { - try { - return (MatchOptions) super.clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - return null; - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchResult.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchResult.java deleted file mode 100644 index c5196e67178d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchResult.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.plugin.util.SmartPsiPointer; -import org.jetbrains.annotations.NonNls; - -import java.util.List; - -/** - * Class describing the match result - */ -public abstract class MatchResult { - @NonNls public static final String LINE_MATCH = "line"; - @NonNls public static final String MULTI_LINE_MATCH = "context"; - - public abstract String getMatchImage(); - - public abstract SmartPsiPointer getMatchRef(); - public abstract PsiElement getMatch(); - public abstract int getStart(); - public abstract int getEnd(); - - public abstract String getName(); - - public abstract List<MatchResult> getAllSons(); - public abstract boolean hasSons(); - public abstract boolean isScopeMatch(); - public abstract boolean isMultipleMatch(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchResultSink.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchResultSink.java deleted file mode 100644 index 8a4fdf968a8c..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchResultSink.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.psi.PsiFile; -import com.intellij.structuralsearch.MatchingProcess; -import com.intellij.openapi.progress.ProgressIndicator; - -/** - * Interface for consumers of match results - */ -public interface MatchResultSink { - /** - * Notifies sink about new match - * @param result - */ - void newMatch(MatchResult result); - - /** - * Notifies sink about starting the matching for given element - * @param element the current file - */ - void processFile(PsiFile element); - - /** - * Sets the reference to the matching process - * @param matchingProcess the matching process reference - */ - void setMatchingProcess(MatchingProcess matchingProcess); - - /** - * Notifies sink about end of matching. - */ - void matchingFinished(); - - ProgressIndicator getProgressIndicator(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchVariableConstraint.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchVariableConstraint.java deleted file mode 100644 index db2aaa901c54..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchVariableConstraint.java +++ /dev/null @@ -1,558 +0,0 @@ -package com.intellij.structuralsearch; - -import org.jdom.Element; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jetbrains.annotations.NonNls; - -/** - * @author Maxim.Mossienko - * Date: Mar 19, 2004 - * Time: 5:36:32 PM - */ -public class MatchVariableConstraint extends NamedScriptableDefinition { - private String regExp = ""; - private boolean invertRegExp; - private boolean withinHierarchy; - private boolean strictlyWithinHierarchy; - private boolean wholeWordsOnly; - private int minCount = 1; - private int maxCount = 1; - private boolean readAccess; - private boolean invertReadAccess; - private boolean writeAccess; - private boolean invertWriteAccess; - private boolean greedy = true; - private boolean reference; - private boolean invertReference; - private String nameOfReferenceVar = ""; - private boolean partOfSearchResults; - private String nameOfExprType = ""; - private boolean invertExprType; - private boolean exprTypeWithinHierarchy; - - private String nameOfFormalArgType = ""; - private boolean invertFormalType; - private boolean formalArgTypeWithinHierarchy; - - private String withinConstraint = ""; - private String containsConstraint = ""; - private boolean invertContainsConstraint; - private boolean invertWithinConstraint; - private final boolean artificial; - - @NonNls private static final String NAME_OF_REFEENCE_VAR = "nameOfReferenceVar"; - @NonNls private static final String NAME_OF_EXPRTYPE = "nameOfExprType"; - @NonNls private static final String NAME_OF_FORMALTYPE = "nameOfFormalType"; - @NonNls private static final String REGEXP = "regexp"; - @NonNls private static final String EXPRTYPE_WITHIN_HIERARCHY = "exprTypeWithinHierarchy"; - @NonNls private static final String FORMALTYPE_WITHIN_HIERARCHY = "formalTypeWithinHierarchy"; - - @NonNls private static final String WITHIN_HIERARCHY = "withinHierarchy"; - @NonNls private static final String MAX_OCCURS = "maxCount"; - @NonNls private static final String MIN_OCCURS = "minCount"; - - @NonNls private static final String NEGATE_NAME_CONDITION = "negateName"; - @NonNls private static final String NEGATE_EXPRTYPE_CONDITION = "negateExprType"; - @NonNls private static final String NEGATE_FORMALTYPE_CONDITION = "negateFormalType"; - @NonNls private static final String NEGATE_READ_CONDITION = "negateRead"; - @NonNls private static final String NEGATE_WRITE_CONDITION = "negateWrite"; - @NonNls private static final String NEGATE_CONTAINS_CONDITION = "negateContains"; - @NonNls private static final String NEGATE_WITHIN_CONDITION = "negateWithin"; - @NonNls private static final String WITHIN_CONDITION = "within"; - @NonNls private static final String CONTAINS_CONDITION = "contains"; - @NonNls private static final String READ = "readAccess"; - @NonNls private static final String WRITE = "writeAccess"; - @NonNls private static final String TARGET = "target"; - - @NonNls private static final String WHOLE_WORDS_ONLY = "wholeWordsOnly"; - @NonNls private static final String TRUE = Boolean.TRUE.toString(); - - public MatchVariableConstraint() { this(false); } - public MatchVariableConstraint(boolean _artificial) { artificial = _artificial; } - - public boolean isGreedy() { - return greedy; - } - - public void setGreedy(boolean greedy) { - this.greedy = greedy; - } - - public String getRegExp() { - return regExp; - } - - public void setRegExp(String regExp) { - this.regExp = regExp; - } - - public boolean isInvertRegExp() { - return invertRegExp; - } - - public void setInvertRegExp(boolean invertRegExp) { - this.invertRegExp = invertRegExp; - } - - public boolean isWithinHierarchy() { - return withinHierarchy; - } - - public void setWithinHierarchy(boolean withinHierarchy) { - this.withinHierarchy = withinHierarchy; - } - - public int getMinCount() { - return minCount; - } - - public void setMinCount(int minCount) { - this.minCount = minCount; - } - - public int getMaxCount() { - return maxCount; - } - - public void setMaxCount(int maxCount) { - this.maxCount = maxCount; - } - - public boolean isReadAccess() { - return readAccess; - } - - public void setReadAccess(boolean readAccess) { - this.readAccess = readAccess; - } - - public boolean isInvertReadAccess() { - return invertReadAccess; - } - - public void setInvertReadAccess(boolean invertReadAccess) { - this.invertReadAccess = invertReadAccess; - } - - public boolean isWriteAccess() { - return writeAccess; - } - - public void setWriteAccess(boolean writeAccess) { - this.writeAccess = writeAccess; - } - - public boolean isInvertWriteAccess() { - return invertWriteAccess; - } - - public void setInvertWriteAccess(boolean invertWriteAccess) { - this.invertWriteAccess = invertWriteAccess; - } - - public boolean isPartOfSearchResults() { - return partOfSearchResults; - } - - public void setPartOfSearchResults(boolean partOfSearchResults) { - this.partOfSearchResults = partOfSearchResults; - } - - public boolean isReference() { - return reference; - } - - public void setReference(boolean reference) { - this.reference = reference; - } - - public boolean isInvertReference() { - return invertReference; - } - - public void setInvertReference(boolean invertReference) { - this.invertReference = invertReference; - } - - public String getNameOfReferenceVar() { - return nameOfReferenceVar; - } - - public void setNameOfReferenceVar(String nameOfReferenceVar) { - this.nameOfReferenceVar = nameOfReferenceVar; - } - - public boolean isStrictlyWithinHierarchy() { - return strictlyWithinHierarchy; - } - - public void setStrictlyWithinHierarchy(boolean strictlyWithinHierarchy) { - this.strictlyWithinHierarchy = strictlyWithinHierarchy; - } - - public String getNameOfExprType() { - return nameOfExprType; - } - - public void setNameOfExprType(String nameOfExprType) { - this.nameOfExprType = nameOfExprType; - } - - public boolean isInvertExprType() { - return invertExprType; - } - - public void setInvertExprType(boolean invertExprType) { - this.invertExprType = invertExprType; - } - - public boolean isExprTypeWithinHierarchy() { - return exprTypeWithinHierarchy; - } - - public void setExprTypeWithinHierarchy(boolean exprTypeWithinHierarchy) { - this.exprTypeWithinHierarchy = exprTypeWithinHierarchy; - } - - public boolean isWholeWordsOnly() { - return wholeWordsOnly; - } - - public void setWholeWordsOnly(boolean wholeWordsOnly) { - this.wholeWordsOnly = wholeWordsOnly; - } - - public String getNameOfFormalArgType() { - return nameOfFormalArgType; - } - - public void setNameOfFormalArgType(String nameOfFormalArgType) { - this.nameOfFormalArgType = nameOfFormalArgType; - } - - public boolean isInvertFormalType() { - return invertFormalType; - } - - public void setInvertFormalType(boolean invertFormalType) { - this.invertFormalType = invertFormalType; - } - - public boolean isFormalArgTypeWithinHierarchy() { - return formalArgTypeWithinHierarchy; - } - - public void setFormalArgTypeWithinHierarchy(boolean formalArgTypeWithinHierarchy) { - this.formalArgTypeWithinHierarchy = formalArgTypeWithinHierarchy; - } - - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof MatchVariableConstraint)) return false; - if (!(super.equals(o))) return false; - - final MatchVariableConstraint matchVariableConstraint = (MatchVariableConstraint)o; - - if (exprTypeWithinHierarchy != matchVariableConstraint.exprTypeWithinHierarchy) return false; - if (formalArgTypeWithinHierarchy != matchVariableConstraint.formalArgTypeWithinHierarchy) return false; - if (greedy != matchVariableConstraint.greedy) return false; - if (invertExprType != matchVariableConstraint.invertExprType) return false; - if (invertFormalType != matchVariableConstraint.invertFormalType) return false; - if (invertReadAccess != matchVariableConstraint.invertReadAccess) return false; - if (invertReference != matchVariableConstraint.invertReference) return false; - if (invertRegExp != matchVariableConstraint.invertRegExp) return false; - if (invertWriteAccess != matchVariableConstraint.invertWriteAccess) return false; - if (maxCount != matchVariableConstraint.maxCount) return false; - if (minCount != matchVariableConstraint.minCount) return false; - if (partOfSearchResults != matchVariableConstraint.partOfSearchResults) return false; - if (readAccess != matchVariableConstraint.readAccess) return false; - if (reference != matchVariableConstraint.reference) return false; - if (strictlyWithinHierarchy != matchVariableConstraint.strictlyWithinHierarchy) return false; - if (wholeWordsOnly != matchVariableConstraint.wholeWordsOnly) return false; - if (withinHierarchy != matchVariableConstraint.withinHierarchy) return false; - if (writeAccess != matchVariableConstraint.writeAccess) return false; - if (!nameOfExprType.equals(matchVariableConstraint.nameOfExprType)) return false; - if (!nameOfFormalArgType.equals(matchVariableConstraint.nameOfFormalArgType)) return false; - if (!nameOfReferenceVar.equals(matchVariableConstraint.nameOfReferenceVar)) return false; - if (!regExp.equals(matchVariableConstraint.regExp)) return false; - if (!withinConstraint.equals(matchVariableConstraint.withinConstraint)) return false; - if (!containsConstraint.equals(matchVariableConstraint.containsConstraint)) return false; - if (invertWithinConstraint != matchVariableConstraint.invertWithinConstraint) return false; - if (invertContainsConstraint != matchVariableConstraint.invertContainsConstraint) return false; - - return true; - } - - public int hashCode() { - int result; - result = super.hashCode(); - result = 29 * result + regExp.hashCode(); - result = 29 * result + (invertRegExp ? 1 : 0); - result = 29 * result + (withinHierarchy ? 1 : 0); - result = 29 * result + (strictlyWithinHierarchy ? 1 : 0); - result = 29 * result + (wholeWordsOnly ? 1 : 0); - result = 29 * result + minCount; - result = 29 * result + maxCount; - result = 29 * result + (readAccess ? 1 : 0); - result = 29 * result + (invertReadAccess ? 1 : 0); - result = 29 * result + (writeAccess ? 1 : 0); - result = 29 * result + (invertWriteAccess ? 1 : 0); - result = 29 * result + (greedy ? 1 : 0); - result = 29 * result + (reference ? 1 : 0); - result = 29 * result + (invertReference ? 1 : 0); - result = 29 * result + nameOfReferenceVar.hashCode(); - result = 29 * result + (partOfSearchResults ? 1 : 0); - result = 29 * result + nameOfExprType.hashCode(); - result = 29 * result + (invertExprType ? 1 : 0); - result = 29 * result + (exprTypeWithinHierarchy ? 1 : 0); - result = 29 * result + nameOfFormalArgType.hashCode(); - result = 29 * result + (invertFormalType ? 1 : 0); - result = 29 * result + (formalArgTypeWithinHierarchy ? 1 : 0); - result = 29 * result + withinConstraint.hashCode(); - result = 29 * result + containsConstraint.hashCode(); - - if (invertContainsConstraint) result = 29 * result + 1; - if (invertWithinConstraint) result = 29 * result + 1; - return result; - } - - public void readExternal(Element element) { - super.readExternal(element); - Attribute attribute; - - attribute = element.getAttribute(REGEXP); - if (attribute != null) { - regExp = attribute.getValue(); - } - - attribute = element.getAttribute(NAME_OF_EXPRTYPE); - if (attribute != null) { - nameOfExprType = attribute.getValue(); - } - - attribute = element.getAttribute(NAME_OF_FORMALTYPE); - if (attribute != null) { - nameOfFormalArgType = attribute.getValue(); - } - - attribute = element.getAttribute(NAME_OF_REFEENCE_VAR); - if (attribute != null) { - nameOfReferenceVar = attribute.getValue(); - } - - attribute = element.getAttribute(WITHIN_HIERARCHY); - if (attribute != null) { - try { - withinHierarchy = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(EXPRTYPE_WITHIN_HIERARCHY); - if (attribute != null) { - try { - exprTypeWithinHierarchy = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(FORMALTYPE_WITHIN_HIERARCHY); - if (attribute != null) { - try { - formalArgTypeWithinHierarchy = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(NEGATE_NAME_CONDITION); - if (attribute != null) { - try { - invertRegExp = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(NEGATE_EXPRTYPE_CONDITION); - if (attribute != null) { - try { - invertExprType = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(NEGATE_FORMALTYPE_CONDITION); - if (attribute != null) { - try { - invertFormalType = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(NEGATE_READ_CONDITION); - if (attribute != null) { - try { - invertReadAccess = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(NEGATE_WRITE_CONDITION); - if (attribute != null) { - try { - invertWriteAccess = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(READ); - if (attribute != null) { - try { - readAccess = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(WRITE); - if (attribute != null) { - try { - writeAccess = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(TARGET); - if (attribute != null) { - try { - partOfSearchResults = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(MIN_OCCURS); - if (attribute != null) { - try { - minCount = attribute.getIntValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(MAX_OCCURS); - if (attribute != null) { - try { - maxCount = attribute.getIntValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(WHOLE_WORDS_ONLY); - if (attribute != null) { - try { - wholeWordsOnly = attribute.getBooleanValue(); - } - catch (DataConversionException ex) { - } - } - - attribute = element.getAttribute(NEGATE_WITHIN_CONDITION); - if (attribute != null) { - try { - invertWithinConstraint = attribute.getBooleanValue(); - } catch (DataConversionException ex) {} - } - - attribute = element.getAttribute(NEGATE_CONTAINS_CONDITION); - if (attribute != null) { - try { - invertContainsConstraint = attribute.getBooleanValue(); - } catch (DataConversionException ex) {} - } - - attribute = element.getAttribute(CONTAINS_CONDITION); - if(attribute != null) containsConstraint = attribute.getValue(); - - attribute = element.getAttribute(WITHIN_CONDITION); - if(attribute != null) withinConstraint = attribute.getValue(); - } - - public void writeExternal(Element element) { - super.writeExternal(element); - - if (regExp.length() > 0) element.setAttribute(REGEXP,regExp); - if (nameOfExprType.length() > 0) element.setAttribute(NAME_OF_EXPRTYPE,nameOfExprType); - if (nameOfReferenceVar.length() > 0) element.setAttribute(NAME_OF_REFEENCE_VAR,nameOfReferenceVar); - if (nameOfFormalArgType.length() > 0) element.setAttribute(NAME_OF_FORMALTYPE,nameOfFormalArgType); - - - if (withinHierarchy) element.setAttribute(WITHIN_HIERARCHY,TRUE); - if (exprTypeWithinHierarchy) element.setAttribute(EXPRTYPE_WITHIN_HIERARCHY,TRUE); - if (formalArgTypeWithinHierarchy) element.setAttribute(FORMALTYPE_WITHIN_HIERARCHY,TRUE); - - if (minCount!=1) element.setAttribute(MIN_OCCURS,String.valueOf(minCount)); - if (maxCount!=1) element.setAttribute(MAX_OCCURS,String.valueOf(maxCount)); - if (partOfSearchResults) element.setAttribute(TARGET,TRUE); - if (readAccess) element.setAttribute(READ,TRUE); - if (writeAccess) element.setAttribute(WRITE,TRUE); - - if (invertRegExp) element.setAttribute(NEGATE_NAME_CONDITION,TRUE); - if (invertExprType) element.setAttribute(NEGATE_EXPRTYPE_CONDITION,TRUE); - if (invertFormalType) element.setAttribute(NEGATE_FORMALTYPE_CONDITION,TRUE); - if (invertReadAccess) element.setAttribute(NEGATE_READ_CONDITION,TRUE); - if (invertWriteAccess) element.setAttribute(NEGATE_WRITE_CONDITION,TRUE); - - if (wholeWordsOnly) element.setAttribute(WHOLE_WORDS_ONLY,TRUE); - if (invertContainsConstraint) element.setAttribute(NEGATE_CONTAINS_CONDITION,TRUE); - if (invertWithinConstraint) element.setAttribute(NEGATE_WITHIN_CONDITION,TRUE); - element.setAttribute(WITHIN_CONDITION, withinConstraint); - element.setAttribute(CONTAINS_CONDITION, containsConstraint); - } - - public String getWithinConstraint() { - return withinConstraint; - } - - public void setWithinConstraint(final String withinConstraint) { - this.withinConstraint = withinConstraint; - } - - public String getContainsConstraint() { - return containsConstraint; - } - - public void setContainsConstraint(final String containsConstraint) { - this.containsConstraint = containsConstraint; - } - - public boolean isInvertContainsConstraint() { - return invertContainsConstraint; - } - - public void setInvertContainsConstraint(final boolean invertContainsConstraint) { - this.invertContainsConstraint = invertContainsConstraint; - } - - public boolean isInvertWithinConstraint() { - return invertWithinConstraint; - } - - public void setInvertWithinConstraint(final boolean invertWithinConstraint) { - this.invertWithinConstraint = invertWithinConstraint; - } - - public boolean isArtificial() { - return artificial; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/Matcher.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/Matcher.java deleted file mode 100644 index 594686e14d49..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/Matcher.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatcherImpl; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -/** - * This class makes program structure tree matching: - */ -public class Matcher extends MatcherImpl { - - public Matcher(Project project) { - super(project); - } - - public Matcher(final Project project, final MatchOptions matchOptions) { - super(project, matchOptions); - } - - /** - * Finds the matches of given pattern starting from given tree element. - * @throws MalformedPatternException - * @throws UnsupportedPatternException - */ - public void findMatches(MatchResultSink sink,MatchOptions options) throws - MalformedPatternException, UnsupportedPatternException - { - super.findMatches(sink,options); - } - - /** - * Finds the matches of given pattern starting from given tree element. - * @param source string for search - * @param pattern to be searched - * @return list of matches found - * @throws MalformedPatternException - * @throws UnsupportedPatternException - */ - public List<MatchResult> testFindMatches(String source, - String pattern, - MatchOptions options, - boolean filePattern, - FileType sourceFileType, - String sourceExtension, - boolean physicalSourceFile) - throws MalformedPatternException, UnsupportedPatternException { - return super.testFindMatches(source, pattern, options, filePattern, sourceFileType, sourceExtension, physicalSourceFile); - } - - public List<MatchResult> testFindMatches(String source, String pattern, MatchOptions options, boolean filePattern) - throws MalformedPatternException, UnsupportedPatternException { - return super.testFindMatches(source, pattern, options, filePattern); - } - - /** - * Finds the matches of given pattern starting from given tree element. - * @param sink - * @param options - * @throws MalformedPatternException - * @throws UnsupportedPatternException - */ - public void testFindMatches(MatchResultSink sink,MatchOptions options) - throws MalformedPatternException, UnsupportedPatternException { - - super.testFindMatches(sink,options); - } - - /** - * Tests if given element is matched by given pattern starting from target variable. If matching succeeds - * then not null match result is returned. - * @throws MalformedPatternException - * @throws UnsupportedPatternException - */ - @Nullable - public MatchResult isMatchedByDownUp(PsiElement element,MatchOptions options) throws - MalformedPatternException, UnsupportedPatternException - { - return super.isMatchedByDownUp(element, options); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchingProcess.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchingProcess.java deleted file mode 100644 index 6ecb42d800c3..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/MatchingProcess.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.intellij.structuralsearch; - -/** - * Interface of running matching process - */ -public interface MatchingProcess { - void stop(); - void pause(); - void resume(); - - boolean isSuspended(); - boolean isEnded(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/NamedScriptableDefinition.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/NamedScriptableDefinition.java deleted file mode 100644 index 8c954ab5a0ef..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/NamedScriptableDefinition.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.openapi.util.JDOMExternalizable; -import org.jdom.Element; -import org.jdom.Attribute; -import org.jetbrains.annotations.NonNls; - -/** - * @author Maxim.Mossienko - * Date: 11.06.2009 - * Time: 12:55:39 - */ -public class NamedScriptableDefinition implements JDOMExternalizable, Cloneable { - @NonNls private static final String NAME = "name"; - @NonNls private static final String SCRIPT = "script"; - private String name; - private String scriptCodeConstraint = ""; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getScriptCodeConstraint() { - return scriptCodeConstraint; - } - - public void setScriptCodeConstraint(String scriptCodeConstraint) { - this.scriptCodeConstraint = scriptCodeConstraint; - } - - public Object clone() { - try { - return super.clone(); - } catch(CloneNotSupportedException ex) { - return null; - } - } - - public void readExternal(Element element) { - Attribute attribute = element.getAttribute(NAME); - if (attribute != null) { - name = attribute.getValue(); - } - - String s = element.getAttributeValue(SCRIPT); - if (s != null) { - setScriptCodeConstraint(s); - } - } - - public void writeExternal(Element element) { - element.setAttribute(NAME,name); - if (scriptCodeConstraint.length() > 0) element.setAttribute(SCRIPT,scriptCodeConstraint); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof NamedScriptableDefinition)) return false; - - NamedScriptableDefinition that = (NamedScriptableDefinition)o; - - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (scriptCodeConstraint != null ? !scriptCodeConstraint.equals(that.scriptCodeConstraint) : that.scriptCodeConstraint != null) { - return false; - } - - return true; - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (scriptCodeConstraint != null ? scriptCodeConstraint.hashCode() : 0); - return result; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/PredefinedConfigurationUtil.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/PredefinedConfigurationUtil.java deleted file mode 100644 index 6e14ce437025..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/PredefinedConfigurationUtil.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchConfiguration; -import org.jetbrains.annotations.NonNls; - -public class PredefinedConfigurationUtil { - - public static Configuration createSearchTemplateInfo(String name, @NonNls String criteria, String category) { - return createSearchTemplateInfo(name, criteria, category, StdFileTypes.JAVA); - } - - public static Configuration createSearchTemplateInfo(String name, @NonNls String criteria, String category, FileType fileType) { - final SearchConfiguration config = new SearchConfiguration(); - config.setPredefined(true); - config.setName(name); - config.setCategory(category); - config.getMatchOptions().setSearchPattern(criteria); - config.getMatchOptions().setFileType(fileType); - MatcherImplUtil.transform( config.getMatchOptions() ); - - return config; - } - - public static Configuration createSearchTemplateInfoSimple(String name, @NonNls String criteria, String category) { - final Configuration info = createSearchTemplateInfo(name,criteria,category); - info.getMatchOptions().setRecursiveSearch(false); - - return info; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/ReplacementVariableDefinition.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/ReplacementVariableDefinition.java deleted file mode 100644 index 1010db48c1f8..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/ReplacementVariableDefinition.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.intellij.structuralsearch; - -/** - * @author Maxim.Mossienko - * Date: Mar 19, 2004 - * Time: 5:36:32 PM - */ -public class ReplacementVariableDefinition extends NamedScriptableDefinition { - @Override - public boolean equals(Object o) { - if (!(o instanceof ReplacementVariableDefinition)) return false; - return super.equals(o); - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/SSRBundle.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/SSRBundle.java deleted file mode 100644 index 8ef278154b24..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/SSRBundle.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.CommonBundle; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.PropertyKey; - -import java.lang.ref.Reference; -import java.lang.ref.SoftReference; -import java.util.ResourceBundle; - -public class SSRBundle { - - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return CommonBundle.message(getBundle(), key, params); - } - - private static Reference<ResourceBundle> ourBundle; - @NonNls private static final String BUNDLE = "messages.SSRBundle"; - - private SSRBundle() { - } - - private static ResourceBundle getBundle() { - ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle); - if (bundle == null) { - bundle = ResourceBundle.getBundle(BUNDLE); - ourBundle = new SoftReference<ResourceBundle>(bundle); - } - return bundle; - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralReplaceHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralReplaceHandler.java deleted file mode 100644 index 063f272cf4c4..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralReplaceHandler.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; - -/** - * @author Eugene.Kudelevsky - */ -public abstract class StructuralReplaceHandler { - public abstract void replace(final ReplacementInfo info, ReplaceOptions options); - - public void prepare - (ReplacementInfo info) { - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchException.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchException.java deleted file mode 100644 index f925285054f0..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchException.java +++ /dev/null @@ -1,13 +0,0 @@ - -package com.intellij.structuralsearch; - -/** - * @author Bas Leijdekkers - */ -public class StructuralSearchException extends RuntimeException { - public StructuralSearchException() {} - - public StructuralSearchException(String message) { - super(message); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java deleted file mode 100644 index ff7b379a161f..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfile.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.template.TemplateContextType; -import com.intellij.lang.Language; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.CompiledPattern; -import com.intellij.structuralsearch.impl.matcher.GlobalMatchingVisitor; -import com.intellij.structuralsearch.impl.matcher.PatternTreeContext; -import com.intellij.structuralsearch.impl.matcher.compiler.GlobalCompilingVisitor; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.impl.ParameterInfo; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementBuilder; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementContext; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchContext; -import com.intellij.structuralsearch.plugin.ui.UIUtil; -import com.intellij.util.ArrayUtil; -import com.intellij.util.LocalTimeCounter; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; - -/** - * @author Eugene.Kudelevsky - */ -public abstract class StructuralSearchProfile { - public static final ExtensionPointName<StructuralSearchProfile> EP_NAME = - ExtensionPointName.create("com.intellij.structuralsearch.profile"); - - public abstract void compile(PsiElement[] elements, @NotNull GlobalCompilingVisitor globalVisitor); - - @NotNull - public abstract PsiElementVisitor createMatchingVisitor(@NotNull GlobalMatchingVisitor globalVisitor); - - @NotNull - public abstract PsiElementVisitor getLexicalNodesFilter(@NotNull LexicalNodesFilter filter); - - @NotNull - public abstract CompiledPattern createCompiledPattern(); - - public static String getTypeName(FileType fileType) { - return fileType.getName().toLowerCase(); - } - - public abstract boolean canProcess(@NotNull FileType fileType); - - public abstract boolean isMyLanguage(@NotNull Language language); - - public boolean isMyFile(PsiFile file, @NotNull Language language, Language... patternLanguages) { - if (isMyLanguage(language) && ArrayUtil.find(patternLanguages, language) >= 0) { - return true; - } - return false; - } - - @NotNull - public PsiElement[] createPatternTree(@NotNull String text, - @NotNull PatternTreeContext context, - @NotNull FileType fileType, - @Nullable Language language, - @Nullable String contextName, - @Nullable String extension, - @NotNull Project project, - boolean physical) { - final String ext = extension != null ? extension : fileType.getDefaultExtension(); - final String name = "__dummy." + ext; - final PsiFileFactory factory = PsiFileFactory.getInstance(project); - - final PsiFile file = language == null - ? factory.createFileFromText(name, fileType, text, LocalTimeCounter.currentTime(), physical, true) - : factory.createFileFromText(name, language, text, physical, true); - - return file != null ? file.getChildren() : PsiElement.EMPTY_ARRAY; - } - - @NotNull - public PsiElement[] createPatternTree(@NotNull String text, - @NotNull PatternTreeContext context, - @NotNull FileType fileType, - @NotNull Project project, - boolean physical) { - return createPatternTree(text, context, fileType, null, null, null, project, physical); - } - - @NotNull - public Editor createEditor(@NotNull SearchContext searchContext, - @NotNull FileType fileType, - Language dialect, - String text, - boolean useLastConfiguration) { - PsiFile codeFragment = createCodeFragment(searchContext.getProject(), text, null); - if (codeFragment == null) { - codeFragment = createFileFragment(searchContext, fileType, dialect, text); - } - - if (codeFragment != null) { - final Document doc = PsiDocumentManager.getInstance(searchContext.getProject()).getDocument(codeFragment); - assert doc != null : "code fragment element should be physical"; - DaemonCodeAnalyzer.getInstance(searchContext.getProject()).setHighlightingEnabled(codeFragment, false); - return UIUtil.createEditor(doc, searchContext.getProject(), true, true, getTemplateContextType()); - } - - final EditorFactory factory = EditorFactory.getInstance(); - final Document document = factory.createDocument(text); - final EditorEx editor = (EditorEx)factory.createEditor(document, searchContext.getProject()); - editor.getSettings().setFoldingOutlineShown(false); - return editor; - } - - private static PsiFile createFileFragment(SearchContext searchContext, FileType fileType, Language dialect, String text) { - final String name = "__dummy." + fileType.getDefaultExtension(); - final PsiFileFactory factory = PsiFileFactory.getInstance(searchContext.getProject()); - - return dialect == null ? - factory.createFileFromText(name, fileType, text, LocalTimeCounter.currentTime(), true, true) : - factory.createFileFromText(name, dialect, text, true, true); - } - - @Nullable - public PsiCodeFragment createCodeFragment(Project project, String text, @Nullable PsiElement context) { - return null; - } - - @Nullable - public Class<? extends TemplateContextType> getTemplateContextTypeClass() { - return null; - } - - public final TemplateContextType getTemplateContextType() { - final Class<? extends TemplateContextType> clazz = getTemplateContextTypeClass(); - return clazz != null ? ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), clazz) : null; - } - - @Nullable - public FileType detectFileType(@NotNull PsiElement context) { - return null; - } - - @Nullable - public StructuralReplaceHandler getReplaceHandler(@NotNull ReplacementContext context) { - return null; - } - - public void checkSearchPattern(Project project, MatchOptions options) { - } - - public void checkReplacementPattern(Project project, ReplaceOptions options) { - String fileType = getTypeName(options.getMatchOptions().getFileType()); - throw new UnsupportedPatternException(SSRBundle.message("replacement.not.supported.for.filetype", fileType)); - } - - @NotNull - public Language getLanguage(PsiElement element) { - return element.getLanguage(); - } - - // only for nodes not filtered by lexical-nodes filter; they can be by default - public boolean canBeVarDelimeter(@NotNull PsiElement element) { - return false; - } - - public String getText(PsiElement match, int start, int end) { - final String matchText = match.getText(); - if (start==0 && end==-1) return matchText; - return matchText.substring(start, end == -1 ? matchText.length() : end); - } - - public Class getElementContextByPsi(PsiElement element) { - return element.getClass(); - } - - public String getTypedVarString(PsiElement element) { - if (element instanceof PsiNamedElement) { - return ((PsiNamedElement)element).getName(); - } - return element.getText(); - } - - public String getMeaningfulText(PsiElement element) { - return getTypedVarString(element); - } - - public PsiElement updateCurrentNode(PsiElement node) { - return node; - } - - public PsiElement extendMatchedByDownUp(PsiElement node) { - return node; - } - - public PsiElement extendMatchOnePsiFile(PsiElement file) { - return file; - } - - public LanguageFileType getDefaultFileType(@Nullable LanguageFileType fileType) { - return fileType; - } - - Configuration[] getPredefinedTemplates() { - return Configuration.EMPTY_ARRAY; - } - - public void provideAdditionalReplaceOptions(@NotNull PsiElement node, ReplaceOptions options, ReplacementBuilder builder) {} - - public int handleSubstitution(final ParameterInfo info, - MatchResult match, - StringBuilder result, - int offset, - HashMap<String, MatchResult> matchMap) { - return defaultHandleSubstitution(info, match, result, offset); - } - - public static int defaultHandleSubstitution(ParameterInfo info, MatchResult match, StringBuilder result, int offset) { - if (info.getName().equals(match.getName())) { - String replacementString = match.getMatchImage(); - boolean forceAddingNewLine = false; - if (match.getAllSons().size() > 0 && !match.isScopeMatch()) { - // compound matches - StringBuilder buf = new StringBuilder(); - - for (final MatchResult matchResult : match.getAllSons()) { - final PsiElement currentElement = matchResult.getMatch(); - - if (buf.length() > 0) { - if (info.isParameterContext()) { - buf.append(','); - } else { - buf.append(' '); - } - } - - buf.append(matchResult.getMatchImage()); - forceAddingNewLine = currentElement instanceof PsiComment; - } - replacementString = buf.toString(); - } else { - if (info.isStatementContext()) { - forceAddingNewLine = match.getMatch() instanceof PsiComment; - } - } - - offset = Replacer.insertSubstitution(result, offset, info, replacementString); - if (forceAddingNewLine && info.isStatementContext()) { - result.insert(info.getStartIndex() + offset + 1, '\n'); - offset ++; - } - } - return offset; - } - - public int processAdditionalOptions(ParameterInfo info, int offset, StringBuilder result, MatchResult r) { - return offset; - } - - public boolean isIdentifier(PsiElement element) { - return false; - } - - public Collection<String> getReservedWords() { - return Collections.emptySet(); - } - - public boolean isDocCommentOwner(PsiElement match) { - return false; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java deleted file mode 100644 index 9e9496115809..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchProfileBase.java +++ /dev/null @@ -1,674 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.dupLocator.PsiElementRole; -import com.intellij.dupLocator.equivalence.EquivalenceDescriptor; -import com.intellij.dupLocator.equivalence.EquivalenceDescriptorProvider; -import com.intellij.dupLocator.equivalence.MultiChildDescriptor; -import com.intellij.dupLocator.equivalence.SingleChildDescriptor; -import com.intellij.dupLocator.iterators.FilteringNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.dupLocator.util.DuplocatorUtil; -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; -import com.intellij.lang.LanguageParserDefinitions; -import com.intellij.lang.ParserDefinition; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.*; -import com.intellij.psi.impl.source.tree.LeafElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.tree.TokenSet; -import com.intellij.structuralsearch.impl.matcher.*; -import com.intellij.structuralsearch.impl.matcher.compiler.GlobalCompilingVisitor; -import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.handlers.*; -import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator; -import com.intellij.structuralsearch.impl.matcher.strategies.MatchingStrategy; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementContext; -import com.intellij.util.ArrayUtil; -import com.intellij.util.LocalTimeCounter; -import com.intellij.util.containers.HashSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.regex.Pattern; - -/** - * @author Eugene.Kudelevsky - */ -public abstract class StructuralSearchProfileBase extends StructuralSearchProfile { - private static final String DELIMETER_CHARS = ",;.[]{}():"; - protected static final String PATTERN_PLACEHOLDER = "$$PATTERN_PLACEHOLDER$$"; - private PsiElementVisitor myLexicalNodesFilter; - - @Override - public void compile(PsiElement[] elements, @NotNull final GlobalCompilingVisitor globalVisitor) { - final PsiElement topElement = elements[0].getParent(); - final PsiElement element = elements.length > 1 ? topElement : elements[0]; - - element.accept(new MyCompilingVisitor(globalVisitor, topElement)); - - element.accept(new PsiRecursiveElementVisitor() { - @Override - public void visitElement(PsiElement element) { - super.visitElement(element); - if (DuplocatorUtil.isIgnoredNode(element)) { - return; - } - CompiledPattern pattern = globalVisitor.getContext().getPattern(); - MatchingHandler handler = pattern.getHandler(element); - - if (!(handler instanceof SubstitutionHandler) && - !(handler instanceof TopLevelMatchingHandler) && - !(handler instanceof LightTopLevelMatchingHandler)) { - pattern.setHandler(element, new SkippingHandler(handler)); - } - - // todo: simplify logic - - /* - place skipping handler under top-level handler, because when we skip top-level node we can get non top-level handler, so - depth matching won't be done!; - */ - if (handler instanceof LightTopLevelMatchingHandler) { - MatchingHandler delegate = ((LightTopLevelMatchingHandler)handler).getDelegate(); - if (!(delegate instanceof SubstitutionHandler)) { - pattern.setHandler(element, new LightTopLevelMatchingHandler(new SkippingHandler(delegate))); - } - } - } - }); - - - final Language baseLanguage = element.getContainingFile().getLanguage(); - - // todo: try to optimize it: too heavy strategy! - globalVisitor.getContext().getPattern().setStrategy(new MatchingStrategy() { - @Override - public boolean continueMatching(PsiElement start) { - Language language = start.getLanguage(); - - PsiFile file = start.getContainingFile(); - if (file != null) { - Language fileLanguage = file.getLanguage(); - if (fileLanguage.isKindOf(language)) { - // dialect - language = fileLanguage; - } - } - - return language == baseLanguage; - } - - @Override - public boolean shouldSkip(PsiElement element, PsiElement elementToMatchWith) { - return DuplocatorUtil.shouldSkip(element, elementToMatchWith); - } - }); - } - - @NotNull - @Override - public PsiElementVisitor createMatchingVisitor(@NotNull GlobalMatchingVisitor globalVisitor) { - return new MyMatchingVisitor(globalVisitor); - } - - @NotNull - @Override - public PsiElementVisitor getLexicalNodesFilter(@NotNull final LexicalNodesFilter filter) { - if (myLexicalNodesFilter == null) { - myLexicalNodesFilter = new PsiElementVisitor() { - @Override - public void visitElement(PsiElement element) { - super.visitElement(element); - if (DuplocatorUtil.isIgnoredNode(element)) { - filter.setResult(true); - } - } - }; - } - return myLexicalNodesFilter; - } - - public static boolean containsOnlyDelimeters(String s) { - for (int i = 0, n = s.length(); i < n; i++) { - if (DELIMETER_CHARS.indexOf(s.charAt(i)) < 0) { - return false; - } - } - return true; - } - - @NotNull - protected abstract String[] getVarPrefixes(); - - @NotNull - @Override - public CompiledPattern createCompiledPattern() { - return new CompiledPattern() { - - @Override - protected SubstitutionHandler doCreateSubstitutionHandler(String name, boolean target, int minOccurs, int maxOccurs, boolean greedy) { - return new MySubstitutionHandler(name, target, minOccurs, maxOccurs, greedy); - } - - @Override - public String[] getTypedVarPrefixes() { - return getVarPrefixes(); - } - - @Override - public boolean isTypedVar(String str) { - for (String prefix : getVarPrefixes()) { - if (str.startsWith(prefix)) { - return true; - } - } - return false; - } - - @Override - public String getTypedVarString(PsiElement element) { - final PsiElement initialElement = element; - PsiElement child = SkippingHandler.getOnlyNonWhitespaceChild(element); - - while (child != element && child != null && !(child instanceof LeafElement)) { - element = child; - child = SkippingHandler.getOnlyNonWhitespaceChild(element); - } - return child instanceof LeafElement ? element.getText() : initialElement.getText(); - } - }; - } - - @Override - public boolean canProcess(@NotNull FileType fileType) { - return fileType instanceof LanguageFileType && - isMyLanguage(((LanguageFileType)fileType).getLanguage()); - } - - @Override - public boolean isMyLanguage(@NotNull Language language) { - return language.isKindOf(getFileType().getLanguage()); - } - - @NotNull - protected abstract LanguageFileType getFileType(); - - @NotNull - @Override - public PsiElement[] createPatternTree(@NotNull String text, - @NotNull PatternTreeContext context, - @NotNull FileType fileType, - @Nullable Language language, - @Nullable String contextName, - @Nullable String extension, - @NotNull Project project, - boolean physical) { - if (context == PatternTreeContext.Block) { - final String strContext = getContext(text, language, contextName); - return strContext != null ? - parsePattern(project, strContext, text, fileType, language, extension, physical) : - PsiElement.EMPTY_ARRAY; - } - return super.createPatternTree(text, context, fileType, language, contextName, extension, project, physical); - } - - @Override - public void checkReplacementPattern(Project project, ReplaceOptions options) { - final CompiledPattern compiledPattern = PatternCompiler.compilePattern(project, options.getMatchOptions()); - if (compiledPattern == null) { - return; - } - - final NodeIterator it = compiledPattern.getNodes(); - if (!it.hasNext()) { - return; - } - - final PsiElement root = it.current().getParent(); - - if (!checkOptionalChildren(root) || - !checkErrorElements(root)) { - throw new UnsupportedPatternException(": Partial and expression patterns are not supported"); - } - } - - private static boolean checkErrorElements(PsiElement element) { - final boolean[] result = {true}; - final int endOffset = element.getTextRange().getEndOffset(); - - element.accept(new PsiRecursiveElementWalkingVisitor() { - @Override - public void visitElement(PsiElement element) { - super.visitElement(element); - - if (element instanceof PsiErrorElement && element.getTextRange().getEndOffset() == endOffset) { - result[0] = false; - } - } - }); - - return result[0]; - } - - private static boolean checkOptionalChildren(PsiElement root) { - final boolean[] result = {true}; - - root.accept(new PsiRecursiveElementWalkingVisitor() { - @Override - public void visitElement(PsiElement element) { - super.visitElement(element); - - if (element instanceof LeafElement) { - return; - } - - final EquivalenceDescriptorProvider provider = EquivalenceDescriptorProvider.getInstance(element); - if (provider == null) { - return; - } - - final EquivalenceDescriptor descriptor = provider.buildDescriptor(element); - if (descriptor == null) { - return; - } - - for (SingleChildDescriptor childDescriptor : descriptor.getSingleChildDescriptors()) { - if (childDescriptor.getType() == SingleChildDescriptor.MyType.OPTIONALLY_IN_PATTERN && - childDescriptor.getElement() == null) { - result[0] = false; - } - } - - for (MultiChildDescriptor childDescriptor : descriptor.getMultiChildDescriptors()) { - if (childDescriptor.getType() == MultiChildDescriptor.MyType.OPTIONALLY_IN_PATTERN) { - PsiElement[] elements = childDescriptor.getElements(); - if (elements == null || elements.length == 0) { - result[0] = false; - } - } - } - } - }); - return result[0]; - } - - @Override - public StructuralReplaceHandler getReplaceHandler(@NotNull ReplacementContext context) { - return new DocumentBasedReplaceHandler(context.getProject()); - } - - @NotNull - public String[] getContextNames() { - return ArrayUtil.EMPTY_STRING_ARRAY; - } - - @Nullable - protected String getContext(@NotNull String pattern, @Nullable Language language, @Nullable String contextName) { - return PATTERN_PLACEHOLDER; - } - - private static boolean canBePatternVariable(PsiElement element) { - // can be leaf element! (ex. var a = 1 <-> var $a$ = 1) - if (element instanceof LeafElement) { - return true; - } - - while (!(element instanceof LeafElement) && element != null) { - element = SkippingHandler.getOnlyNonWhitespaceChild(element); - } - return element != null; - } - - private static boolean isLiteral(PsiElement element) { - if (element == null) return false; - final ASTNode astNode = element.getNode(); - if (astNode == null) { - return false; - } - final IElementType elementType = astNode.getElementType(); - final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage()); - if (parserDefinition != null) { - final TokenSet literals = parserDefinition.getStringLiteralElements(); - return literals.contains(elementType); - } - return false; - } - - private static boolean canBePatternVariableValue(PsiElement element) { - // can be leaf element! (ex. var a = 1 <-> var $a$ = 1) - return !containsOnlyDelimeters(element.getText()); - } - - @Override - public boolean canBeVarDelimeter(@NotNull PsiElement element) { - final ASTNode node = element.getNode(); - return node != null && getVariableDelimiters().contains(node.getElementType()); - } - - protected TokenSet getVariableDelimiters() { - return TokenSet.EMPTY; - } - - public static PsiElement[] parsePattern(Project project, - String context, - String pattern, - FileType fileType, - Language language, - String extension, - boolean physical) { - int offset = context.indexOf(PATTERN_PLACEHOLDER); - - final int patternLength = pattern.length(); - final String patternInContext = context.replace(PATTERN_PLACEHOLDER, pattern); - - final String ext = extension != null ? extension : fileType.getDefaultExtension(); - final String name = "__dummy." + ext; - final PsiFileFactory factory = PsiFileFactory.getInstance(project); - - final PsiFile file = language == null - ? factory.createFileFromText(name, fileType, patternInContext, LocalTimeCounter.currentTime(), physical, true) - : factory.createFileFromText(name, language, patternInContext, physical, true); - if (file == null) { - return PsiElement.EMPTY_ARRAY; - } - - final List<PsiElement> result = new ArrayList<PsiElement>(); - - PsiElement element = file.findElementAt(offset); - if (element == null) { - return PsiElement.EMPTY_ARRAY; - } - - PsiElement topElement = element; - element = element.getParent(); - - while (element != null) { - if (element.getTextRange().getStartOffset() == offset && element.getTextLength() <= patternLength) { - topElement = element; - } - element = element.getParent(); - } - - if (topElement instanceof PsiFile) { - return topElement.getChildren(); - } - - final int endOffset = offset + patternLength; - result.add(topElement); - topElement = topElement.getNextSibling(); - - while (topElement != null && topElement.getTextRange().getEndOffset() <= endOffset) { - result.add(topElement); - topElement = topElement.getNextSibling(); - } - - return result.toArray(new PsiElement[result.size()]); - } - - // todo: support expression patterns - // todo: support {statement;} = statement; (node has only non-lexical child) - - private static class MyCompilingVisitor extends PsiRecursiveElementVisitor { - private final GlobalCompilingVisitor myGlobalVisitor; - private final PsiElement myTopElement; - - private Pattern[] mySubstitutionPatterns; - - private MyCompilingVisitor(GlobalCompilingVisitor globalVisitor, PsiElement topElement) { - myGlobalVisitor = globalVisitor; - myTopElement = topElement; - } - - @Override - public void visitElement(PsiElement element) { - doVisitElement(element); - - if (isLiteral(element)) { - visitLiteral(element); - } - } - - private void doVisitElement(PsiElement element) { - CompiledPattern pattern = myGlobalVisitor.getContext().getPattern(); - - if (myGlobalVisitor.getCodeBlockLevel() == 0) { - initTopLevelElement(element); - return; - } - - if (canBePatternVariable(element) && pattern.isRealTypedVar(element)) { - myGlobalVisitor.handle(element); - final MatchingHandler handler = pattern.getHandler(element); - handler.setFilter(new NodeFilter() { - public boolean accepts(PsiElement other) { - return canBePatternVariableValue(other); - } - }); - - super.visitElement(element); - - return; - } - - super.visitElement(element); - - if (myGlobalVisitor.getContext().getSearchHelper().doOptimizing() && element instanceof LeafElement) { - ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage()); - if (parserDefinition != null) { - String text = element.getText(); - - // todo: support variables inside comments - boolean flag = true; - if (StringUtil.isJavaIdentifier(text) && flag) { - myGlobalVisitor.processTokenizedName(text, true, GlobalCompilingVisitor.OccurenceKind.CODE); - } - } - } - } - - private void visitLiteral(PsiElement literal) { - String value = literal.getText(); - - if (value.length() > 2 && - (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') || - (value.charAt(0) == '\'' && value.charAt(value.length() - 1) == '\'')) { - - if (mySubstitutionPatterns == null) { - final String[] prefixes = myGlobalVisitor.getContext().getPattern().getTypedVarPrefixes(); - mySubstitutionPatterns = createPatterns(prefixes); - } - - for (Pattern substitutionPattern : mySubstitutionPatterns) { - @Nullable MatchingHandler handler = - myGlobalVisitor.processPatternStringWithFragments(value, GlobalCompilingVisitor.OccurenceKind.LITERAL, substitutionPattern); - - if (handler != null) { - literal.putUserData(CompiledPattern.HANDLER_KEY, handler); - break; - } - } - } - } - - private static Pattern[] createPatterns(String[] prefixes) { - final Pattern[] patterns = new Pattern[prefixes.length]; - - for (int i = 0; i < prefixes.length; i++) { - final String s = StructuralSearchUtil.shieldSpecialChars(prefixes[0]); - patterns[i] = Pattern.compile("\\b(" + s + "\\w+)\\b"); - } - return patterns; - } - - private void initTopLevelElement(PsiElement element) { - CompiledPattern pattern = myGlobalVisitor.getContext().getPattern(); - - PsiElement newElement = SkippingHandler.skipNodeIfNeccessary(element); - - if (element != newElement && newElement != null) { - // way to support partial matching (ex. if ($condition$) ) - newElement.accept(this); - pattern.setHandler(element, new LightTopLevelMatchingHandler(pattern.getHandler(element))); - } - else { - myGlobalVisitor.setCodeBlockLevel(myGlobalVisitor.getCodeBlockLevel() + 1); - - for (PsiElement el = element.getFirstChild(); el != null; el = el.getNextSibling()) { - if (GlobalCompilingVisitor.getFilter().accepts(el)) { - if (el instanceof PsiWhiteSpace) { - myGlobalVisitor.addLexicalNode(el); - } - } - else { - el.accept(this); - - MatchingHandler matchingHandler = pattern.getHandler(el); - pattern.setHandler(el, element == myTopElement ? new TopLevelMatchingHandler(matchingHandler) : - new LightTopLevelMatchingHandler(matchingHandler)); - - /* - do not assign light-top-level handlers through skipping, because it is incorrect; - src: if (...) { st1; st2; } - pattern: if (...) {$a$;} - - $a$ will have top-level handler, so matching will be considered as correct, although "st2;" is left! - */ - } - } - - myGlobalVisitor.setCodeBlockLevel(myGlobalVisitor.getCodeBlockLevel() - 1); - pattern.setHandler(element, new TopLevelMatchingHandler(pattern.getHandler(element))); - } - } - } - - private static class MyMatchingVisitor extends PsiElementVisitor { - private final GlobalMatchingVisitor myGlobalVisitor; - - private MyMatchingVisitor(GlobalMatchingVisitor globalVisitor) { - myGlobalVisitor = globalVisitor; - } - - private boolean shouldIgnoreVarNode(PsiElement element) { - MatchingHandler handler = myGlobalVisitor.getMatchContext().getPattern().getHandlerSimple(element); - if (handler instanceof DelegatingHandler) { - handler = ((DelegatingHandler)handler).getDelegate(); - } - return handler instanceof MySubstitutionHandler && ((MySubstitutionHandler)handler).myExceptedNodes.contains(element); - } - - @Override - public void visitElement(PsiElement element) { - super.visitElement(element); - - final EquivalenceDescriptorProvider descriptorProvider = EquivalenceDescriptorProvider.getInstance(element); - - if (descriptorProvider != null) { - final EquivalenceDescriptor descriptor1 = descriptorProvider.buildDescriptor(element); - final EquivalenceDescriptor descriptor2 = descriptorProvider.buildDescriptor(myGlobalVisitor.getElement()); - - if (descriptor1 != null && descriptor2 != null) { - final boolean result = DuplocatorUtil - .match(descriptor1, descriptor2, myGlobalVisitor, Collections.<PsiElementRole>emptySet(), null); - myGlobalVisitor.setResult(result); - return; - } - } - - if (isLiteral(element)) { - visitLiteral(element); - return; - } - - if (canBePatternVariable(element) && - myGlobalVisitor.getMatchContext().getPattern().isRealTypedVar(element) && - !shouldIgnoreVarNode(element)) { - - PsiElement matchedElement = myGlobalVisitor.getElement(); - PsiElement newElement = SkippingHandler.skipNodeIfNeccessary(matchedElement); - while (newElement != matchedElement) { - matchedElement = newElement; - newElement = SkippingHandler.skipNodeIfNeccessary(matchedElement); - } - - myGlobalVisitor.setResult(myGlobalVisitor.handleTypedElement(element, matchedElement)); - } - else if (element instanceof LeafElement) { - myGlobalVisitor.setResult(element.getText().equals(myGlobalVisitor.getElement().getText())); - } - else if (element.getFirstChild() == null && element.getTextLength() == 0) { - myGlobalVisitor.setResult(true); - } - else { - PsiElement patternChild = element.getFirstChild(); - PsiElement matchedChild = myGlobalVisitor.getElement().getFirstChild(); - - FilteringNodeIterator patternIterator = new SsrFilteringNodeIterator(patternChild); - FilteringNodeIterator matchedIterator = new SsrFilteringNodeIterator(matchedChild); - - boolean matched = myGlobalVisitor.matchSequentially(patternIterator, matchedIterator); - myGlobalVisitor.setResult(matched); - } - } - - public void visitLiteral(PsiElement literal) { - final PsiElement l2 = myGlobalVisitor.getElement(); - - MatchingHandler handler = (MatchingHandler)literal.getUserData(CompiledPattern.HANDLER_KEY); - - if (handler instanceof SubstitutionHandler) { - int offset = 0; - int length = l2.getTextLength(); - final String text = l2.getText(); - - if (length > 2 && - (text.charAt(0) == '"' && text.charAt(length - 1) == '"') || - (text.charAt(0) == '\'' && text.charAt(length - 1) == '\'')) { - length--; - offset++; - } - myGlobalVisitor.setResult(((SubstitutionHandler)handler).handle(l2, offset, length, myGlobalVisitor.getMatchContext())); - } - else if (handler != null) { - myGlobalVisitor.setResult(handler.match(literal, l2, myGlobalVisitor.getMatchContext())); - } - else { - myGlobalVisitor.setResult(literal.textMatches(l2)); - } - } - } - - private static class MySubstitutionHandler extends SubstitutionHandler { - final Set<PsiElement> myExceptedNodes; - - public MySubstitutionHandler(String name, boolean target, int minOccurs, int maxOccurs, boolean greedy) { - super(name, target, minOccurs, maxOccurs, greedy); - myExceptedNodes = new HashSet<PsiElement>(); - } - - @Override - public boolean matchSequentially(NodeIterator nodes, NodeIterator nodes2, MatchContext context) { - if (doMatchSequentially(nodes, nodes2, context)) { - return true; - } - final PsiElement current = nodes.current(); - if (current != null) { - myExceptedNodes.add(current); - } - final boolean result = doMatchSequentiallyBySimpleHandler(nodes, nodes2, context); - myExceptedNodes.remove(current); - return result; - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchUtil.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchUtil.java deleted file mode 100644 index b37c10143636..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/StructuralSearchUtil.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.*; -import com.intellij.openapi.fileTypes.impl.AbstractFileType; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchUtils; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.tokenindex.LanguageTokenizer; -import com.intellij.tokenindex.Tokenizer; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -/** - * @author Eugene.Kudelevsky - */ -public class StructuralSearchUtil { - private static LanguageFileType ourDefaultFileType = null; - - public static boolean ourUseUniversalMatchingAlgorithm = false; - private static StructuralSearchProfile[] ourNewStyleProfiles; - private static List<Configuration> ourPredefinedConfigurations = null; - - private StructuralSearchUtil() {} - - @Nullable - public static StructuralSearchProfile getProfileByPsiElement(@NotNull PsiElement element) { - return getProfileByLanguage(element.getLanguage()); - } - - @Contract("null -> false") - public static boolean isIdentifier(PsiElement element) { - final StructuralSearchProfile profile = getProfileByPsiElement(element); - return profile != null && profile.isIdentifier(element); - } - - private static StructuralSearchProfile[] getNewStyleProfiles() { - if (ourNewStyleProfiles == null) { - final List<StructuralSearchProfile> list = new ArrayList<StructuralSearchProfile>(); - - for (StructuralSearchProfile profile : StructuralSearchProfile.EP_NAME.getExtensions()) { - if (profile instanceof StructuralSearchProfileBase) { - list.add(profile); - } - } - list.add(new XmlStructuralSearchProfile()); - ourNewStyleProfiles = list.toArray(new StructuralSearchProfile[list.size()]); - } - return ourNewStyleProfiles; - } - - private static StructuralSearchProfile[] getProfiles() { - return ourUseUniversalMatchingAlgorithm - ? getNewStyleProfiles() - : StructuralSearchProfile.EP_NAME.getExtensions(); - } - - public static FileType getDefaultFileType() { - if (ourDefaultFileType == null) { - for (StructuralSearchProfile profile : getProfiles()) { - ourDefaultFileType = profile.getDefaultFileType(ourDefaultFileType); - } - if (ourDefaultFileType == null) { - ourDefaultFileType = StdFileTypes.XML; - } - } - assert isValidFileType(ourDefaultFileType) : "file type not valid for structural search: " + ourDefaultFileType.getName(); - return ourDefaultFileType; - } - - @Nullable - public static StructuralSearchProfile getProfileByLanguage(@NotNull Language language) { - - for (StructuralSearchProfile profile : getProfiles()) { - if (profile.isMyLanguage(language)) { - return profile; - } - } - return null; - } - - @Nullable - public static Tokenizer getTokenizerForLanguage(@NotNull Language language) { - return LanguageTokenizer.INSTANCE.forLanguage(language); - } - - public static boolean isTypedVariable(@NotNull final String name) { - return name.charAt(0)=='$' && name.charAt(name.length()-1)=='$'; - } - - @Nullable - public static StructuralSearchProfile getProfileByFileType(FileType fileType) { - - for (StructuralSearchProfile profile : getProfiles()) { - if (profile.canProcess(fileType)) { - return profile; - } - } - - return null; - } - - @NotNull - public static FileType[] getSuitableFileTypes() { - Set<FileType> allFileTypes = new HashSet<FileType>(); - Collections.addAll(allFileTypes, FileTypeManager.getInstance().getRegisteredFileTypes()); - for (Language language : Language.getRegisteredLanguages()) { - FileType fileType = language.getAssociatedFileType(); - if (fileType != null) { - allFileTypes.add(fileType); - } - } - - List<FileType> result = new ArrayList<FileType>(); - for (FileType fileType : allFileTypes) { - if (isValidFileType(fileType)) { - result.add(fileType); - } - } - - return result.toArray(new FileType[result.size()]); - } - - private static boolean isValidFileType(FileType fileType) { - return fileType != StdFileTypes.GUI_DESIGNER_FORM && - fileType != StdFileTypes.IDEA_MODULE && - fileType != StdFileTypes.IDEA_PROJECT && - fileType != StdFileTypes.IDEA_WORKSPACE && - fileType != FileTypes.ARCHIVE && - fileType != FileTypes.UNKNOWN && - fileType != FileTypes.PLAIN_TEXT && - !(fileType instanceof AbstractFileType) && - !fileType.isBinary() && - !fileType.isReadOnly(); - } - - public static String shieldSpecialChars(String word) { - final StringBuilder buf = new StringBuilder(word.length()); - - for (int i = 0; i < word.length(); ++i) { - if (MatchUtils.SPECIAL_CHARS.indexOf(word.charAt(i)) != -1) { - buf.append("\\"); - } - buf.append(word.charAt(i)); - } - - return buf.toString(); - } - - public static List<Configuration> getPredefinedTemplates() { - if (ourPredefinedConfigurations == null) { - final List<Configuration> result = new ArrayList<Configuration>(); - for (StructuralSearchProfile profile : getProfiles()) { - Collections.addAll(result, profile.getPredefinedTemplates()); - } - Collections.sort(result); - ourPredefinedConfigurations = Collections.unmodifiableList(result); - } - return ourPredefinedConfigurations; - } - - public static boolean isDocCommentOwner(PsiElement match) { - final StructuralSearchProfile profile = getProfileByPsiElement(match); - return profile != null && profile.isDocCommentOwner(match); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/UnsupportedPatternException.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/UnsupportedPatternException.java deleted file mode 100644 index 1236264118c2..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/UnsupportedPatternException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.intellij.structuralsearch; - -/** - * Exception about encountering yet unsupported pattern event. - */ -public class UnsupportedPatternException extends RuntimeException { - - public UnsupportedPatternException(String _pattern) { - super(_pattern); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/XmlStructuralSearchProfile.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/XmlStructuralSearchProfile.java deleted file mode 100644 index 5e0ca8bde957..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/XmlStructuralSearchProfile.java +++ /dev/null @@ -1,229 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.codeInsight.template.TemplateContextType; -import com.intellij.codeInsight.template.XmlContextType; -import com.intellij.lang.Language; -import com.intellij.lang.StdLanguages; -import com.intellij.lang.xml.XMLLanguage; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.psi.xml.XmlDocument; -import com.intellij.psi.xml.XmlFile; -import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlText; -import com.intellij.structuralsearch.impl.matcher.*; -import com.intellij.structuralsearch.impl.matcher.compiler.GlobalCompilingVisitor; -import com.intellij.structuralsearch.impl.matcher.compiler.XmlCompilingVisitor; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.filters.XmlLexicalNodesFilter; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementContext; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacerUtil; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.LocalTimeCounter; -import com.intellij.xml.util.HtmlUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import static com.intellij.structuralsearch.PredefinedConfigurationUtil.createSearchTemplateInfo; - -/** - * @author Eugene.Kudelevsky - */ -public class XmlStructuralSearchProfile extends StructuralSearchProfile { - - private XmlLexicalNodesFilter myLexicalNodesFilter; - - public void compile(PsiElement[] elements, @NotNull GlobalCompilingVisitor globalVisitor) { - elements[0].getParent().accept(new XmlCompilingVisitor(globalVisitor)); - } - - @NotNull - public PsiElementVisitor createMatchingVisitor(@NotNull GlobalMatchingVisitor globalVisitor) { - return new XmlMatchingVisitor(globalVisitor); - } - - @NotNull - @Override - public PsiElementVisitor getLexicalNodesFilter(@NotNull LexicalNodesFilter filter) { - if (myLexicalNodesFilter == null) { - myLexicalNodesFilter = new XmlLexicalNodesFilter(filter); - } - return myLexicalNodesFilter; - } - - @NotNull - public CompiledPattern createCompiledPattern() { - return new XmlCompiledPattern(); - } - - @Override - public boolean canProcess(@NotNull FileType fileType) { - return fileType == StdFileTypes.XML || fileType == StdFileTypes.HTML || fileType == StdFileTypes.JSP || - fileType == StdFileTypes.JSPX || fileType == StdFileTypes.XHTML; - } - - public boolean isMyLanguage(@NotNull Language language) { - return language instanceof XMLLanguage; - } - - @NotNull - @Override - public PsiElement[] createPatternTree(@NotNull String text, - @NotNull PatternTreeContext context, - @NotNull FileType fileType, - @Nullable Language language, - String contextName, @Nullable String extension, - @NotNull Project project, - boolean physical) { - final String ext = extension != null ? extension : fileType.getDefaultExtension(); - String text1 = context == PatternTreeContext.File ? text : "<QQQ>" + text + "</QQQ>"; - final PsiFile fileFromText = PsiFileFactory.getInstance(project) - .createFileFromText("dummy." + ext, fileType, text1, LocalTimeCounter.currentTime(), physical, true); - - final XmlDocument document = HtmlUtil.getRealXmlDocument(((XmlFile)fileFromText).getDocument()); - if (context == PatternTreeContext.File) { - return new PsiElement[]{document}; - } - - return document.getRootTag().getValue().getChildren(); - } - - @Override - public Class<? extends TemplateContextType> getTemplateContextTypeClass() { - return XmlContextType.class; - } - - @NotNull - @Override - public FileType detectFileType(@NotNull PsiElement context) { - PsiFile file = context instanceof PsiFile ? (PsiFile)context : context.getContainingFile(); - Language contextLanguage = context instanceof PsiFile ? null : context.getLanguage(); - if (file.getLanguage() == StdLanguages.HTML || (file.getFileType() == StdFileTypes.JSP && contextLanguage == StdLanguages.HTML)) { - return StdFileTypes.HTML; - } - return StdFileTypes.XML; - } - - @Override - public void checkReplacementPattern(Project project, ReplaceOptions options) { - } - - @Override - public StructuralReplaceHandler getReplaceHandler(@NotNull ReplacementContext context) { - return new MyReplaceHandler(context); - } - - private static class MyReplaceHandler extends StructuralReplaceHandler { - private final ReplacementContext myContext; - - private MyReplaceHandler(ReplacementContext context) { - myContext = context; - } - - public void replace(ReplacementInfo info, ReplaceOptions options) { - PsiElement elementToReplace = info.getMatch(0); - assert elementToReplace != null; - PsiElement elementParent = elementToReplace.getParent(); - String replacementToMake = info.getReplacement(); - boolean listContext = elementToReplace.getParent() instanceof XmlTag; - - if (listContext) { - doReplaceInContext(info, elementToReplace, replacementToMake, elementParent, myContext); - } - - PsiElement[] statements = ReplacerUtil.createTreeForReplacement(replacementToMake, PatternTreeContext.Block, myContext); - - if (statements.length > 0) { - PsiElement replacement = ReplacerUtil.copySpacesAndCommentsBefore(elementToReplace, statements, replacementToMake, elementParent); - - // preserve comments - Replacer.handleComments(elementToReplace, replacement, myContext); - elementToReplace.replace(replacement); - } - else { - final PsiElement nextSibling = elementToReplace.getNextSibling(); - elementToReplace.delete(); - assert nextSibling != null; - if (nextSibling.isValid()) { - if (nextSibling instanceof PsiWhiteSpace) { - nextSibling.delete(); - } - } - } - } - } - - private static void doReplaceInContext(ReplacementInfo info, - PsiElement elementToReplace, - String replacementToMake, - PsiElement elementParent, - ReplacementContext context) { - PsiElement[] statements = ReplacerUtil.createTreeForReplacement(replacementToMake, PatternTreeContext.Block, context); - - if (statements.length > 1) { - elementParent.addRangeBefore(statements[0], statements[statements.length - 1], elementToReplace); - } - else if (statements.length == 1) { - PsiElement replacement = statements[0]; - - Replacer.handleComments(elementToReplace, replacement, context); - - try { - elementParent.addBefore(replacement, elementToReplace); - } - catch (IncorrectOperationException e) { - elementToReplace.replace(replacement); - } - } - - final int matchSize = info.getMatchesCount(); - - for (int i = 0; i < matchSize; ++i) { - PsiElement element = info.getMatch(i); - - if (element == null) continue; - PsiElement firstToDelete = element; - PsiElement lastToDelete = element; - PsiElement prevSibling = element.getPrevSibling(); - PsiElement nextSibling = element.getNextSibling(); - - if (prevSibling instanceof PsiWhiteSpace) { - firstToDelete = prevSibling; - } - else if (prevSibling == null && nextSibling instanceof PsiWhiteSpace) { - lastToDelete = nextSibling; - } - if (nextSibling instanceof XmlText && i + 1 < matchSize) { - final PsiElement next = info.getMatch(i + 1); - if (next != null && next == nextSibling.getNextSibling()) { - lastToDelete = nextSibling; - } - } - element.getParent().deleteChildRange(firstToDelete, lastToDelete); - } - } - - @Override - Configuration[] getPredefinedTemplates() { - return XmlPredefinedConfigurations.createPredefinedTemplates(); - } - - private static class XmlPredefinedConfigurations { - private static final String HTML_XML = SSRBundle.message("xml_html.category"); - - private static Configuration[] createPredefinedTemplates() { - return new Configuration[]{ - createSearchTemplateInfo("xml tag", "<'a/>", HTML_XML, StdFileTypes.XML), - createSearchTemplateInfo("xml attribute", "<'_tag 'attribute=\"'_value\"/>", HTML_XML, StdFileTypes.XML), - createSearchTemplateInfo("xml attribute value", "<'_tag '_attribute=\"'value\"/>", HTML_XML, StdFileTypes.XML), - createSearchTemplateInfo("xml/html tag value", "<table>'_content*</table>", HTML_XML, StdFileTypes.HTML), - }; - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java deleted file mode 100644 index 565f80ac01ce..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/CompiledPattern.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.openapi.util.Key; -import com.intellij.psi.PsiElement; -import com.intellij.psi.search.SearchScope; -import com.intellij.psi.util.PsiUtilCore; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.SimpleHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler; -import com.intellij.structuralsearch.impl.matcher.strategies.MatchingStrategy; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.List; - -/** - * Class to hold compiled pattern information - */ -public abstract class CompiledPattern { - public static final String ALL_CLASS_UNMATCHED_CONTENT_VAR_ARTIFICIAL_NAME = "__class_unmatched__"; - private SearchScope scope; - private NodeIterator nodes; - private MatchingStrategy strategy; - private PsiElement targetNode; - private int optionsHashStamp; - private int nodeCount; - - // @todo support this property during matching (how many nodes should be advanced) - // when match is not successful (or successful partially) - //private int advancement = 1; - - public abstract String[] getTypedVarPrefixes(); - public abstract boolean isTypedVar(String str); - - public void setTargetNode(final PsiElement element) { - targetNode = element; - } - - public PsiElement getTargetNode() { - return targetNode; - } - - public int getOptionsHashStamp() { - return optionsHashStamp; - } - - public void setOptionsHashStamp(final int optionsHashStamp) { - this.optionsHashStamp = optionsHashStamp; - } - - public static final Key<Object> HANDLER_KEY = Key.create("ss.handler"); - - public MatchingStrategy getStrategy() { - return strategy; - } - - public void setStrategy(MatchingStrategy strategy) { - this.strategy = strategy; - } - - public int getNodeCount() { - return nodeCount; - } - - public NodeIterator getNodes() { - return nodes; - } - - public void setNodes(List<PsiElement> elements) { - this.nodes = new ArrayBackedNodeIterator(PsiUtilCore.toPsiElementArray(elements)); - this.nodeCount = elements.size(); - } - - public boolean isTypedVar(final PsiElement element) { - return element!=null && isTypedVar( element.getText() ); - } - - public boolean isRealTypedVar(PsiElement element) { - if (element!=null && element.getTextLength()>0) { - String str = getTypedVarString(element); - if (str.length()==0) { - return false; - } - return isTypedVar( str ); - } else { - return false; - } - } - - public String getTypedVarString(PsiElement element) { - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(element); - if (profile == null) { - return element.getText(); - } - return profile.getTypedVarString(element); - } - - private final HashMap<Object,MatchingHandler> handlers = new HashMap<Object,MatchingHandler>(); - - public MatchingHandler getHandlerSimple(PsiElement node) { - return handlers.get(node); - } - - private PsiElement last; - private MatchingHandler lastHandler; - - public MatchingHandler getHandler(PsiElement node) { - if (node==last) { - return lastHandler; - } - MatchingHandler handler = handlers.get(node); - - if (handler==null) { - handler = new SimpleHandler(); - setHandler(node,handler); - } - - last = node; - lastHandler = handler; - - return handler; - } - - public MatchingHandler getHandler(String name) { - return handlers.get(name); - } - - public void setHandler(PsiElement node, MatchingHandler handler) { - last = null; - handlers.put(node,handler); - } - - public SubstitutionHandler createSubstitutionHandler( - String name, String compiledName, boolean target,int minOccurs, int maxOccurs, boolean greedy) { - - SubstitutionHandler handler = (SubstitutionHandler) handlers.get(compiledName); - if (handler != null) return handler; - - handler = doCreateSubstitutionHandler(name, target, minOccurs, maxOccurs, greedy); - - handlers.put(compiledName,handler); - - return handler; - } - - protected SubstitutionHandler doCreateSubstitutionHandler(String name, boolean target, int minOccurs, int maxOccurs, boolean greedy) { - return new SubstitutionHandler(name, target, minOccurs, maxOccurs, greedy); - } - - public SearchScope getScope() { - return scope; - } - - public void setScope(SearchScope scope) { - this.scope = scope; - } - - public void clearHandlers() { - handlers.clear(); - last = null; - lastHandler = null; - } - - void clearHandlersState() { - for (final MatchingHandler h : handlers.values()) { - if (h != null) h.reset(); - } - } - - public boolean isToResetHandler(PsiElement element) { - return true; - } - - @Nullable - public String getAlternativeTextToMatch(PsiElement node, String previousText) { - return null; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/DataProvider.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/DataProvider.java deleted file mode 100644 index e7327fad7e5e..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/DataProvider.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 07.01.2004 - * Time: 1:06:51 - * To change this template use Options | File Templates. - */ -public interface DataProvider { - Editor getEditor(); - Project getProject(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java deleted file mode 100644 index bfbe065e461c..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/GlobalMatchingVisitor.java +++ /dev/null @@ -1,319 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.dupLocator.AbstractMatchingVisitor; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.lang.Language; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiElementVisitor; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.handlers.DelegatingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.util.SmartPsiPointer; -import com.intellij.util.containers.HashMap; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Map; - -/** - * Visitor class to manage pattern matching - */ -@SuppressWarnings({"RefusedBequest"}) -public class GlobalMatchingVisitor extends AbstractMatchingVisitor { - private static final Logger LOG = Logger.getInstance("#com.intellij.structuralsearch.impl.matcher.GlobalMatchingVisitor"); - - // the pattern element for visitor check - private PsiElement myElement; - - // the result of matching in visitor - private boolean myResult; - - // context of matching - private MatchContext matchContext; - - private MatchingHandler myLastHandler; - - private Map<Language, PsiElementVisitor> myLanguage2MatchingVisitor = new HashMap<Language, PsiElementVisitor>(1); - - public PsiElement getElement() { - return myElement; - } - - public boolean getResult() { - return myResult; - } - - public void setElement(PsiElement element) { - this.myElement = element; - } - - public void setResult(boolean result) { - this.myResult = result; - } - - public MatchContext getMatchContext() { - return matchContext; - } - - @Override - protected boolean doMatchInAnyOrder(NodeIterator elements, NodeIterator elements2) { - return matchContext.getPattern().getHandler(elements.current()).matchInAnyOrder( - elements, - elements2, - matchContext - ); - } - - @NotNull - @Override - protected NodeFilter getNodeFilter() { - return LexicalNodesFilter.getInstance(); - } - - public final boolean handleTypedElement(final PsiElement typedElement, final PsiElement match) { - MatchingHandler handler = matchContext.getPattern().getHandler(typedElement); - final MatchingHandler initialHandler = handler; - if (handler instanceof DelegatingHandler) { - handler = ((DelegatingHandler)handler).getDelegate(); - } - assert handler instanceof SubstitutionHandler : - handler != null ? handler.getClass() : "null" + ' ' + (initialHandler != null ? initialHandler.getClass() : "null"); - - return ((SubstitutionHandler)handler).handle(match, matchContext); - } - - /** - * Identifies the match between given element of program tree and pattern element - * - * @param el1 the pattern for matching - * @param el2 the tree element for matching - * @return true if equal and false otherwise - */ - public boolean match(final PsiElement el1, final PsiElement el2) { - // null - if (el1 == el2) return true; - if (el2 == null || el1 == null) { - // this a bug! - return false; - } - - // copy changed data to local stack - PsiElement prevElement = myElement; - myElement = el2; - - try { - /*if (el1 instanceof XmlElement) { - el1.accept(myXmlVisitor); - } - else { - el1.accept(myJavaVisitor); - }*/ - PsiElementVisitor visitor = getVisitorForElement(el1); - if (visitor != null) { - el1.accept(visitor); - } - } - catch (ClassCastException ex) { - myResult = false; - } - finally { - myElement = prevElement; - } - - return myResult; - } - - @Nullable - private PsiElementVisitor getVisitorForElement(PsiElement element) { - Language language = element.getLanguage(); - PsiElementVisitor visitor = myLanguage2MatchingVisitor.get(language); - if (visitor == null) { - visitor = createMatchingVisitor(language); - myLanguage2MatchingVisitor.put(language, visitor); - } - return visitor; - } - - @Nullable - private PsiElementVisitor createMatchingVisitor(Language language) { - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language); - if (profile == null) { - LOG.warn("there is no StructuralSearchProfile for language " + language.getID()); - return null; - } - else { - return profile.createMatchingVisitor(this); - } - } - - /** - * Matches tree segments starting with given elements to find equality - * - * @param nodes the pattern element for matching - * @param nodes2 the tree element for matching - * @return if they are equal and false otherwise - */ - public boolean matchSequentially(NodeIterator nodes, NodeIterator nodes2) { - if (!nodes.hasNext()) { - return nodes.hasNext() == nodes2.hasNext(); - } - - myLastHandler = matchContext.getPattern().getHandler(nodes.current()); - return myLastHandler.matchSequentially( - nodes, - nodes2, - matchContext - ); - } - - public static boolean continueMatchingSequentially(final NodeIterator nodes, final NodeIterator nodes2, MatchContext matchContext) { - if (!nodes.hasNext()) { - return nodes.hasNext() == nodes2.hasNext(); - } - - return matchContext.getPattern().getHandler(nodes.current()).matchSequentially( - nodes, - nodes2, - matchContext - ); - } - - /** - * Descents the tree in depth finding matches - * - * @param elements the element for which the sons are looked for match - */ - public void matchContext(final NodeIterator elements) { - final CompiledPattern pattern = matchContext.getPattern(); - final NodeIterator patternNodes = pattern.getNodes().clone(); - final MatchResultImpl saveResult = matchContext.hasResult() ? matchContext.getResult() : null; - final List<PsiElement> saveMatchedNodes = matchContext.getMatchedNodes(); - - try { - matchContext.setResult(null); - matchContext.setMatchedNodes(null); - - if (!patternNodes.hasNext()) return; - final MatchingHandler firstMatchingHandler = pattern.getHandler(patternNodes.current()); - - for (; elements.hasNext(); elements.advance()) { - final PsiElement elementNode = elements.current(); - - boolean matched = firstMatchingHandler.matchSequentially(patternNodes, elements, matchContext); - - if (matched) { - MatchingHandler matchingHandler = matchContext.getPattern().getHandler(Configuration.CONTEXT_VAR_NAME); - if (matchingHandler != null) { - matched = ((SubstitutionHandler)matchingHandler).handle(elementNode, matchContext); - } - } - - final List<PsiElement> matchedNodes = matchContext.getMatchedNodes(); - - if (matched) { - dispatchMatched(matchedNodes, matchContext.getResult()); - } - - matchContext.setMatchedNodes(null); - matchContext.setResult(null); - - patternNodes.reset(); - if (matchedNodes != null && matchedNodes.size() > 0 && matched) { - elements.rewind(); - } - } - } - finally { - matchContext.setResult(saveResult); - matchContext.setMatchedNodes(saveMatchedNodes); - } - } - - private void dispatchMatched(final List<PsiElement> matchedNodes, MatchResultImpl result) { - if (!matchContext.getOptions().isResultIsContextMatch() && doDispatch(result, result)) return; - - // There is no substitutions so show the context - - processNoSubstitutionMatch(matchedNodes, result); - matchContext.getSink().newMatch(result); - } - - private boolean doDispatch(final MatchResultImpl result, MatchResultImpl context) { - boolean ret = false; - - for (MatchResult _r : result.getAllSons()) { - final MatchResultImpl r = (MatchResultImpl)_r; - - if ((r.isScopeMatch() && !r.isTarget()) || r.isMultipleMatch()) { - ret |= doDispatch(r, context); - } - else if (r.isTarget()) { - r.setContext(context); - matchContext.getSink().newMatch(r); - ret = true; - } - } - return ret; - } - - private static void processNoSubstitutionMatch(List<PsiElement> matchedNodes, MatchResultImpl result) { - boolean complexMatch = matchedNodes.size() > 1; - final PsiElement match = matchedNodes.get(0); - - if (!complexMatch) { - result.setMatchRef(new SmartPsiPointer(match)); - result.setMatchImage(match.getText()); - } - else { - MatchResultImpl sonresult; - - for (final PsiElement matchStatement : matchedNodes) { - result.getMatches().add( - sonresult = new MatchResultImpl( - MatchResult.LINE_MATCH, - matchStatement.getText(), - new SmartPsiPointer(matchStatement), - true - ) - ); - - sonresult.setParent(result); - } - - result.setMatchRef( - new SmartPsiPointer(match) - ); - result.setMatchImage( - match.getText() - ); - result.setName(MatchResult.MULTI_LINE_MATCH); - } - } - - public void setMatchContext(MatchContext matchContext) { - this.matchContext = matchContext; - } - - // Matches the sons of given elements to find equality - // @param el1 the pattern element for matching - // @param el2 the tree element for matching - // @return if they are equal and false otherwise - - @Override - protected boolean isLeftLooseMatching() { - return matchContext.getOptions().isLooseMatching(); - } - - @Override - protected boolean isRightLooseMatching() { - return false; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchConstraintsSink.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchConstraintsSink.java deleted file mode 100644 index 2036c83d56f4..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchConstraintsSink.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.MatchResultSink; -import com.intellij.structuralsearch.MatchingProcess; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.psi.PsiFile; -import com.intellij.openapi.progress.ProgressIndicator; - -import javax.swing.*; -import java.util.HashMap; - -/** - * Sink to detect - */ -class MatchConstraintsSink implements MatchResultSink { - private final MatchResultSink delegate; - private MatchingProcess process; - private final boolean distinct; - private final boolean caseSensitive; - private int matchCount; - private final int maxMatches; - private final HashMap<Object, MatchResult> matches = new HashMap<Object, MatchResult>(); - - MatchConstraintsSink(MatchResultSink _delegate, int _maxMatches,boolean distinct, boolean _caseSensitive) { - delegate = _delegate; - maxMatches = _maxMatches; - this.distinct = distinct; - caseSensitive = _caseSensitive; - } - - public void newMatch(MatchResult result) { - if (distinct) { - String matchImage = result.getMatchImage(); - - if (!caseSensitive) matchImage = matchImage.toLowerCase(); - - if (matches.get(matchImage)!=null) { - return; - } - - matches.put(matchImage,result); - } - else { - final PsiElement match = result.getMatch(); - if (matches.containsKey(match)) { - return; - } - matches.put(match, result); - } - - delegate.newMatch(result); - ++matchCount; - - if (matchCount==maxMatches) { - JOptionPane.showMessageDialog(null, SSRBundle.message("search.produced.too.many.results.message")); - process.stop(); - } - } - - /* Notifies sink about starting the matching for given element - * @param element the current file - * @param task process continuation reference - */ - public void processFile(PsiFile element) { - delegate.processFile(element); - } - - public void setMatchingProcess(MatchingProcess matchingProcess) { - process = matchingProcess; - delegate.setMatchingProcess(process); - } - - public void matchingFinished() { - matchCount = 0; - matches.clear(); - delegate.matchingFinished(); - } - - public ProgressIndicator getProgressIndicator() { - return delegate.getProgressIndicator(); - } - -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchContext.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchContext.java deleted file mode 100644 index c4c8d21e3ab3..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchContext.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.MatchResultSink; -import com.intellij.util.containers.Stack; - -import java.util.Collection; -import java.util.List; - -/** - * Global context of matching process - */ -public class MatchContext { - private MatchResultSink sink; - private final Stack<MatchResultImpl> previousResults = new Stack<MatchResultImpl>(); - private MatchResultImpl result; - private CompiledPattern pattern; - private MatchOptions options; - private GlobalMatchingVisitor matcher; - private boolean shouldRecursivelyMatch = true; - private boolean myWithAlternativePatternRoots = true; - - private List<PsiElement> myMatchedNodes; - - public List<PsiElement> getMatchedNodes() { - return myMatchedNodes; - } - - public void setMatchedNodes(final List<PsiElement> matchedNodes) { - myMatchedNodes = matchedNodes; - } - - public boolean isWithAlternativePatternRoots() { - return myWithAlternativePatternRoots; - } - - public void setWithAlternativePatternRoots(boolean withAlternativePatternRoots) { - myWithAlternativePatternRoots = withAlternativePatternRoots; - } - - public interface MatchedElementsListener { - void matchedElements(Collection<PsiElement> matchedElements); - void commitUnmatched(); - } - - private MatchedElementsListener myMatchedElementsListener; - - public void setMatcher(GlobalMatchingVisitor matcher) { - this.matcher = matcher; - } - - public GlobalMatchingVisitor getMatcher() { - return matcher; - } - - public MatchOptions getOptions() { - return options; - } - - public void setOptions(MatchOptions options) { - this.options = options; - } - - public MatchResultImpl getPreviousResult() { - return previousResults.isEmpty() ? null : previousResults.peek(); - } - - public MatchResultImpl getResult() { - if (result==null) result = new MatchResultImpl(); - return result; - } - - public void pushResult() { - previousResults.push(result); - result = null; - } - - public void popResult() { - result = previousResults.pop(); - } - - public void setResult(MatchResultImpl result) { - this.result = result; - if (result == null) { - pattern.clearHandlersState(); - } - } - - public boolean hasResult() { - return result!=null; - } - - public CompiledPattern getPattern() { - return pattern; - } - - public void setPattern(CompiledPattern pattern) { - this.pattern = pattern; - } - - public MatchResultSink getSink() { - return sink; - } - - public void setSink(MatchResultSink sink) { - this.sink = sink; - } - - void clear() { - result = null; - pattern = null; - } - - public boolean shouldRecursivelyMatch() { - return shouldRecursivelyMatch; - } - - public void setShouldRecursivelyMatch(boolean shouldRecursivelyMatch) { - this.shouldRecursivelyMatch = shouldRecursivelyMatch; - } - - public void setMatchedElementsListener(MatchedElementsListener _matchedElementsListener) { - myMatchedElementsListener = _matchedElementsListener; - } - - public MatchedElementsListener getMatchedElementsListener() { - return myMatchedElementsListener; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchPredicateProvider.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchPredicateProvider.java deleted file mode 100644 index b75ffb5d0f5d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchPredicateProvider.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.openapi.extensions.ExtensionPointName; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.MatchVariableConstraint; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; - -import java.util.Set; - -public abstract class MatchPredicateProvider { - public static final ExtensionPointName<MatchPredicateProvider> EP_NAME = ExtensionPointName.create("com.intellij.structuralsearch.matchPredicateProvider"); - public abstract void collectPredicates(MatchVariableConstraint constraint, - String name, - MatchOptions options, - Set<MatchPredicate> predicates); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchResultImpl.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchResultImpl.java deleted file mode 100644 index 8761472d813a..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchResultImpl.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.plugin.util.SmartPsiPointer; -import org.jetbrains.annotations.NonNls; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Class describing the match result - */ -public final class MatchResultImpl extends MatchResult { - private String name; - private SmartPsiPointer matchRef; - private int start; - private int end = -1; - private String matchImage; - private List<MatchResult> matches; - private MatchResult parent; - private boolean target; - - @NonNls public static final String DEFAULT_NAME2 = "end of context match"; - @NonNls public static final String DEFAULT_NAME = "start of context match"; - private boolean myScopeMatch; - private boolean myMultipleMatch; - @NonNls private static final String NULL = "null"; - private MatchResultImpl myContext; - - MatchResultImpl() { - } - - public MatchResultImpl(String name, String image, SmartPsiPointer ref, boolean target) { - this(name,image,ref,0,-1,target); - } - - public MatchResultImpl(String name, String image, SmartPsiPointer ref, int start, int end,boolean target) { - matchRef = ref; - this.name = name; - matchImage = image; - this.target = target; - this.start = start; - this.end = end; - } - - public String getMatchImage() { - if (matchImage==null) { - matchImage = NULL; - } - return matchImage; - } - - public void setParent(MatchResult parent) { - this.parent = parent; - } - - public SmartPsiPointer getMatchRef() { - return matchRef; - } - - public PsiElement getMatch() { - return matchRef.getElement(); - } - - public void setMatchRef(SmartPsiPointer matchStart) { - matchRef = matchStart; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List<MatchResult> getMatches() { - if (matches==null) matches = new ArrayList<MatchResult>(); - return matches; - } - - public List<MatchResult> getAllSons() { - return getMatches(); - } - - public boolean hasSons() { - return matches!=null; - } - - public boolean isScopeMatch() { - return myScopeMatch; - } - - public boolean isMultipleMatch() { - return myMultipleMatch; - } - - public void clear() { - if (matchRef != null) { - matchRef.clear(); - matchRef = null; - } - - if (matches != null) { - for (final MatchResult match : matches) { - ((MatchResultImpl)match).clear(); - } - matches = null; - } - - name = null; - matchImage = null; - } - - public void clearMatches() { - matches = null; - } - - public void setScopeMatch(final boolean scopeMatch) { - myScopeMatch = scopeMatch; - } - - public void setMultipleMatch(final boolean multipleMatch) { - myMultipleMatch = multipleMatch; - } - - public MatchResultImpl findSon(String name) { - if (matches!=null) { - // @todo this could be performance bottleneck, replace with hash lookup! - for (final MatchResult match : matches) { - final MatchResultImpl res = (MatchResultImpl)match; - - if (name.equals(res.getName())) { - return res; - } - } - } - return null; - } - - public MatchResultImpl removeSon(String typedVar) { - if (matches == null) return null; - - // @todo this could be performance bottleneck, replace with hash lookup! - for(Iterator<MatchResult> i=matches.iterator();i.hasNext();) { - final MatchResultImpl res = (MatchResultImpl)i.next(); - if (typedVar.equals(res.getName())) { - i.remove(); - return res; - } - } - - return null; - } - - public void addSon(MatchResultImpl result) { - getMatches().add(result); - } - - public void setMatchImage(String matchImage) { - this.matchImage = matchImage; - } - - public boolean isTarget() { - return target; - } - - public void setTarget(boolean target) { - this.target = target; - } - - public boolean isMatchImageNull() { - return matchImage==null; - } - - public int getStart() { - return start; - } - - public void setStart(int start) { - this.start = start; - } - - public int getEnd() { - return end; - } - - public void setEnd(int end) { - this.end = end; - } - - public void setContext(final MatchResultImpl context) { - myContext = context; - } - - public MatchResultImpl getContext() { - return myContext; - } - - @Override - public String toString() { - return "MatchResultImpl{name='" + name + '\'' + ", matchImage='" + matchImage + '\'' + "}"; - } -} - diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchUtils.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchUtils.java deleted file mode 100644 index 38c31d16524f..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatchUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.psi.*; -import org.jetbrains.annotations.NonNls; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 24.12.2003 - * Time: 22:10:20 - * To change this template use Options | File Templates. - */ -public class MatchUtils { - public static final String SPECIAL_CHARS = "*(){}[]^$\\.-|"; - - public static final boolean compareWithNoDifferenceToPackage(final String typeImage,@NonNls final String typeImage2) { - if (typeImage == null || typeImage2 == null) return typeImage == typeImage2; - return typeImage2.endsWith(typeImage) && ( - typeImage.length() == typeImage2.length() || - typeImage2.charAt(typeImage2.length()-typeImage.length()-1)=='.' // package separator - ); - } - - public static PsiElement getReferencedElement(final PsiElement element) { - if (element instanceof PsiReference) { - return ((PsiReference)element).resolve(); - } - - /*if (element instanceof PsiTypeElement) { - PsiType type = ((PsiTypeElement)element).getType(); - - if (type instanceof PsiArrayType) { - type = ((PsiArrayType)type).getComponentType(); - } - if (type instanceof PsiClassType) { - return ((PsiClassType)type).resolve(); - } - return null; - }*/ - return element; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java deleted file mode 100644 index d667b068ee48..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImpl.java +++ /dev/null @@ -1,737 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.lang.Language; -import com.intellij.lang.StdLanguages; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypes; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.progress.ProcessCanceledException; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ContentIterator; -import com.intellij.openapi.roots.ProjectFileIndex; -import com.intellij.openapi.util.Computable; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.*; -import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil; -import com.intellij.psi.search.DelegatingGlobalSearchScope; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.psi.search.SearchScope; -import com.intellij.structuralsearch.*; -import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.TopLevelMatchingHandler; -import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator; -import com.intellij.structuralsearch.impl.matcher.strategies.MatchingStrategy; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.util.CollectingMatchResultSink; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.PairProcessor; -import com.intellij.util.SmartList; -import com.intellij.util.indexing.FileBasedIndex; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.lang.ref.SoftReference; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * This class makes program structure tree matching: - */ -public class MatcherImpl { - private static final Logger LOG = Logger.getInstance("#com.intellij.structuralsearch.impl.matcher.MatcherImpl"); - // project being worked on - private final Project project; - - // context of matching - private final MatchContext matchContext; - private boolean isTesting; - - // visitor to delegate the real work - private final GlobalMatchingVisitor visitor = new GlobalMatchingVisitor(); - private ProgressIndicator progress; - private final TaskScheduler scheduler = new TaskScheduler(); - - private int totalFilesToScan; - private int scannedFilesCount; - - public MatcherImpl(final Project project, final MatchOptions matchOptions) { - this.project = project; - matchContext = new MatchContext(); - matchContext.setMatcher(visitor); - - if (matchOptions != null) { - matchContext.setOptions(matchOptions); - cacheCompiledPattern(matchOptions, PatternCompiler.compilePattern(project,matchOptions)); - } - } - - static class LastMatchData { - CompiledPattern lastPattern; - MatchOptions lastOptions; - } - - private static SoftReference<LastMatchData> lastMatchData; - - protected MatcherImpl(Project project) { - this(project, null); - } - - public static void validate(Project project, MatchOptions options) { - PsiDocumentManager.getInstance(project).commitAllDocuments(); - - synchronized(MatcherImpl.class) { - final LastMatchData data = new LastMatchData(); - data.lastPattern = PatternCompiler.compilePattern(project, options); - data.lastOptions = options; - lastMatchData = new SoftReference<LastMatchData>(data); - } - - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(options.getFileType()); - profile.checkSearchPattern(project, options); - } - - public static class CompiledOptions { - public final List<Pair<MatchContext, Configuration>> matchContexts; - - public CompiledOptions(final List<Pair<MatchContext, Configuration>> matchContexts) { - this.matchContexts = matchContexts; - } - - public List<Pair<MatchContext, Configuration>> getMatchContexts() { - return matchContexts; - } - } - - public static boolean checkIfShouldAttemptToMatch(MatchContext context, NodeIterator matchedNodes) { - final CompiledPattern pattern = context.getPattern(); - final NodeIterator patternNodes = pattern.getNodes(); - try { - while (true) { - final PsiElement patternNode = patternNodes.current(); - if (patternNode == null) { - return true; - } - final PsiElement matchedNode = matchedNodes.current(); - if (matchedNode == null) { - return false; - } - final MatchingHandler matchingHandler = pattern.getHandler(patternNode); - if (matchingHandler == null || !matchingHandler.canMatch(patternNode, matchedNode)) { - return false; - } - matchedNodes.advance(); - patternNodes.advance(); - } - } finally { - patternNodes.reset(); - matchedNodes.reset(); - } - } - - public void processMatchesInElement(MatchContext context, Configuration configuration, - NodeIterator matchedNodes, - PairProcessor<MatchResult, Configuration> processor) { - try { - configureOptions(context, configuration, matchedNodes.current(), processor); - context.setShouldRecursivelyMatch(false); - visitor.matchContext(matchedNodes); - } finally { - matchedNodes.reset(); - } - } - - public void clearContext() { - matchContext.clear(); - } - - private void configureOptions(MatchContext context, - final Configuration configuration, - PsiElement psiFile, - final PairProcessor<MatchResult, Configuration> processor) { - if (psiFile == null) return; - LocalSearchScope scope = new LocalSearchScope(psiFile); - - matchContext.clear(); - matchContext.setMatcher(visitor); - - MatchOptions options = context.getOptions(); - matchContext.setOptions(options); - matchContext.setPattern(context.getPattern()); - matchContext.setShouldRecursivelyMatch(context.shouldRecursivelyMatch()); - visitor.setMatchContext(matchContext); - - matchContext.setSink( - new MatchConstraintsSink( - new MatchResultSink() { - public void newMatch(MatchResult result) { - processor.process(result, configuration); - } - - public void processFile(PsiFile element) { - } - - public void setMatchingProcess(MatchingProcess matchingProcess) { - } - - public void matchingFinished() { - } - - public ProgressIndicator getProgressIndicator() { - return null; - } - }, - options.getMaxMatchesCount(), - options.isDistinct(), - options.isCaseSensitiveMatch() - ) - ); - options.setScope(scope); - } - - public CompiledOptions precompileOptions(List<Configuration> configurations) { - List<Pair<MatchContext, Configuration>> contexts = new ArrayList<Pair<MatchContext, Configuration>>(); - - for (Configuration configuration : configurations) { - MatchContext matchContext = new MatchContext(); - matchContext.setMatcher(visitor); - MatchOptions matchOptions = configuration.getMatchOptions(); - matchContext.setOptions(matchOptions); - - try { - CompiledPattern compiledPattern = PatternCompiler.compilePattern(project, matchOptions); - matchContext.setPattern(compiledPattern); - contexts.add(Pair.create(matchContext, configuration)); - } - catch (UnsupportedPatternException ignored) {} - catch (MalformedPatternException ignored) {} - } - return new CompiledOptions(contexts); - } - - Project getProject() { - return project; - } - - /** - * Finds the matches of given pattern starting from given tree element. - * @throws MalformedPatternException - * @throws UnsupportedPatternException - */ - protected void findMatches(MatchResultSink sink, final MatchOptions options) throws MalformedPatternException, UnsupportedPatternException - { - CompiledPattern compiledPattern = prepareMatching(sink, options); - if (compiledPattern== null) { - return; - } - - matchContext.getSink().setMatchingProcess( scheduler ); - scheduler.init(); - progress = matchContext.getSink().getProgressIndicator(); - - if (/*TokenBasedSearcher.canProcess(compiledPattern)*/ false) { - //TokenBasedSearcher searcher = new TokenBasedSearcher(this); - //searcher.search(compiledPattern); - if (isTesting) { - matchContext.getSink().matchingFinished(); - return; - } - } - else { - if (isTesting) { - // testing mode; - final PsiElement[] elements = ((LocalSearchScope)options.getScope()).getScope(); - - PsiElement parent = elements[0].getParent(); - if (elements.length > 0 && matchContext.getPattern().getStrategy().continueMatching(parent != null ? parent : elements[0])) { - visitor.matchContext(new SsrFilteringNodeIterator(new ArrayBackedNodeIterator(elements))); - } - else { - for (PsiElement element : elements) { - match(element); - } - } - - matchContext.getSink().matchingFinished(); - return; - } - if (!findMatches(options, compiledPattern)) { - return; - } - } - - if (scheduler.getTaskQueueEndAction()==null) { - scheduler.setTaskQueueEndAction( - new Runnable() { - public void run() { - matchContext.getSink().matchingFinished(); - } - } - ); - } - - scheduler.executeNext(); - } - - private boolean findMatches(MatchOptions options, CompiledPattern compiledPattern) { - LanguageFileType languageFileType = (LanguageFileType)options.getFileType(); - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(languageFileType.getLanguage()); - assert profile != null; - PsiElement node = compiledPattern.getNodes().current(); - final Language ourPatternLanguage = node != null ? profile.getLanguage(node) : ((LanguageFileType)options.getFileType()).getLanguage(); - final Language ourPatternLanguage2 = ourPatternLanguage == StdLanguages.XML ? StdLanguages.XHTML:null; - SearchScope searchScope = compiledPattern.getScope(); - boolean ourOptimizedScope = searchScope != null; - if (!ourOptimizedScope) searchScope = options.getScope(); - - if (searchScope instanceof GlobalSearchScope) { - final GlobalSearchScope scope = (GlobalSearchScope)searchScope; - - final ContentIterator ci = new ContentIterator() { - public boolean processFile(final VirtualFile fileOrDir) { - if (!fileOrDir.isDirectory() && scope.contains(fileOrDir) && fileOrDir.getFileType() != FileTypes.UNKNOWN) { - ++totalFilesToScan; - scheduler.addOneTask(new MatchOneVirtualFile(fileOrDir, profile, ourPatternLanguage, ourPatternLanguage2)); - } - return true; - } - }; - - ApplicationManager.getApplication().runReadAction(new Runnable() { - @Override - public void run() { - FileBasedIndex.getInstance().iterateIndexableFiles(ci, project, progress); - } - }); - progress.setText2(""); - } - else { - final PsiElement[] elementsToScan = ((LocalSearchScope)searchScope).getScope(); - totalFilesToScan = elementsToScan.length; - - for (int i = 0; i < elementsToScan.length; ++i) { - final PsiElement psiElement = elementsToScan[i]; - - if (psiElement == null) continue; - final Language language = psiElement.getLanguage(); - - PsiFile file = psiElement instanceof PsiFile ? (PsiFile)psiElement : psiElement.getContainingFile(); - - if (profile.isMyFile(file, language, ourPatternLanguage, ourPatternLanguage2)) { - scheduler.addOneTask(new MatchOnePsiFile(psiElement)); - } - if (ourOptimizedScope) elementsToScan[i] = null; // to prevent long PsiElement reference - } - } - return true; - } - - private CompiledPattern prepareMatching(final MatchResultSink sink, final MatchOptions options) { - CompiledPattern savedPattern = null; - - if (matchContext.getOptions() == options && matchContext.getPattern() != null && - matchContext.getOptions().hashCode() == matchContext.getPattern().getOptionsHashStamp()) { - savedPattern = matchContext.getPattern(); - } - - matchContext.clear(); - matchContext.setSink( - new MatchConstraintsSink( - sink, - options.getMaxMatchesCount(), - options.isDistinct(), - options.isCaseSensitiveMatch() - ) - ); - matchContext.setOptions(options); - matchContext.setMatcher(visitor); - visitor.setMatchContext(matchContext); - - CompiledPattern compiledPattern = savedPattern; - - if (compiledPattern == null) { - - synchronized(getClass()) { - final LastMatchData data = com.intellij.reference.SoftReference.dereference(lastMatchData); - if (data != null && options == data.lastOptions) { - compiledPattern = data.lastPattern; - } - lastMatchData = null; - } - - if (compiledPattern==null) { - compiledPattern = ApplicationManager.getApplication().runReadAction(new Computable<CompiledPattern>() { - @Override - public CompiledPattern compute() { - return PatternCompiler.compilePattern(project,options); - } - }); - } - } - - cacheCompiledPattern(options, compiledPattern); - return compiledPattern; - } - - private void cacheCompiledPattern(final MatchOptions options, final CompiledPattern compiledPattern) { - matchContext.setPattern(compiledPattern); - compiledPattern.setOptionsHashStamp(options.hashCode()); - } - - /** - * Finds the matches of given pattern starting from given tree element. - * @param sink match result destination - * @throws MalformedPatternException - * @throws UnsupportedPatternException - */ - protected void testFindMatches(MatchResultSink sink, MatchOptions options) - throws MalformedPatternException, UnsupportedPatternException { - isTesting = true; - try { - findMatches(sink,options); - } finally { - isTesting = false; - } - } - - /** - * Finds the matches of given pattern starting from given tree element. - * @param source string for search - * @param pattern to be searched - * @return list of matches found - * @throws MalformedPatternException - * @throws UnsupportedPatternException - */ - protected List<MatchResult> testFindMatches(String source, - String pattern, - MatchOptions options, - boolean filePattern, - FileType sourceFileType, - String sourceExtension, - boolean physicalSourceFile) - throws MalformedPatternException, UnsupportedPatternException { - - CollectingMatchResultSink sink = new CollectingMatchResultSink(); - - try { - PsiElement[] elements = MatcherImplUtil.createSourceTreeFromText(source, - filePattern ? PatternTreeContext.File : PatternTreeContext.Block, - sourceFileType, - sourceExtension, - project, physicalSourceFile); - - options.setSearchPattern(pattern); - options.setScope(new LocalSearchScope(elements)); - testFindMatches(sink, options); - } - catch (IncorrectOperationException e) { - MalformedPatternException exception = new MalformedPatternException(); - exception.initCause(e); - throw exception; - } - - return sink.getMatches(); - } - - protected List<MatchResult> testFindMatches(String source, String pattern, MatchOptions options, boolean filePattern) { - return testFindMatches(source, pattern, options, filePattern, options.getFileType(), null, false); - } - - class TaskScheduler implements MatchingProcess { - private LinkedList<Runnable> tasks = new LinkedList<Runnable>(); - private boolean ended; - private Runnable taskQueueEndAction; - - private boolean suspended; - - public void stop() { - ended = true; - } - - public void pause() { - suspended = true; - } - - public void resume() { - if (!suspended) return; - suspended = false; - executeNext(); - } - - public boolean isSuspended() { - return suspended; - } - - public boolean isEnded() { - return ended; - } - - void setTaskQueueEndAction(Runnable taskQueueEndAction) { - this.taskQueueEndAction = taskQueueEndAction; - } - Runnable getTaskQueueEndAction () { - return taskQueueEndAction; - } - - void addOneTask(Runnable runnable) { - tasks.add(runnable); - } - - private void executeNext() { - while(!suspended && !ended) { - if (tasks.isEmpty()) { - ended = true; - break; - } - - final Runnable task = tasks.removeFirst(); - try { - task.run(); - } - catch (ProcessCanceledException e) { - ended = true; - clearSchedule(); - throw e; - } - catch (StructuralSearchException e) { - ended = true; - clearSchedule(); - throw e; - } - catch (Throwable th) { - LOG.error(th); - } - } - - if (ended) clearSchedule(); - } - - private void init() { - ended = false; - suspended = false; - PsiManager.getInstance(project).startBatchFilesProcessingMode(); - } - - private void clearSchedule() { - if (tasks != null) { - taskQueueEndAction.run(); - if (!project.isDisposed()) { - PsiManager.getInstance(project).finishBatchFilesProcessingMode(); - } - tasks = null; - } - } - - } - - private class MatchOnePsiFile extends MatchOneFile { - private PsiElement file; - - MatchOnePsiFile(PsiElement file) { - this.file = file; - } - - @Nullable - @Override - protected List<PsiElement> getPsiElementsToProcess() { - PsiElement file = this.file; - this.file = null; - return new SmartList<PsiElement>(file); - } - } - - private abstract class MatchOneFile implements Runnable { - public void run() { - List<PsiElement> files = getPsiElementsToProcess(); - - if (progress!=null) { - progress.setFraction((double)scannedFilesCount/totalFilesToScan); - } - - ++scannedFilesCount; - - if (files == null || files.size() == 0) return; - final PsiFile psiFile = files.get(0).getContainingFile(); - - if (psiFile!=null) { - final Runnable action = new Runnable() { - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - if (project.isDisposed()) return; - final PsiDocumentManager manager = PsiDocumentManager.getInstance(project); - Document document = manager.getDocument(psiFile); - if (document != null) manager.commitDocument(document); - } - }); - } - }; - - if (ApplicationManager.getApplication().isDispatchThread()) { - action.run(); - } else { - ApplicationManager.getApplication().invokeAndWait( - action, - ModalityState.defaultModalityState() - ); - } - } - - if (project.isDisposed()) return; - - for(PsiElement file:files) { - if (file instanceof PsiFile) { - matchContext.getSink().processFile((PsiFile)file); - } - - final PsiElement finalFile = file; - ApplicationManager.getApplication().runReadAction( - new Runnable() { - public void run() { - PsiElement file = finalFile; - if (!file.isValid()) return; - file = StructuralSearchUtil.getProfileByLanguage(file.getLanguage()).extendMatchOnePsiFile(file); - match(file); - } - } - ); - } - } - - protected abstract @Nullable List<PsiElement> getPsiElementsToProcess(); - } - - // Initiates the matching process for given element - // @param element the current search tree element - public void match(PsiElement element) { - MatchingStrategy strategy = matchContext.getPattern().getStrategy(); - - if (strategy.continueMatching(element)) { - visitor.matchContext(new ArrayBackedNodeIterator(new PsiElement[] {element})); - return; - } - for(PsiElement el=element.getFirstChild();el!=null;el=el.getNextSibling()) { - match(el); - } - if (element instanceof PsiLanguageInjectionHost) { - InjectedLanguageUtil.enumerate(element, new PsiLanguageInjectionHost.InjectedPsiVisitor() { - @Override - public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) { - match(injectedPsi); - } - }); - } - } - - @Nullable - protected MatchResult isMatchedByDownUp(PsiElement element, final MatchOptions options) { - final CollectingMatchResultSink sink = new CollectingMatchResultSink(); - CompiledPattern compiledPattern = prepareMatching(sink, options); - - if (compiledPattern== null) { - assert false; - return null; - } - - PsiElement targetNode = compiledPattern.getTargetNode(); - PsiElement elementToStartMatching = null; - - if (targetNode == null) { - targetNode = compiledPattern.getNodes().current(); - if (targetNode != null) { - compiledPattern.getNodes().advance(); - assert !compiledPattern.getNodes().hasNext(); - compiledPattern.getNodes().rewind(); - - while (element.getClass() != targetNode.getClass()) { - element = element.getParent(); - if (element == null) return null; - } - - elementToStartMatching = element; - } - } else { - targetNode = StructuralSearchUtil.getProfileByPsiElement(element).extendMatchedByDownUp(targetNode); - - MatchingHandler handler = null; - - while (element.getClass() == targetNode.getClass() || - compiledPattern.isTypedVar(targetNode) && compiledPattern.getHandler(targetNode).canMatch(targetNode, element) - ) { - handler = compiledPattern.getHandler(targetNode); - handler.setPinnedElement(element); - elementToStartMatching = element; - if (handler instanceof TopLevelMatchingHandler) break; - element = element.getParent(); - targetNode = targetNode.getParent(); - - if (options.isLooseMatching()) { - element = StructuralSearchUtil.getProfileByPsiElement(element).updateCurrentNode(element); - targetNode = StructuralSearchUtil.getProfileByPsiElement(element).updateCurrentNode(targetNode); - } - } - - if (!(handler instanceof TopLevelMatchingHandler)) return null; - } - - assert targetNode != null : "Could not match down up when no target node"; - - match(elementToStartMatching); - matchContext.getSink().matchingFinished(); - final int matchCount = sink.getMatches().size(); - assert matchCount <= 1; - return matchCount > 0 ? sink.getMatches().get(0) : null; - } - - private class MatchOneVirtualFile extends MatchOneFile { - private final VirtualFile myFileOrDir; - private final StructuralSearchProfile myProfile; - private final Language myOurPatternLanguage; - private final Language myOurPatternLanguage2; - - public MatchOneVirtualFile(VirtualFile fileOrDir, - StructuralSearchProfile profile, - Language ourPatternLanguage, - Language ourPatternLanguage2) { - myFileOrDir = fileOrDir; - myProfile = profile; - myOurPatternLanguage = ourPatternLanguage; - myOurPatternLanguage2 = ourPatternLanguage2; - } - - @Nullable - @Override - protected List<PsiElement> getPsiElementsToProcess() { - return ApplicationManager.getApplication().runReadAction(new Computable<List<PsiElement>>() { - @Override - public List<PsiElement> compute() { - PsiFile file = PsiManager.getInstance(project).findFile(myFileOrDir); - if (file == null) { - return null; - } - - final FileViewProvider viewProvider = file.getViewProvider(); - List<PsiElement> elementsToProcess = new SmartList<PsiElement>(); - - for(Language lang: viewProvider.getLanguages()) { - if (myProfile.isMyFile(file, lang, myOurPatternLanguage, myOurPatternLanguage2)) { - elementsToProcess.add(viewProvider.getPsi(lang)); - } - } - - return elementsToProcess; - } - }); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImplUtil.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImplUtil.java deleted file mode 100644 index ffc9ae78e876..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/MatcherImplUtil.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler; -import com.intellij.util.IncorrectOperationException; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 19, 2004 - * Time: 6:56:25 PM - * To change this template use File | Settings | File Templates. - */ -public class MatcherImplUtil { - - public static void transform(MatchOptions options) { - if (options.hasVariableConstraints()) return; - PatternCompiler.transformOldPattern(options); - } - - public static PsiElement[] createTreeFromText(String text, PatternTreeContext context, FileType fileType, Project project) - throws IncorrectOperationException { - return createTreeFromText(text, context, fileType, null, null, project, false); - } - - public static PsiElement[] createSourceTreeFromText(String text, - PatternTreeContext context, - FileType fileType, - String extension, - Project project, - boolean physical) { - if (fileType instanceof LanguageFileType) { - Language language = ((LanguageFileType)fileType).getLanguage(); - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language); - if (profile != null) { - return profile.createPatternTree(text, context, fileType, null, null, extension, project, physical); - } - } - return PsiElement.EMPTY_ARRAY; - } - - public static PsiElement[] createTreeFromText(String text, - PatternTreeContext context, - FileType fileType, - Language language, - String contextName, - Project project, - boolean physical) throws IncorrectOperationException { - if (language == null && fileType instanceof LanguageFileType) { - language = ((LanguageFileType)fileType).getLanguage(); - } - if (language != null) { - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language); - if (profile != null) { - return profile.createPatternTree(text, context, fileType, language, contextName, null, project, physical); - } - } - return PsiElement.EMPTY_ARRAY; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/PatternTreeContext.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/PatternTreeContext.java deleted file mode 100644 index 7d93c9ae82e0..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/PatternTreeContext.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -/** -* @author Eugene.Kudelevsky -*/ -public enum PatternTreeContext { - File, Block, Class -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/XmlCompiledPattern.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/XmlCompiledPattern.java deleted file mode 100644 index 0c9f4945e3a5..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/XmlCompiledPattern.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.structuralsearch.impl.matcher.strategies.XmlMatchingStrategy; - -/** -* @author Eugene.Kudelevsky -*/ -public class XmlCompiledPattern extends CompiledPattern { - private static final String XML_TYPED_VAR_PREFIX = "__"; - - public XmlCompiledPattern() { - setStrategy(XmlMatchingStrategy.getInstance()); - } - - public String[] getTypedVarPrefixes() { - return new String[] {XML_TYPED_VAR_PREFIX}; - } - - public boolean isTypedVar(final String str) { - return str.startsWith(XML_TYPED_VAR_PREFIX); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/XmlMatchingVisitor.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/XmlMatchingVisitor.java deleted file mode 100644 index d2e1e210534b..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/XmlMatchingVisitor.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiWhiteSpace; -import com.intellij.psi.XmlElementVisitor; -import com.intellij.psi.util.PsiUtilCore; -import com.intellij.psi.xml.*; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler; -import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator; - -import java.util.ArrayList; -import java.util.List; - -/** -* @author Eugene.Kudelevsky -*/ -public class XmlMatchingVisitor extends XmlElementVisitor { - private final GlobalMatchingVisitor myMatchingVisitor; - private final boolean myCaseSensitive; - - public XmlMatchingVisitor(GlobalMatchingVisitor matchingVisitor) { - myMatchingVisitor = matchingVisitor; - myCaseSensitive = myMatchingVisitor.getMatchContext().getOptions().isCaseSensitiveMatch(); - } - - @Override - public void visitElement(final PsiElement element) { - myMatchingVisitor.setResult(element.textMatches(element)); - } - - @Override public void visitXmlAttribute(XmlAttribute attribute) { - final XmlAttribute another = (XmlAttribute)myMatchingVisitor.getElement(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(attribute.getName()); - - myMatchingVisitor.setResult(matches(attribute.getName(), another.getName()) || isTypedVar); - if (myMatchingVisitor.getResult()) { - myMatchingVisitor.setResult(myMatchingVisitor.match(attribute.getValueElement(), another.getValueElement())); - } - - if (myMatchingVisitor.getResult() && isTypedVar) { - MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(attribute.getName()); - myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(another, myMatchingVisitor.getMatchContext())); - } - } - - @Override public void visitXmlAttributeValue(XmlAttributeValue value) { - final XmlAttributeValue another = (XmlAttributeValue)myMatchingVisitor.getElement(); - final String text = value.getValue(); - - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(text); - MatchingHandler handler; - - if (isTypedVar && (handler = myMatchingVisitor.getMatchContext().getPattern().getHandler( text )) instanceof SubstitutionHandler) { - String text2 = another.getText(); - int offset = text2.length() > 0 && ( text2.charAt(0) == '"' || text2.charAt(0) == '\'') ? 1:0; - myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(another, offset, text2.length() - offset, - myMatchingVisitor.getMatchContext())); - } else { - myMatchingVisitor.setResult(matches(text, another.getValue())); - } - } - - @Override public void visitXmlTag(XmlTag tag) { - final XmlTag another = (XmlTag)myMatchingVisitor.getElement(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(tag.getName()); - - myMatchingVisitor.setResult((matches(tag.getName(), another.getName()) || isTypedVar) && - myMatchingVisitor.matchInAnyOrder(tag.getAttributes(), another.getAttributes())); - - if(myMatchingVisitor.getResult()) { - final XmlTagChild[] contentChildren = tag.getValue().getChildren(); - - if (contentChildren.length > 0) { - PsiElement[] patternNodes = contentChildren; - PsiElement[] matchedNodes = another.getValue().getChildren(); - - if (contentChildren.length != 1) { - patternNodes = expandXmlTexts(patternNodes); - matchedNodes = expandXmlTexts(matchedNodes); - } - - myMatchingVisitor.setResult(myMatchingVisitor.matchSequentially( - new ArrayBackedNodeIterator(patternNodes), - new ArrayBackedNodeIterator(matchedNodes) - )); - } - } - - if (myMatchingVisitor.getResult() && isTypedVar) { - MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler( tag.getName() ); - myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(another, myMatchingVisitor.getMatchContext())); - } - } - - private static PsiElement[] expandXmlTexts(PsiElement[] children) { - List<PsiElement> result = new ArrayList<PsiElement>(children.length); - for(PsiElement c:children) { - if (c instanceof XmlText) { - for(PsiElement p:c.getChildren()) { - if (!(p instanceof PsiWhiteSpace)) result.add(p); - } - } else if (!(c instanceof PsiWhiteSpace)) { - result.add(c); - } - } - return PsiUtilCore.toPsiElementArray(result); - } - - @Override public void visitXmlText(XmlText text) { - myMatchingVisitor.setResult(myMatchingVisitor.matchSequentially(text.getFirstChild(), myMatchingVisitor.getElement().getFirstChild())); - } - - @Override public void visitXmlToken(XmlToken token) { - if (token.getTokenType() == XmlTokenType.XML_DATA_CHARACTERS) { - String text = token.getText(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(text); - - if (isTypedVar) { - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(token, myMatchingVisitor.getElement())); - } else { - myMatchingVisitor.setResult(matches(text, myMatchingVisitor.getElement().getText())); - } - } - } - - private boolean matches(String a, String b) { - return myCaseSensitive ? a.equals(b) : a.equalsIgnoreCase(b); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java deleted file mode 100644 index 09758a5e2191..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/CompileContext.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.Project; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.impl.matcher.CompiledPattern; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 17.11.2004 - * Time: 19:26:37 - * To change this template use File | Settings | File Templates. - */ -public class CompileContext { - private OptimizingSearchHelper searchHelper; - - private CompiledPattern pattern; - private MatchOptions options; - private Project project; - - public void clear() { - if (searchHelper!=null) searchHelper.clear(); - - project = null; - pattern = null; - options = null; - } - - public void init(final CompiledPattern _result, final MatchOptions _options, final Project _project, final boolean _findMatchingFiles) { - options = _options; - project = _project; - pattern = _result; - - searchHelper = ApplicationManager.getApplication().isUnitTestMode() ? - new TestModeOptimizingSearchHelper(this) : - new FindInFilesOptimizingSearchHelper(this, _findMatchingFiles, _project); - } - - public OptimizingSearchHelper getSearchHelper() { - return searchHelper; - } - - void setSearchHelper(OptimizingSearchHelper searchHelper) { - this.searchHelper = searchHelper; - } - - public CompiledPattern getPattern() { - return pattern; - } - - void setPattern(CompiledPattern pattern) { - this.pattern = pattern; - } - - MatchOptions getOptions() { - return options; - } - - void setOptions(MatchOptions options) { - this.options = options; - } - - Project getProject() { - return project; - } - - void setProject(Project project) { - this.project = project; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/DeleteNodesAction.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/DeleteNodesAction.java deleted file mode 100644 index 4b5ad7c64545..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/DeleteNodesAction.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.psi.PsiElement; - -import java.util.ArrayList; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 17.11.2004 - * Time: 19:24:40 - * To change this template use File | Settings | File Templates. - */ -class DeleteNodesAction implements Runnable { - private final ArrayList elements; - - DeleteNodesAction(ArrayList _elements) { - elements = _elements; - } - - private void delete(PsiElement first, PsiElement last) throws Exception { - if (last==first) { - first.delete(); - } else { - first.getParent().deleteChildRange(first,last); - } - } - public void run() { - try { - PsiElement first= null; - PsiElement last = null; - - for(int i = 0;i < elements.size(); ++i) { - final PsiElement el = (PsiElement)elements.get(i); - - if (!el.isValid()) continue; - - if (first==null) { - first = last = el; - } else if (last.getNextSibling()==el) { - last = el; - } else { - delete(first,last); - first = last = null; - --i; - continue; - } - } - - if (first!=null) { - delete(first,last); - } - } catch(Throwable ex) { - ex.printStackTrace(); - } finally { - elements.clear(); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java deleted file mode 100644 index ff7f06a36d5b..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/FindInFilesOptimizingSearchHelper.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.lang.Language; -import com.intellij.lang.LanguageNamesValidation; -import com.intellij.lang.refactoring.NamesValidator; -import com.intellij.lexer.Lexer; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiFile; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.PsiSearchHelper; -import com.intellij.util.Processor; -import gnu.trove.THashMap; - -import java.util.Set; - -/** - * @author Maxim.Mossienko -*/ -class FindInFilesOptimizingSearchHelper extends OptimizingSearchHelperBase { - private PsiSearchHelper helper; - private THashMap<PsiFile,PsiFile> filesToScan; - private THashMap<PsiFile,PsiFile> filesToScan2; - private Lexer javaLexer; - - private final boolean findMatchingFiles; - - FindInFilesOptimizingSearchHelper(CompileContext _context, boolean _findMatchngFiles, Project project) { - super(_context); - findMatchingFiles = _findMatchngFiles; - - if (findMatchingFiles) { - helper = PsiSearchHelper.SERVICE.getInstance(project); - - if (filesToScan == null) { - filesToScan = new THashMap<PsiFile,PsiFile>(); - filesToScan2 = new THashMap<PsiFile,PsiFile>(); - } - } - } - - public boolean doOptimizing() { - return findMatchingFiles; - } - - public void clear() { - super.clear(); - - if (filesToScan != null) { - filesToScan.clear(); - filesToScan2.clear(); - - helper = null; - } - } - - protected void doAddSearchWordInCode(final String refname) { - final FileType fileType = context.getOptions().getFileType(); - final Language language = fileType instanceof LanguageFileType ? ((LanguageFileType)fileType).getLanguage() : Language.ANY; - final NamesValidator namesValidator = LanguageNamesValidation.INSTANCE.forLanguage(language); - if (namesValidator.isKeyword(refname, context.getProject())) { - helper.processAllFilesWithWordInText(refname, (GlobalSearchScope)context.getOptions().getScope(), new MyFileProcessor(), true); - } else { - helper.processAllFilesWithWord(refname, (GlobalSearchScope)context.getOptions().getScope(), new MyFileProcessor(), true); - } - } - - protected void doAddSearchWordInText(final String refname) { - helper.processAllFilesWithWordInText(refname, (GlobalSearchScope)context.getOptions().getScope(), new MyFileProcessor(), true); - } - - protected void doAddSearchWordInComments(final String refname) { - helper.processAllFilesWithWordInComments(refname, (GlobalSearchScope)context.getOptions().getScope(), new MyFileProcessor()); - } - - protected void doAddSearchWordInLiterals(final String refname) { - helper.processAllFilesWithWordInLiterals(refname, (GlobalSearchScope)context.getOptions().getScope(), new MyFileProcessor()); - } - - public void endTransaction() { - super.endTransaction(); - THashMap<PsiFile,PsiFile> map = filesToScan; - if (map.size() > 0) map.clear(); - filesToScan = filesToScan2; - filesToScan2 = map; - } - - public Set<PsiFile> getFilesSetToScan() { - return filesToScan.keySet(); - } - - private class MyFileProcessor implements Processor<PsiFile> { - public boolean process(PsiFile file) { - if (scanRequest == 0 || - filesToScan.get(file)!=null) { - filesToScan2.put(file,file); - } - return true; - } - } - -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/GlobalCompilingVisitor.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/GlobalCompilingVisitor.java deleted file mode 100644 index 130751adec67..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/GlobalCompilingVisitor.java +++ /dev/null @@ -1,314 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.filters.CompositeFilter; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.handlers.LiteralWithSubstitutionHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler; -import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; - -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static com.intellij.structuralsearch.MatchOptions.INSTANCE_MODIFIER_NAME; -import static com.intellij.structuralsearch.MatchOptions.MODIFIER_ANNOTATION_NAME; - -/** - * @author maxim - */ -public class GlobalCompilingVisitor { - @NonNls private static final String SUBSTITUTION_PATTERN_STR = "\\b(__\\$_\\w+)\\b"; - private static final Pattern ourSubstitutionPattern = Pattern.compile(SUBSTITUTION_PATTERN_STR); - private static final Set<String> ourReservedWords = new HashSet<String>(Arrays.asList(MODIFIER_ANNOTATION_NAME, INSTANCE_MODIFIER_NAME)) { - { - for (StructuralSearchProfile profile : Extensions.getExtensions(StructuralSearchProfile.EP_NAME)) { - addAll(profile.getReservedWords()); - } - } - }; - private static final Pattern ourAlternativePattern = Pattern.compile("^\\((.+)\\)$"); - @NonNls private static final String WORD_SEARCH_PATTERN_STR = ".*?\\b(.+?)\\b.*?"; - private static final Pattern ourWordSearchPattern = Pattern.compile(WORD_SEARCH_PATTERN_STR); - private CompileContext context; - private final ArrayList<PsiElement> myLexicalNodes = new ArrayList<PsiElement>(); - - private int myCodeBlockLevel; - - private static final NodeFilter ourFilter = LexicalNodesFilter.getInstance(); - - public static NodeFilter getFilter() { - return ourFilter; - } - - public void setHandler(PsiElement element, MatchingHandler handler) { - MatchingHandler realHandler = context.getPattern().getHandlerSimple(element); - - if (realHandler instanceof SubstitutionHandler) { - ((SubstitutionHandler)realHandler).setMatchHandler(handler); - } - else { - // @todo care about composite handler in this case of simple handler! - context.getPattern().setHandler(element, handler); - } - } - - public final void handle(PsiElement element) { - - if ((!ourFilter.accepts(element) || - StructuralSearchUtil.isIdentifier(element)) && - context.getPattern().isRealTypedVar(element) && - context.getPattern().getHandlerSimple(element) == null - ) { - String name = context.getPattern().getTypedVarString(element); - // name is the same for named element (clazz,methods, etc) and token (name of ... itself) - // @todo need fix this - final SubstitutionHandler handler; - - context.getPattern().setHandler( - element, - handler = (SubstitutionHandler)context.getPattern().getHandler(name) - ); - - if (handler != null && context.getOptions().getVariableConstraint(handler.getName()).isPartOfSearchResults()) { - handler.setTarget(true); - context.getPattern().setTargetNode(element); - } - } - } - - public CompileContext getContext() { - return context; - } - - public int getCodeBlockLevel() { - return myCodeBlockLevel; - } - - public void setCodeBlockLevel(int codeBlockLevel) { - this.myCodeBlockLevel = codeBlockLevel; - } - - static void setFilter(MatchingHandler handler, NodeFilter filter) { - if (handler.getFilter() != null && - handler.getFilter().getClass() != filter.getClass() - ) { - // for constructor we will have the same handler for class and method and tokens itselfa - handler.setFilter( - new CompositeFilter( - filter, - handler.getFilter() - ) - ); - } - else { - handler.setFilter(filter); - } - } - - public ArrayList<PsiElement> getLexicalNodes() { - return myLexicalNodes; - } - - public void addLexicalNode(PsiElement node) { - myLexicalNodes.add(node); - } - - void compile(PsiElement[] elements, CompileContext context) { - myCodeBlockLevel = 0; - this.context = context; - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(context.getOptions().getFileType()); - assert profile != null; - profile.compile(elements, this); - - if (context.getPattern().getStrategy() == null) { - System.out.println(); - } - } - - @Nullable - public MatchingHandler processPatternStringWithFragments(String pattern, OccurenceKind kind) { - return processPatternStringWithFragments(pattern, kind, ourSubstitutionPattern); - } - - @Nullable - public MatchingHandler processPatternStringWithFragments(String pattern, OccurenceKind kind, Pattern substitutionPattern) { - String content; - - if (kind == OccurenceKind.LITERAL) { - content = pattern.substring(1, pattern.length() - 1); - } - else if (kind == OccurenceKind.COMMENT) { - content = pattern; - } - else { - return null; - } - - @NonNls StringBuilder buf = new StringBuilder(content.length()); - Matcher matcher = substitutionPattern.matcher(content); - List<SubstitutionHandler> handlers = null; - int start = 0; - String word; - boolean hasLiteralContent = false; - - SubstitutionHandler handler = null; - while (matcher.find()) { - if (handlers == null) handlers = new ArrayList<SubstitutionHandler>(); - handler = (SubstitutionHandler)getContext().getPattern().getHandler(matcher.group(1)); - if (handler != null) handlers.add(handler); - - word = content.substring(start, matcher.start()); - - if (word.length() > 0) { - buf.append(StructuralSearchUtil.shieldSpecialChars(word)); - hasLiteralContent = true; - - processTokenizedName(word, false, kind); - } - - RegExpPredicate predicate = MatchingHandler.getSimpleRegExpPredicate(handler); - - if (predicate == null || !predicate.isWholeWords()) { - buf.append("(.*?)"); - } - else { - buf.append(".*?\\b(").append(predicate.getRegExp()).append(")\\b.*?"); - } - - if (isSuitablePredicate(predicate, handler)) { - processTokenizedName(predicate.getRegExp(), false, kind); - } - - start = matcher.end(); - } - - word = content.substring(start, content.length()); - - if (word.length() > 0) { - hasLiteralContent = true; - buf.append(StructuralSearchUtil.shieldSpecialChars(word)); - - processTokenizedName(word, false, kind); - } - - if (hasLiteralContent) { - if (kind == OccurenceKind.LITERAL) { - buf.insert(0, "[\"']"); - buf.append("[\"']"); - } - buf.append("$"); - } - - if (handlers != null) { - return hasLiteralContent ? new LiteralWithSubstitutionHandler(buf.toString(), handlers) : handler; - } - - return null; - } - - @Contract("null,_ -> false") - static boolean isSuitablePredicate(RegExpPredicate predicate, SubstitutionHandler handler) { - return predicate != null && handler.getMinOccurs() != 0 && predicate.couldBeOptimized(); - } - - public static void addFilesToSearchForGivenWord(String refname, - boolean endTransaction, - GlobalCompilingVisitor.OccurenceKind kind, - CompileContext compileContext) { - if (!compileContext.getSearchHelper().doOptimizing()) { - return; - } - if (ourReservedWords.contains(refname)) return; // skip our special annotations !!! - - boolean addedSomething = false; - - if (kind == GlobalCompilingVisitor.OccurenceKind.CODE) { - addedSomething = compileContext.getSearchHelper().addWordToSearchInCode(refname); - } - else if (kind == GlobalCompilingVisitor.OccurenceKind.COMMENT) { - addedSomething = compileContext.getSearchHelper().addWordToSearchInComments(refname); - } - else if (kind == GlobalCompilingVisitor.OccurenceKind.LITERAL) { - addedSomething = compileContext.getSearchHelper().addWordToSearchInLiterals(refname); - } - - if (addedSomething && endTransaction) { - compileContext.getSearchHelper().endTransaction(); - } - } - - public void processTokenizedName(String name, boolean skipComments, GlobalCompilingVisitor.OccurenceKind kind) { - WordTokenizer tokenizer = new WordTokenizer(name); - for (Iterator<String> i = tokenizer.iterator(); i.hasNext();) { - String nextToken = i.next(); - if (skipComments && - (nextToken.equals("/*") || nextToken.equals("/**") || nextToken.equals("*/") || nextToken.equals("*") || nextToken.equals("//")) - ) { - continue; - } - - Matcher matcher = ourAlternativePattern.matcher(nextToken); - if (matcher.matches()) { - StringTokenizer alternatives = new StringTokenizer(matcher.group(1), "|"); - while (alternatives.hasMoreTokens()) { - addFilesToSearchForGivenWord(alternatives.nextToken(), !alternatives.hasMoreTokens(), kind, getContext()); - } - } - else { - addFilesToSearchForGivenWord(nextToken, true, kind, getContext()); - } - } - } - - public enum OccurenceKind { - LITERAL, COMMENT, CODE - } - - private static class WordTokenizer { - private final List<String> myWords = new ArrayList<String>(); - - WordTokenizer(String text) { - final StringTokenizer tokenizer = new StringTokenizer(text); - Matcher matcher = null; - - while (tokenizer.hasMoreTokens()) { - String nextToken = tokenizer.nextToken(); - if (matcher == null) { - matcher = ourWordSearchPattern.matcher(nextToken); - } - else { - matcher.reset(nextToken); - } - - nextToken = (matcher.matches()) ? matcher.group(1) : nextToken; - int lastWordStart = 0; - int i; - for (i = 0; i < nextToken.length(); ++i) { - if (!Character.isJavaIdentifierStart(nextToken.charAt(i))) { - if (i != lastWordStart) { - myWords.add(nextToken.substring(lastWordStart, i)); - } - lastWordStart = i + 1; - } - } - - if (i != lastWordStart) { - myWords.add(nextToken.substring(lastWordStart, i)); - } - } - } - - Iterator<String> iterator() { - return myWords.iterator(); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/OptimizingSearchHelper.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/OptimizingSearchHelper.java deleted file mode 100644 index 8d6a08b6ef95..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/OptimizingSearchHelper.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.psi.PsiFile; - -import java.util.Set; - -/** - * @author Maxim.Mossienko -*/ -public interface OptimizingSearchHelper { - boolean doOptimizing(); - void clear(); - - boolean addWordToSearchInCode(final String refname); - - boolean addWordToSearchInText(final String refname); - - boolean addWordToSearchInComments(final String refname); - - boolean addWordToSearchInLiterals(final String refname); - - void endTransaction(); - - boolean isScannedSomething(); - - Set<PsiFile> getFilesSetToScan(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/OptimizingSearchHelperBase.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/OptimizingSearchHelperBase.java deleted file mode 100644 index 2d6f2bc41b37..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/OptimizingSearchHelperBase.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import gnu.trove.THashSet; - -/** - * @author Maxim.Mossienko -*/ -abstract class OptimizingSearchHelperBase implements OptimizingSearchHelper { - private final THashSet<String> scanned; - private final THashSet<String> scannedText; - private final THashSet<String> scannedComments; - private final THashSet<String> scannedLiterals; - protected int scanRequest; - - - protected final CompileContext context; - - OptimizingSearchHelperBase(CompileContext _context) { - context = _context; - - scanRequest = 0; - scanned = new THashSet<String>(); - scannedText = new THashSet<String>(); - scannedComments = new THashSet<String>(); - scannedLiterals = new THashSet<String>(); - } - - public void clear() { - scanned.clear(); - scannedComments.clear(); - scannedLiterals.clear(); - } - - public boolean addWordToSearchInCode(final String refname) { - if (!scanned.contains(refname)) { - doAddSearchWordInCode(refname); - scanned.add( refname ); - return true; - } - - return false; - } - - public boolean addWordToSearchInText(final String refname) { - if (!scannedText.contains(refname)) { - doAddSearchWordInText(refname); - scannedText.add(refname); - return true; - } - return false; - } - - protected abstract void doAddSearchWordInCode(final String refname); - protected abstract void doAddSearchWordInText(final String refname); - - protected abstract void doAddSearchWordInComments(final String refname); - protected abstract void doAddSearchWordInLiterals(final String refname); - - public void endTransaction() { - scanRequest++; - } - - public boolean addWordToSearchInComments(final String refname) { - if (!scannedComments.contains(refname)) { - doAddSearchWordInComments(refname); - - scannedComments.add( refname ); - return true; - } - return false; - } - - public boolean addWordToSearchInLiterals(final String refname) { - if (!scannedLiterals.contains(refname)) { - doAddSearchWordInLiterals(refname); - scannedLiterals.add( refname ); - return true; - } - return false; - } - - public boolean isScannedSomething() { - return scanned.size() > 0 || scannedComments.size() > 0 || scannedLiterals.size() > 0; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java deleted file mode 100644 index e290ebb70793..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/PatternCompiler.java +++ /dev/null @@ -1,512 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.codeInsight.template.Template; -import com.intellij.codeInsight.template.TemplateManager; -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.lang.Language; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiErrorElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiRecursiveElementWalkingVisitor; -import com.intellij.psi.impl.source.PsiFileImpl; -import com.intellij.psi.impl.source.tree.LeafElement; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.psi.util.PsiUtilCore; -import com.intellij.structuralsearch.*; -import com.intellij.structuralsearch.impl.matcher.CompiledPattern; -import com.intellij.structuralsearch.impl.matcher.MatchPredicateProvider; -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; -import com.intellij.structuralsearch.impl.matcher.PatternTreeContext; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler; -import com.intellij.structuralsearch.impl.matcher.predicates.*; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.util.IncorrectOperationException; -import gnu.trove.TIntArrayList; -import gnu.trove.TIntHashSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Compiles the handlers for usability - */ -public class PatternCompiler { - private static CompileContext lastTestingContext; - - public static void transformOldPattern(MatchOptions options) { - StringToConstraintsTransformer.transformOldPattern(options); - } - - public static CompiledPattern compilePattern(final Project project, final MatchOptions options) throws MalformedPatternException, - UnsupportedOperationException { - FileType fileType = options.getFileType(); - assert fileType instanceof LanguageFileType; - Language language = ((LanguageFileType)fileType).getLanguage(); - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByLanguage(language); - assert profile != null; - CompiledPattern result = profile.createCompiledPattern(); - - final String[] prefixes = result.getTypedVarPrefixes(); - assert prefixes.length > 0; - - final CompileContext context = new CompileContext(); - if (ApplicationManager.getApplication().isUnitTestMode()) lastTestingContext = context; - - /*CompiledPattern result = options.getFileType() == StdFileTypes.JAVA ? - new JavaCompiledPattern() : - new XmlCompiledPattern();*/ - - try { - context.init(result, options, project, options.getScope() instanceof GlobalSearchScope); - - List<PsiElement> elements = compileByAllPrefixes(project, options, result, context, prefixes); - - context.getPattern().setNodes(elements); - - if (context.getSearchHelper().doOptimizing() && context.getSearchHelper().isScannedSomething()) { - final Set<PsiFile> set = context.getSearchHelper().getFilesSetToScan(); - final List<PsiFile> filesToScan = new ArrayList<PsiFile>(set.size()); - final GlobalSearchScope scope = (GlobalSearchScope)options.getScope(); - - for (final PsiFile file : set) { - if (!scope.contains(file.getVirtualFile())) { - continue; - } - - if (file instanceof PsiFileImpl) { - ((PsiFileImpl)file).clearCaches(); - } - filesToScan.add(file); - } - - if (filesToScan.size() == 0) { - throw new MalformedPatternException(SSRBundle.message("ssr.will.not.find.anything")); - } - result.setScope( - new LocalSearchScope(PsiUtilCore.toPsiElementArray(filesToScan)) - ); - } - } finally { - context.clear(); - } - - return result; - } - - public static String getLastFindPlan() { - return ((TestModeOptimizingSearchHelper)lastTestingContext.getSearchHelper()).getSearchPlan(); - } - - @NotNull - private static List<PsiElement> compileByAllPrefixes(Project project, - MatchOptions options, - CompiledPattern pattern, - CompileContext context, - String[] applicablePrefixes) { - if (applicablePrefixes.length == 0) { - return Collections.emptyList(); - } - - List<PsiElement> elements = doCompile(project, options, pattern, new ConstantPrefixProvider(applicablePrefixes[0]), context); - if (elements.isEmpty()) { - return elements; - } - - final PsiFile file = elements.get(0).getContainingFile(); - if (file == null) { - return elements; - } - - final PsiElement last = elements.get(elements.size() - 1); - final Pattern[] patterns = new Pattern[applicablePrefixes.length]; - - for (int i = 0; i < applicablePrefixes.length; i++) { - String s = StructuralSearchUtil.shieldSpecialChars(applicablePrefixes[i]); - patterns[i] = Pattern.compile(s + "\\w+\\b"); - } - - final int[] varEndOffsets = findAllTypedVarOffsets(file, patterns); - - final int patternEndOffset = last.getTextRange().getEndOffset(); - if (elements.size() == 0 || - checkErrorElements(file, patternEndOffset, patternEndOffset, varEndOffsets, true) != Boolean.TRUE) { - return elements; - } - - final int varCount = varEndOffsets.length; - final String[] prefixSequence = new String[varCount]; - - for (int i = 0; i < varCount; i++) { - prefixSequence[i] = applicablePrefixes[0]; - } - - final List<PsiElement> finalElements = - compileByPrefixes(project, options, pattern, context, applicablePrefixes, patterns, prefixSequence, 0); - return finalElements != null - ? finalElements - : doCompile(project, options, pattern, new ConstantPrefixProvider(applicablePrefixes[0]), context); - } - - @Nullable - private static List<PsiElement> compileByPrefixes(Project project, - MatchOptions options, - CompiledPattern pattern, - CompileContext context, - String[] applicablePrefixes, - Pattern[] substitutionPatterns, - String[] prefixSequence, - int index) { - if (index >= prefixSequence.length) { - final List<PsiElement> elements = doCompile(project, options, pattern, new ArrayPrefixProvider(prefixSequence), context); - if (elements.isEmpty()) { - return elements; - } - - final PsiElement parent = elements.get(0).getParent(); - final PsiElement last = elements.get(elements.size() - 1); - final int[] varEndOffsets = findAllTypedVarOffsets(parent.getContainingFile(), substitutionPatterns); - final int patternEndOffset = last.getTextRange().getEndOffset(); - return checkErrorElements(parent, patternEndOffset, patternEndOffset, varEndOffsets, false) != Boolean.TRUE - ? elements - : null; - } - - String[] alternativeVariant = null; - - for (String applicablePrefix : applicablePrefixes) { - prefixSequence[index] = applicablePrefix; - - List<PsiElement> elements = doCompile(project, options, pattern, new ArrayPrefixProvider(prefixSequence), context); - if (elements.isEmpty()) { - return elements; - } - - final PsiFile file = elements.get(0).getContainingFile(); - if (file == null) { - return elements; - } - - final int[] varEndOffsets = findAllTypedVarOffsets(file, substitutionPatterns); - final int offset = varEndOffsets[index]; - - final int patternEndOffset = elements.get(elements.size() - 1).getTextRange().getEndOffset(); - final Boolean result = checkErrorElements(file, offset, patternEndOffset, varEndOffsets, false); - - if (result == Boolean.TRUE) { - continue; - } - - if (result == Boolean.FALSE || (result == null && alternativeVariant == null)) { - final List<PsiElement> finalElements = - compileByPrefixes(project, options, pattern, context, applicablePrefixes, substitutionPatterns, prefixSequence, index + 1); - if (finalElements != null) { - if (result == Boolean.FALSE) { - return finalElements; - } - alternativeVariant = new String[prefixSequence.length]; - System.arraycopy(prefixSequence, 0, alternativeVariant, 0, prefixSequence.length); - } - } - } - - return alternativeVariant != null ? - compileByPrefixes(project, options, pattern, context, applicablePrefixes, substitutionPatterns, alternativeVariant, index + 1) : - null; - } - - @NotNull - private static int[] findAllTypedVarOffsets(final PsiFile file, final Pattern[] substitutionPatterns) { - final TIntHashSet result = new TIntHashSet(); - - file.accept(new PsiRecursiveElementWalkingVisitor() { - @Override - public void visitElement(PsiElement element) { - super.visitElement(element); - - if (element instanceof LeafElement) { - final String text = element.getText(); - - for (Pattern pattern : substitutionPatterns) { - final Matcher matcher = pattern.matcher(text); - - while (matcher.find()) { - result.add(element.getTextRange().getStartOffset() + matcher.end()); - } - } - } - } - }); - - final int[] resultArray = result.toArray(); - Arrays.sort(resultArray); - return resultArray; - } - - - /** - * False: there are no error elements before offset, except patternEndOffset - * Null: there are only error elements located exactly after template variables or at the end of the pattern - * True: otherwise - */ - @Nullable - private static Boolean checkErrorElements(PsiElement element, - final int offset, - final int patternEndOffset, - final int[] varEndOffsets, - final boolean strict) { - final TIntArrayList errorOffsets = new TIntArrayList(); - final boolean[] containsErrorTail = {false}; - final TIntHashSet varEndOffsetsSet = new TIntHashSet(varEndOffsets); - - element.accept(new PsiRecursiveElementWalkingVisitor() { - @Override - public void visitElement(PsiElement element) { - super.visitElement(element); - - if (!(element instanceof PsiErrorElement)) { - return; - } - - final int startOffset = element.getTextRange().getStartOffset(); - - if ((strict || !varEndOffsetsSet.contains(startOffset)) && startOffset != patternEndOffset) { - errorOffsets.add(startOffset); - } - - if (startOffset == offset) { - containsErrorTail[0] = true; - } - } - }); - - for (int i = 0; i < errorOffsets.size(); i++) { - final int errorOffset = errorOffsets.get(i); - if (errorOffset <= offset) { - return true; - } - } - return containsErrorTail[0] ? null : false; - } - - private interface PrefixProvider { - String getPrefix(int varIndex); - } - - private static class ConstantPrefixProvider implements PrefixProvider { - private final String myPrefix; - - private ConstantPrefixProvider(String prefix) { - myPrefix = prefix; - } - - @Override - public String getPrefix(int varIndex) { - return myPrefix; - } - } - - private static class ArrayPrefixProvider implements PrefixProvider { - private final String[] myPrefixes; - - private ArrayPrefixProvider(String[] prefixes) { - myPrefixes = prefixes; - } - - @Override - public String getPrefix(int varIndex) { - try { - return myPrefixes[varIndex]; - } catch (ArrayIndexOutOfBoundsException e) { - return null; - } - } - } - - private static List<PsiElement> doCompile(Project project, - MatchOptions options, - CompiledPattern result, - PrefixProvider prefixProvider, - CompileContext context) { - result.clearHandlers(); - context.init(result, options, project, options.getScope() instanceof GlobalSearchScope); - - final StringBuilder buf = new StringBuilder(); - - Template template = TemplateManager.getInstance(project).createTemplate("","",options.getSearchPattern()); - - int segmentsCount = template.getSegmentsCount(); - String text = template.getTemplateText(); - buf.setLength(0); - int prevOffset = 0; - - for(int i=0;i<segmentsCount;++i) { - final int offset = template.getSegmentOffset(i); - final String name = template.getSegmentName(i); - - final String prefix = prefixProvider.getPrefix(i); - if (prefix == null) { - throw new MalformedPatternException(); - } - - buf.append(text.substring(prevOffset,offset)); - buf.append(prefix); - buf.append(name); - - MatchVariableConstraint constraint = options.getVariableConstraint(name); - if (constraint==null) { - // we do not edited the constraints - constraint = new MatchVariableConstraint(); - constraint.setName( name ); - options.addVariableConstraint(constraint); - } - - SubstitutionHandler handler = result.createSubstitutionHandler( - name, - prefix + name, - constraint.isPartOfSearchResults(), - constraint.getMinCount(), - constraint.getMaxCount(), - constraint.isGreedy() - ); - - if(constraint.isWithinHierarchy()) { - handler.setSubtype(true); - } - - if(constraint.isStrictlyWithinHierarchy()) { - handler.setStrictSubtype(true); - } - - MatchPredicate predicate; - - if (!StringUtil.isEmptyOrSpaces(constraint.getRegExp())) { - predicate = new RegExpPredicate( - constraint.getRegExp(), - options.isCaseSensitiveMatch(), - name, - constraint.isWholeWordsOnly(), - constraint.isPartOfSearchResults() - ); - if (constraint.isInvertRegExp()) { - predicate = new NotPredicate(predicate); - } - addPredicate(handler,predicate); - } - - if (constraint.isReference()) { - predicate = new ReferencePredicate( constraint.getNameOfReferenceVar() ); - - if (constraint.isInvertReference()) { - predicate = new NotPredicate(predicate); - } - addPredicate(handler,predicate); - } - - Set<MatchPredicate> predicates = new LinkedHashSet<MatchPredicate>(); - for (MatchPredicateProvider matchPredicateProvider : Extensions.getExtensions(MatchPredicateProvider.EP_NAME)) { - matchPredicateProvider.collectPredicates(constraint, name, options, predicates); - } - for (MatchPredicate matchPredicate : predicates) { - addPredicate(handler, matchPredicate); - } - - addScriptConstraint(name, constraint, handler); - - if (!StringUtil.isEmptyOrSpaces(constraint.getContainsConstraint())) { - predicate = new ContainsPredicate(name, constraint.getContainsConstraint()); - if (constraint.isInvertContainsConstraint()) { - predicate = new NotPredicate(predicate); - } - addPredicate(handler,predicate); - } - - if (!StringUtil.isEmptyOrSpaces(constraint.getWithinConstraint())) { - assert false; - } - - prevOffset = offset; - } - - MatchVariableConstraint constraint = options.getVariableConstraint(Configuration.CONTEXT_VAR_NAME); - if (constraint != null) { - SubstitutionHandler handler = result.createSubstitutionHandler( - Configuration.CONTEXT_VAR_NAME, - Configuration.CONTEXT_VAR_NAME, - constraint.isPartOfSearchResults(), - constraint.getMinCount(), - constraint.getMaxCount(), - constraint.isGreedy() - ); - - if (!StringUtil.isEmptyOrSpaces(constraint.getWithinConstraint())) { - MatchPredicate predicate = new WithinPredicate(Configuration.CONTEXT_VAR_NAME, constraint.getWithinConstraint(), project); - if (constraint.isInvertWithinConstraint()) { - predicate = new NotPredicate(predicate); - } - addPredicate(handler,predicate); - } - - addScriptConstraint(Configuration.CONTEXT_VAR_NAME, constraint, handler); - } - - buf.append(text.substring(prevOffset,text.length())); - - PsiElement[] matchStatements; - - try { - final String pattern = buf.toString(); - matchStatements = MatcherImplUtil.createTreeFromText(pattern, PatternTreeContext.Block, options.getFileType(), - options.getDialect(), options.getPatternContext(), project, false); - if (matchStatements.length==0) throw new MalformedPatternException(pattern); - } catch (IncorrectOperationException e) { - throw new MalformedPatternException(e.getMessage()); - } - - NodeFilter filter = LexicalNodesFilter.getInstance(); - - GlobalCompilingVisitor compilingVisitor = new GlobalCompilingVisitor(); - compilingVisitor.compile(matchStatements,context); - ArrayList<PsiElement> elements = new ArrayList<PsiElement>(); - - for (PsiElement matchStatement : matchStatements) { - if (!filter.accepts(matchStatement)) { - elements.add(matchStatement); - } - } - - new DeleteNodesAction(compilingVisitor.getLexicalNodes()).run(); - return elements; - } - - private static void addScriptConstraint(String name, MatchVariableConstraint constraint, SubstitutionHandler handler) { - MatchPredicate predicate; - if (constraint.getScriptCodeConstraint()!= null && constraint.getScriptCodeConstraint().length() > 2) { - final String script = StringUtil.stripQuotesAroundValue(constraint.getScriptCodeConstraint()); - final String s = ScriptSupport.checkValidScript(script); - if (s != null) throw new MalformedPatternException("Script constraint for " + constraint.getName() + " has problem "+s); - predicate = new ScriptPredicate(name, script); - addPredicate(handler,predicate); - } - } - - static void addPredicate(SubstitutionHandler handler, MatchPredicate predicate) { - if (handler.getPredicate()==null) { - handler.setPredicate(predicate); - } else { - handler.setPredicate(new BinaryPredicate(handler.getPredicate(), predicate, false)); - } - } - -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/StringToConstraintsTransformer.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/StringToConstraintsTransformer.java deleted file mode 100644 index 0d684503a14d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/StringToConstraintsTransformer.java +++ /dev/null @@ -1,436 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.structuralsearch.*; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import org.jetbrains.annotations.NonNls; - -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 17.11.2004 - * Time: 19:29:05 - * To change this template use File | Settings | File Templates. - */ -class StringToConstraintsTransformer { - @NonNls private static final String P_STR = "(\\w+)\\('(\\w+)\\)"; - private static final Pattern p = Pattern.compile(P_STR); - @NonNls private static final String P2_STR = "(\\w+)"; - private static final Pattern p2 = Pattern.compile(P2_STR); - @NonNls private static final String P3_STR = "(\\w+)\\(( ?(?:[\\\"\\*<>!\\.\\?\\:\\$\\\\\\(\\)\\[\\]\\w\\|\\+ =]*|(?:\\\"[^\\\"]*\\\")) ?)\\)"; - private static final Pattern p3 = Pattern.compile(P3_STR); - @NonNls private static final String REF = "ref"; - @NonNls private static final String READ = "read"; - @NonNls private static final String WRITE = "write"; - @NonNls private static final String REGEX = "regex"; - @NonNls private static final String REGEXW = "regexw"; - @NonNls private static final String EXPRTYPE = "exprtype"; - @NonNls private static final String FORMAL = "formal"; - @NonNls private static final String SCRIPT = "script"; - @NonNls private static final String CONTAINS = "contains"; - @NonNls private static final String WITHIN = "within"; - - static void transformOldPattern(MatchOptions options) { - final String pattern = options.getSearchPattern(); - - final StringBuilder buf = new StringBuilder(); - - StringBuilder miscBuffer = null; - int anonymousTypedVarsCount = 0; - - for(int index=0;index < pattern.length();++index) { - char ch = pattern.charAt(index); - - if (ch=='\'') { - // doubling ' - final int length = pattern.length(); - if (index + 1 < length && - pattern.charAt(index + 1)=='\'' - ) { - // ignore next ' - index++; - } else if (index + 2 < length && - pattern.charAt(index + 2)=='\'' - ) { - // eat simple character - buf.append(ch); - buf.append(pattern.charAt(++index)); - ch = pattern.charAt(++index); - } else if (index + 3 < length && - pattern.charAt(index + 1)=='\\' && - pattern.charAt(index + 3)=='\'' - ) { - // eat simple escape character - buf.append(ch); - buf.append(pattern.charAt(++index)); - buf.append(pattern.charAt(++index)); - ch = pattern.charAt(++index); - } else if (index + 7 < length && - pattern.charAt(index + 1)=='\\' && - pattern.charAt(index + 2)=='u' && - pattern.charAt(index + 7)=='\'') { - // eat simple escape character - buf.append(ch); - buf.append(pattern.charAt(++index)); - buf.append(pattern.charAt(++index)); - buf.append(pattern.charAt(++index)); - buf.append(pattern.charAt(++index)); - buf.append(pattern.charAt(++index)); - buf.append(pattern.charAt(++index)); - ch = pattern.charAt(++index); - } else { - // typed variable - - buf.append("$"); - if (miscBuffer == null) miscBuffer = new StringBuilder(); - else miscBuffer.setLength(0); - - // eat the name of typed var - for(++index; index< length && Character.isJavaIdentifierPart(ch = pattern.charAt(index)); ++index) { - miscBuffer.append(ch); - buf.append(ch); - } - - boolean anonymous = false; - - if (miscBuffer.length() == 0) throw new MalformedPatternException(SSRBundle.message("error.expected.character")); - if (miscBuffer.charAt(0)=='_') { - anonymous = true; - - if(miscBuffer.length() == 1) { - // anonymous var, make it unique for the case of constraints - anonymousTypedVarsCount++; - miscBuffer.append(anonymousTypedVarsCount); - buf.append(anonymousTypedVarsCount); - } else { - buf.deleteCharAt(buf.length()-miscBuffer.length()); - miscBuffer.deleteCharAt(0); - } - } - - - buf.append("$"); - String typedVar = miscBuffer.toString(); - int minOccurs = 1; - int maxOccurs = 1; - boolean greedy = true; - MatchVariableConstraint constraint = options.getVariableConstraint(typedVar); - boolean constraintCreated = false; - - if (constraint==null) { - constraint = new MatchVariableConstraint(); - constraint.setName( typedVar ); - constraintCreated = true; - } - - // Check the number of occurrences for typed variable - if (index < length) { - char possibleQuantifier = pattern.charAt(index); - - if (possibleQuantifier=='+') { - maxOccurs = Integer.MAX_VALUE; - ++index; - } else if (possibleQuantifier=='?') { - minOccurs = 0; - ++index; - } else if (possibleQuantifier=='*') { - minOccurs = 0; - maxOccurs = Integer.MAX_VALUE; - ++index; - } else if (possibleQuantifier=='{') { - ++index; - minOccurs = 0; - while (index < length && (ch = pattern.charAt(index)) >= '0' && ch <= '9') { - minOccurs *= 10; - minOccurs += (ch - '0'); - if (minOccurs < 0) throw new MalformedPatternException(SSRBundle.message("error.overflow")); - ++index; - } - - if (ch==',') { - ++index; - maxOccurs = 0; - - while (index < length && (ch = pattern.charAt(index)) >= '0' && ch <= '9') { - maxOccurs *= 10; - maxOccurs += (ch - '0'); - if (maxOccurs < 0) throw new MalformedPatternException(SSRBundle.message("error.overflow")); - ++index; - } - } else { - maxOccurs = Integer.MAX_VALUE; - } - - if (ch != '}') { - if (maxOccurs == Integer.MAX_VALUE) throw new MalformedPatternException(SSRBundle.message("error.expected.brace1")); - else throw new MalformedPatternException(SSRBundle.message("error.expected.brace2")); - } - ++index; - } - - if (index < length) { - ch = pattern.charAt(index); - if (ch=='?') { - greedy = false; - ++index; - } - } - } - - if (constraintCreated) { - constraint.setMinCount(minOccurs); - constraint.setMaxCount(maxOccurs); - constraint.setGreedy(greedy); - constraint.setPartOfSearchResults(!anonymous); - } - - if (index < length && pattern.charAt(index) == ':') { - ++index; - if (index >= length) throw new MalformedPatternException(SSRBundle.message("error.expected.condition", ':')); - ch = pattern.charAt(index); - if (ch == ':') { - // double colon instead of condition - buf.append(ch); - } - else { - index = eatTypedVarCondition(index, pattern, miscBuffer, constraint); - } - } - - if (constraintCreated) { - if (constraint.getWithinConstraint().length() > 0) { - constraint.setName(Configuration.CONTEXT_VAR_NAME); - } - options.addVariableConstraint(constraint); - } - - if (index == length) break; - // fall through to append white space - ch = pattern.charAt(index); - } - } - - buf.append(ch); - } - - options.setSearchPattern( buf.toString() ); - } - - private static int eatTypedVarCondition(int index, - String pattern, - StringBuilder miscBuffer, - MatchVariableConstraint constraint) { - final int length = pattern.length(); - - char ch = pattern.charAt(index); - if (ch == '+' || ch == '*') { - // this is type axis navigation relation - switch(ch) { - case '+': - constraint.setStrictlyWithinHierarchy(true); - break; - case '*': - constraint.setWithinHierarchy(true); - break; - } - - ++index; - if (index >= length) throw new MalformedPatternException(SSRBundle.message("error.expected.condition", ch)); - ch = pattern.charAt(index); - } - - if (ch == '[') { - // eat complete condition - - miscBuffer.setLength(0); - for(++index; index < length && ((ch = pattern.charAt(index))!=']' || pattern.charAt(index-1)=='\\'); ++index) { - miscBuffer.append(ch); - } - if (ch != ']') throw new MalformedPatternException(SSRBundle.message("error.expected.condition.or.bracket")); - ++index; - parseCondition(constraint, miscBuffer.toString()); - } else { - // eat reg exp constraint - miscBuffer.setLength(0); - index = handleRegExp(index, pattern, miscBuffer, constraint); - } - return index; - } - - private static int handleRegExp(int index, - String pattern, - StringBuilder miscBuffer, - MatchVariableConstraint constraint) { - char c = pattern.charAt(index - 1); - final int length = pattern.length(); - for(char ch; index < length && !Character.isWhitespace(ch = pattern.charAt(index)); ++index) { - miscBuffer.append(ch); - } - - if (miscBuffer.length() == 0) - if (c == ':') throw new MalformedPatternException(SSRBundle.message("error.expected.condition", c)); - else return index; - String regexp = miscBuffer.toString(); - - if (constraint.getRegExp()!=null && - constraint.getRegExp().length() > 0 && - !constraint.getRegExp().equals(regexp)) { - throw new MalformedPatternException(SSRBundle.message("error.two.different.type.constraints")); - } else { - try { - Pattern.compile(regexp); - } catch (PatternSyntaxException e) { - throw new MalformedPatternException(SSRBundle.message("invalid.regular.expression")); - } - constraint.setRegExp(regexp); - } - - return index; - } - - private static void parseCondition(MatchVariableConstraint constraint, String condition) { - if (condition.isEmpty()) throw new MalformedPatternException(SSRBundle.message("error.expected.condition", "[")); - final List<String> tokens = StringUtil.split(condition, "&&", true, false); - - for (String token : tokens) { - token = token.trim(); - if (token.isEmpty()) throw new MalformedPatternException(SSRBundle.message("error.expected.condition", "&&")); - boolean hasNot = false; - boolean consumed = false; - - if (StringUtil.startsWithChar(token, '!')) { - token = token.substring(1); - if (token.isEmpty()) throw new MalformedPatternException(SSRBundle.message("error.expected.condition", "!")); - hasNot = true; - } - - Matcher m = p.matcher(token); - - if (m.matches()) { - String option = m.group(1); - - if (option.equalsIgnoreCase(REF)) { - String name = m.group(2); - - constraint.setReference(true); - constraint.setInvertReference(hasNot); - constraint.setNameOfReferenceVar(name); - consumed = true; - } - } else { - m = p2.matcher(token); - - if (m.matches()) { - String option = m.group(1); - - if (option.equalsIgnoreCase(READ)) { - constraint.setReadAccess(true); - constraint.setInvertReadAccess(hasNot); - consumed = true; - } else if (option.equalsIgnoreCase(WRITE)) { - constraint.setWriteAccess(true); - constraint.setInvertWriteAccess(hasNot); - consumed = true; - } - } else { - m = p3.matcher(token); - - if (m.matches()) { - String option = m.group(1); - - if (option.equalsIgnoreCase(REGEX) || option.equalsIgnoreCase(REGEXW)) { - String typePattern = getSingleParameter(m, SSRBundle.message("reg.exp.should.be.delimited.with.spaces.error.message")); - if (typePattern.isEmpty()) throw new MalformedPatternException(SSRBundle.message("no.reg.exp.specified.error.message")); - - if (StringUtil.startsWithChar(typePattern, '*')) { - typePattern = typePattern.substring(1); - constraint.setWithinHierarchy(true); - } - try { - Pattern.compile(typePattern); - } catch (PatternSyntaxException e) { - throw new MalformedPatternException(SSRBundle.message("invalid.regular.expression")); - } - constraint.setRegExp( typePattern ); - constraint.setInvertRegExp( hasNot ); - consumed = true; - if (option.equalsIgnoreCase(REGEXW)) { - constraint.setWholeWordsOnly(true); - } - } else if (option.equalsIgnoreCase(EXPRTYPE)) { - String exprTypePattern = getSingleParameter(m, SSRBundle.message( - "reg.exp.in.expr.type.should.be.delimited.with.spaces.error.message")); - - if (StringUtil.startsWithChar(exprTypePattern, '*')) { - exprTypePattern = exprTypePattern.substring(1); - constraint.setExprTypeWithinHierarchy(true); - } - try { - Pattern.compile(exprTypePattern); - } catch (PatternSyntaxException e) { - throw new MalformedPatternException(SSRBundle.message("invalid.regular.expression")); - } - constraint.setNameOfExprType( exprTypePattern ); - constraint.setInvertExprType( hasNot ); - consumed = true; - } else if (option.equalsIgnoreCase(FORMAL)) { - String exprTypePattern = getSingleParameter(m, SSRBundle.message( - "reg.exp.in.formal.arg.type.should.be.delimited.with.spaces.error.message")); - - if (StringUtil.startsWithChar(exprTypePattern, '*')) { - exprTypePattern = exprTypePattern.substring(1); - constraint.setFormalArgTypeWithinHierarchy(true); - } - try { - Pattern.compile(exprTypePattern); - } catch (PatternSyntaxException e) { - throw new MalformedPatternException(SSRBundle.message("invalid.regular.expression")); - } - constraint.setNameOfFormalArgType( exprTypePattern ); - constraint.setInvertFormalType( hasNot ); - consumed = true; - } else if (option.equalsIgnoreCase(SCRIPT)) { - String script = getSingleParameter(m, SSRBundle.message("script.should.be.delimited.with.spaces.error.message")); - - constraint.setScriptCodeConstraint( script ); - consumed = true; - } else if (option.equalsIgnoreCase(CONTAINS)) { - if (hasNot) constraint.setInvertContainsConstraint(true); - String script = getSingleParameter(m, SSRBundle.message("script.should.be.delimited.with.spaces.error.message")); - - constraint.setContainsConstraint(script ); - consumed = true; - } else if (option.equalsIgnoreCase(WITHIN)) { - if (hasNot) constraint.setInvertWithinConstraint(true); - String script = getSingleParameter(m, SSRBundle.message("script.should.be.delimited.with.spaces.error.message")); - - constraint.setWithinConstraint(script); - consumed = true; - } - } - } - } - - if (!consumed) { - throw new UnsupportedPatternException( - SSRBundle.message("option.is.not.recognized.error.message", token) - ); - } - } - } - - private static String getSingleParameter(Matcher m, String errorMessage) { - final String value = m.group(2); - if (value.isEmpty()) return value; - - if (value.charAt(0)!=' ' || value.charAt(value.length()-1)!=' ') { - throw new MalformedPatternException(errorMessage); - } - return value.trim(); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/TestModeOptimizingSearchHelper.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/TestModeOptimizingSearchHelper.java deleted file mode 100644 index e341b57da8ce..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/TestModeOptimizingSearchHelper.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.psi.PsiFile; - -import java.util.Collections; -import java.util.Set; - -/** - * @author Maxim.Mossienko - */ -public class TestModeOptimizingSearchHelper extends OptimizingSearchHelperBase { - private static String lastString; - private final StringBuilder builder = new StringBuilder(); - private int lastLength; - - TestModeOptimizingSearchHelper(CompileContext _context) { - super(_context); - } - - public boolean doOptimizing() { - return true; - } - - public void clear() { - lastString = builder.toString(); - builder.setLength(0); - lastLength = 0; - } - - protected void doAddSearchWordInCode(final String refname) { - append(refname, "reserved in code:"); - } - - @Override - protected void doAddSearchWordInText(String refname) { - append(refname, "in text:"); - } - - private void append(final String refname, final String str) { - if (builder.length() == lastLength) builder.append("["); - else builder.append("|"); - builder.append(str).append(refname); - } - - protected void doAddSearchWordInComments(final String refname) { - append(refname, "in comments:"); - } - - protected void doAddSearchWordInLiterals(final String refname) { - append(refname, "in literals:"); - } - - public void endTransaction() { - super.endTransaction(); - builder.append("]"); - lastLength = builder.length(); - } - - public boolean isScannedSomething() { - return false; - } - - public Set<PsiFile> getFilesSetToScan() { - return Collections.emptySet(); - } - - public String getSearchPlan() { - return lastString; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/XmlCompilingVisitor.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/XmlCompilingVisitor.java deleted file mode 100644 index 99917ad23240..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/compiler/XmlCompilingVisitor.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.XmlRecursiveElementVisitor; -import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlText; -import com.intellij.psi.xml.XmlToken; -import com.intellij.structuralsearch.impl.matcher.filters.TagValueFilter; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.TopLevelMatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.XmlTextHandler; -import com.intellij.structuralsearch.impl.matcher.strategies.XmlMatchingStrategy; - -/** -* @author Eugene.Kudelevsky -*/ -public class XmlCompilingVisitor extends XmlRecursiveElementVisitor { - private final GlobalCompilingVisitor myCompilingVisitor; - - public XmlCompilingVisitor(GlobalCompilingVisitor compilingVisitor) { - this.myCompilingVisitor = compilingVisitor; - } - - @Override public void visitElement(PsiElement element) { - myCompilingVisitor.handle(element); - super.visitElement(element); - } - - @Override public void visitXmlToken(XmlToken token) { - super.visitXmlToken(token); - - if (token.getParent() instanceof XmlText && myCompilingVisitor.getContext().getPattern().isRealTypedVar(token)) { - final MatchingHandler handler = myCompilingVisitor.getContext().getPattern().getHandler(token); - handler.setFilter(TagValueFilter.getInstance()); - - final XmlTextHandler parentHandler = new XmlTextHandler(); - myCompilingVisitor.getContext().getPattern().setHandler(token.getParent(), parentHandler); - parentHandler.setFilter(TagValueFilter.getInstance()); - } - } - - @Override public void visitXmlTag(XmlTag xmlTag) { - myCompilingVisitor.setCodeBlockLevel(myCompilingVisitor.getCodeBlockLevel() + 1); - super.visitXmlTag(xmlTag); - myCompilingVisitor.setCodeBlockLevel(myCompilingVisitor.getCodeBlockLevel() - 1); - - if (myCompilingVisitor.getCodeBlockLevel() == 1) { - myCompilingVisitor.getContext().getPattern().setStrategy(XmlMatchingStrategy.getInstance()); - myCompilingVisitor.getContext().getPattern() - .setHandler(xmlTag, new TopLevelMatchingHandler(myCompilingVisitor.getContext().getPattern().getHandler(xmlTag))); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/CompositeFilter.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/CompositeFilter.java deleted file mode 100644 index db962ed8edf1..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/CompositeFilter.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.PsiElement; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 28.12.2003 - * Time: 0:13:19 - * To change this template use Options | File Templates. - */ -public class CompositeFilter implements NodeFilter { - private final NodeFilter first; - private final NodeFilter second; - protected boolean result; - - public boolean accepts(PsiElement element) { - return first.accepts(element) || - second.accepts(element); - } - - public CompositeFilter(NodeFilter _first, NodeFilter _second) { - first = _first; - second = _second; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/DefaultFilter.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/DefaultFilter.java deleted file mode 100644 index 267f37699945..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/DefaultFilter.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.source.tree.LeafElement; - -/** - * Default searching filter - */ -public class DefaultFilter { - public static boolean accepts(PsiElement element, PsiElement element2) { - if (element instanceof LeafElement && element2 instanceof LeafElement) { - return ((LeafElement)element).getElementType() == ((LeafElement)element2).getElementType(); - } - return element.getClass()==element2.getClass(); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/LexicalNodesFilter.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/LexicalNodesFilter.java deleted file mode 100644 index 3cef402b09d3..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/LexicalNodesFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; - -/** - * Filter for lexical nodes - */ -public final class LexicalNodesFilter implements NodeFilter { - private boolean careKeyWords; - private boolean result; - - private LexicalNodesFilter() {} - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - public boolean getResult() { - return result; - } - - public void setResult(boolean result) { - this.result = result; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new LexicalNodesFilter(); - } - - public boolean isCareKeyWords() { - return careKeyWords; - } - - public void setCareKeyWords(boolean careKeyWords) { - this.careKeyWords = careKeyWords; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) { - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(element); - if (profile != null) { - element.accept(profile.getLexicalNodesFilter(this)); - } - } - return result; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/TagValueFilter.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/TagValueFilter.java deleted file mode 100644 index 97ed9627e3fc..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/TagValueFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.PsiElement; -import com.intellij.psi.XmlElementVisitor; -import com.intellij.psi.xml.XmlTag; -import com.intellij.psi.xml.XmlText; - -/** - * Created by IntelliJ IDEA. - * User: maxim.mossienko - * Date: Oct 12, 2005 - * Time: 4:44:19 PM - * To change this template use File | Settings | File Templates. - */ -public class TagValueFilter extends XmlElementVisitor implements NodeFilter { - private boolean result; - - @Override public void visitXmlText(XmlText text) { - result = true; - } - - @Override public void visitXmlTag(XmlTag tag) { - result = true; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new TagValueFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private TagValueFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/XmlLexicalNodesFilter.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/XmlLexicalNodesFilter.java deleted file mode 100644 index 89c295ce1d80..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/filters/XmlLexicalNodesFilter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.psi.XmlElementVisitor; -import com.intellij.psi.xml.XmlText; - -/** -* @author Eugene.Kudelevsky -*/ -public class XmlLexicalNodesFilter extends XmlElementVisitor { - private final LexicalNodesFilter myLexicalNodesFilter; - - public XmlLexicalNodesFilter(LexicalNodesFilter lexicalNodesFilter) { - this.myLexicalNodesFilter = lexicalNodesFilter; - } - - @Override public void visitXmlText(XmlText text) { - myLexicalNodesFilter.setResult(true); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/DelegatingHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/DelegatingHandler.java deleted file mode 100644 index c95a85623753..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/DelegatingHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -/** - * @author Eugene.Kudelevsky - */ -public interface DelegatingHandler { - MatchingHandler getDelegate(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/LightTopLevelMatchingHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/LightTopLevelMatchingHandler.java deleted file mode 100644 index 34941cfa0257..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/LightTopLevelMatchingHandler.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.dupLocator.iterators.NodeIterator; -import org.jetbrains.annotations.NotNull; - -public final class LightTopLevelMatchingHandler extends MatchingHandler implements DelegatingHandler { - private final MatchingHandler myDelegate; - - public LightTopLevelMatchingHandler(@NotNull MatchingHandler delegate) { - myDelegate = delegate; - } - - public boolean match(final PsiElement patternNode, final PsiElement matchedNode, final MatchContext matchContext) { - return myDelegate.match(patternNode, matchedNode, matchContext); - } - - @Override - public boolean canMatch(PsiElement patternNode, PsiElement matchedNode) { - return myDelegate.canMatch(patternNode, matchedNode); - } - - @Override - public boolean matchSequentially(final NodeIterator nodes, final NodeIterator nodes2, final MatchContext context) { - return myDelegate.matchSequentially(nodes, nodes2, context); - } - - public boolean match(final PsiElement patternNode, - final PsiElement matchedNode, final int start, final int end, final MatchContext context) { - return myDelegate.match(patternNode, matchedNode, start, end, context); - } - - public boolean isMatchSequentiallySucceeded(final NodeIterator nodes2) { - return true; - } - - @Override - public boolean shouldAdvanceTheMatchFor(final PsiElement patternElement, final PsiElement matchedElement) { - return myDelegate.shouldAdvanceTheMatchFor(patternElement, matchedElement); - } - - public MatchingHandler getDelegate() { - return myDelegate; - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/LiteralWithSubstitutionHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/LiteralWithSubstitutionHandler.java deleted file mode 100644 index 78967106755f..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/LiteralWithSubstitutionHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Jun 30, 2004 - * Time: 5:07:33 PM - * To change this template use File | Settings | File Templates. - */ -public class LiteralWithSubstitutionHandler extends MatchingHandler { - private final String matchExpression; - private Matcher matcher; - private final List<SubstitutionHandler> handlers; - - public LiteralWithSubstitutionHandler(String _matchedExpression,List<SubstitutionHandler> _handlers) { - matchExpression = _matchedExpression; - handlers = _handlers; - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - final String text = RegExpPredicate.getMeaningfulText(matchedNode); - int offset = matchedNode.getText().indexOf(text); - if (matcher==null) { - matcher = Pattern.compile(matchExpression).matcher(text); - } else { - matcher.reset(text); - } - - while (matcher.find()) { - for (int i = 0; i < handlers.size(); ++i) { - SubstitutionHandler handler = handlers.get(i); - - if (!handler.handle(matchedNode,offset + matcher.start(i+1), offset + matcher.end(i+1),context)) { - return false; - } - } - return true; - } - return false; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchPredicate.java deleted file mode 100644 index cba96681ab71..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchPredicate.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * Root of handlers for pattern node matching. Handles simpliest type of the match. - */ -public abstract class MatchPredicate { - /** - * Matches given handler node against given value. - * @param matchedNode for matching - * @param context of the matching - * @return true if matching was successfull and false otherwise - */ - public boolean match(PsiElement patternNode,PsiElement matchedNode, int start, int end, MatchContext context) { - return match(patternNode,matchedNode,context); - } - - /** - * Matches given handler node against given value. - * @param matchedNode for matching - * @param context of the matching - * @return true if matching was successfull and false otherwise - */ - public abstract boolean match(PsiElement patternNode,PsiElement matchedNode, MatchContext context); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchingHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchingHandler.java deleted file mode 100644 index c53b08412b6b..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/MatchingHandler.java +++ /dev/null @@ -1,271 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.CompiledPattern; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.MatchResultImpl; -import com.intellij.structuralsearch.impl.matcher.filters.DefaultFilter; -import com.intellij.structuralsearch.impl.matcher.predicates.BinaryPredicate; -import com.intellij.structuralsearch.impl.matcher.predicates.NotPredicate; -import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate; -import com.intellij.structuralsearch.impl.matcher.strategies.MatchingStrategy; - -import java.util.HashSet; -import java.util.Set; - -/** - * Root of handlers for pattern node matching. Handles simplest type of the match. - */ -public abstract class MatchingHandler extends MatchPredicate { - protected NodeFilter filter; - private PsiElement pinnedElement; - - public void setFilter(NodeFilter filter) { - this.filter = filter; - } - - /** - * Matches given handler node against given value. - * @param matchedNode for matching - * @param context of the matching - * @return true if matching was successful and false otherwise - */ - public boolean match(PsiElement patternNode,PsiElement matchedNode, int start, int end, MatchContext context) { - return match(patternNode,matchedNode,context); - } - - /** - * Matches given handler node against given value. - * @param matchedNode for matching - * @param context of the matching - * @return true if matching was successful and false otherwise - */ - public boolean match(PsiElement patternNode,PsiElement matchedNode, MatchContext context) { - if (patternNode == null) { - return matchedNode == null; - } - - return canMatch(patternNode, matchedNode); - } - - public boolean canMatch(final PsiElement patternNode, final PsiElement matchedNode) { - if (filter!=null) { - return filter.accepts(matchedNode); - } else { - return DefaultFilter.accepts(patternNode, matchedNode); - } - } - - public boolean matchSequentially(NodeIterator nodes, NodeIterator nodes2, MatchContext context) { - PsiElement patternElement; - MatchingHandler handler; - MatchingStrategy strategy = context.getPattern().getStrategy(); - - skipIfNecessary(nodes, nodes2, strategy); - skipIfNecessary(nodes2, nodes, strategy); - - if (nodes2.hasNext() && - (handler = context.getPattern().getHandler(nodes.current())).match(patternElement = nodes.current(),nodes2.current(),context)) { - - nodes.advance(); - - if (shouldAdvanceTheMatchFor(patternElement, nodes2.current())) { - nodes2.advance(); - skipIfNecessary(nodes, nodes2, strategy); - } - skipIfNecessary(nodes2, nodes, strategy); - - if (nodes.hasNext()) { - final MatchingHandler nextHandler = context.getPattern().getHandler(nodes.current()); - - if (nextHandler.matchSequentially(nodes,nodes2,context)) { - // match was found! - return true; - } else { - // rewind, we was not able to match descendants - nodes.rewind(); - nodes2.rewind(); - } - } else { - // match was found - return handler.isMatchSequentiallySucceeded(nodes2); - } - } - return false; - } - - private static void skipIfNecessary(NodeIterator nodes, NodeIterator nodes2, MatchingStrategy strategy) { - while (strategy.shouldSkip(nodes2.current(), nodes.current())) { - nodes2.advance(); - } - } - - protected boolean isMatchSequentiallySucceeded(final NodeIterator nodes2) { - return !nodes2.hasNext(); - } - - private static MatchPredicate findRegExpPredicate(MatchPredicate start) { - if (start==null) return null; - if (start instanceof RegExpPredicate) return start; - - if(start instanceof BinaryPredicate) { - BinaryPredicate binary = (BinaryPredicate)start; - final MatchPredicate result = findRegExpPredicate(binary.getFirst()); - if (result!=null) return result; - - return findRegExpPredicate(binary.getSecond()); - } else if (start instanceof NotPredicate) { - return null; - } - return null; - } - - public static RegExpPredicate getSimpleRegExpPredicate(SubstitutionHandler handler) { - if (handler == null) return null; - return (RegExpPredicate)findRegExpPredicate(handler.getPredicate()); - } - - static class ClearStateVisitor extends PsiRecursiveElementWalkingVisitor { - private CompiledPattern pattern; - - ClearStateVisitor() { - super(true); - } - - @Override public void visitElement(PsiElement element) { - // We do not reset certain handlers because they are also bound to higher level nodes - // e.g. Identifier handler in name is also bound to PsiMethod - if (pattern.isToResetHandler(element)) { - MatchingHandler handler = pattern.getHandlerSimple(element); - if (handler instanceof SubstitutionHandler) { - handler.reset(); - } - } - super.visitElement(element); - } - - synchronized void clearState(CompiledPattern _pattern, PsiElement el) { - pattern = _pattern; - el.acceptChildren(this); - pattern = null; - } - } - - protected static ClearStateVisitor clearingVisitor = new ClearStateVisitor(); - - public boolean matchInAnyOrder(NodeIterator patternNodes, NodeIterator matchedNodes, final MatchContext context) { - final MatchResultImpl saveResult = context.hasResult() ? context.getResult() : null; - context.setResult(null); - - try { - - if (patternNodes.hasNext() && !matchedNodes.hasNext()) { - return validateSatisfactionOfHandlers(patternNodes, context); - } - - Set<PsiElement> matchedElements = null; - - for(; patternNodes.hasNext(); patternNodes.advance()) { - final PsiElement patternNode = patternNodes.current(); - final CompiledPattern pattern = context.getPattern(); - final MatchingHandler handler = pattern.getHandler(patternNode); - - final PsiElement startMatching = matchedNodes.current(); - do { - final PsiElement element = handler.getPinnedNode(null); - final PsiElement matchedNode = element != null ? element : matchedNodes.current(); - - if (element == null) matchedNodes.advance(); - if (!matchedNodes.hasNext()) matchedNodes.reset(); - - if (matchedElements == null || !matchedElements.contains(matchedNode)) { - - if (handler.match(patternNode, matchedNode, context)) { - if (matchedElements == null) matchedElements = new HashSet<PsiElement>(); - matchedElements.add(matchedNode); - if (handler.shouldAdvanceThePatternFor(patternNode, matchedNode)) { - break; - } - } else if (element != null) { - return false; - } - - // clear state of dependent objects - clearingVisitor.clearState(pattern, patternNode); - } - - // passed of elements and does not found the match - if (startMatching == matchedNodes.current()) { - final boolean result = validateSatisfactionOfHandlers(patternNodes,context); - if (result && context.getMatchedElementsListener() != null) { - context.getMatchedElementsListener().matchedElements(matchedElements); - } - return result; - } - } while(true); - - if (!handler.shouldAdvanceThePatternFor(patternNode, null)) { - patternNodes.rewind(); - } - } - - final boolean result = validateSatisfactionOfHandlers(patternNodes, context); - if (result && context.getMatchedElementsListener() != null) { - context.getMatchedElementsListener().matchedElements(matchedElements); - } - return result; - } finally { - if (saveResult!=null) { - if (context.hasResult()) { - saveResult.getMatches().addAll(context.getResult().getMatches()); - } - context.setResult(saveResult); - } - } - } - - protected static boolean validateSatisfactionOfHandlers(NodeIterator nodes, MatchContext context) { - while(nodes.hasNext()) { - final PsiElement element = nodes.current(); - final MatchingHandler handler = context.getPattern().getHandler( element ); - - if (handler instanceof SubstitutionHandler) { - if (!((SubstitutionHandler)handler).validate( - context, StructuralSearchUtil.getProfileByPsiElement(element).getElementContextByPsi(element))) { - return false; - } - } else { - return false; - } - nodes.advance(); - } - return true; - } - - public NodeFilter getFilter() { - return filter; - } - - public boolean shouldAdvanceThePatternFor(PsiElement patternElement, PsiElement matchedElement) { - return true; - } - - public boolean shouldAdvanceTheMatchFor(PsiElement patternElement, PsiElement matchedElement) { - return true; - } - - public void reset() { - //pinnedElement = null; - } - - public PsiElement getPinnedNode(PsiElement context) { - return pinnedElement; - } - - public void setPinnedElement(final PsiElement pinnedElement) { - this.pinnedElement = pinnedElement; - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SimpleHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SimpleHandler.java deleted file mode 100644 index 3dffe792e308..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SimpleHandler.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * Root of handlers for pattern node matching. Handles simpliest type of the match. - */ -public final class SimpleHandler extends MatchingHandler { - /** - * Matches given handler node against given value. - * @param matchedNode for matching - * @param context of the matching - * @return true if matching was successfull and false otherwise - */ - public boolean match(PsiElement patternNode,PsiElement matchedNode, MatchContext context) { - if (!super.match(patternNode,matchedNode,context)) return false; - return context.getMatcher().match(patternNode,matchedNode); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SkippingHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SkippingHandler.java deleted file mode 100644 index 389c4a7916c2..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SkippingHandler.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.dupLocator.equivalence.EquivalenceDescriptor; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.dupLocator.util.DuplocatorUtil; -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * @author Eugene.Kudelevsky - */ -public class SkippingHandler extends MatchingHandler implements DelegatingHandler { - - private final MatchingHandler myDelegate; - - public SkippingHandler(@NotNull MatchingHandler delegate) { - myDelegate = delegate; - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, final MatchContext matchContext) { - if (patternNode == null || matchedNode == null || matchedNode.getClass() == patternNode.getClass()) { - return myDelegate.match(patternNode, matchedNode, matchContext); - } - - /*if (patternNode != null && matchedNode != null && patternNode.getClass() == matchedNode.getClass()) { - //return myDelegate.match(patternNode, matchedNode, matchContext); - }*/ - PsiElement newPatternNode = skipNodeIfNeccessary(patternNode); - matchedNode = skipNodeIfNeccessary(matchedNode); - - if (newPatternNode != patternNode) { - return matchContext.getPattern().getHandler(newPatternNode).match(newPatternNode, matchedNode, matchContext); - } - - return myDelegate.match(patternNode, matchedNode, matchContext); - } - - @Override - public boolean canMatch(PsiElement patternNode, PsiElement matchedNode) { - return myDelegate.canMatch(patternNode, matchedNode); - } - - @Override - public boolean matchSequentially(final NodeIterator nodes, final NodeIterator nodes2, final MatchContext context) { - return myDelegate.matchSequentially(nodes, nodes2, context); - } - - public boolean match(PsiElement patternNode, - PsiElement matchedNode, - final int start, - final int end, - final MatchContext context) { - if (patternNode == null || matchedNode == null || patternNode.getClass() == matchedNode.getClass()) { - return myDelegate.match(patternNode, matchedNode, start, end, context); - } - - PsiElement newPatternNode = skipNodeIfNeccessary(patternNode); - matchedNode = skipNodeIfNeccessary(matchedNode); - - if (newPatternNode != patternNode) { - return context.getPattern().getHandler(newPatternNode).match(newPatternNode, matchedNode, start, end, context); - } - - return myDelegate.match(patternNode, matchedNode, start, end, context); - } - - protected boolean isMatchSequentiallySucceeded(final NodeIterator nodes2) { - return myDelegate.isMatchSequentiallySucceeded(nodes2); - } - - @Override - public boolean shouldAdvanceTheMatchFor(PsiElement patternElement, PsiElement matchedElement) { - return true; - } - - public MatchingHandler getDelegate() { - return myDelegate; - } - - @Nullable - public static PsiElement getOnlyNonWhitespaceChild(PsiElement element) { - PsiElement onlyChild = null; - for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { - if (DuplocatorUtil.isIgnoredNode(element) || child.getTextLength() == 0) { - continue; - } - if (onlyChild != null) { - return null; - } - onlyChild = child; - } - return onlyChild; - } - - @Nullable - public static PsiElement skipNodeIfNeccessary(PsiElement element) { - return skipNodeIfNeccessary(element, null, null); - } - - @Nullable - public static PsiElement skipNodeIfNeccessary(PsiElement element, EquivalenceDescriptor descriptor, NodeFilter filter) { - return DuplocatorUtil.skipNodeIfNeccessary(element, descriptor, filter != null ? filter : LexicalNodesFilter.getInstance()); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SubstitutionHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SubstitutionHandler.java deleted file mode 100644 index 0c84e3bb2436..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SubstitutionHandler.java +++ /dev/null @@ -1,557 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.dupLocator.iterators.FilteringNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.CompiledPattern; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.MatchResultImpl; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.util.SmartPsiPointer; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Matching handler that manages substitutions matching - */ -public class SubstitutionHandler extends MatchingHandler { - private final String name; - private final int maxOccurs; - private final int minOccurs; - private final boolean greedy; - private boolean target; - private MatchPredicate predicate; - private MatchingHandler matchHandler; - private boolean subtype; - private boolean strictSubtype; - // matchedOccurs + 1 = number of item being matched - private int matchedOccurs; - private int totalMatchedOccurs = -1; - private MatchResultImpl myNestedResult; - - private static final NodeFilter VARS_DELIM_FILTER = new NodeFilter() { - @Override - public boolean accepts(PsiElement element) { - if (element == null) { - return false; - } - - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(element); - if (profile == null) { - return false; - } - - return profile.canBeVarDelimeter(element); - } - }; - - public SubstitutionHandler(final String name, final boolean target, int minOccurs, - int maxOccurs, boolean greedy) { - this.name = name; - this.maxOccurs = maxOccurs; - this.minOccurs = minOccurs; - this.target = target; - this.greedy = greedy; - } - - public SubstitutionHandler(final SubstitutionHandler substitutionHandler) { - this(substitutionHandler.getName(),substitutionHandler.isTarget(), substitutionHandler.getMinOccurs(), - substitutionHandler.getMaxOccurs(), substitutionHandler.greedy); - } - - public boolean isSubtype() { - return subtype; - } - - public boolean isStrictSubtype() { - return strictSubtype; - } - - public void setStrictSubtype(boolean strictSubtype) { - this.strictSubtype = strictSubtype; - } - - public void setSubtype(boolean subtype) { - this.subtype = subtype; - } - - public void setPredicate(MatchPredicate handler) { - predicate = handler; - } - - // Matcher - - public MatchPredicate getPredicate() { - return predicate; - } - - private static boolean validateOneMatch(final PsiElement match, int start, int end, final MatchResultImpl result, final MatchContext matchContext) { - final boolean matchresult; - - if (match!=null) { - if (start==0 && end==-1 && result.getStart()==0 && result.getEnd()==-1) { - matchresult = matchContext.getMatcher().match(match,result.getMatchRef().getElement()); - } else { - matchresult = StructuralSearchUtil.getProfileByPsiElement(match).getText(match, start, end).equals( - result.getMatchImage() - ); - } - } else { - matchresult = result.isMatchImageNull(); - } - - return matchresult; - } - - public boolean validate(final PsiElement match, int start, int end, MatchContext context) { - if (predicate!=null) { - if(!predicate.match(null,match,start,end,context)) return false; - } - - if (maxOccurs==0) { - totalMatchedOccurs++; - return false; - } - - MatchResultImpl result = context.getResult().findSon(name); - - if (result == null && context.getPreviousResult() != null) { - result = context.getPreviousResult().findSon(name); - } - - if (result!=null) { - if (minOccurs == 1 && maxOccurs == 1) { - // check if they are the same - return validateOneMatch(match, start, end, result,context); - } else if (maxOccurs > 1 && totalMatchedOccurs!=-1) { - final int size = result.getAllSons().size(); - if (matchedOccurs >= size) { - return false; - } - result = size == 0 ?result:(MatchResultImpl)result.getAllSons().get(matchedOccurs); - // check if they are the same - return validateOneMatch(match, start, end, result, context); - } - } - - return true; - } - - public boolean match(final PsiElement node, final PsiElement match, MatchContext context) { - if (!super.match(node,match,context)) return false; - - return matchHandler == null ? - context.getMatcher().match(node, match): - matchHandler.match(node,match,context); - } - - public boolean handle(final PsiElement match, MatchContext context) { - return handle(match,0,-1,context); - } - - public void addResult(PsiElement match,int start, int end,MatchContext context) { - if (totalMatchedOccurs == -1) { - final MatchResultImpl matchResult = context.getResult(); - final MatchResultImpl substitution = matchResult.findSon(name); - - if (substitution == null) { - matchResult.addSon( createMatch(match,start,end) ); - } else if (maxOccurs > 1) { - final MatchResultImpl result = createMatch(match,start,end); - - if (!substitution.isMultipleMatch()) { - // adding intermediate node to contain all multiple matches - MatchResultImpl sonresult = new MatchResultImpl( - substitution.getName(), - substitution.getMatchImage(), - substitution.getMatchRef(), - substitution.getStart(), - substitution.getEnd(), - target - ); - - sonresult.setParent(substitution); - substitution.setMatchRef( - new SmartPsiPointer(match == null ? null : match) - ); - - substitution.setMultipleMatch(true); - - if (substitution.isScopeMatch()) { - substitution.setScopeMatch(false); - sonresult.setScopeMatch(true); - for(MatchResult r:substitution.getAllSons()) sonresult.addSon((MatchResultImpl)r); - substitution.clearMatches(); - } - - substitution.addSon( sonresult); - } - - result.setParent(substitution); - substitution.addSon( result ); - } - } - } - - public boolean handle(final PsiElement match, int start, int end, MatchContext context) { - if (!validate(match,start,end,context)) { - myNestedResult = null; - - //if (maxOccurs==1 && minOccurs==1) { - // if (context.hasResult()) context.getResult().removeSon(name); - //} - // @todo we may fail fast the match by throwing an exception - - return false; - } - - if (!Configuration.CONTEXT_VAR_NAME.equals(name)) addResult(match, start, end, context); - - return true; - } - - private MatchResultImpl createMatch(final PsiElement match, int start, int end) { - final String image = match == null ? null : StructuralSearchUtil.getProfileByPsiElement(match).getText(match, start, end); - final SmartPsiPointer ref = new SmartPsiPointer(match); - - final MatchResultImpl result = myNestedResult == null ? new MatchResultImpl( - name, - image, - ref, - start, - end, - target - ) : myNestedResult; - - if (myNestedResult != null) { - myNestedResult.setName( name ); - myNestedResult.setMatchImage( image ); - myNestedResult.setMatchRef( ref ); - myNestedResult.setStart( start ); - myNestedResult.setEnd( end ); - myNestedResult.setTarget( target ); - myNestedResult = null; - } - - return result; - } - - boolean validate(MatchContext context, Class elementContext) { - MatchResult substitution = context.getResult().findSon(name); - - if (minOccurs >= 1 && - ( substitution == null || - StructuralSearchUtil.getProfileByFileType(context.getOptions().getFileType()).getElementContextByPsi(substitution.getMatchRef().getElement()) != elementContext - ) - ) { - return false; - } else if (maxOccurs <= 1 && - substitution!=null && substitution.hasSons() - ) { - return false; - } else if (maxOccurs==0 && totalMatchedOccurs!=-1) { - return false; - } - return true; - } - - public int getMinOccurs() { - return minOccurs; - } - - public int getMaxOccurs() { - return maxOccurs; - } - - private void removeLastResults(int numberOfResults, MatchContext context) { - if (numberOfResults == 0) return; - final MatchResultImpl substitution = context.getResult().findSon(name); - - if (substitution!=null) { - final List<PsiElement> matchedNodes = context.getMatchedNodes(); - - if (substitution.hasSons()) { - final List<MatchResult> sons = substitution.getMatches(); - - while(numberOfResults > 0) { - --numberOfResults; - final MatchResult matchResult = sons.remove(sons.size() - 1); - if (matchedNodes != null) matchedNodes.remove(matchResult.getMatch()); - } - - if (sons.isEmpty()) { - context.getResult().removeSon(name); - } - } else { - final MatchResultImpl matchResult = context.getResult().removeSon(name); - if (matchedNodes != null) matchedNodes.remove(matchResult.getMatch()); - } - } - } - - public boolean matchInAnyOrder(NodeIterator patternNodes, NodeIterator matchedNodes, final MatchContext context) { - final MatchResultImpl saveResult = context.hasResult() ? context.getResult() : null; - context.setResult(null); - - try { - - if (patternNodes.hasNext() && !matchedNodes.hasNext()) { - return validateSatisfactionOfHandlers(patternNodes, context); - } - - Set<PsiElement> matchedElements = null; - - for(; patternNodes.hasNext(); patternNodes.advance()) { - int matchedOccurs = 0; - final PsiElement patternNode = patternNodes.current(); - final CompiledPattern pattern = context.getPattern(); - final MatchingHandler handler = pattern.getHandler(patternNode); - - final PsiElement startMatching = matchedNodes.current(); - do { - final PsiElement element = handler.getPinnedNode(null); - final PsiElement matchedNode = (element != null) ? element : matchedNodes.current(); - - if (element == null) matchedNodes.advance(); - if (!matchedNodes.hasNext()) matchedNodes.reset(); - - if (matchedOccurs <= maxOccurs && - (matchedElements == null || !matchedElements.contains(matchedNode))) { - - if (handler.match(patternNode, matchedNode, context)) { - ++matchedOccurs; - if (matchedElements == null) matchedElements = new HashSet<PsiElement>(); - matchedElements.add(matchedNode); - if (handler.shouldAdvanceThePatternFor(patternNode, matchedNode)) { - break; - } - } else if (element != null) { - return false; - } - - // clear state of dependent objects - clearingVisitor.clearState(pattern, patternNode); - } - - // passed of elements and does not found the match - if (startMatching == matchedNodes.current()) { - final boolean result = validateSatisfactionOfHandlers(patternNodes, context) && - matchedOccurs >= minOccurs && matchedOccurs <= maxOccurs; - if (result && context.getMatchedElementsListener() != null) { - context.getMatchedElementsListener().matchedElements(matchedElements); - } - return result; - } - } while(true); - - if (!handler.shouldAdvanceThePatternFor(patternNode, null)) { - patternNodes.rewind(); - } - } - - final boolean result = validateSatisfactionOfHandlers(patternNodes, context); - if (result && context.getMatchedElementsListener() != null) { - context.getMatchedElementsListener().matchedElements(matchedElements); - } - return result; - } finally { - if (saveResult!=null) { - if (context.hasResult()) { - saveResult.getMatches().addAll(context.getResult().getMatches()); - } - context.setResult(saveResult); - } - } - } - - public boolean matchSequentially(NodeIterator nodes, NodeIterator nodes2, MatchContext context) { - return doMatchSequentially(nodes, nodes2, context); - } - - protected boolean doMatchSequentiallyBySimpleHandler(NodeIterator nodes, NodeIterator nodes2, MatchContext context) { - final boolean oldValue = context.shouldRecursivelyMatch(); - context.setShouldRecursivelyMatch(false); - final boolean result = super.matchSequentially(nodes, nodes2, context); - context.setShouldRecursivelyMatch(oldValue); - return result; - } - - protected boolean doMatchSequentially(NodeIterator nodes, NodeIterator nodes2, MatchContext context) { - final int previousMatchedOccurs = matchedOccurs; - - FilteringNodeIterator fNodes2 = new FilteringNodeIterator(nodes2, VARS_DELIM_FILTER); - - try { - MatchingHandler handler = context.getPattern().getHandler(nodes.current()); - matchedOccurs = 0; - - boolean flag = false; - - while(fNodes2.hasNext() && matchedOccurs < minOccurs) { - if (handler.match(nodes.current(), nodes2.current(), context)) { - ++matchedOccurs; - } else { - break; - } - fNodes2.advance(); - flag = true; - } - - if (matchedOccurs!=minOccurs) { - // failed even for min occurs - removeLastResults(matchedOccurs, context); - fNodes2.rewind(matchedOccurs); - return false; - } - - if (greedy) { - // go greedily to maxOccurs - - while(fNodes2.hasNext() && matchedOccurs < maxOccurs) { - if (handler.match(nodes.current(), nodes2.current(), context)) { - ++matchedOccurs; - } else { - // no more matches could take! - break; - } - fNodes2.advance(); - flag = true; - } - - if (flag) { - fNodes2.rewind(); - nodes2.advance(); - } - - nodes.advance(); - - if (nodes.hasNext()) { - final MatchingHandler nextHandler = context.getPattern().getHandler(nodes.current()); - - while(matchedOccurs >= minOccurs) { - if (nextHandler.matchSequentially(nodes, nodes2, context)) { - totalMatchedOccurs = matchedOccurs; - // match found - return true; - } - - if (matchedOccurs > 0) { - nodes2.rewind(); - removeLastResults(1,context); - } - --matchedOccurs; - } - - if (matchedOccurs > 0) { - removeLastResults(matchedOccurs, context); - } - nodes.rewind(); - return false; - } else { - // match found - if (handler.isMatchSequentiallySucceeded(nodes2)) { - return checkSameOccurrencesConstraint(); - } - removeLastResults(matchedOccurs, context); - return false; - } - } else { - nodes.advance(); - - if (flag) { - fNodes2.rewind(); - nodes2.advance(); - } - - if (nodes.hasNext()) { - final MatchingHandler nextHandler = context.getPattern().getHandler(nodes.current()); - - flag = false; - - while(nodes2.hasNext() && matchedOccurs <= maxOccurs) { - if (nextHandler.matchSequentially(nodes, nodes2, context)) { - return checkSameOccurrencesConstraint(); - } - - if (flag) { - nodes2.rewind(); - fNodes2.advance(); - } - - if (handler.match(nodes.current(), nodes2.current(), context)) { - matchedOccurs++; - } else { - nodes.rewind(); - removeLastResults(matchedOccurs,context); - return false; - } - nodes2.advance(); - flag = true; - } - - nodes.rewind(); - removeLastResults(matchedOccurs,context); - return false; - } else { - return checkSameOccurrencesConstraint(); - } - } - } finally { - matchedOccurs = previousMatchedOccurs; - } - } - - private boolean checkSameOccurrencesConstraint() { - if (totalMatchedOccurs == -1) { - totalMatchedOccurs = matchedOccurs; - return true; - } - else { - return totalMatchedOccurs == matchedOccurs; - } - } - - public void setTarget(boolean target) { - this.target = target; - } - - public MatchingHandler getMatchHandler() { - return matchHandler; - } - - public void setMatchHandler(MatchingHandler matchHandler) { - this.matchHandler = matchHandler; - } - - public boolean isTarget() { - return target; - } - - public String getName() { - return name; - } - - public void reset() { - super.reset(); - totalMatchedOccurs = -1; - } - - public boolean shouldAdvanceThePatternFor(PsiElement patternElement, PsiElement matchedElement) { - if(maxOccurs > 1) return false; - return super.shouldAdvanceThePatternFor(patternElement,matchedElement); - } - - public void setNestedResult(final MatchResultImpl nestedResult) { - myNestedResult = nestedResult; - } - - public MatchResultImpl getNestedResult() { - return myNestedResult; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SymbolHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SymbolHandler.java deleted file mode 100644 index 4d1f9a852940..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/SymbolHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * Search handler for symbol search - */ -public class SymbolHandler extends MatchingHandler { - private final SubstitutionHandler handler; - - public SymbolHandler(SubstitutionHandler handler) { - this.handler = handler; - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - // there is no need to do filtering since this is delegate of Substituion handler - - return handler.handle(matchedNode,context); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TopLevelMatchingHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TopLevelMatchingHandler.java deleted file mode 100644 index 6711bcb1fc7f..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TopLevelMatchingHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.dupLocator.iterators.SiblingNodeIterator; -import com.intellij.psi.PsiComment; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -public final class TopLevelMatchingHandler extends MatchingHandler implements DelegatingHandler { - private final MatchingHandler delegate; - - public TopLevelMatchingHandler(@NotNull MatchingHandler _delegate) { - delegate = _delegate; - setFilter(_delegate.getFilter()); - } - - public boolean match(final PsiElement patternNode, final PsiElement matchedNode, final MatchContext matchContext) { - final boolean matched = delegate.match(patternNode, matchedNode, matchContext); - - if (matched) { - List<PsiElement> matchedNodes = matchContext.getMatchedNodes(); - if (matchedNodes == null) { - matchedNodes = new ArrayList<PsiElement>(); - matchContext.setMatchedNodes(matchedNodes); - } - - PsiElement elementToAdd = matchedNode; - - if (patternNode instanceof PsiComment && StructuralSearchUtil.isDocCommentOwner(matchedNode)) { - // psicomment and psidoccomment are placed inside the psimember next to them so - // simple topdown matching should do additional "dances" to cover this case. - elementToAdd = matchedNode.getFirstChild(); - assert elementToAdd instanceof PsiComment; - } - - matchedNodes.add(elementToAdd); - } - - if ((!matched || matchContext.getOptions().isRecursiveSearch()) && - matchContext.getPattern().getStrategy().continueMatching(matchedNode) && - matchContext.shouldRecursivelyMatch() - ) { - matchContext.getMatcher().matchContext( - new SsrFilteringNodeIterator( - new SiblingNodeIterator(matchedNode.getFirstChild()) - ) - ); - } - return matched; - } - - @Override - public boolean canMatch(PsiElement patternNode, PsiElement matchedNode) { - return delegate.canMatch(patternNode, matchedNode); - } - - @Override - public boolean matchSequentially(final NodeIterator nodes, final NodeIterator nodes2, final MatchContext context) { - return delegate.matchSequentially(nodes, nodes2, context); - } - - public boolean match(final PsiElement patternNode, - final PsiElement matchedNode, final int start, final int end, final MatchContext context) { - return match(patternNode, matchedNode, context); - } - - public boolean isMatchSequentiallySucceeded(final NodeIterator nodes2) { - return true; - } - - @Override - public boolean shouldAdvanceTheMatchFor(final PsiElement patternElement, final PsiElement matchedElement) { - return delegate.shouldAdvanceTheMatchFor(patternElement, matchedElement); - } - - public MatchingHandler getDelegate() { - return delegate; - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TypedSymbolHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TypedSymbolHandler.java deleted file mode 100644 index 08e335614d5a..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/TypedSymbolHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiDeclarationStatement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * Search handler for typed symbol ('T<a*>) - */ -public class TypedSymbolHandler extends MatchingHandler { - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - if (!super.match(patternNode,matchedNode,context)) { - return false; - } - - return context.getMatcher().match( - patternNode.getFirstChild(), - matchedNode - ); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/XmlTextHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/XmlTextHandler.java deleted file mode 100644 index cc71c02ee403..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/handlers/XmlTextHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.GlobalMatchingVisitor; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator; - -/** - * Root of handlers for pattern node matching. Handles simpliest type of the match. - */ -public final class XmlTextHandler extends MatchingHandler { - public boolean matchSequentially(NodeIterator nodes, NodeIterator nodes2, MatchContext context) { - final PsiElement psiElement = nodes.current(); - - return GlobalMatchingVisitor.continueMatchingSequentially( - new SsrFilteringNodeIterator( new ArrayBackedNodeIterator(psiElement.getChildren()) ), - nodes2, - context - ); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/iterators/SsrFilteringNodeIterator.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/iterators/SsrFilteringNodeIterator.java deleted file mode 100644 index a2b14ae83e17..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/iterators/SsrFilteringNodeIterator.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.iterators; - -import com.intellij.dupLocator.iterators.FilteringNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.dupLocator.iterators.SiblingNodeIterator; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; - -/** - * @author Eugene.Kudelevsky - */ -public class SsrFilteringNodeIterator extends FilteringNodeIterator { - public SsrFilteringNodeIterator(final NodeIterator iterator) { - super(iterator, LexicalNodesFilter.getInstance()); - } - - public SsrFilteringNodeIterator(final PsiElement element) { - this(new SiblingNodeIterator(element)); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/AbstractStringBasedPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/AbstractStringBasedPredicate.java deleted file mode 100644 index 916fc1e15639..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/AbstractStringBasedPredicate.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; - -/** - * @author Maxim.Mossienko - */ -public class AbstractStringBasedPredicate extends MatchPredicate { - protected final String myName; - protected final String myWithin; - - public AbstractStringBasedPredicate(String name, String within) { - myName = name; - myWithin = within; - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - return match(patternNode, matchedNode, 0, -1, context); - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java deleted file mode 100644 index b7d5432964d4..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/BinaryPredicate.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * Binary predicate - */ -public final class BinaryPredicate extends MatchPredicate { - private final MatchPredicate first; - private final MatchPredicate second; - private final boolean or; - - public BinaryPredicate(MatchPredicate first, MatchPredicate second, boolean or) { - this.first = first; - this.second = second; - this.or = or; - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - if (or) { - return first.match(patternNode,matchedNode,context) || - second.match(patternNode,matchedNode,context); - } else { - return first.match(patternNode,matchedNode,context) && - second.match(patternNode,matchedNode,context); - } - } - - public MatchPredicate getFirst() { - return first; - } - - public MatchPredicate getSecond() { - return second; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ContainsPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ContainsPredicate.java deleted file mode 100644 index 2ed894fe6b64..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ContainsPredicate.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * @author Maxim.Mossienko - */ -public class ContainsPredicate extends AbstractStringBasedPredicate { - - public ContainsPredicate(String name, String within) { - super(name, within); - } - - public boolean match(PsiElement node, PsiElement match, int start, int end, MatchContext context) { - return false; - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/NotPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/NotPredicate.java deleted file mode 100644 index 3d28a635e3af..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/NotPredicate.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; - -/** - * Negates predicate - */ -public final class NotPredicate extends MatchPredicate { - private final MatchPredicate handler; - - public NotPredicate(final MatchPredicate _handler) { - handler = _handler; - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - return !handler.match(patternNode,matchedNode,context); - } - - public MatchPredicate getHandler() { - return handler; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ReferencePredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ReferencePredicate.java deleted file mode 100644 index 17570ed8f5df..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ReferencePredicate.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.*; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.MatchUtils; - -/** - * Handles finding method - */ -public final class ReferencePredicate extends SubstitutionHandler { - public ReferencePredicate(String _name) { - super(_name, true, 1, 1, true); - } - - public boolean match(PsiElement node, PsiElement match, MatchContext context) { - if (StructuralSearchUtil.isIdentifier(match)) { - // since we pickup tokens - match = match.getParent(); - } - - PsiElement result = MatchUtils.getReferencedElement(match); - if (result == null) { - result = match; - //return false; - } - - return handle(result,context); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/RegExpPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/RegExpPredicate.java deleted file mode 100644 index f7b8ecedcf3d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/RegExpPredicate.java +++ /dev/null @@ -1,175 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.*; -import com.intellij.structuralsearch.MalformedPatternException; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.MatchResultImpl; -import com.intellij.structuralsearch.impl.matcher.MatchUtils; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.plugin.util.SmartPsiPointer; -import org.jetbrains.annotations.NonNls; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -/** - * Root of handlers for pattern node matching. Handles simpliest type of the match. - */ -public final class RegExpPredicate extends MatchPredicate { - private Pattern pattern; - private final String baseHandlerName; - private boolean simpleString; - private final boolean couldBeOptimized; - private final String regexp; - private final boolean caseSensitive; - private boolean multiline; - private final boolean wholeWords; - private final boolean target; - private NodeTextGenerator myNodeTextGenerator; - - public interface NodeTextGenerator { - String getText(PsiElement element); - } - - public RegExpPredicate(final String regexp, final boolean caseSensitive, final String _baseHandlerName, boolean _wholeWords, boolean _target) { - couldBeOptimized = containsRegExp(regexp); - if (!_wholeWords) { - simpleString = couldBeOptimized; - } - - this.regexp = regexp; - this.caseSensitive = caseSensitive; - this.wholeWords = _wholeWords; - baseHandlerName = _baseHandlerName; - - if (!simpleString) { - compilePattern(); - } - target = _target; - } - - private static boolean containsRegExp(final String regexp) { - for(int i=0;i<regexp.length();++i) { - if(MatchUtils.SPECIAL_CHARS.indexOf(regexp.charAt(i))!=-1) { - return false; - } - } - - return true; - } - - private void compilePattern() { - try { - @NonNls String realRegexp = regexp; - if (wholeWords) { - realRegexp = ".*?\\b(?:" + realRegexp + ")\\b.*?"; - } - - pattern = Pattern.compile( - realRegexp, - (caseSensitive ? 0: Pattern.CASE_INSENSITIVE) | (multiline ? Pattern.DOTALL:0) - ); - } catch(PatternSyntaxException ex) { - throw new MalformedPatternException(SSRBundle.message("error.incorrect.regexp.constraint", regexp, baseHandlerName)); - } - } - - public boolean couldBeOptimized() { - return couldBeOptimized; - } - - public String getRegExp() { - return regexp; - } - - /** - * Attempts to match given handler node against given node. - * @param matchedNode for matching - * @param context of the matching - * @return true if matching was successfull and false otherwise - */ - public boolean match(PsiElement node,PsiElement matchedNode, int start, int end, MatchContext context) { - if (matchedNode==null) return false; - String text; - - text = myNodeTextGenerator != null ? myNodeTextGenerator.getText(matchedNode) : getMeaningfulText(matchedNode); - - boolean result = doMatch(text, start, end, context, matchedNode); - - if (!result) { - - if(StructuralSearchUtil.isIdentifier(matchedNode)) { - matchedNode = matchedNode.getParent(); - } - - String alternativeText = context.getPattern().getAlternativeTextToMatch(matchedNode, text); - if (alternativeText != null) { - result = doMatch(alternativeText, start, end, context, matchedNode); - } - } - - return result; - } - - public static String getMeaningfulText(PsiElement matchedNode) { - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(matchedNode); - return profile != null ? profile.getMeaningfulText(matchedNode) : matchedNode.getText(); - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - return match(patternNode,matchedNode,0,-1,context); - } - - boolean doMatch(String text, MatchContext context, PsiElement matchedElement) { - return doMatch(text,0,-1,context, matchedElement); - } - - boolean doMatch(String text, int from, int end, MatchContext context,PsiElement matchedElement) { - if (from > 0 || end != -1) { - text = text.substring(from, end == -1 || end >= text.length() ? text.length():end); - } - - if (simpleString) { - return (caseSensitive)?text.equals(regexp):text.equalsIgnoreCase(regexp); - } - - if(!multiline && text.contains("\n")) setMultiline(true); - final Matcher matcher = pattern.matcher(text); - - if (matcher.matches()) { - for (int i=1;i<=matcher.groupCount();++i) { - context.getResult().addSon( - new MatchResultImpl( - baseHandlerName + "_" + i, - matcher.group(i), - new SmartPsiPointer(matchedElement), - matcher.start(i), - matcher.end(i), - target - ) - ); - } - return true; - } else { - return false; - } - } - - - public void setNodeTextGenerator(final NodeTextGenerator nodeTextGenerator) { - myNodeTextGenerator = nodeTextGenerator; - } - - public void setMultiline(boolean b) { - multiline = b; - compilePattern(); - } - - public boolean isWholeWords() { - return wholeWords; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java deleted file mode 100644 index 9310eb9e70a0..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptPredicate.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * @author Maxim.Mossienko - */ -public class ScriptPredicate extends AbstractStringBasedPredicate { - private final ScriptSupport scriptSupport; - - public ScriptPredicate(String name, String within) { - super(name, within); - scriptSupport = new ScriptSupport(within, name); - } - - public boolean match(PsiElement node, PsiElement match, int start, int end, MatchContext context) { - if (match == null) return false; - - return Boolean.TRUE.equals( - Boolean.valueOf(scriptSupport.evaluate( - context.hasResult() ? context.getResult() : null, - match - )) - ); - } - -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptSupport.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptSupport.java deleted file mode 100644 index e4136ede2831..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/ScriptSupport.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.StructuralSearchException; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.MatchResultImpl; -import groovy.lang.Binding; -import groovy.lang.GroovyRuntimeException; -import groovy.lang.GroovyShell; -import groovy.lang.Script; -import org.codehaus.groovy.control.CompilationFailedException; -import org.codehaus.groovy.control.ErrorCollector; -import org.codehaus.groovy.control.MultipleCompilationErrorsException; -import org.codehaus.groovy.control.messages.Message; -import org.codehaus.groovy.control.messages.SyntaxErrorMessage; -import org.codehaus.groovy.syntax.SyntaxException; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -/** - * @author Maxim.Mossienko - * Date: 11.06.2009 - * Time: 16:25:12 - */ -public class ScriptSupport { - private final Script script; - - public ScriptSupport(String text, String name) { - File scriptFile = new File(text); - GroovyShell shell = new GroovyShell(); - try { - script = scriptFile.exists() ? shell.parse(scriptFile):shell.parse(text, name); - } catch (Exception ex) { - Logger.getInstance(getClass().getName()).error(ex); - throw new RuntimeException(ex); - } - } - - public String evaluate(MatchResultImpl result, PsiElement context) { - try { - Binding binding = new Binding(); - - if (result != null) { - for(MatchResult r:result.getMatches()) { - binding.setVariable(r.getName(),r.getMatchRef().getElement()); - } - } - - if (context == null) { - context = result.getMatchRef().getElement(); - } - if (StructuralSearchUtil.isIdentifier(context)) context = context.getParent(); - binding.setVariable("__context__", context); - script.setBinding(binding); - - Object o = script.run(); - return String.valueOf(o); - } catch (GroovyRuntimeException ex) { - throw new StructuralSearchException(SSRBundle.message("groovy.script.error", ex.getMessage())); - } - } - - public static String checkValidScript(String scriptText) { - try { - final File scriptFile = new File(scriptText); - final GroovyShell shell = new GroovyShell(); - final Script script = scriptFile.exists() ? shell.parse(scriptFile) : shell.parse(scriptText); - return null; - } catch (IOException e) { - return e.getMessage(); - } catch (MultipleCompilationErrorsException e) { - final ErrorCollector errorCollector = e.getErrorCollector(); - final List<Message> errors = errorCollector.getErrors(); - for (Message error : errors) { - if (error instanceof SyntaxErrorMessage) { - final SyntaxErrorMessage errorMessage = (SyntaxErrorMessage)error; - final SyntaxException cause = errorMessage.getCause(); - return cause.getMessage(); - } - } - return e.getMessage(); - } catch (CompilationFailedException ex) { - return ex.getLocalizedMessage(); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/WithinPredicate.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/WithinPredicate.java deleted file mode 100644 index 3904eb397bce..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/predicates/WithinPredicate.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiElement; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.Matcher; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler; - -/** - * @author Maxim.Mossienko - */ -public class WithinPredicate extends AbstractStringBasedPredicate { - private final MatchOptions myMatchOptions; - private Matcher matcher; - - public WithinPredicate(String name, String within, Project project) { - super(name, within); - myMatchOptions = new MatchOptions(); - - myMatchOptions.setLooseMatching(true); - final String unquoted = StringUtil.stripQuotesAroundValue(within); - if (!unquoted.equals(within)) { - myMatchOptions.setSearchPattern(unquoted); - PatternCompiler.transformOldPattern(myMatchOptions); - matcher = new Matcher(project, myMatchOptions); - } else { - assert false; - } - } - - public boolean match(PsiElement node, PsiElement match, int start, int end, MatchContext context) { - final MatchResult result = matcher.isMatchedByDownUp(match, myMatchOptions); - return result != null; - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/strategies/MatchingStrategy.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/strategies/MatchingStrategy.java deleted file mode 100644 index 8f5b5bc2fc20..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/strategies/MatchingStrategy.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.strategies; - -import com.intellij.psi.PsiElement; - - -/** - * CommonStrategy of metching process - */ -public interface MatchingStrategy { - boolean continueMatching(PsiElement start); - - boolean shouldSkip(PsiElement element, PsiElement elementToMatchWith); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/strategies/XmlMatchingStrategy.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/strategies/XmlMatchingStrategy.java deleted file mode 100644 index b2ca87a176e8..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/impl/matcher/strategies/XmlMatchingStrategy.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.strategies; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.PsiElement; -import com.intellij.psi.XmlElementVisitor; -import com.intellij.psi.xml.XmlTag; - -/** - * Base filtering strategy to find statements - */ -public class XmlMatchingStrategy extends XmlElementVisitor implements MatchingStrategy,NodeFilter { - protected boolean result; - - @Override public void visitXmlTag(final XmlTag element) { - result = true; - } - - public boolean continueMatching(final PsiElement start) { - return accepts(start); - } - - @Override - public boolean shouldSkip(PsiElement element, PsiElement elementToMatchWith) { - return false; - } - - protected XmlMatchingStrategy() {} - - private static class XmlMatchingStrategyHolder { - private static final XmlMatchingStrategy instance = new XmlMatchingStrategy(); - } - - public static MatchingStrategy getInstance() { - return XmlMatchingStrategyHolder.instance; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspection.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspection.java deleted file mode 100644 index 7a38ddb2ea65..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspection.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.structuralsearch.inspection.highlightTemplate; - -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInspection.*; -import com.intellij.dupLocator.iterators.CountingNodeIterator; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; -import com.intellij.notification.Notifications; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.InvalidDataException; -import com.intellij.openapi.util.Pair; -import com.intellij.openapi.util.WriteExternalException; -import com.intellij.profile.codeInspection.InspectionProfileManager; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiElementVisitor; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.Matcher; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.StructuralSearchException; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.MatcherImpl; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.ConfigurationManager; -import com.intellij.structuralsearch.plugin.ui.SearchContext; -import com.intellij.util.PairProcessor; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; - -import javax.swing.*; -import java.util.*; - -/** - * @author cdr - */ -public class SSBasedInspection extends LocalInspectionTool { - static final String SHORT_NAME = "SSBasedInspection"; - private List<Configuration> myConfigurations = new ArrayList<Configuration>(); - private Set<String> myProblemsReported = new HashSet<String>(1); - - public void writeSettings(@NotNull Element node) throws WriteExternalException { - ConfigurationManager.writeConfigurations(node, myConfigurations, Collections.<Configuration>emptyList()); - } - - public void readSettings(@NotNull Element node) throws InvalidDataException { - myProblemsReported.clear(); - myConfigurations.clear(); - ConfigurationManager.readConfigurations(node, myConfigurations, new ArrayList<Configuration>()); - } - - @NotNull - public String getGroupDisplayName() { - return GENERAL_GROUP_NAME; - } - - @NotNull - public String getDisplayName() { - return SSRBundle.message("SSRInspection.display.name"); - } - - @NotNull - @NonNls - public String getShortName() { - return SHORT_NAME; - } - - @NotNull - @Override - public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) { - final MatcherImpl.CompiledOptions compiledOptions = - SSBasedInspectionCompiledPatternsCache.getCompiledOptions(holder.getProject()); - - if (compiledOptions == null) return super.buildVisitor(holder, isOnTheFly); - - return new PsiElementVisitor() { - final List<Pair<MatchContext,Configuration>> contexts = compiledOptions.getMatchContexts(); - final Matcher matcher = new Matcher(holder.getManager().getProject()); - final PairProcessor<MatchResult, Configuration> processor = new PairProcessor<MatchResult, Configuration>() { - public boolean process(MatchResult matchResult, Configuration configuration) { - PsiElement element = matchResult.getMatch(); - String name = configuration.getName(); - LocalQuickFix fix = createQuickFix(holder.getManager().getProject(), matchResult, configuration); - holder.registerProblem( - holder.getManager().createProblemDescriptor(element, name, fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly) - ); - return true; - } - }; - - @Override - public void visitElement(PsiElement element) { - if (LexicalNodesFilter.getInstance().accepts(element)) return; - final SsrFilteringNodeIterator matchedNodes = new SsrFilteringNodeIterator(element); - for (Pair<MatchContext, Configuration> pair : contexts) { - Configuration configuration = pair.second; - MatchContext context = pair.first; - - if (MatcherImpl.checkIfShouldAttemptToMatch(context, matchedNodes)) { - final int nodeCount = context.getPattern().getNodeCount(); - try { - matcher.processMatchesInElement(context, configuration, new CountingNodeIterator(nodeCount, matchedNodes), processor); - } - catch (StructuralSearchException e) { - if (myProblemsReported.add(configuration.getName())) { // don't overwhelm the user with messages - Notifications.Bus.notify(new Notification(SSRBundle.message("structural.search.title"), - SSRBundle.message("template.problem", configuration.getName()), - e.getMessage(), - NotificationType.ERROR), element.getProject()); - } - } - matchedNodes.reset(); - } - } - } - }; - } - - private static LocalQuickFix createQuickFix(final Project project, final MatchResult matchResult, final Configuration configuration) { - if (!(configuration instanceof ReplaceConfiguration)) return null; - ReplaceConfiguration replaceConfiguration = (ReplaceConfiguration)configuration; - final Replacer replacer = new Replacer(project, replaceConfiguration.getOptions()); - final ReplacementInfo replacementInfo = replacer.buildReplacement(matchResult); - - return new LocalQuickFix() { - @NotNull - public String getName() { - return SSRBundle.message("SSRInspection.replace.with", replacementInfo.getReplacement()); - } - - public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - PsiElement element = descriptor.getPsiElement(); - if (element != null && FileModificationService.getInstance().preparePsiElementsForWrite(element)) { - replacer.replace(replacementInfo); - } - } - - @NotNull - public String getFamilyName() { - return SSRBundle.message("SSRInspection.family.name"); - } - }; - } - - @Nullable - public JComponent createOptionsPanel() { - return new SSBasedInspectionOptions(myConfigurations){ - public void configurationsChanged(final SearchContext searchContext) { - super.configurationsChanged(searchContext); - SSBasedInspectionCompiledPatternsCache.precompileConfigurations(searchContext.getProject(), SSBasedInspection.this); - InspectionProfileManager.getInstance().fireProfileChanged(null); - } - }.getComponent(); - } - - @TestOnly - public void setConfigurations(final List<Configuration> configurations, final Project project) { - myConfigurations = configurations; - SSBasedInspectionCompiledPatternsCache.setCompiledOptions(project, configurations); - } - - public List<Configuration> getConfigurations() { - return myConfigurations; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspectionCompiledPatternsCache.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspectionCompiledPatternsCache.java deleted file mode 100644 index 2d6335fe10ce..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspectionCompiledPatternsCache.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.intellij.structuralsearch.inspection.highlightTemplate; - -import com.intellij.codeInspection.InspectionProfile; -import com.intellij.codeInspection.ex.InspectionToolWrapper; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.startup.StartupActivity; -import com.intellij.openapi.util.Key; -import com.intellij.profile.codeInspection.InspectionProjectProfileManager; -import com.intellij.structuralsearch.Matcher; -import com.intellij.structuralsearch.impl.matcher.MatcherImpl; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.TestOnly; - -import java.util.Collections; -import java.util.List; - -/** - * @author Eugene.Kudelevsky - */ -public class SSBasedInspectionCompiledPatternsCache implements StartupActivity { - private static final Key<MatcherImpl.CompiledOptions> COMPILED_OPTIONS_KEY = Key.create("SSR_INSPECTION_COMPILED_OPTIONS_KEY"); - - @Override - public void runActivity(@NotNull final Project project) { - precompileConfigurations(project, null); - } - - static void precompileConfigurations(final Project project, @Nullable final SSBasedInspection ssBasedInspection) { - if (project.isDisposed()) { - return; - } - final MatcherImpl.CompiledOptions currentCompiledOptions = getCompiledOptions(project); - - final SSBasedInspection inspection = ssBasedInspection != null ? ssBasedInspection : getInspection(project); - if (inspection == null) { - return; - } - - List<Configuration> configurations = inspection.getConfigurations(); - if (configurations == null) { - configurations = Collections.emptyList(); - } - - if ((currentCompiledOptions == null || currentCompiledOptions.getMatchContexts().isEmpty()) && - configurations.isEmpty()) { - return; - } - - final Matcher matcher = new Matcher(project); - final MatcherImpl.CompiledOptions compiledOptions = matcher.precompileOptions(configurations); - - if (compiledOptions != null) { - project.putUserData(COMPILED_OPTIONS_KEY, compiledOptions); - } - } - - @Nullable - private static SSBasedInspection getInspection(@NotNull Project project) { - final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile(); - final InspectionToolWrapper entry = profile.getInspectionTool(SSBasedInspection.SHORT_NAME, project); - - return entry == null ? null : (SSBasedInspection)entry.getTool(); - } - - @Nullable - static MatcherImpl.CompiledOptions getCompiledOptions(@NotNull Project project) { - return project.getUserData(COMPILED_OPTIONS_KEY); - } - - @TestOnly - static void setCompiledOptions(@NotNull Project project, @NotNull List<Configuration> configurations) { - final Matcher matcher = new Matcher(project); - project.putUserData(COMPILED_OPTIONS_KEY, - matcher.precompileOptions(configurations)); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspectionOptions.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspectionOptions.java deleted file mode 100644 index 8dd7211eefb4..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/inspection/highlightTemplate/SSBasedInspectionOptions.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.structuralsearch.inspection.highlightTemplate; - -import com.intellij.ide.DataManager; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.AnAction; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.DefaultActionGroup; -import com.intellij.openapi.ui.popup.JBPopupFactory; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceDialog; -import com.intellij.structuralsearch.plugin.ui.*; -import com.intellij.ui.AnActionButton; -import com.intellij.ui.AnActionButtonRunnable; -import com.intellij.ui.DoubleClickListener; -import com.intellij.ui.ToolbarDecorator; -import com.intellij.ui.components.JBList; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.util.Iterator; -import java.util.List; - -/** - * @author cdr - */ -public class SSBasedInspectionOptions { - private JBList myTemplatesList; - // for externalization - private final List<Configuration> myConfigurations; - - public SSBasedInspectionOptions(final List<Configuration> configurations) { - myConfigurations = configurations; - myTemplatesList = new JBList(new MyListModel()); - myTemplatesList.setCellRenderer(new DefaultListCellRenderer() { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - JLabel component = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - Configuration configuration = myConfigurations.get(index); - component.setText(configuration.getName()); - return component; - } - }); - } - - private static void copyConfiguration(final Configuration configuration, final Configuration newConfiguration) { - @NonNls Element temp = new Element("temp"); - configuration.writeExternal(temp); - newConfiguration.readExternal(temp); - } - - interface SearchDialogFactory { - SearchDialog createDialog(SearchContext searchContext); - } - - private void addTemplate(SearchDialogFactory searchDialogFactory) { - SearchDialog dialog = createDialog(searchDialogFactory); - dialog.show(); - if (!dialog.isOK()) return; - Configuration configuration = dialog.getConfiguration(); - - if (configuration.getName() == null || configuration.getName().equals(SearchDialog.USER_DEFINED)) { - String name = dialog.showSaveTemplateAsDialog(); - - if (name != null) { - name = ConfigurationManager.findAppropriateName(myConfigurations, name, dialog.getProject()); - } - if (name == null) return; - configuration.setName(name); - } - myConfigurations.add(configuration); - - configurationsChanged(dialog.getSearchContext()); - } - - private static SearchDialog createDialog(final SearchDialogFactory searchDialogFactory) { - SearchContext searchContext = createSearchContext(); - return searchDialogFactory.createDialog(searchContext); - } - - private static SearchContext createSearchContext() { - AnActionEvent event = new AnActionEvent(null, DataManager.getInstance().getDataContext(), - "", new DefaultActionGroup().getTemplatePresentation(), ActionManager.getInstance(), 0); - return SearchContext.buildFromDataContext(event.getDataContext()); - } - - public void configurationsChanged(final SearchContext searchContext) { - ((MyListModel)myTemplatesList.getModel()).fireContentsChanged(); - } - - public JPanel getComponent() { - JPanel panel = new JPanel(new BorderLayout()); - panel.add(new JLabel(SSRBundle.message("SSRInspection.selected.templates"))); - panel.add( - ToolbarDecorator.createDecorator(myTemplatesList) - .setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - final AnAction[] children = new AnAction[]{ - new AnAction(SSRBundle.message("SSRInspection.add.search.template.button")) { - @Override - public void actionPerformed(AnActionEvent e) { - addTemplate(new SearchDialogFactory() { - public SearchDialog createDialog(SearchContext searchContext) { - return new SearchDialog(searchContext, false, false); - } - }); - } - }, - new AnAction(SSRBundle.message("SSRInspection.add.replace.template.button")) { - @Override - public void actionPerformed(AnActionEvent e) { - addTemplate(new SearchDialogFactory() { - public SearchDialog createDialog(SearchContext searchContext) { - return new ReplaceDialog(searchContext, false, false); - } - }); - } - } - }; - JBPopupFactory.getInstance().createActionGroupPopup(null, new DefaultActionGroup(children), - DataManager.getInstance() - .getDataContext(button.getContextComponent()), - JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true) - .show(button.getPreferredPopupPoint()); - } - }).setEditAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - performEditAction(); - } - }).setRemoveAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - Object[] selected = myTemplatesList.getSelectedValues(); - for (Object o : selected) { - Configuration configuration = (Configuration)o; - Iterator<Configuration> iterator = myConfigurations.iterator(); - while (iterator.hasNext()) { - Configuration configuration1 = iterator.next(); - if (configuration1.getName().equals(configuration.getName())) { - iterator.remove(); - } - } - } - configurationsChanged(createSearchContext()); - } - }).setMoveUpAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - performMoveUpDown(false); - } - }).setMoveDownAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - performMoveUpDown(true); - } - }).createPanel() - ); - new DoubleClickListener() { - @Override - protected boolean onDoubleClick(MouseEvent e) { - performEditAction(); - return true; - } - }.installOn(myTemplatesList); - return panel; - } - - private void performMoveUpDown(boolean down) { - final int[] indices = myTemplatesList.getSelectedIndices(); - if (indices.length == 0) return; - final int delta = down ? 1 : -1; - myTemplatesList.removeSelectionInterval(0, myConfigurations.size() - 1); - for (int i = down ? indices[indices.length - 1] : 0; - down ? i >= 0 : i < indices.length; - i -= delta) { - final int index = indices[i]; - final Configuration temp = myConfigurations.get(index); - myConfigurations.set(index, myConfigurations.get(index + delta)); - myConfigurations.set(index + delta, temp); - myTemplatesList.addSelectionInterval(index + delta, index + delta); - } - final int index = down ? myTemplatesList.getMaxSelectionIndex() : myTemplatesList.getMinSelectionIndex(); - final Rectangle cellBounds = myTemplatesList.getCellBounds(index, index); - if (cellBounds != null) { - myTemplatesList.scrollRectToVisible(cellBounds); - } - } - - private void performEditAction() { - final Configuration configuration = (Configuration)myTemplatesList.getSelectedValue(); - if (configuration == null) return; - - SearchDialog dialog = createDialog(new SearchDialogFactory() { - public SearchDialog createDialog(SearchContext searchContext) { - if (configuration instanceof SearchConfiguration) { - return new SearchDialog(searchContext, false, false) { - public Configuration createConfiguration() { - SearchConfiguration newConfiguration = new SearchConfiguration(); - copyConfiguration(configuration, newConfiguration); - return newConfiguration; - } - }; - } - else { - return new ReplaceDialog(searchContext, false, false) { - public Configuration createConfiguration() { - ReplaceConfiguration newConfiguration = new ReplaceConfiguration(); - copyConfiguration(configuration, newConfiguration); - return newConfiguration; - } - }; - } - } - }); - dialog.setValuesFromConfig(configuration); - dialog.setUseLastConfiguration(true); - dialog.show(); - if (!dialog.isOK()) return; - Configuration newConfiguration = dialog.getConfiguration(); - copyConfiguration(newConfiguration, configuration); - configurationsChanged(dialog.getSearchContext()); - } - - private class MyListModel extends AbstractListModel { - public int getSize() { - return myConfigurations.size(); - } - - public Object getElementAt(int index) { - return index < myConfigurations.size() ? myConfigurations.get(index) : null; - } - - public void fireContentsChanged() { - fireContentsChanged(myTemplatesList, -1, -1); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralReplaceAction.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralReplaceAction.java deleted file mode 100644 index 33e7ac5b4d4d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralReplaceAction.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.intellij.structuralsearch.plugin; - -import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.project.Project; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceDialog; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchContext; - -/** - * Search and replace structural java code patterns action. - */ -public class StructuralReplaceAction extends AnAction { - - public StructuralReplaceAction() { - super(SSRBundle.message("structuralreplace.action")); - } - - /** Handles IDEA action event - * @param event the event of action - */ - public void actionPerformed(AnActionEvent event) { - triggerAction(null, SearchContext.buildFromDataContext(event.getDataContext())); - } - - public static void triggerAction(Configuration config, SearchContext searchContext) { - ReplaceDialog replaceDialog = new ReplaceDialog(searchContext); - - if (config!=null) { - replaceDialog.setUseLastConfiguration(true); - replaceDialog.setValuesFromConfig(config); - } - - replaceDialog.show(); - } - - /** Updates the state of the action - * @param event the action event - */ - public void update(AnActionEvent event) { - final Presentation presentation = event.getPresentation(); - final DataContext context = event.getDataContext(); - final Project project = CommonDataKeys.PROJECT.getData(context); - final StructuralSearchPlugin plugin = (project == null)? null:StructuralSearchPlugin.getInstance( project ); - - if (plugin== null || plugin.isSearchInProgress() || plugin.isReplaceInProgress() || plugin.isDialogVisible()) { - presentation.setEnabled( false ); - } else { - presentation.setEnabled( true ); - } - - super.update(event); - } -} - diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralSearchAction.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralSearchAction.java deleted file mode 100644 index 116f885b4679..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralSearchAction.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.intellij.structuralsearch.plugin; - -import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.project.Project; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchContext; -import com.intellij.structuralsearch.plugin.ui.SearchDialog; - -public class StructuralSearchAction extends AnAction { - - public StructuralSearchAction() { - super(SSRBundle.message("structuralsearch.action")); - } - - /** Handles IDEA action event - * @param event the event of action - */ - public void actionPerformed(AnActionEvent event) { - triggerAction(null, SearchContext.buildFromDataContext(event.getDataContext())); - } - - public static void triggerAction(Configuration config, SearchContext searchContext) { - //StructuralSearchPlugin.getInstance(searchContext.getProject()); - final SearchDialog searchDialog = new SearchDialog(searchContext); - - if (config!=null) { - searchDialog.setUseLastConfiguration(true); - searchDialog.setValuesFromConfig(config); - } - - searchDialog.show(); - } - - /** Updates the state of the action - * @param event the action event - */ - public void update(AnActionEvent event) { - final Presentation presentation = event.getPresentation(); - final DataContext context = event.getDataContext(); - final Project project = CommonDataKeys.PROJECT.getData(context); - final StructuralSearchPlugin plugin = project==null ? null:StructuralSearchPlugin.getInstance( project ); - - if (plugin == null || plugin.isSearchInProgress() || plugin.isDialogVisible()) { - presentation.setEnabled( false ); - } else { - presentation.setEnabled( true ); - } - - super.update(event); - } - -} - diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralSearchPlugin.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralSearchPlugin.java deleted file mode 100644 index 23de5efb9cde..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/StructuralSearchPlugin.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.intellij.structuralsearch.plugin; - -import com.intellij.openapi.components.ProjectComponent; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.structuralsearch.plugin.ui.ConfigurationManager; -import com.intellij.structuralsearch.plugin.ui.ExistingTemplatesComponent; -import org.jetbrains.annotations.NotNull; - -/** - * Structural search plugin main class. - */ -public final class StructuralSearchPlugin implements ProjectComponent, JDOMExternalizable { - private boolean searchInProgress; - private boolean replaceInProgress; - private boolean myDialogVisible; - private final ConfigurationManager myConfigurationManager = new ConfigurationManager(); - private ExistingTemplatesComponent myExistingTemplatesComponent; - - public boolean isSearchInProgress() { - return searchInProgress; - } - - public void setSearchInProgress(boolean searchInProgress) { - this.searchInProgress = searchInProgress; - } - - public boolean isReplaceInProgress() { - return replaceInProgress; - } - - public void setReplaceInProgress(boolean replaceInProgress) { - this.replaceInProgress = replaceInProgress; - } - - public boolean isDialogVisible() { - return myDialogVisible; - } - - public void setDialogVisible(boolean dialogVisible) { - myDialogVisible = dialogVisible; - } - - /** - * Method is called after plugin is already created and configured. Plugin can start to communicate with - * other plugins only in this method. - */ - public void initComponent() { - } - - /** - * This method is called on plugin disposal. - */ - public void disposeComponent() { - } - - /** - * Returns the name of component - * - * @return String representing component name. Use PluginName.ComponentName notation - * to avoid conflicts. - */ - @NotNull - public String getComponentName() { - return "StructuralSearchPlugin"; - } - - // Simple logging facility - - // Logs given string to IDEA logger - - private static class LoggerHolder { - private static final Logger logger = Logger.getInstance("Structural search"); - } - - public static void debug(String str) { - LoggerHolder.logger.info(str); - } - - public void readExternal(org.jdom.Element element) { - myConfigurationManager.loadConfigurations(element); - } - - public void writeExternal(org.jdom.Element element) { - myConfigurationManager.saveConfigurations(element); - } - - public void projectOpened() { - } - - public void projectClosed() { - } - - public static StructuralSearchPlugin getInstance(Project project) { - return project.getComponent(StructuralSearchPlugin.class); - } - - public ConfigurationManager getConfigurationManager() { - return myConfigurationManager; - } - - public ExistingTemplatesComponent getExistingTemplatesComponent() { - return myExistingTemplatesComponent; - } - - public void setExistingTemplatesComponent(ExistingTemplatesComponent existingTemplatesComponent) { - myExistingTemplatesComponent = existingTemplatesComponent; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ReplaceOptions.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ReplaceOptions.java deleted file mode 100644 index d18d51acd93c..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ReplaceOptions.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace; - -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.UserDataHolder; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.ReplacementVariableDefinition; -import gnu.trove.THashMap; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.util.*; - -/** - * @author Maxim.Mossienko - * Date: Mar 5, 2004 - * Time: 7:51:38 PM - */ -public class ReplaceOptions implements JDOMExternalizable, Cloneable, UserDataHolder { - private Map<String, ReplacementVariableDefinition> variableDefs; - private String replacement = ""; - private boolean toShortenFQN; - private boolean myToReformatAccordingToStyle; - private MatchOptions matchOptions = new MatchOptions(); - - @NonNls private static final String REFORMAT_ATTR_NAME = "reformatAccordingToStyle"; - @NonNls private static final String REPLACEMENT_ATTR_NAME = "replacement"; - @NonNls private static final String SHORTEN_FQN_ATTR_NAME = "shortenFQN"; - - private THashMap myUserMap = null; - @NonNls private static final String VARIABLE_DEFINITION_TAG_NAME = "variableDefinition"; - - public String getReplacement() { - return replacement; - } - - public void setReplacement(String replacement) { - this.replacement = replacement; - } - - public boolean isToShortenFQN() { - return toShortenFQN; - } - - public void setToShortenFQN(boolean shortedFQN) { - this.toShortenFQN = shortedFQN; - } - - public boolean isToReformatAccordingToStyle() { - return myToReformatAccordingToStyle; - } - - public MatchOptions getMatchOptions() { - return matchOptions; - } - - public void setMatchOptions(MatchOptions matchOptions) { - this.matchOptions = matchOptions; - } - - public void setToReformatAccordingToStyle(boolean reformatAccordingToStyle) { - myToReformatAccordingToStyle = reformatAccordingToStyle; - } - - public void readExternal(Element element) { - matchOptions.readExternal(element); - - Attribute attribute = element.getAttribute(REFORMAT_ATTR_NAME); - try { - myToReformatAccordingToStyle = attribute.getBooleanValue(); - } catch(DataConversionException ex) { - } - - attribute = element.getAttribute(SHORTEN_FQN_ATTR_NAME); - try { - toShortenFQN = attribute.getBooleanValue(); - } catch(DataConversionException ex) {} - - replacement = element.getAttributeValue(REPLACEMENT_ATTR_NAME); - - List<Element> elements = element.getChildren(VARIABLE_DEFINITION_TAG_NAME); - - if (elements!=null && elements.size() > 0) { - for (final Element element1 : elements) { - final ReplacementVariableDefinition variableDefinition = new ReplacementVariableDefinition(); - variableDefinition.readExternal(element1); - addVariableDefinition(variableDefinition); - } - } - } - - public void writeExternal(Element element) { - matchOptions.writeExternal(element); - - element.setAttribute(REFORMAT_ATTR_NAME,String.valueOf(myToReformatAccordingToStyle)); - element.setAttribute(SHORTEN_FQN_ATTR_NAME,String.valueOf(toShortenFQN)); - element.setAttribute(REPLACEMENT_ATTR_NAME,replacement); - - if (variableDefs!=null) { - for (final ReplacementVariableDefinition variableDefinition : variableDefs.values()) { - final Element infoElement = new Element(VARIABLE_DEFINITION_TAG_NAME); - element.addContent(infoElement); - variableDefinition.writeExternal(infoElement); - } - } - } - - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ReplaceOptions)) return false; - - final ReplaceOptions replaceOptions = (ReplaceOptions)o; - - if (myToReformatAccordingToStyle != replaceOptions.myToReformatAccordingToStyle) return false; - if (toShortenFQN != replaceOptions.toShortenFQN) return false; - if (matchOptions != null ? !matchOptions.equals(replaceOptions.matchOptions) : replaceOptions.matchOptions != null) return false; - if (replacement != null ? !replacement.equals(replaceOptions.replacement) : replaceOptions.replacement != null) return false; - if (variableDefs != null ? !variableDefs.equals(replaceOptions.variableDefs) : replaceOptions.variableDefs != null) { - return false; - } - - return true; - } - - public int hashCode() { - int result; - result = (replacement != null ? replacement.hashCode() : 0); - result = 29 * result + (toShortenFQN ? 1 : 0); - result = 29 * result + (myToReformatAccordingToStyle ? 1 : 0); - result = 29 * result + (matchOptions != null ? matchOptions.hashCode() : 0); - result = 29 * result + (variableDefs != null ? variableDefs.hashCode() : 0); - return result; - } - - public ReplaceOptions clone() { - try { - ReplaceOptions replaceOptions = (ReplaceOptions) super.clone(); - replaceOptions.matchOptions = matchOptions.clone(); - return replaceOptions; - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - return null; - } - } - - public <T> T getUserData(@NotNull Key<T> key) { - if (myUserMap==null) return null; - return (T)myUserMap.get(key); - } - - public <T> void putUserData(@NotNull Key<T> key, T value) { - if (myUserMap==null) myUserMap = new THashMap(1); - myUserMap.put(key,value); - } - - public ReplacementVariableDefinition getVariableDefinition(String name) { - return variableDefs != null ? variableDefs.get(name): null; - } - - public void addVariableDefinition(ReplacementVariableDefinition definition) { - if (variableDefs==null) { - variableDefs = new LinkedHashMap<String, ReplacementVariableDefinition>(); - } - variableDefs.put( definition.getName(), definition ); - } - - public Collection<ReplacementVariableDefinition> getReplacementVariableDefinitions() { - return variableDefs != null ? variableDefs.values() : Collections.<ReplacementVariableDefinition>emptyList(); - } - - public void clearVariableDefinitions() { - variableDefs = null; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ReplacementInfo.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ReplacementInfo.java deleted file mode 100644 index 6b74197c19dd..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ReplacementInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace; - -import com.intellij.psi.PsiElement; -import org.jetbrains.annotations.Nullable; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 03.12.2004 - * Time: 21:33:53 - * To change this template use File | Settings | File Templates. - */ -public abstract class ReplacementInfo { - public abstract String getReplacement(); - - public abstract void setReplacement(String replacement); - - @Nullable - public abstract PsiElement getMatch(int index); - - public abstract int getMatchesCount(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ParameterInfo.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ParameterInfo.java deleted file mode 100644 index 43ce859b17dd..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ParameterInfo.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.impl; - -import com.intellij.psi.PsiElement; - -public final class ParameterInfo { - private String name; - private int startIndex; - private boolean parameterContext; - private boolean methodParameterContext; - private boolean statementContext; - private boolean variableInitialContext; - private int afterDelimiterPos; - private boolean hasCommaBefore; - private int beforeDelimiterPos; - private boolean hasCommaAfter; - private boolean scopeParameterization; - private boolean replacementVariable; - private PsiElement myElement; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getStartIndex() { - return startIndex; - } - - public void setStartIndex(int startIndex) { - this.startIndex = startIndex; - } - - public boolean isParameterContext() { - return parameterContext; - } - - public void setParameterContext(boolean parameterContext) { - this.parameterContext = parameterContext; - } - - public boolean isMethodParameterContext() { - return methodParameterContext; - } - - public void setMethodParameterContext(boolean methodParameterContext) { - this.methodParameterContext = methodParameterContext; - } - - public boolean isStatementContext() { - return statementContext; - } - - public void setStatementContext(boolean statementContext) { - this.statementContext = statementContext; - } - - public boolean isVariableInitialContext() { - return variableInitialContext; - } - - public void setVariableInitialContext(boolean variableInitialContext) { - this.variableInitialContext = variableInitialContext; - } - - public int getAfterDelimiterPos() { - return afterDelimiterPos; - } - - public void setAfterDelimiterPos(int afterDelimiterPos) { - this.afterDelimiterPos = afterDelimiterPos; - } - - public boolean isHasCommaBefore() { - return hasCommaBefore; - } - - public void setHasCommaBefore(boolean hasCommaBefore) { - this.hasCommaBefore = hasCommaBefore; - } - - public int getBeforeDelimiterPos() { - return beforeDelimiterPos; - } - - public void setBeforeDelimiterPos(int beforeDelimiterPos) { - this.beforeDelimiterPos = beforeDelimiterPos; - } - - public boolean isHasCommaAfter() { - return hasCommaAfter; - } - - public void setHasCommaAfter(boolean hasCommaAfter) { - this.hasCommaAfter = hasCommaAfter; - } - - public boolean isScopeParameterization() { - return scopeParameterization; - } - - public void setScopeParameterization(boolean scopeParameterization) { - this.scopeParameterization = scopeParameterization; - } - - public boolean isReplacementVariable() { - return replacementVariable; - } - - public void setReplacementVariable(boolean replacementVariable) { - this.replacementVariable = replacementVariable; - } - - public PsiElement getElement() { - return myElement; - } - - public void setElement(PsiElement element) { - myElement = element; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementBuilder.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementBuilder.java deleted file mode 100644 index 81933d9c9a91..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementBuilder.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.impl; - -import com.intellij.codeInsight.template.Template; -import com.intellij.codeInsight.template.TemplateManager; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.*; -import com.intellij.structuralsearch.MalformedPatternException; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.impl.matcher.MatchResultImpl; -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; -import com.intellij.structuralsearch.impl.matcher.PatternTreeContext; -import com.intellij.structuralsearch.impl.matcher.predicates.ScriptSupport; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.util.IncorrectOperationException; - -import java.util.*; - -/** - * @author maxim - * Date: 24.02.2004 - * Time: 15:34:57 - */ -public final class ReplacementBuilder { - private String replacement; - private List<ParameterInfo> parameterizations; - private HashMap<String,MatchResult> matchMap; - private final Map<String, ScriptSupport> replacementVarsMap; - private final ReplaceOptions options; - //private Map<TextRange,ParameterInfo> scopedParameterizations; - - ReplacementBuilder(final Project project,final ReplaceOptions options) { - replacementVarsMap = new HashMap<String, ScriptSupport>(); - this.options = options; - String _replacement = options.getReplacement(); - FileType fileType = options.getMatchOptions().getFileType(); - - final Template template = TemplateManager.getInstance(project).createTemplate("","",_replacement); - - final int segmentsCount = template.getSegmentsCount(); - replacement = template.getTemplateText(); - - for(int i=0;i<segmentsCount;++i) { - final int offset = template.getSegmentOffset(i); - final String name = template.getSegmentName(i); - - final ParameterInfo info = new ParameterInfo(); - info.setStartIndex(offset); - info.setName(name); - info.setReplacementVariable(options.getVariableDefinition(name) != null); - - // find delimiter - int pos; - for(pos = offset-1; pos >=0 && pos < replacement.length() && Character.isWhitespace(replacement.charAt(pos));) { - --pos; - } - - if (pos >= 0) { - if (replacement.charAt(pos) == ',') { - info.setHasCommaBefore(true); - } - info.setBeforeDelimiterPos(pos); - } - - for(pos = offset; pos < replacement.length() && Character.isWhitespace(replacement.charAt(pos));) { - ++pos; - } - - if (pos < replacement.length()) { - final char ch = replacement.charAt(pos); - - if (ch == ';') { - info.setStatementContext(true); - } - else if (ch == ',' || ch == ')') { - info.setParameterContext(true); - info.setHasCommaAfter(ch == ','); - } - info.setAfterDelimiterPos(pos); - } - - if (parameterizations==null) { - parameterizations = new ArrayList<ParameterInfo>(); - } - - parameterizations.add(info); - } - - final StructuralSearchProfile profile = parameterizations != null ? StructuralSearchUtil.getProfileByFileType(fileType) : null; - if (profile != null) { - try { - final PsiElement[] elements = MatcherImplUtil.createTreeFromText( - _replacement, - PatternTreeContext.Block, - fileType, - options.getMatchOptions().getDialect(), - options.getMatchOptions().getPatternContext(), - project, - false - ); - if (elements.length > 0) { - final PsiElement patternNode = elements[0].getParent(); - profile.provideAdditionalReplaceOptions(patternNode, options, this); - } - } catch (IncorrectOperationException e) { - throw new MalformedPatternException(); - } - } - } - - private static void fill(MatchResult r,Map<String,MatchResult> m) { - if (r.getName()!=null) { - if (m.get(r.getName()) == null) { - m.put(r.getName(), r); - } - } - - if (!r.isScopeMatch() || !r.isMultipleMatch()) { - for (final MatchResult matchResult : r.getAllSons()) { - fill(matchResult, m); - } - } else if (r.hasSons()) { - final List<MatchResult> allSons = r.getAllSons(); - if (allSons.size() > 0) { - fill(allSons.get(0),m); - } - } - } - - String process(MatchResult match, ReplacementInfoImpl replacementInfo, FileType type) { - if (parameterizations==null) { - return replacement; - } - - final StringBuilder result = new StringBuilder(replacement); - matchMap = new HashMap<String,MatchResult>(); - fill(match, matchMap); - - int offset = 0; - - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(type); - - for (final ParameterInfo info : parameterizations) { - MatchResult r = matchMap.get(info.getName()); - if (info.isReplacementVariable()) { - offset = Replacer.insertSubstitution(result, offset, info, generateReplacement(info, match)); - } - else if (r != null) { - offset = profile != null ? profile.handleSubstitution(info, r, result, offset, matchMap) : StructuralSearchProfile.defaultHandleSubstitution(info, r, result, offset); - } - else { - if (info.isHasCommaBefore()) { - result.delete(info.getBeforeDelimiterPos() + offset, info.getBeforeDelimiterPos() + 1 + offset); - --offset; - } - else if (info.isHasCommaAfter()) { - result.delete(info.getAfterDelimiterPos() + offset, info.getAfterDelimiterPos() + 1 + offset); - --offset; - } - else if (info.isVariableInitialContext()) { - //if (info.afterDelimiterPos > 0) { - result.delete(info.getBeforeDelimiterPos() + offset, info.getAfterDelimiterPos() + offset - 1); - offset -= (info.getAfterDelimiterPos() - info.getBeforeDelimiterPos() - 1); - //} - } else if (profile != null) { - offset = profile.processAdditionalOptions(info, offset, result, r); - } - offset = Replacer.insertSubstitution(result, offset, info, ""); - } - } - - replacementInfo.variableMap = (HashMap<String, MatchResult>)matchMap.clone(); - matchMap.clear(); - return result.toString(); - } - - private String generateReplacement(ParameterInfo info, MatchResult match) { - ScriptSupport scriptSupport = replacementVarsMap.get(info.getName()); - - if (scriptSupport == null) { - String constraint = options.getVariableDefinition(info.getName()).getScriptCodeConstraint(); - scriptSupport = new ScriptSupport(StringUtil.stripQuotesAroundValue(constraint), info.getName()); - replacementVarsMap.put(info.getName(), scriptSupport); - } - return scriptSupport.evaluate((MatchResultImpl)match, null); - } - - public ParameterInfo findParameterization(String name) { - if (parameterizations==null) return null; - - for (final ParameterInfo info : parameterizations) { - - if (info.getName().equals(name)) { - return info; - } - } - - return null; - } - - public void clear() { - replacement = null; - - if (parameterizations!=null) { - parameterizations.clear(); - parameterizations = null; - } - } - - public void addParametrization(ParameterInfo e) { - assert parameterizations != null; - parameterizations.add(e); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementContext.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementContext.java deleted file mode 100644 index c77d0b7ce1f1..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementContext.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.impl; - -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNamedElement; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; - -import java.util.HashMap; -import java.util.Map; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: 27.09.2005 - * Time: 14:27:20 - * To change this template use File | Settings | File Templates. - */ -public class ReplacementContext { - ReplacementInfoImpl replacementInfo; - ReplaceOptions options; - Project project; - - public ReplaceOptions getOptions() { - return options; - } - - public Project getProject() { - return project; - } - - ReplacementContext(ReplaceOptions _options, Project _project) { - options = _options; - project = _project; - } - - public Map<String, String> getNewName2PatternNameMap() { - Map<String, String> newNameToSearchPatternNameMap = new HashMap<String, String>(1); - final Map<String, MatchResult> variableMap = replacementInfo.getVariableMap(); - - if (variableMap != null) { - for (String s : variableMap.keySet()) { - final MatchResult matchResult = replacementInfo.getVariableMap().get(s); - PsiElement match = matchResult.getMatchRef() != null ? matchResult.getMatch() : null; - if (StructuralSearchUtil.isIdentifier(match)) match = match.getParent(); - - if (match instanceof PsiNamedElement) { - final String name = ((PsiNamedElement)match).getName(); - - newNameToSearchPatternNameMap.put(name, s); - } - } - } - return newNameToSearchPatternNameMap; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementInfoImpl.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementInfoImpl.java deleted file mode 100644 index 318e88f27c24..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacementInfoImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.impl; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.SmartPsiElementPointer; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; -import org.jetbrains.annotations.Nullable; - -import java.util.List; -import java.util.Map; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 03.12.2004 - * Time: 21:33:53 - * To change this template use File | Settings | File Templates. - */ -public class ReplacementInfoImpl extends ReplacementInfo { - List<SmartPsiElementPointer> matchesPtrList; - String result; - MatchResult matchResult; - Map<String,MatchResult> variableMap; - Map<PsiElement,String> elementToVariableNameMap; - - public String getReplacement() { - return result; - } - - public void setReplacement(String replacement) { - result = replacement; - } - - @Nullable - @Override - public PsiElement getMatch(int index) { - return matchesPtrList.get(index).getElement(); - } - - @Override - public int getMatchesCount() { - return matchesPtrList.size(); - } - - public Map<String, MatchResult> getVariableMap() { - return variableMap; - } - - public MatchResult getMatchResult() { - return matchResult; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/Replacer.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/Replacer.java deleted file mode 100644 index 9980e95c77d7..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/Replacer.java +++ /dev/null @@ -1,424 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.impl; - -import com.intellij.codeInsight.template.Template; -import com.intellij.codeInsight.template.TemplateManager; -import com.intellij.lang.Language; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.command.CommandProcessor; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.*; -import com.intellij.psi.codeStyle.CodeStyleManager; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.structuralsearch.*; -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; -import com.intellij.structuralsearch.impl.matcher.PatternTreeContext; -import com.intellij.structuralsearch.impl.matcher.predicates.ScriptSupport; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; -import com.intellij.structuralsearch.plugin.util.CollectingMatchResultSink; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -/** - * @author Maxim.Mossienko - * Date: Mar 4, 2004 - * Time: 9:19:34 PM - */ -public class Replacer { - private final Project project; - private ReplacementBuilder replacementBuilder; - private ReplaceOptions options; - private ReplacementContext context; - private StructuralReplaceHandler replaceHandler; - - public Replacer(Project project, ReplaceOptions options) { - this.project = project; - this.options = options; - } - - public static String stripTypedVariableDecoration(final String type) { - return type.substring(1,type.length()-1); - } - - public static int insertSubstitution(StringBuilder result, int offset, final ParameterInfo info, String image) { - if (image.length() > 0) result.insert(offset+ info.getStartIndex(),image); - offset += image.length(); - return offset; - } - - public String testReplace(String in, String what, String by, ReplaceOptions options) throws IncorrectOperationException { - return testReplace(in, what, by, options,false); - } - - public String testReplace(String in, String what, String by, ReplaceOptions options, boolean filePattern) { - FileType type = options.getMatchOptions().getFileType(); - return testReplace(in, what, by, options, filePattern, false, type, null); - } - - public String testReplace(String in, String what, String by, ReplaceOptions options, boolean filePattern, boolean createPhysicalFile, - FileType sourceFileType, Language sourceDialect) { - this.options = options; - this.options.getMatchOptions().setSearchPattern(what); - this.options.setReplacement(by); - replacementBuilder=null; - context = null; - replaceHandler = null; - - this.options.getMatchOptions().clearVariableConstraints(); - MatcherImplUtil.transform(this.options.getMatchOptions()); - - checkSupportedReplacementPattern(project, options); - - Matcher matcher = new Matcher(project); - try { - PsiElement firstElement, lastElement, parent; - - if (options.getMatchOptions().getScope() == null) { - PsiElement[] elements = MatcherImplUtil.createTreeFromText( - in, - filePattern ? PatternTreeContext.File : PatternTreeContext.Block, - sourceFileType, sourceDialect, null, - project, - createPhysicalFile - ); - - firstElement = elements[0]; - lastElement = elements[elements.length-1]; - parent = firstElement.getParent(); - - this.options.getMatchOptions().setScope( - new LocalSearchScope(parent) - ); - } else { - parent = ((LocalSearchScope)options.getMatchOptions().getScope()).getScope()[0]; - firstElement = parent.getFirstChild(); - lastElement = parent.getLastChild(); - } - - this.options.getMatchOptions().setResultIsContextMatch(true); - CollectingMatchResultSink sink = new CollectingMatchResultSink(); - matcher.testFindMatches(sink, this.options.getMatchOptions()); - - final List<ReplacementInfo> resultPtrList = new ArrayList<ReplacementInfo>(); - - for (final MatchResult result : sink.getMatches()) { - resultPtrList.add(buildReplacement(result)); - } - - sink.getMatches().clear(); - - int startOffset = firstElement.getTextRange().getStartOffset(); - int endOffset = filePattern ?0: parent.getTextLength() - (lastElement.getTextRange().getEndOffset()); - - // get nodes from text may contain - PsiElement prevSibling = firstElement.getPrevSibling(); - if (prevSibling instanceof PsiWhiteSpace) { - startOffset -= prevSibling.getTextLength() - 1; - } - - PsiElement nextSibling = lastElement.getNextSibling(); - if (nextSibling instanceof PsiWhiteSpace) { - endOffset -= nextSibling.getTextLength() - 1; - } - - replaceAll(resultPtrList); - - String result = parent.getText(); - result = result.substring(startOffset); - result = result.substring(0,result.length() - endOffset); - - return result; - } - catch (Exception e) { - throw new IncorrectOperationException(e); - } - finally { - options.getMatchOptions().setScope(null); - } - } - - public void replaceAll(final List<ReplacementInfo> resultPtrList) { - PsiElement lastAffectedElement = null; - PsiElement currentAffectedElement; - - for (ReplacementInfo info : resultPtrList) { - PsiElement element = info.getMatch(0); - initContextAndHandler(element); - if (replaceHandler != null) { - replaceHandler.prepare(info); - } - } - - for (final ReplacementInfo aResultPtrList : resultPtrList) { - currentAffectedElement = doReplace(aResultPtrList); - - if (currentAffectedElement != lastAffectedElement) { - if (lastAffectedElement != null) reformatAndShortenRefs(lastAffectedElement); - lastAffectedElement = currentAffectedElement; - } - } - - reformatAndShortenRefs(lastAffectedElement); - } - - public void replace(ReplacementInfo info) { - PsiElement element = info.getMatch(0); - initContextAndHandler(element); - - if (replaceHandler != null) { - replaceHandler.prepare(info); - } - reformatAndShortenRefs(doReplace(info)); - } - - @Nullable - private PsiElement doReplace(final ReplacementInfo info) { - final ReplacementInfoImpl replacementInfo = (ReplacementInfoImpl)info; - final PsiElement element = replacementInfo.matchesPtrList.get(0).getElement(); - - if (element==null || !element.isWritable() || !element.isValid()) return null; - - final PsiElement elementParent = element.getParent(); - - //noinspection HardCodedStringLiteral - CommandProcessor.getInstance().executeCommand( - project, - new Runnable() { - public void run() { - ApplicationManager.getApplication().runWriteAction( - new Runnable() { - public void run() { - doReplace(element, replacementInfo); - } - } - ); - PsiDocumentManager.getInstance(project).commitAllDocuments(); - } - }, - "ssreplace", - "test" - ); - - if (!elementParent.isValid() || !elementParent.isWritable()) { - return null; - } - - return elementParent; - } - - private void reformatAndShortenRefs(final PsiElement elementParent) { - if (elementParent == null) return; - final Runnable action = new Runnable() { - public void run() { - CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(PsiManager.getInstance(project).getProject()); - final PsiFile containingFile = elementParent.getContainingFile(); - - if (containingFile != null && options.isToReformatAccordingToStyle()) { - if (containingFile.getVirtualFile() != null) { - PsiDocumentManager.getInstance(project) - .commitDocument(FileDocumentManager.getInstance().getDocument(containingFile.getVirtualFile())); - } - - final int parentOffset = elementParent.getTextRange().getStartOffset(); - - codeStyleManager.reformatRange(containingFile, parentOffset, parentOffset + elementParent.getTextLength(), true); - } - } - }; - - CommandProcessor.getInstance().executeCommand( - project, - new Runnable() { - public void run() { - ApplicationManager.getApplication().runWriteAction(action); - } - }, - "reformat and shorten refs after ssr", - "test" - ); - } - - private void doReplace(final PsiElement elementToReplace, - final ReplacementInfoImpl info) { - CodeStyleManager.getInstance(project).performActionWithFormatterDisabled(new Runnable() { - public void run() { - initContextAndHandler(elementToReplace); - - context.replacementInfo = info; - - if (replaceHandler != null) { - replaceHandler.replace(info, options); - } - } - } - ); - } - - private void initContextAndHandler(PsiElement psiContext) { - if (context == null) { - context = new ReplacementContext(options, project); - } - if (replaceHandler == null) { - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(psiContext); - if (profile != null) { - replaceHandler = profile.getReplaceHandler(this.context); - } - } - } - - public static void handleComments(final PsiElement el, final PsiElement replacement, ReplacementContext context) throws IncorrectOperationException { - ReplacementInfoImpl replacementInfo = context.replacementInfo; - if (replacementInfo.elementToVariableNameMap == null) { - replacementInfo.elementToVariableNameMap = new HashMap<PsiElement, String>(1); - Map<String, MatchResult> variableMap = replacementInfo.variableMap; - if (variableMap != null) { - for(String name:variableMap.keySet()) { - fill(name,replacementInfo.variableMap.get(name),replacementInfo.elementToVariableNameMap); - } - } - } - - PsiElement lastChild = el.getLastChild(); - if (lastChild instanceof PsiComment && - replacementInfo.elementToVariableNameMap.get(lastChild) == null && - !(replacement.getLastChild() instanceof PsiComment) - ) { - PsiElement firstElementAfterStatementEnd = lastChild; - for(PsiElement curElement=firstElementAfterStatementEnd.getPrevSibling();curElement!=null;curElement = curElement.getPrevSibling()) { - if (!(curElement instanceof PsiWhiteSpace) && !(curElement instanceof PsiComment)) break; - firstElementAfterStatementEnd = curElement; - } - replacement.addRangeAfter(firstElementAfterStatementEnd,lastChild,replacement.getLastChild()); - } - - final PsiElement firstChild = el.getFirstChild(); - if (firstChild instanceof PsiComment && - !(firstChild instanceof PsiDocCommentBase) && - replacementInfo.elementToVariableNameMap.get(firstChild) == null - ) { - PsiElement lastElementBeforeStatementStart = firstChild; - - for(PsiElement curElement=lastElementBeforeStatementStart.getNextSibling();curElement!=null;curElement = curElement.getNextSibling()) { - if (!(curElement instanceof PsiWhiteSpace) && !(curElement instanceof PsiComment)) break; - lastElementBeforeStatementStart = curElement; - } - replacement.addRangeBefore(firstChild,lastElementBeforeStatementStart,replacement.getFirstChild()); - } - } - - private static void fill(final String name, final MatchResult matchResult, final Map<PsiElement, String> elementToVariableNameMap) { - boolean b = matchResult.isMultipleMatch() || matchResult.isScopeMatch(); - if(matchResult.hasSons() && b) { - for(MatchResult r:matchResult.getAllSons()) { - fill(name, r, elementToVariableNameMap); - } - } else if (!b && matchResult.getMatchRef() != null) { - elementToVariableNameMap.put(matchResult.getMatch(),name); - } - } - - public static void checkSupportedReplacementPattern(Project project, ReplaceOptions options) throws UnsupportedPatternException { - try { - String search = options.getMatchOptions().getSearchPattern(); - String replacement = options.getReplacement(); - FileType fileType = options.getMatchOptions().getFileType(); - Template template = TemplateManager.getInstance(project).createTemplate("","",search); - Template template2 = TemplateManager.getInstance(project).createTemplate("","",replacement); - - int segmentCount = template2.getSegmentsCount(); - for(int i=0;i<segmentCount;++i) { - final String replacementSegmentName = template2.getSegmentName(i); - final int segmentCount2 = template.getSegmentsCount(); - int j; - - for(j=0;j<segmentCount2;++j) { - final String searchSegmentName = template.getSegmentName(j); - - if (replacementSegmentName.equals(searchSegmentName)) break; - - // Reference to - if (replacementSegmentName.startsWith(searchSegmentName) && - replacementSegmentName.charAt(searchSegmentName.length())=='_' - ) { - try { - Integer.parseInt(replacementSegmentName.substring(searchSegmentName.length()+1)); - break; - } catch(NumberFormatException ex) {} - } - } - - if (j==segmentCount2) { - ReplacementVariableDefinition definition = options.getVariableDefinition(replacementSegmentName); - - if (definition == null || definition.getScriptCodeConstraint().length() <= 2 /*empty quotes*/) { - throw new UnsupportedPatternException( - SSRBundle.message("replacement.variable.is.not.defined.message", replacementSegmentName) - ); - } else { - String message = ScriptSupport.checkValidScript(StringUtil.stripQuotesAroundValue(definition.getScriptCodeConstraint())); - if (message != null) { - throw new UnsupportedPatternException( - SSRBundle.message("replacement.variable.is.not.valid", replacementSegmentName, message) - ); - } - } - } - } - - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType); - - profile.checkReplacementPattern(project, options); - - } catch(IncorrectOperationException ex) { - throw new UnsupportedPatternException(SSRBundle.message("incorrect.pattern.message")); - } - } - - public ReplacementInfo buildReplacement(MatchResult result) { - List<SmartPsiElementPointer> l = new ArrayList<SmartPsiElementPointer>(); - SmartPointerManager manager = SmartPointerManager.getInstance(project); - - if (MatchResult.MULTI_LINE_MATCH.equals(result.getName())) { - for(Iterator<MatchResult> i=result.getAllSons().iterator();i.hasNext();) { - final MatchResult r = i.next(); - - if (MatchResult.LINE_MATCH.equals(r.getName())) { - PsiElement element = r.getMatchRef().getElement(); - - if (element instanceof PsiDocCommentBase) { // doc comment is not collapsed when created in block - if (i.hasNext()) { - MatchResult matchResult = i.next(); - - if (MatchResult.LINE_MATCH.equals(matchResult.getName()) && - StructuralSearchUtil.isDocCommentOwner(matchResult.getMatch())) { - element = matchResult.getMatch(); - } else { - l.add( manager.createSmartPsiElementPointer(element) ); - element = matchResult.getMatch(); - } - } - } - l.add( manager.createSmartPsiElementPointer(element) ); - } - } - } else { - l.add( manager.createSmartPsiElementPointer(result.getMatchRef().getElement())); - } - - ReplacementInfoImpl replacementInfo = new ReplacementInfoImpl(); - - replacementInfo.matchesPtrList = l; - if (replacementBuilder==null) { - replacementBuilder = new ReplacementBuilder(project,options); - } - replacementInfo.result = replacementBuilder.process(result, replacementInfo, options.getMatchOptions().getFileType()); - replacementInfo.matchResult = result; - - return replacementInfo; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacerUtil.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacerUtil.java deleted file mode 100644 index 365ec74bc01e..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/impl/ReplacerUtil.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.impl; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.psi.PsiComment; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiWhiteSpace; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; -import com.intellij.structuralsearch.impl.matcher.PatternTreeContext; - -/** - * @author Eugene.Kudelevsky - */ -public class ReplacerUtil { - private ReplacerUtil() { - } - - public static PsiElement[] createTreeForReplacement(String replacement, PatternTreeContext treeContext, ReplacementContext context) { - FileType fileType = context.getOptions().getMatchOptions().getFileType(); - return MatcherImplUtil.createTreeFromText(replacement, treeContext, fileType, context.getProject()); - } - - public static PsiElement copySpacesAndCommentsBefore(PsiElement elementToReplace, - PsiElement[] patternElements, - String replacementToMake, - PsiElement elementParent) { - int i = 0; - while (true) { // if it goes out of bounds then deep error happens - if (!(patternElements[i] instanceof PsiComment || patternElements[i] instanceof PsiWhiteSpace)) { - break; - } - ++i; - if (patternElements.length == i) { - break; - } - } - - if (patternElements.length == i) { - Logger logger = Logger.getInstance(StructuralSearchProfile.class.getName()); - logger.error("Unexpected replacement structure:" + replacementToMake); - } - - if (i != 0) { - elementParent.addRangeBefore(patternElements[0], patternElements[i - 1], elementToReplace); - } - return patternElements[i]; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceCommand.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceCommand.java deleted file mode 100644 index 32b99d76456d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.ui; - -import com.intellij.structuralsearch.plugin.ui.SearchCommand; -import com.intellij.structuralsearch.plugin.StructuralSearchPlugin; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.openapi.project.Project; -import com.intellij.usages.Usage; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 31, 2004 - * Time: 3:54:03 PM - * To change this template use File | Settings | File Templates. - */ -public class ReplaceCommand extends SearchCommand { - private final ReplaceOptions options; - - public ReplaceCommand(Project project, ReplaceUsageViewContext context) { - super( project, context ); - options = ((ReplaceConfiguration)context.getConfiguration()).getOptions(); - - } - - protected void findStarted() { - super.findStarted(); - - StructuralSearchPlugin.getInstance(project).setReplaceInProgress(true); - } - - protected void findEnded() { - StructuralSearchPlugin.getInstance(project).setReplaceInProgress( false ); - - super.findEnded(); - } - - protected void foundUsage(MatchResult result, Usage usage) { - super.foundUsage(result, usage); - - final ReplaceUsageViewContext replaceUsageViewContext = ((ReplaceUsageViewContext)context); - replaceUsageViewContext.addReplaceUsage(usage,replaceUsageViewContext.getReplacer().buildReplacement(result)); - } - - public ReplaceOptions getOptions() { - return options; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceConfiguration.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceConfiguration.java deleted file mode 100644 index fa9beaa36a23..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.ui; - -import org.jdom.Element; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.MatchOptions; - -/** - * @author Maxim.Mossienko - * Date: Apr 14, 2004 - * Time: 4:41:37 PM - */ -public class ReplaceConfiguration extends Configuration { - private final ReplaceOptions options = new ReplaceOptions(); - public static final String REPLACEMENT_VARIABLE_SUFFIX = "$replacement"; - - public ReplaceOptions getOptions() { - return options; - } - - public MatchOptions getMatchOptions() { - return options.getMatchOptions(); - } - - public void readExternal(Element element) { - super.readExternal(element); - options.readExternal(element); - } - - public void writeExternal(Element element) { - super.writeExternal(element); - options.writeExternal(element); - } - - public boolean equals(Object configuration) { - if (!super.equals(configuration)) return false; - if (configuration instanceof ReplaceConfiguration) { - return options.equals(((ReplaceConfiguration)configuration).options); - } - return false; - } - - public int hashCode() { - return options.hashCode(); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceDialog.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceDialog.java deleted file mode 100644 index 2ae0b18469fb..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceDialog.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.ui; - -import com.intellij.codeInsight.template.impl.Variable; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.ui.Splitter; -import com.intellij.structuralsearch.MalformedPatternException; -import com.intellij.structuralsearch.ReplacementVariableDefinition; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.UnsupportedPatternException; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.structuralsearch.plugin.ui.*; -import com.intellij.util.containers.hash.LinkedHashMap; - -import javax.swing.*; -import java.awt.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -// Class to show the user the request for search - -@SuppressWarnings({"RefusedBequest"}) -public class ReplaceDialog extends SearchDialog { - private Editor replaceCriteriaEdit; - private JCheckBox shortenFQN; - private JCheckBox formatAccordingToStyle; - - private String mySavedEditorText; - - protected String getDefaultTitle() { - return SSRBundle.message("structural.replace.title"); - } - - protected boolean isChanged(Configuration configuration) { - if (super.isChanged(configuration)) return true; - - String replacement; - - if (configuration instanceof ReplaceConfiguration) { - replacement = ((ReplaceConfiguration)configuration).getOptions().getReplacement(); - } - else { - replacement = configuration.getMatchOptions().getSearchPattern(); - } - - if (replacement == null) return false; - - return !replaceCriteriaEdit.getDocument().getText().equals(replacement); - } - - protected JComponent createEditorContent() { - JPanel result = new JPanel(new BorderLayout()); - Splitter p; - - result.add(BorderLayout.CENTER, p = new Splitter(true, 0.5f)); - p.setFirstComponent(super.createEditorContent()); - - replaceCriteriaEdit = createEditor(searchContext, mySavedEditorText != null ? mySavedEditorText : ""); - JPanel replace = new JPanel(new BorderLayout()); - replace.add(BorderLayout.NORTH, new JLabel(SSRBundle.message("replacement.template.label"))); - replace.add(BorderLayout.CENTER, replaceCriteriaEdit.getComponent()); - replaceCriteriaEdit.getComponent().setMinimumSize(new Dimension(150, 100)); - - p.setSecondComponent(replace); - - return result; - } - - protected int getRowsCount() { - return super.getRowsCount() + 1; - } - - protected String getDimensionServiceKey() { - return "#com.intellij.structuralsearch.plugin.replace.ui.ReplaceDialog"; - } - - protected void buildOptions(JPanel searchOptions) { - super.buildOptions(searchOptions); - searchOptions - .add(UIUtil.createOptionLine(shortenFQN = new JCheckBox(SSRBundle.message("shorten.fully.qualified.names.checkbox"), true))); - - searchOptions - .add(UIUtil.createOptionLine(formatAccordingToStyle = new JCheckBox(SSRBundle.message("format.according.to.style.checkbox"), true))); - - } - - protected UsageViewContext createUsageViewContext(Configuration configuration) { - return new ReplaceUsageViewContext(searchContext, configuration); - } - - public ReplaceDialog(SearchContext searchContext) { - super(searchContext); - } - - public ReplaceDialog(SearchContext searchContext, boolean showScope, boolean runFindActionOnClose) { - super(searchContext, showScope, runFindActionOnClose); - } - - - public Configuration createConfiguration() { - ReplaceConfiguration configuration = new ReplaceConfiguration(); - configuration.setName(USER_DEFINED); - return configuration; - } - - protected void disposeEditorContent() { - mySavedEditorText = replaceCriteriaEdit.getDocument().getText(); - EditorFactory.getInstance().releaseEditor(replaceCriteriaEdit); - super.disposeEditorContent(); - } - - public void setValuesFromConfig(Configuration configuration) { - //replaceCriteriaEdit.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, configuration); - - if (configuration instanceof ReplaceConfiguration) { - final ReplaceConfiguration config = (ReplaceConfiguration)configuration; - final ReplaceOptions options = config.getOptions(); - super.setValuesFromConfig(config); - - UIUtil.setContent(replaceCriteriaEdit, config.getOptions().getReplacement(), 0, replaceCriteriaEdit.getDocument().getTextLength(), - searchContext.getProject()); - - shortenFQN.setSelected(options.isToShortenFQN()); - formatAccordingToStyle.setSelected(options.isToReformatAccordingToStyle()); - - ReplaceOptions newReplaceOptions = ((ReplaceConfiguration)model.getConfig()).getOptions(); - newReplaceOptions.clearVariableDefinitions(); - - for (ReplacementVariableDefinition def : options.getReplacementVariableDefinitions()) { - newReplaceOptions.addVariableDefinition((ReplacementVariableDefinition)def.clone()); - } - } - else { - super.setValuesFromConfig(configuration); - - UIUtil.setContent(replaceCriteriaEdit, configuration.getMatchOptions().getSearchPattern(), 0, - replaceCriteriaEdit.getDocument().getTextLength(), searchContext.getProject()); - } - } - - protected void setValuesToConfig(Configuration config) { - super.setValuesToConfig(config); - - final ReplaceConfiguration replaceConfiguration = (ReplaceConfiguration)config; - final ReplaceOptions options = replaceConfiguration.getOptions(); - - options.setMatchOptions(replaceConfiguration.getMatchOptions()); - options.setReplacement(replaceCriteriaEdit.getDocument().getText()); - options.setToShortenFQN(shortenFQN.isSelected()); - options.setToReformatAccordingToStyle(formatAccordingToStyle.isSelected()); - } - - protected boolean isRecursiveSearchEnabled() { - return false; - } - - protected java.util.List<Variable> getVariablesFromListeners() { - ArrayList<Variable> vars = getVarsFrom(replaceCriteriaEdit); - List<Variable> searchVars = super.getVariablesFromListeners(); - Map<String, Variable> varsMap = new LinkedHashMap<String, Variable>(searchVars.size()); - - for(Variable var:searchVars) varsMap.put(var.getName(), var); - for(Variable var:vars) { - if (!varsMap.containsKey(var.getName())) { - String newVarName = var.getName() + ReplaceConfiguration.REPLACEMENT_VARIABLE_SUFFIX; - varsMap.put(newVarName, new Variable(newVarName, null, null, false, false)); - } - } - return new ArrayList<Variable>(varsMap.values()); - } - - protected boolean isValid() { - if (!super.isValid()) return false; - - try { - Replacer.checkSupportedReplacementPattern(searchContext.getProject(), ((ReplaceConfiguration)model.getConfig()).getOptions()); - } - catch (UnsupportedPatternException ex) { - reportMessage("unsupported.replacement.pattern.message", replaceCriteriaEdit, ex.getMessage()); - return false; - } - catch (MalformedPatternException ex) { - reportMessage("malformed.replacement.pattern.message", replaceCriteriaEdit, ex.getMessage()); - return false; - } - - return true; - } - - public void show() { - replaceCriteriaEdit.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, model.getConfig()); - - super.show(); - } - - protected boolean isReplaceDialog() { - return true; - } - - protected void addOrReplaceSelection(final String selection) { - super.addOrReplaceSelection(selection); - addOrReplaceSelectionForEditor(selection, replaceCriteriaEdit); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceUsageViewContext.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceUsageViewContext.java deleted file mode 100644 index 6a0d352d3284..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplaceUsageViewContext.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.ui; - -import com.intellij.history.LocalHistory; -import com.intellij.history.LocalHistoryAction; -import com.intellij.openapi.vfs.ReadonlyStatusHandler; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchCommand; -import com.intellij.structuralsearch.plugin.ui.SearchContext; -import com.intellij.structuralsearch.plugin.ui.UsageViewContext; -import com.intellij.usageView.UsageInfo; -import com.intellij.usages.Usage; -import com.intellij.usages.UsageInfo2UsageAdapter; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 9, 2005 - * Time: 4:37:08 PM - * To change this template use File | Settings | File Templates. - */ -class ReplaceUsageViewContext extends UsageViewContext { - private HashMap<Usage,ReplacementInfo> usage2ReplacementInfo; - private Replacer replacer; - - ReplaceUsageViewContext(final SearchContext context, final Configuration configuration) { - super(context,configuration); - } - - protected SearchCommand createCommand() { - ReplaceCommand command = new ReplaceCommand(mySearchContext.getProject(), this); - - usage2ReplacementInfo = new HashMap<Usage, ReplacementInfo>(); - replacer = new Replacer(mySearchContext.getProject(), ((ReplaceConfiguration)myConfiguration).getOptions()); - - return command; - } - - protected String _getPresentableText() { - return SSRBundle.message("replaceusageview.text", - getConfiguration().getMatchOptions().getSearchPattern(), - ((ReplaceConfiguration)getConfiguration()).getOptions().getReplacement() - ); - } - - public Replacer getReplacer() { - return replacer; - } - - public void addReplaceUsage(final Usage usage, final ReplacementInfo replacementInfo) { - usage2ReplacementInfo.put(usage,replacementInfo); - } - - private boolean isValid(UsageInfo2UsageAdapter info) { - final UsageInfo usageInfo = info.getUsageInfo(); - return !isExcluded(info) && usageInfo.getElement() != null && usageInfo.getElement().isValid(); - } - - @Override - protected void configureActions() { - final Runnable replaceRunnable = new Runnable() { - public void run() { - LocalHistoryAction labelAction = LocalHistory.getInstance().startAction(SSRBundle.message("structural.replace.title")); - - doReplace(); - getUsageView().close(); - - labelAction.finish(); - } - }; - - //noinspection HardCodedStringLiteral - getUsageView().addPerformOperationAction(replaceRunnable, "Replace All", null, SSRBundle.message("do.replace.all.button")); - - final Runnable replaceSelected = new Runnable() { - public void run() { - final Set<Usage> infos = getUsageView().getSelectedUsages(); - if (infos == null || infos.isEmpty()) return; - - LocalHistoryAction labelAction = LocalHistory.getInstance().startAction(SSRBundle.message("structural.replace.title")); - - for (final Usage info : infos) { - final UsageInfo2UsageAdapter usage = (UsageInfo2UsageAdapter)info; - - if (isValid(usage)) { - replaceOne(usage, false); - } - } - - labelAction.finish(); - - if (getUsageView().getUsagesCount() > 0) { - for (Usage usage : getUsageView().getSortedUsages()) { - if (!isExcluded(usage)) { - getUsageView().selectUsages(new Usage[]{usage}); - return; - } - } - } - } - }; - - getUsageView().addButtonToLowerPane(replaceSelected, SSRBundle.message("replace.selected.button")); - - final Runnable previewReplacement = new Runnable() { - public void run() { - Set<Usage> selection = getUsageView().getSelectedUsages(); - - if (selection != null && !selection.isEmpty()) { - UsageInfo2UsageAdapter usage = (UsageInfo2UsageAdapter)selection.iterator().next(); - - if (isValid(usage)) { - replaceOne(usage, true); - } - } - } - }; - - getUsageView().addButtonToLowerPane(previewReplacement, SSRBundle.message("preview.replacement.button")); - - super.configureActions(); - } - - private static void ensureFileWritable(final UsageInfo2UsageAdapter usage) { - final VirtualFile file = usage.getFile(); - - if (file != null && !file.isWritable()) { - ReadonlyStatusHandler.getInstance(usage.getElement().getProject()).ensureFilesWritable(file); - } - } - - private void replaceOne(UsageInfo2UsageAdapter info, boolean doConfirm) { - ReplacementInfo replacementInfo = usage2ReplacementInfo.get(info); - boolean approved; - - if (doConfirm) { - ReplacementPreviewDialog wrapper = - new ReplacementPreviewDialog(mySearchContext.getProject(), info.getUsageInfo(), replacementInfo.getReplacement()); - - wrapper.show(); - approved = wrapper.isOK(); - } - else { - approved = true; - } - - if (approved) { - ensureFileWritable(info); - getUsageView().removeUsage(info); - getReplacer().replace(replacementInfo); - - if (getUsageView().getUsagesCount() == 0) { - getUsageView().close(); - } - } - } - - private void doReplace() { - List<Usage> infos = getUsageView().getSortedUsages(); - List<ReplacementInfo> results = new ArrayList<ReplacementInfo>(infos.size()); - - for (final Usage info : infos) { - UsageInfo2UsageAdapter usage = (UsageInfo2UsageAdapter)info; - - if (isValid(usage)) { - results.add(usage2ReplacementInfo.get(usage)); - } - } - - getReplacer().replaceAll(results); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplacementPreviewDialog.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplacementPreviewDialog.java deleted file mode 100644 index 5bec5a920b45..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/replace/ui/ReplacementPreviewDialog.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.intellij.structuralsearch.plugin.replace.ui; - -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.colors.EditorColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.markup.HighlighterLayer; -import com.intellij.openapi.editor.markup.HighlighterTargetArea; -import com.intellij.openapi.editor.markup.RangeHighlighter; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.OpenFileDescriptor; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypes; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.util.Segment; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.util.PsiUtilCore; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.plugin.ui.UIUtil; -import com.intellij.usageView.UsageInfo; - -import javax.swing.*; -import java.awt.*; - -/** - * Navigates through the search results - */ -public final class ReplacementPreviewDialog extends DialogWrapper { - private final FileType myFileType; - private Editor replacement; - - private final Project project; - private RangeHighlighter hilighter; - private Editor editor; - - - public ReplacementPreviewDialog(final Project project, UsageInfo info, String replacementString) { - super(project,true); - - setTitle(SSRBundle.message("structural.replace.preview.dialog.title")); - setOKButtonText(SSRBundle.message("replace.preview.oktext")); - this.project = project; - final PsiElement element = info.getElement(); - final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element); - myFileType = virtualFile != null ? virtualFile.getFileType() : FileTypes.PLAIN_TEXT; - init(); - - Segment range = info.getSegment(); - hilight(virtualFile, range.getStartOffset(), range.getEndOffset()); - UIUtil.setContent(replacement, replacementString,0,-1,project); - - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(element); - if (profile != null) { - UIUtil.updateHighlighter(replacement, profile); - } - } - - private void hilight(VirtualFile file,int start, int end) { - removeHilighter(); - - editor = FileEditorManager.getInstance(project).openTextEditor( - new OpenFileDescriptor(project, file), - false - ); - hilighter = editor.getMarkupModel().addRangeHighlighter( - start, - end, - HighlighterLayer.SELECTION - 100, - EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES), - HighlighterTargetArea.EXACT_RANGE - ); - } - - private void removeHilighter() { - if (hilighter!=null && hilighter.isValid()) { - hilighter.dispose(); - hilighter = null; - editor = null; - } - } - - protected String getDimensionServiceKey() { - return "#com.intellij.strucuturalsearch.plugin.replace.ReplacementPreviewDialog"; - } - - protected JComponent createCenterPanel() { - JComponent centerPanel = new JPanel( new BorderLayout() ); - - PsiFile file = null; - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(myFileType); - if (profile != null) { - file = profile.createCodeFragment(project, "", null); - } - - if (file != null) { - final Document document = PsiDocumentManager.getInstance(project).getDocument(file); - replacement = UIUtil.createEditor(document, project, true, null); - DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(file,false); - } else { - final EditorFactory factory = EditorFactory.getInstance(); - final Document document = factory.createDocument(""); - replacement = factory.createEditor(document, project, myFileType, false); - } - - centerPanel.add(BorderLayout.NORTH,new JLabel(SSRBundle.message("replacement.code")) ); - centerPanel.add(BorderLayout.CENTER,replacement.getComponent() ); - centerPanel.setMaximumSize(new Dimension(640,480)); - - return centerPanel; - } - - public void dispose() { - final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(replacement.getDocument()); - if (file != null) { - DaemonCodeAnalyzer.getInstance(project).setHighlightingEnabled(file, true); - } - - EditorFactory.getInstance().releaseEditor(replacement); - removeHilighter(); - - super.dispose(); - } -} - diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/Configuration.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/Configuration.java deleted file mode 100644 index 440d33164f1d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/Configuration.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.openapi.util.JDOMExternalizable; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.structuralsearch.MatchOptions; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Apr 14, 2004 - * Time: 5:29:37 PM - * To change this template use File | Settings | File Templates. - */ -public abstract class Configuration implements JDOMExternalizable, Comparable<Configuration> { - public static final Configuration[] EMPTY_ARRAY = {}; - @NonNls protected static final String NAME_ATTRIBUTE_NAME = "name"; - private String name = ""; - private String category = null; - private boolean predefined; - - private static ConfigurationCreator configurationCreator; - - public String getName() { - return name; - } - - public void setName(String value) { - name = value; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public void readExternal(Element element) { - name = element.getAttributeValue(NAME_ATTRIBUTE_NAME); - } - - public void writeExternal(Element element) { - element.setAttribute(NAME_ATTRIBUTE_NAME,name); - } - - public boolean isPredefined() { - return predefined; - } - - public void setPredefined(boolean predefined) { - this.predefined = predefined; - } - - public abstract MatchOptions getMatchOptions(); - - @Override - public int compareTo(Configuration other) { - int result = StringUtil.naturalCompare(getCategory(), other.getCategory()); - return result != 0 ? result : StringUtil.naturalCompare(getName(), other.getName()); - } - - public boolean equals(Object configuration) { - if (!(configuration instanceof Configuration)) return false; - Configuration other = (Configuration)configuration; - if (category != null ? !category.equals(other.category) : other.category != null) { - return false; - } - return name.equals(other.name); - } - - public int hashCode() { - return getMatchOptions().hashCode(); - } - - public static void setActiveCreator(ConfigurationCreator creator) { - configurationCreator = creator; - } - - public static ConfigurationCreator getConfigurationCreator() { - return configurationCreator; - } - - @NonNls public static final String CONTEXT_VAR_NAME = "__context__"; -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ConfigurationCreator.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ConfigurationCreator.java deleted file mode 100644 index 74332fd72e74..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ConfigurationCreator.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Apr 21, 2004 - * Time: 7:46:16 PM - * To change this template use File | Settings | File Templates. - */ -public interface ConfigurationCreator { - Configuration createConfiguration(); -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ConfigurationManager.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ConfigurationManager.java deleted file mode 100644 index 151e78d6863f..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ConfigurationManager.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.icons.AllIcons; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.ui.NonEmptyInputValidator; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration; -import org.jdom.Element; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 10.02.2004 - * Time: 14:29:45 - * To change this template use File | Settings | File Templates. - */ -public class ConfigurationManager { - @NonNls static final String SEARCH_TAG_NAME = "searchConfiguration"; - @NonNls static final String REPLACE_TAG_NAME = "replaceConfiguration"; - @NonNls private static final String SAVE_HISTORY_ATTR_NAME = "history"; - - private List<Configuration> configurations; - private LinkedList<Configuration> historyConfigurations; - - public void addHistoryConfigurationToFront(Configuration configuration) { - if (historyConfigurations == null) historyConfigurations = new LinkedList<Configuration>(); - - if (historyConfigurations.indexOf(configuration) == -1) { - historyConfigurations.addFirst(configuration); - } - } - - public void removeHistoryConfiguration(Configuration configuration) { - if (historyConfigurations != null) { - historyConfigurations.remove(configuration); - } - } - - public void addConfiguration(Configuration configuration) { - if (configurations == null) configurations = new ArrayList<Configuration>(); - - if (configurations.indexOf(configuration) == -1) { - configurations.add(configuration); - } - } - - public void removeConfiguration(Configuration configuration) { - if (configurations != null) { - configurations.remove(configuration); - } - } - - public void saveConfigurations(Element element) { - writeConfigurations(element, configurations, historyConfigurations); - } - - public static void writeConfigurations(final Element element, - final Collection<Configuration> configurations, - final Collection<Configuration> historyConfigurations) { - if (configurations != null) { - for (final Configuration configuration : configurations) { - saveConfiguration(element, configuration); - } - } - - if (historyConfigurations != null) { - for (final Configuration historyConfiguration : historyConfigurations) { - final Element infoElement = saveConfiguration(element, historyConfiguration); - infoElement.setAttribute(SAVE_HISTORY_ATTR_NAME, "1"); - } - } - } - - public static Element saveConfiguration(Element element, final Configuration config) { - Element infoElement = new Element(config instanceof SearchConfiguration ? SEARCH_TAG_NAME : REPLACE_TAG_NAME); - element.addContent(infoElement); - config.writeExternal(infoElement); - - return infoElement; - } - - public void loadConfigurations(Element element) { - if (configurations != null) return; - ArrayList<Configuration> configurations = new ArrayList<Configuration>(); - ArrayList<Configuration> historyConfigurations = new ArrayList<Configuration>(); - readConfigurations(element, configurations, historyConfigurations); - for (Configuration configuration : historyConfigurations) { - addHistoryConfigurationToFront(configuration); - } - for (Configuration configuration : configurations) { - addConfiguration(configuration); - } - if (this.historyConfigurations != null) { - Collections.reverse(this.historyConfigurations); - } - } - - public static void readConfigurations(final Element element, @NotNull Collection<Configuration> configurations, @NotNull Collection<Configuration> historyConfigurations) { - final List<Element> patterns = element.getChildren(); - - if (patterns != null && patterns.size() > 0) { - for (final Element pattern : patterns) { - final Configuration config = readConfiguration(pattern); - if (config == null) continue; - - if (pattern.getAttribute(SAVE_HISTORY_ATTR_NAME) != null) { - historyConfigurations.add(config); - } - else { - configurations.add(config); - } - } - } - } - - public static Configuration readConfiguration(final Element childElement) { - String s = childElement.getName(); - final Configuration config = - s.equals(SEARCH_TAG_NAME) ? new SearchConfiguration() : s.equals(REPLACE_TAG_NAME) ? new ReplaceConfiguration():null; - if (config != null) config.readExternal(childElement); - return config; - } - - public Collection<Configuration> getConfigurations() { - return configurations; - } - - public static Configuration findConfigurationByName(final Collection<Configuration> configurations, final String name) { - for(Configuration config:configurations) { - if (config.getName().equals(name)) return config; - } - - return null; - } - - public Collection<Configuration> getHistoryConfigurations() { - return historyConfigurations; - } - - public static @Nullable String findAppropriateName(@NotNull final Collection<Configuration> configurations, @NotNull String _name, - @NotNull final Project project) { - Configuration config; - String name = _name; - - while ((config = findConfigurationByName(configurations, name)) != null) { - int i = Messages.showYesNoDialog( - project, - SSRBundle.message("overwrite.message"), - SSRBundle.message("overwrite.title"), - AllIcons.General.QuestionDialog - ); - - if (i == Messages.YES) { - configurations.remove(config); - break; - } - name = showSaveTemplateAsDialog(name, project); - if (name == null) break; - } - return name; - } - - public static @Nullable String showSaveTemplateAsDialog(@NotNull String initial, @NotNull Project project) { - return Messages.showInputDialog( - project, - SSRBundle.message("template.name.button"), - SSRBundle.message("save.template.description.button"), - AllIcons.General.QuestionDialog, - initial, - new NonEmptyInputValidator() - ); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/DialogBase.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/DialogBase.java deleted file mode 100644 index 83d93ba0d05c..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/DialogBase.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.openapi.MnemonicHelper; -import com.intellij.CommonBundle; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.awt.event.InputEvent; -import java.awt.*; - -import org.jetbrains.annotations.NonNls; - -/** - * Base dialog class - */ -public abstract class DialogBase extends JDialog { - private JButton ok; - private JButton cancel; - - private Action okAction; - private Action cancelAction; - private static Rectangle virtualBounds; - - class OkAction extends AbstractAction { - OkAction() { - putValue(NAME, CommonBundle.getOkButtonText()); - } - public void actionPerformed(ActionEvent e) { - doOKAction(); - } - } - - class CancelAction extends AbstractAction { - CancelAction() { - putValue(NAME,CommonBundle.getCancelButtonText()); - } - - public void actionPerformed(ActionEvent e) { - doCancelAction(); - } - } - - protected DialogBase() { - this(null); - } - - protected DialogBase(Frame frame) { - this(frame,true); - } - - protected DialogBase(Frame frame,boolean modal) { - super(frame,modal); - - new MnemonicHelper().register(getContentPane()); - - okAction = new OkAction(); - cancelAction = new CancelAction(); - - ok = createJButtonForAction(okAction); - cancel = createJButtonForAction(cancelAction); - - if (virtualBounds == null) { - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - GraphicsDevice[] gs = ge.getScreenDevices(); - virtualBounds = new Rectangle(); - - for (int j = 0; j < gs.length; j++) { - GraphicsDevice gd = gs[j]; - GraphicsConfiguration[] gc = gd.getConfigurations(); - - for (int i=0; i < gc.length; i++) { - virtualBounds = virtualBounds.union(gc[i].getBounds()); - } - } - } - - @NonNls String cancelCommandName = "close"; - KeyStroke escKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0); - ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escKeyStroke, cancelCommandName); - ok.getActionMap().put(cancelCommandName, cancelAction); - - @NonNls String startCommandName = "start"; - KeyStroke enterKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,InputEvent.CTRL_MASK); - ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(enterKeyStroke, startCommandName); - ok.getActionMap().put(startCommandName, okAction); - } - - protected JButton getCancelButton() { - return cancel; - } - - protected JButton getOkButton() { - return ok; - } - - protected abstract JComponent createCenterPanel(); - - protected JComponent createSouthPanel() { - JPanel p = new JPanel( null ); - p.setLayout( new BoxLayout(p,BoxLayout.X_AXIS) ); - p.add(Box.createHorizontalGlue()); - p.add(getOkButton()); - p.add(getCancelButton()); - return p; - } - - public void init() { - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(BorderLayout.CENTER,createCenterPanel()); - getContentPane().add(BorderLayout.SOUTH,createSouthPanel()); - pack(); - - Dimension dim = getPreferredSize(); - setLocation( - (int)(virtualBounds.getWidth()/2 - dim.getWidth()/2), - (int)(virtualBounds.getHeight()/2 - dim.getHeight()/2) - ); - } - - public void show() { - pack(); - super.show(); - } - - protected void doCancelAction() { - setVisible(false); - } - - protected void doOKAction() { - setVisible(false); - } - - protected void setOKActionEnabled(boolean b) { - okAction.setEnabled(b); - } - - protected void setOKButtonText(String text) { - okAction.putValue(Action.NAME,text); - } - - protected void setCancelButtonText(String text) { - cancelAction.putValue(Action.NAME,text); - } - - protected JButton createJButtonForAction(Action _action) { - JButton jb = new JButton( (String)_action.getValue(Action.NAME) ); - jb.setAction(_action); - - return jb; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java deleted file mode 100644 index 368240ff50be..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/EditVarConstraintsDialog.java +++ /dev/null @@ -1,635 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.codeInsight.template.impl.Variable; -import com.intellij.find.impl.RegExHelpPopup; -import com.intellij.ide.highlighter.HighlighterFactory; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.EditorSettings; -import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager; -import com.intellij.openapi.editor.event.DocumentAdapter; -import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.FileTypeManager; -import com.intellij.openapi.fileTypes.FileTypes; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.help.HelpManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.ComponentWithBrowseButton; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.ui.popup.JBPopup; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiFileFactory; -import com.intellij.structuralsearch.MatchVariableConstraint; -import com.intellij.structuralsearch.NamedScriptableDefinition; -import com.intellij.structuralsearch.ReplacementVariableDefinition; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.impl.matcher.predicates.ScriptSupport; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration; -import com.intellij.ui.ComboboxWithBrowseButton; -import com.intellij.ui.EditorTextField; -import com.intellij.ui.components.labels.LinkLabel; -import com.intellij.ui.components.labels.LinkListener; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.text.BadLocationException; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; -import java.util.regex.Pattern; -import java.util.regex.PatternSyntaxException; - -/** - * @author Maxim.Mossienko - * Date: Mar 25, 2004 - * Time: 1:52:18 PM - */ -class EditVarConstraintsDialog extends DialogWrapper { - private static final Logger LOG = Logger.getInstance("#com.intellij.structuralsearch.plugin.ui.EditVarConstraintsDialog"); - - private JTextField maxoccurs; - private JCheckBox applyWithinTypeHierarchy; - private JCheckBox notRegexp; - private EditorTextField regexp; - private JTextField minoccurs; - private JPanel mainForm; - private JCheckBox notWrite; - private JCheckBox notRead; - private JCheckBox write; - private JCheckBox read; - private JList parameterList; - private JCheckBox partOfSearchResults; - private JCheckBox notExprType; - private EditorTextField regexprForExprType; - private final SearchModel model; - private JCheckBox exprTypeWithinHierarchy; - - private final List<Variable> variables; - private Variable current; - private JCheckBox wholeWordsOnly; - private JCheckBox formalArgTypeWithinHierarchy; - private JCheckBox invertFormalArgType; - private EditorTextField formalArgType; - private ComponentWithBrowseButton<EditorTextField> customScriptCode; - private JCheckBox maxoccursUnlimited; - - private ComboboxWithBrowseButton withinCombo; - private JPanel containedInConstraints; - private JCheckBox invertWithinIn; - private JPanel expressionConstraints; - private JPanel occurencePanel; - private JPanel textConstraintsPanel; - private JLabel myRegExHelpLabel; - - private static Project myProject; - - EditVarConstraintsDialog(final Project project,SearchModel _model,List<Variable> _variables, boolean replaceContext, FileType fileType) { - super(project, false); - - variables = _variables; - model = _model; - - setTitle(SSRBundle.message("editvarcontraints.edit.variables")); - - regexp.getDocument().addDocumentListener(new MyDocumentListener(notRegexp, applyWithinTypeHierarchy, wholeWordsOnly)); - read.addChangeListener(new MyChangeListener(notRead, false)); - write.addChangeListener(new MyChangeListener(notWrite, false)); - regexprForExprType.getDocument().addDocumentListener(new MyDocumentListener(exprTypeWithinHierarchy, notExprType)); - formalArgType.getDocument().addDocumentListener(new MyDocumentListener(formalArgTypeWithinHierarchy, invertFormalArgType)); - - partOfSearchResults.setEnabled(!replaceContext); // todo: this doesn't do anything - containedInConstraints.setVisible(false); - withinCombo.getComboBox().setEditable(true); - - withinCombo.getButton().addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - final SelectTemplateDialog dialog = new SelectTemplateDialog(project, false, false); - dialog.show(); - if (dialog.getExitCode() == OK_EXIT_CODE) { - final Configuration[] selectedConfigurations = dialog.getSelectedConfigurations(); - if (selectedConfigurations.length == 1) { - withinCombo.getComboBox().getEditor().setItem(selectedConfigurations[0].getMatchOptions().getSearchPattern()); // TODO: - } - } - } - }); - - boolean hasContextVar = false; - for(Variable var:variables) { - if (Configuration.CONTEXT_VAR_NAME.equals(var.getName())) { - hasContextVar = true; break; - } - } - - if (!hasContextVar) { - variables.add(new Variable(Configuration.CONTEXT_VAR_NAME, "", "", true)); - } - - if (fileType == StdFileTypes.JAVA) { - - formalArgTypeWithinHierarchy.setEnabled(true); - invertFormalArgType.setEnabled(true); - formalArgType.setEnabled(true); - - exprTypeWithinHierarchy.setEnabled(true); - notExprType.setEnabled(true); - regexprForExprType.setEnabled(true); - - read.setEnabled(true); - notRead.setEnabled(false); - write.setEnabled(true); - notWrite.setEnabled(false); - - applyWithinTypeHierarchy.setEnabled(true); - } else { - formalArgTypeWithinHierarchy.setEnabled(false); - invertFormalArgType.setEnabled(false); - formalArgType.setEnabled(false); - - exprTypeWithinHierarchy.setEnabled(false); - notExprType.setEnabled(false); - regexprForExprType.setEnabled(false); - - read.setEnabled(false); - notRead.setEnabled(false); - write.setEnabled(false); - notWrite.setEnabled(false); - - applyWithinTypeHierarchy.setEnabled(false); - } - - parameterList.setModel( - new AbstractListModel() { - public Object getElementAt(int index) { - return variables.get(index); - } - - public int getSize() { - return variables.size(); - } - } - ); - - parameterList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); - - parameterList.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - boolean rollingBackSelection; - - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting()) return; - if (rollingBackSelection) { - rollingBackSelection=false; - return; - } - final Variable var = variables.get(parameterList.getSelectedIndex()); - if (validateParameters()) { - if (current!=null) copyValuesFromUI(current); - ApplicationManager.getApplication().runWriteAction(new Runnable() { public void run() { copyValuesToUI(var); }}); - current = var; - } else { - rollingBackSelection = true; - parameterList.setSelectedIndex(e.getFirstIndex()==parameterList.getSelectedIndex()?e.getLastIndex():e.getFirstIndex()); - } - } - } - ); - - parameterList.setCellRenderer( - new DefaultListCellRenderer() { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - String name = ((Variable)value).getName(); - if (Configuration.CONTEXT_VAR_NAME.equals(name)) name = SSRBundle.message("complete.match.variable.name"); - if (isReplacementVariable(name)) { - name = stripReplacementVarDecoration(name); - } - return super.getListCellRendererComponent(list, name, index, isSelected, cellHasFocus); - } - } - ); - - maxoccursUnlimited.addChangeListener(new MyChangeListener(maxoccurs, true)); - - customScriptCode.getButton().addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent e) { - final EditScriptDialog dialog = new EditScriptDialog(project, customScriptCode.getChildComponent().getText()); - dialog.show(); - if (dialog.getExitCode() == OK_EXIT_CODE) { - customScriptCode.getChildComponent().setText(dialog.getScriptText()); - } - } - }); - init(); - - if (variables.size() > 0) parameterList.setSelectedIndex(0); - } - - private static String stripReplacementVarDecoration(String name) { - name = name.substring(0, name.length() - ReplaceConfiguration.REPLACEMENT_VARIABLE_SUFFIX.length()); - return name; - } - - private static boolean isReplacementVariable(String name) { - return name.endsWith(ReplaceConfiguration.REPLACEMENT_VARIABLE_SUFFIX); - } - - private boolean validateParameters() { - return validateRegExp(regexp) && validateRegExp(regexprForExprType) && - validateIntOccurence(minoccurs) && - validateScript(customScriptCode.getChildComponent()) && - (maxoccursUnlimited.isSelected() || validateIntOccurence(maxoccurs)); - } - - protected JComponent createCenterPanel() { - return mainForm; - } - - protected void doOKAction() { - if(validateParameters()) { - if (current!=null) copyValuesFromUI(current); - super.doOKAction(); - } - } - - void copyValuesFromUI(Variable var) { - String varName = var.getName(); - Configuration configuration = model.getConfig(); - - if (isReplacementVariable(varName)) { - saveScriptInfo(getOrAddReplacementVariableDefinition(varName, configuration)); - return; - } - - MatchVariableConstraint varInfo = getOrAddVariableConstraint(varName, configuration); - - varInfo.setInvertReadAccess(notRead.isSelected()); - varInfo.setReadAccess(read.isSelected()); - varInfo.setInvertWriteAccess(notWrite.isSelected()); - varInfo.setWriteAccess(write.isSelected()); - varInfo.setRegExp(regexp.getDocument().getText()); - varInfo.setInvertRegExp(notRegexp.isSelected()); - - int minCount = Integer.parseInt( minoccurs.getText() ); - varInfo.setMinCount(minCount); - - int maxCount; - if (maxoccursUnlimited.isSelected()) maxCount = Integer.MAX_VALUE; - else maxCount = Integer.parseInt( maxoccurs.getText() ); - - varInfo.setMaxCount(maxCount); - varInfo.setWithinHierarchy(applyWithinTypeHierarchy.isSelected()); - varInfo.setInvertRegExp(notRegexp.isSelected()); - - varInfo.setPartOfSearchResults(partOfSearchResults.isEnabled() && partOfSearchResults.isSelected()); - - varInfo.setInvertExprType(notExprType.isSelected()); - varInfo.setNameOfExprType(regexprForExprType.getDocument().getText()); - varInfo.setExprTypeWithinHierarchy(exprTypeWithinHierarchy.isSelected()); - varInfo.setWholeWordsOnly(wholeWordsOnly.isSelected()); - varInfo.setInvertFormalType(invertFormalArgType.isSelected()); - varInfo.setFormalArgTypeWithinHierarchy(formalArgTypeWithinHierarchy.isSelected()); - varInfo.setNameOfFormalArgType(formalArgType.getDocument().getText()); - saveScriptInfo(varInfo); - - final String withinConstraint = (String)withinCombo.getComboBox().getEditor().getItem(); - varInfo.setWithinConstraint(withinConstraint.length() > 0 ? "\"" + withinConstraint +"\"":""); - varInfo.setInvertWithinConstraint(invertWithinIn.isSelected()); - } - - private static MatchVariableConstraint getOrAddVariableConstraint(String varName, Configuration configuration) { - MatchVariableConstraint varInfo = configuration.getMatchOptions().getVariableConstraint(varName); - - if (varInfo == null) { - varInfo = new MatchVariableConstraint(); - varInfo.setName(varName); - configuration.getMatchOptions().addVariableConstraint(varInfo); - } - return varInfo; - } - - private static ReplacementVariableDefinition getOrAddReplacementVariableDefinition(String varName, Configuration configuration) { - ReplaceOptions replaceOptions = ((ReplaceConfiguration)configuration).getOptions(); - String realVariableName = stripReplacementVarDecoration(varName); - ReplacementVariableDefinition variableDefinition = replaceOptions.getVariableDefinition(realVariableName); - - if (variableDefinition == null) { - variableDefinition = new ReplacementVariableDefinition(); - variableDefinition.setName(realVariableName); - replaceOptions.addVariableDefinition(variableDefinition); - } - return variableDefinition; - } - - private void saveScriptInfo(NamedScriptableDefinition varInfo) { - varInfo.setScriptCodeConstraint("\"" + customScriptCode.getChildComponent().getText() + "\""); - } - - private void copyValuesToUI(Variable var) { - Configuration configuration = model.getConfig(); - String varName = var.getName(); - - if (isReplacementVariable(varName)) { - ReplacementVariableDefinition definition = ((ReplaceConfiguration)configuration).getOptions().getVariableDefinition( - stripReplacementVarDecoration(varName) - ); - - restoreScriptCode(definition); - setSearchConstraintsVisible(false); - return; - } else { - setSearchConstraintsVisible(true); - } - - MatchVariableConstraint varInfo = configuration.getMatchOptions().getVariableConstraint(varName); - - if (varInfo == null) { - notRead.setSelected(false); - notRegexp.setSelected(false); - read.setSelected(false); - notWrite.setSelected(false); - write.setSelected(false); - regexp.getDocument().setText(""); - - minoccurs.setText("1"); - maxoccurs.setText("1"); - maxoccursUnlimited.setSelected(false); - applyWithinTypeHierarchy.setSelected(false); - partOfSearchResults.setSelected(false); - - regexprForExprType.getDocument().setText(""); - notExprType.setSelected(false); - exprTypeWithinHierarchy.setSelected(false); - wholeWordsOnly.setSelected(false); - - invertFormalArgType.setSelected(false); - formalArgTypeWithinHierarchy.setSelected(false); - formalArgType.getDocument().setText(""); - customScriptCode.getChildComponent().setText(""); - - withinCombo.getComboBox().getEditor().setItem(""); - invertWithinIn.setSelected(false); - } else { - notRead.setSelected(varInfo.isInvertReadAccess()); - read.setSelected(varInfo.isReadAccess()); - notWrite.setSelected(varInfo.isInvertWriteAccess()); - write.setSelected(varInfo.isWriteAccess()); - - applyWithinTypeHierarchy.setSelected(varInfo.isWithinHierarchy()); - regexp.getDocument().setText(varInfo.getRegExp()); - //doProcessing(applyWithinTypeHierarchy,regexp); - - notRegexp.setSelected(varInfo.isInvertRegExp()); - minoccurs.setText(Integer.toString(varInfo.getMinCount())); - - if(varInfo.getMaxCount() == Integer.MAX_VALUE) { - maxoccursUnlimited.setSelected(true); - maxoccurs.setText(""); - } else { - maxoccursUnlimited.setSelected(false); - maxoccurs.setText(Integer.toString(varInfo.getMaxCount())); - } - - partOfSearchResults.setSelected( partOfSearchResults.isEnabled() && varInfo.isPartOfSearchResults() ); - - exprTypeWithinHierarchy.setSelected(varInfo.isExprTypeWithinHierarchy()); - regexprForExprType.getDocument().setText(varInfo.getNameOfExprType()); - - notExprType.setSelected( varInfo.isInvertExprType() ); - wholeWordsOnly.setSelected( varInfo.isWholeWordsOnly() ); - - invertFormalArgType.setSelected( varInfo.isInvertFormalType() ); - formalArgTypeWithinHierarchy.setSelected(varInfo.isFormalArgTypeWithinHierarchy()); - formalArgType.getDocument().setText(varInfo.getNameOfFormalArgType()); - restoreScriptCode(varInfo); - - withinCombo.getComboBox().getEditor().setItem(StringUtil.stripQuotesAroundValue(varInfo.getWithinConstraint())); - invertWithinIn.setSelected(varInfo.isInvertWithinConstraint()); - } - - boolean isExprContext = true; - final boolean contextVar = Configuration.CONTEXT_VAR_NAME.equals(var.getName()); - if (contextVar) isExprContext = false; - containedInConstraints.setVisible(contextVar); - expressionConstraints.setVisible(isExprContext); - partOfSearchResults.setEnabled(!contextVar); //? - - occurencePanel.setVisible(!contextVar); - } - - private void setSearchConstraintsVisible(boolean b) { - textConstraintsPanel.setVisible(b); - occurencePanel.setVisible(b); - expressionConstraints.setVisible(b); - partOfSearchResults.setVisible(b); - containedInConstraints.setVisible(b); - pack(); - } - - private void restoreScriptCode(NamedScriptableDefinition varInfo) { - customScriptCode.getChildComponent().setText( - varInfo != null ? StringUtil.stripQuotesAroundValue(varInfo.getScriptCodeConstraint()) : ""); - } - - protected String getDimensionServiceKey() { - return "#com.intellij.structuralsearch.plugin.ui.EditVarConstraintsDialog"; - } - - private static boolean validateRegExp(EditorTextField field) { - try { - final String s = field.getDocument().getText(); - if (s.length() > 0) { - Pattern.compile(s); - } - } catch(PatternSyntaxException ex) { - Messages.showErrorDialog(SSRBundle.message("invalid.regular.expression"), SSRBundle.message("invalid.regular.expression")); - field.requestFocus(); - return false; - } - return true; - } - - private static boolean validateScript(EditorTextField field) { - final String text = field.getText(); - - if (text.length() > 0) { - final String message = ScriptSupport.checkValidScript(text); - - if (message != null) { - Messages.showErrorDialog(message, SSRBundle.message("invalid.groovy.script")); - field.requestFocus(); - return false; - } - } - return true; - } - - private static boolean validateIntOccurence(JTextField field) { - try { - int a = Integer.parseInt(field.getText()); - if (a==-1) throw new NumberFormatException(); - } catch(NumberFormatException ex) { - Messages.showErrorDialog(SSRBundle.message("invalid.occurence.count"), SSRBundle.message("invalid.occurence.count")); - field.requestFocus(); - return false; - } - return true; - } - - @NotNull - protected Action[] createActions() { - return new Action[]{getOKAction(), getCancelAction(), getHelpAction()}; - } - - protected void doHelpAction() { - HelpManager.getInstance().invokeHelp("reference.dialogs.search.replace.structural.editvariable"); - } - - private void createUIComponents() { - regexp = createRegexComponent(); - regexprForExprType = createRegexComponent(); - formalArgType = createRegexComponent(); - customScriptCode = new ComponentWithBrowseButton<EditorTextField>(createScriptComponent(), null); - - myRegExHelpLabel = new LinkLabel(SSRBundle.message("regular.expression.help.label"), null, new LinkListener() { - public void linkSelected(LinkLabel aSource, Object aLinkData) { - try { - final JBPopup helpPopup = RegExHelpPopup.createRegExHelpPopup(); - helpPopup.showInCenterOf(mainForm); - } - catch (BadLocationException e) { - LOG.info(e); - } - } - }); - - myRegExHelpLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5)); - } - - private static EditorTextField createRegexComponent() { - @NonNls final String fileName = "1.regexp"; - final FileType fileType = getFileType(fileName); - final Document doc = createDocument(fileName, fileType, ""); - return new EditorTextField(doc, myProject, fileType); - } - - private static EditorTextField createScriptComponent() { - @NonNls final String fileName = "1.groovy"; - final FileType fileType = getFileType(fileName); - final Document doc = createDocument(fileName, fileType, ""); - return new EditorTextField(doc, myProject, fileType); - } - - private static Document createDocument(final String fileName, final FileType fileType, String text) { - final PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText(fileName, fileType, text, -1, true); - - return PsiDocumentManager.getInstance(myProject).getDocument(file); - } - - private static FileType getFileType(final String fileName) { - FileType fileType = FileTypeManager.getInstance().getFileTypeByFileName(fileName); - if (fileType == FileTypes.UNKNOWN) fileType = FileTypes.PLAIN_TEXT; - return fileType; - } - - public static void setProject(final Project project) { - myProject = project; - } - - private static class MyChangeListener implements ChangeListener { - private final JComponent component; - private final boolean inverted; - - MyChangeListener(JComponent _component, boolean _inverted) { - component = _component; - inverted = _inverted; - } - - public void stateChanged(ChangeEvent e) { - final JCheckBox jCheckBox = (JCheckBox)e.getSource(); - component.setEnabled(inverted ^ jCheckBox.isSelected()); - } - } - - private static class MyDocumentListener extends DocumentAdapter { - private final JComponent[] components; - - private MyDocumentListener(JComponent... _components) { - components = _components; - } - - @Override - public void documentChanged(DocumentEvent e) { - final boolean enable = e.getDocument().getTextLength() > 0; - for (JComponent component : components) { - component.setEnabled(enable); - } - } - } - - private static Editor createEditor(final Project project, final String text, final String fileName) { - final FileType fileType = getFileType(fileName); - final Document doc = createDocument(fileName, fileType, text); - final Editor editor = EditorFactory.getInstance().createEditor(doc, project); - - ((EditorEx)editor).setEmbeddedIntoDialogWrapper(true); - final EditorSettings settings = editor.getSettings(); - settings.setLineNumbersShown(false); - settings.setFoldingOutlineShown(false); - settings.setRightMarginShown(false); - settings.setLineMarkerAreaShown(false); - settings.setIndentGuidesShown(false); - ((EditorEx)editor).setHighlighter(HighlighterFactory.createHighlighter(fileType, DefaultColorSchemesManager.getInstance().getAllSchemes()[0], project)); - - return editor; - } - - private static class EditScriptDialog extends DialogWrapper { - private final Editor editor; - - public EditScriptDialog(final Project project, String text) { - super(project, true); - setTitle(SSRBundle.message("edit.groovy.script.constraint.title")); - editor = createEditor(project, text, "1.groovy"); - init(); - } - - @Override - protected String getDimensionServiceKey() { - return getClass().getName(); - } - - @Override - public JComponent getPreferredFocusedComponent() { - return editor.getContentComponent(); - } - - protected JComponent createCenterPanel() { - return editor.getComponent(); - } - - String getScriptText() { - return editor.getDocument().getText(); - } - - @Override - protected void dispose() { - EditorFactory.getInstance().releaseEditor(editor); - super.dispose(); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ExistingTemplatesComponent.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ExistingTemplatesComponent.java deleted file mode 100644 index 3dd79e16175c..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/ExistingTemplatesComponent.java +++ /dev/null @@ -1,333 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.structuralsearch.plugin.StructuralSearchPlugin; -import com.intellij.ui.*; -import com.intellij.ui.components.JBList; -import com.intellij.ui.treeStructure.Tree; -import com.intellij.util.containers.Convertor; -import com.intellij.util.ui.tree.TreeUtil; - -import javax.swing.*; -import javax.swing.tree.*; -import java.awt.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.util.LinkedList; -import java.util.List; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Apr 2, 2004 - * Time: 1:27:54 PM - * To change this template use File | Settings | File Templates. - */ -public class ExistingTemplatesComponent { - private final Tree patternTree; - private final DefaultTreeModel patternTreeModel; - private final DefaultMutableTreeNode userTemplatesNode; - private final JComponent panel; - private final DefaultListModel historyModel; - private final JList historyList; - private final JComponent historyPanel; - private DialogWrapper owner; - private final Project project; - - private ExistingTemplatesComponent(Project project) { - - this.project = project; - final DefaultMutableTreeNode root; - patternTreeModel = new DefaultTreeModel( - root = new DefaultMutableTreeNode(null) - ); - - DefaultMutableTreeNode parent = null; - String lastCategory = null; - LinkedList<Object> nodesToExpand = new LinkedList<Object>(); - - final List<Configuration> predefined = StructuralSearchUtil.getPredefinedTemplates(); - for (final Configuration info : predefined) { - final DefaultMutableTreeNode node = new DefaultMutableTreeNode(info); - - if (lastCategory == null || !lastCategory.equals(info.getCategory())) { - if (info.getCategory().length() > 0) { - root.add(parent = new DefaultMutableTreeNode(info.getCategory())); - nodesToExpand.add(parent); - lastCategory = info.getCategory(); - } - else { - root.add(node); - continue; - } - } - - parent.add(node); - } - - parent = new DefaultMutableTreeNode(SSRBundle.message("user.defined.category")); - userTemplatesNode = parent; - root.add(parent); - nodesToExpand.add(parent); - - final ConfigurationManager configurationManager = StructuralSearchPlugin.getInstance(this.project).getConfigurationManager(); - if (configurationManager.getConfigurations() != null) { - for (final Configuration config : configurationManager.getConfigurations()) { - parent.add(new DefaultMutableTreeNode(config)); - } - } - - patternTree = createTree(patternTreeModel); - - for (final Object aNodesToExpand : nodesToExpand) { - patternTree.expandPath( - new TreePath(new Object[]{root, aNodesToExpand}) - ); - } - - panel = ToolbarDecorator.createDecorator(patternTree) - .setAddAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - addSelectedTreeNodeAndClose(); - } - }).setRemoveAction(new AnActionButtonRunnable() { - @Override - public void run(AnActionButton button) { - Object selection = patternTree.getLastSelectedPathComponent(); - - if (selection instanceof DefaultMutableTreeNode) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)selection; - - if (node.getUserObject() instanceof Configuration) { - Configuration configuration = (Configuration)node.getUserObject(); - patternTreeModel.removeNodeFromParent(node); - configurationManager.removeConfiguration(configuration); - } - } - } - }).createPanel(); - - new JPanel(new BorderLayout()); - - configureSelectTemplateAction(patternTree); - - historyModel = new DefaultListModel(); - historyPanel = new JPanel(new BorderLayout()); - historyPanel.add( - BorderLayout.NORTH, - new JLabel(SSRBundle.message("used.templates")) - ); - Component view = historyList = new JBList(historyModel); - historyPanel.add( - BorderLayout.CENTER, - ScrollPaneFactory.createScrollPane(view) - ); - - historyList.setCellRenderer( - new ListCellRenderer() - ); - - historyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - new ListSpeedSearch(historyList); - - if (configurationManager.getHistoryConfigurations() != null) { - for (final Configuration configuration : configurationManager.getHistoryConfigurations()) { - historyModel.addElement(configuration); - } - - historyList.setSelectedIndex(0); - } - - configureSelectTemplateAction(historyList); - } - - private void configureSelectTemplateAction(JComponent component) { - component.addKeyListener( - new KeyAdapter() { - public void keyPressed(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER) { - owner.close(DialogWrapper.OK_EXIT_CODE); - } - } - } - ); - - new DoubleClickListener() { - @Override - protected boolean onDoubleClick(MouseEvent event) { - owner.close(DialogWrapper.OK_EXIT_CODE); - return true; - } - }.installOn(component); - } - - private void addSelectedTreeNodeAndClose() { - addConfigurationToUserTemplates( - Configuration.getConfigurationCreator().createConfiguration() - ); - owner.close(DialogWrapper.OK_EXIT_CODE); - } - - private static Tree createTree(TreeModel treeModel) { - final Tree tree = new Tree(treeModel); - - tree.setRootVisible(false); - tree.setShowsRootHandles(true); - tree.setDragEnabled(false); - tree.setEditable(false); - tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); - - tree.setCellRenderer(new TreeCellRenderer()); - - new TreeSpeedSearch( - tree, - new Convertor<TreePath, String>() { - public String convert(TreePath object) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)object.getLastPathComponent(); - Object displayValue = node.getUserObject(); - - if (displayValue instanceof Configuration) { - displayValue = ((Configuration)displayValue).getName(); - } - else { - displayValue = ""; - } - return displayValue.toString(); - } - } - ); - - return tree; - } - - public JTree getPatternTree() { - return patternTree; - } - - public JComponent getTemplatesPanel() { - return panel; - } - - public static ExistingTemplatesComponent getInstance(Project project) { - StructuralSearchPlugin plugin = StructuralSearchPlugin.getInstance(project); - - if (plugin.getExistingTemplatesComponent() == null) { - plugin.setExistingTemplatesComponent(new ExistingTemplatesComponent(project)); - } - - return plugin.getExistingTemplatesComponent(); - } - - static class ListCellRenderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - if (value instanceof Configuration) { - value = ((Configuration)value).getName(); - } - - Component comp = super.getListCellRendererComponent( - list, - value, - index, - isSelected, - cellHasFocus - ); - - return comp; - } - } - - static class TreeCellRenderer extends DefaultTreeCellRenderer { - TreeCellRenderer() { - setOpenIcon(null); - setLeafIcon(null); - setClosedIcon(null); - } - - public Component getTreeCellRendererComponent(JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) { - DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode)value; - Object displayValue = treeNode.getUserObject(); - - if (displayValue instanceof Configuration) { - displayValue = ((Configuration)displayValue).getName(); - } - - Component comp = super.getTreeCellRendererComponent( - tree, - displayValue, - sel, - expanded, - leaf, - row, - hasFocus - ); - - return comp; - } - } - - void addConfigurationToHistory(Configuration configuration) { - //configuration.setName( configuration.getName() +" "+new Date()); - historyModel.insertElementAt(configuration, 0); - ConfigurationManager configurationManager = StructuralSearchPlugin.getInstance(project).getConfigurationManager(); - configurationManager.addHistoryConfigurationToFront(configuration); - historyList.setSelectedIndex(0); - - if (historyModel.getSize() > 25) { - configurationManager.removeHistoryConfiguration( - (Configuration)historyModel.getElementAt(25) - ); - // we add by one! - historyModel.removeElementAt(25); - } - } - - private void insertNode(Configuration configuration, DefaultMutableTreeNode parent, int index) { - DefaultMutableTreeNode node; - patternTreeModel.insertNodeInto( - node = new DefaultMutableTreeNode( - configuration - ), - parent, - index - ); - - TreeUtil.selectPath( - patternTree, - new TreePath(new Object[]{patternTreeModel.getRoot(), parent, node}) - ); - } - - void addConfigurationToUserTemplates(Configuration configuration) { - insertNode(configuration, userTemplatesNode, userTemplatesNode.getChildCount()); - ConfigurationManager configurationManager = StructuralSearchPlugin.getInstance(project).getConfigurationManager(); - configurationManager.addConfiguration(configuration); - } - - boolean isConfigurationFromHistory(Configuration config) { - return historyModel.indexOf(config) != -1; - } - - public JList getHistoryList() { - return historyList; - } - - public JComponent getHistoryPanel() { - return historyPanel; - } - - public void setOwner(DialogWrapper owner) { - this.owner = owner; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchCommand.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchCommand.java deleted file mode 100644 index 7c51fa85af3b..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchCommand.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.notification.NotificationGroup; -import com.intellij.openapi.application.ModalityState; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.ProgressManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.wm.ToolWindowId; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiNameIdentifierOwner; -import com.intellij.structuralsearch.*; -import com.intellij.structuralsearch.impl.matcher.MatchResultImpl; -import com.intellij.structuralsearch.plugin.StructuralSearchPlugin; -import com.intellij.structuralsearch.plugin.ui.actions.DoSearchAction; -import com.intellij.usageView.UsageInfo; -import com.intellij.usages.Usage; -import com.intellij.usages.UsageInfo2UsageAdapter; -import com.intellij.util.Alarm; -import com.intellij.util.ObjectUtils; -import com.intellij.util.Processor; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 15, 2004 - * Time: 4:49:07 PM - * To change this template use File | Settings | File Templates. - */ -public class SearchCommand { - protected UsageViewContext context; - private MatchingProcess process; - protected Project project; - - public SearchCommand(Project _project, UsageViewContext _context) { - project = _project; - context = _context; - } - - public void findUsages(final Processor<Usage> processor) { - final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); - - try { - DoSearchAction.execute( - project, - new MatchResultSink() { - int count; - - public void setMatchingProcess(MatchingProcess _process) { - process = _process; - findStarted(); - } - - public void processFile(PsiFile element) { - final VirtualFile virtualFile = element.getVirtualFile(); - if (virtualFile != null) - progress.setText(SSRBundle.message("looking.in.progress.message", virtualFile.getPresentableName())); - } - - public void matchingFinished() { - findEnded(); - progress.setText(SSRBundle.message("found.progress.message", count)); - } - - public ProgressIndicator getProgressIndicator() { - return progress; - } - - public void newMatch(MatchResult result) { - UsageInfo info; - - if (MatchResult.MULTI_LINE_MATCH.equals(result.getName())) { - int start = -1; - int end = -1; - PsiElement parent = result.getMatchRef().getElement().getParent(); - - for (final MatchResult matchResult : ((MatchResultImpl)result).getMatches()) { - PsiElement el = matchResult.getMatchRef().getElement(); - final int elementStart = el.getTextRange().getStartOffset(); - - if (start == -1 || start > elementStart) { - start = elementStart; - } - final int newend = elementStart + el.getTextLength(); - - if (newend > end) { - end = newend; - } - } - - final int parentStart = parent.getTextRange().getStartOffset(); - int startOffset = start - parentStart; - info = new UsageInfo(parent, startOffset, end - parentStart); - } - else { - PsiElement element = result.getMatch(); - if (element instanceof PsiNameIdentifierOwner) { - element = ObjectUtils.notNull(((PsiNameIdentifierOwner)element).getNameIdentifier(), element); - } - info = new UsageInfo(element, result.getStart(), result.getEnd() == -1 ? element.getTextLength() : result.getEnd()); - } - - Usage usage = new UsageInfo2UsageAdapter(info); - processor.process(usage); - foundUsage(result, usage); - ++count; - } - }, - context.getConfiguration() - ); - } - catch (final StructuralSearchException e) { - final Alarm alarm = new Alarm(); - alarm.addRequest( - new Runnable() { - @Override - public void run() { - NotificationGroup.toolWindowGroup("Structural Search", ToolWindowId.FIND, true) - .createNotification(SSRBundle.message("problem", e.getMessage()), MessageType.ERROR).notify(project); - } - }, - 100, ModalityState.NON_MODAL - ); - } - } - - public void stopAsyncSearch() { - if (process!=null) process.stop(); - } - - protected void findStarted() { - StructuralSearchPlugin.getInstance(project).setSearchInProgress(true); - } - - protected void findEnded() { - if (!project.isDisposed()) { - StructuralSearchPlugin.getInstance(project).setSearchInProgress(false); - } - } - - protected void foundUsage(MatchResult result, Usage usage) { - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchConfiguration.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchConfiguration.java deleted file mode 100644 index afb2f9451bbe..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchConfiguration.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.openapi.actionSystem.AnAction; -import org.jdom.Element; -import org.jdom.Attribute; -import org.jdom.DataConversionException; - -/** - * Configuration of the search - */ -public class SearchConfiguration extends Configuration { - private MatchOptions matchOptions; - - public SearchConfiguration() { - matchOptions = new MatchOptions(); - } - - public MatchOptions getMatchOptions() { - return matchOptions; - } - - public void setMatchOptions(MatchOptions matchOptions) { - this.matchOptions = matchOptions; - } - - public void readExternal(Element element) { - super.readExternal(element); - - matchOptions.readExternal(element); - } - - public void writeExternal(Element element) { - super.writeExternal(element); - - matchOptions.writeExternal(element); - } - -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchContext.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchContext.java deleted file mode 100644 index 62371e7e29d1..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchContext.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiManager; -import com.intellij.structuralsearch.impl.matcher.DataProvider; - -/** - * Context of the search to be done - */ -public final class SearchContext implements DataProvider, Cloneable { - private final PsiFile file; - private final Project project; - - private SearchContext(Project project, PsiFile file) { - this.project = project; - this.file = file; - } - - public PsiFile getFile() { - return file; - } - - public Project getProject() { - return project; - } - - public static SearchContext buildFromDataContext(DataContext context) { - Project project = CommonDataKeys.PROJECT.getData(context); - if (project == null) { - project = ProjectManager.getInstance().getDefaultProject(); - } - - PsiFile file = CommonDataKeys.PSI_FILE.getData(context); - final VirtualFile vFile = CommonDataKeys.VIRTUAL_FILE.getData(context); - if (vFile != null && (file == null || !vFile.equals(file.getContainingFile().getVirtualFile()))) { - file = PsiManager.getInstance(project).findFile(vFile); - } - return new SearchContext(project, file); - } - - public Editor getEditor() { - return FileEditorManager.getInstance(project).getSelectedTextEditor(); - } - - protected Object clone() { - try { - return super.clone(); - } catch(CloneNotSupportedException ex) { - return null; - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java deleted file mode 100644 index 5255472d4ce6..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchDialog.java +++ /dev/null @@ -1,1000 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.template.impl.Variable; -import com.intellij.find.FindBundle; -import com.intellij.find.FindProgressIndicator; -import com.intellij.find.FindSettings; -import com.intellij.ide.IdeBundle; -import com.intellij.ide.util.scopeChooser.ScopeChooserCombo; -import com.intellij.lang.Language; -import com.intellij.lang.LanguageUtil; -import com.intellij.openapi.application.Result; -import com.intellij.openapi.application.WriteAction; -import com.intellij.openapi.command.WriteCommandAction; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.SelectionModel; -import com.intellij.openapi.editor.event.DocumentEvent; -import com.intellij.openapi.editor.event.DocumentListener; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.fileTypes.impl.FileTypeRenderer; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.ComboBox; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.util.Disposer; -import com.intellij.openapi.util.Factory; -import com.intellij.openapi.util.TextRange; -import com.intellij.openapi.wm.ToolWindow; -import com.intellij.openapi.wm.ToolWindowId; -import com.intellij.openapi.wm.ToolWindowManager; -import com.intellij.psi.PsiDocumentManager; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.codeStyle.CodeStyleManager; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.SearchScope; -import com.intellij.structuralsearch.*; -import com.intellij.structuralsearch.impl.matcher.MatcherImpl; -import com.intellij.structuralsearch.plugin.StructuralSearchPlugin; -import com.intellij.ui.ComboboxSpeedSearch; -import com.intellij.ui.IdeBorderFactory; -import com.intellij.ui.ListCellRendererWrapper; -import com.intellij.ui.TitledSeparator; -import com.intellij.usages.*; -import com.intellij.util.Alarm; -import com.intellij.util.Processor; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.*; -import java.util.List; - -/** - * Class to show the user the request for search - */ -@SuppressWarnings({"RefusedBequest", "AssignmentToStaticFieldFromInstanceMethod"}) -public class SearchDialog extends DialogWrapper implements ConfigurationCreator { - protected SearchContext searchContext; - - // text for search - protected Editor searchCriteriaEdit; - - // options of search scope - private ScopeChooserCombo myScopeChooserCombo; - - private JCheckBox recursiveMatching; - private JCheckBox caseSensitiveMatch; - - private JComboBox fileTypes; - private JComboBox contexts; - private JComboBox dialects; - private JLabel status; - private JLabel statusText; - - protected SearchModel model; - private JCheckBox openInNewTab; - private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.SHARED_THREAD); - - public static final String USER_DEFINED = SSRBundle.message("new.template.defaultname"); - protected final ExistingTemplatesComponent existingTemplatesComponent; - - private boolean useLastConfiguration; - - private static boolean ourOpenInNewTab; - - @NonNls private FileType ourFtSearchVariant = StructuralSearchUtil.getDefaultFileType(); - private static Language ourDialect = null; - private static String ourContext = null; - - private final boolean myShowScopePanel; - private final boolean myRunFindActionOnClose; - private boolean myDoingOkAction; - - private String mySavedEditorText; - private JPanel myContentPanel; - private JComponent myEditorPanel; - - public SearchDialog(SearchContext searchContext) { - this(searchContext, true, true); - } - - public SearchDialog(SearchContext searchContext, boolean showScope, boolean runFindActionOnClose) { - super(searchContext.getProject(), true); - - if (showScope) setModal(false); - myShowScopePanel = showScope; - myRunFindActionOnClose = runFindActionOnClose; - this.searchContext = (SearchContext)searchContext.clone(); - setTitle(getDefaultTitle()); - - if (runFindActionOnClose) { - setOKButtonText(FindBundle.message("find.dialog.find.button")); - } - - existingTemplatesComponent = ExistingTemplatesComponent.getInstance(this.searchContext.getProject()); - model = new SearchModel(createConfiguration()); - - init(); - } - - protected UsageViewContext createUsageViewContext(Configuration configuration) { - return new UsageViewContext(searchContext, configuration); - } - - public void setUseLastConfiguration(boolean useLastConfiguration) { - this.useLastConfiguration = useLastConfiguration; - } - - protected boolean isChanged(Configuration configuration) { - return configuration.getMatchOptions().getSearchPattern() != null && - !searchCriteriaEdit.getDocument().getText().equals(configuration.getMatchOptions().getSearchPattern()); - } - - public void setSearchPattern(final Configuration config) { - model.setShadowConfig(config); - setValuesFromConfig(config); - initiateValidation(); - } - - protected Editor createEditor(final SearchContext searchContext, String text) { - Editor editor = null; - - if (fileTypes != null) { - final FileType fileType = (FileType)fileTypes.getSelectedItem(); - final Language dialect = (Language)dialects.getSelectedItem(); - - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType); - if (profile != null) { - editor = profile.createEditor(searchContext, fileType, dialect, text, useLastConfiguration); - } - } - - if (editor == null) { - final EditorFactory factory = EditorFactory.getInstance(); - final Document document = factory.createDocument(""); - editor = factory.createEditor(document, searchContext.getProject()); - editor.getSettings().setFoldingOutlineShown(false); - } - - editor.getDocument().addDocumentListener(new DocumentListener() { - @Override - public void beforeDocumentChange(final DocumentEvent event) { - } - - @Override - public void documentChanged(final DocumentEvent event) { - initiateValidation(); - } - }); - - return editor; - } - - private void initiateValidation() { - myAlarm.cancelAllRequests(); - myAlarm.addRequest(new Runnable() { - - @Override - public void run() { - try { - new WriteAction(){ - @Override - protected void run(Result result) throws Throwable { - if (!isValid()) { - getOKAction().setEnabled(false); - } - else { - getOKAction().setEnabled(true); - reportMessage(null, null); - } - } - }.execute(); - } - catch (Exception e) { - e.printStackTrace(); - } - } - }, 500); - } - - protected void buildOptions(JPanel searchOptions) { - recursiveMatching = new JCheckBox(SSRBundle.message("recursive.matching.checkbox"), true); - if (isRecursiveSearchEnabled()) { - searchOptions.add(UIUtil.createOptionLine(recursiveMatching)); - } - - caseSensitiveMatch = new JCheckBox(FindBundle.message("find.options.case.sensitive"), true); - searchOptions.add(UIUtil.createOptionLine(caseSensitiveMatch)); - - final List<FileType> types = new ArrayList<FileType>(); - - for (FileType fileType : StructuralSearchUtil.getSuitableFileTypes()) { - if (StructuralSearchUtil.getProfileByFileType(fileType) != null) { - types.add(fileType); - } - } - Collections.sort(types, new Comparator<FileType>() { - @Override - public int compare(FileType o1, FileType o2) { - return o1.getName().compareToIgnoreCase(o2.getName()); - } - }); - - final DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel(types.toArray(new FileType[types.size()])); - comboBoxModel.setSelectedItem(ourFtSearchVariant); - fileTypes = new ComboBox(comboBoxModel); - fileTypes.setRenderer(new FileTypeRenderer()); - new ComboboxSpeedSearch(fileTypes) { - @Override - protected String getElementText(Object element) { - return ((FileType)element).getName(); - } - }; - fileTypes.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - updateDialectsAndContexts(); - updateEditor(); - } - }); - - contexts = new JComboBox(new DefaultComboBoxModel()); - contexts.setPreferredSize(new Dimension(60, -1)); - - dialects = new JComboBox(new DefaultComboBoxModel()); - dialects.setRenderer(new ListCellRendererWrapper() { - @Override - public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) { - if (value == null) { - setText("None"); - } - else if (value instanceof Language) { - setText(((Language)value).getDisplayName()); - } - } - }); - dialects.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - updateEditor(); - } - }); - new ComboboxSpeedSearch(dialects); - dialects.setPreferredSize(new Dimension(120, -1)); - - final JLabel jLabel = new JLabel(SSRBundle.message("search.dialog.file.type.label")); - final JLabel jLabel2 = new JLabel(SSRBundle.message("search.dialog.context.label")); - final JLabel jLabel3 = new JLabel(SSRBundle.message("search.dialog.file.dialect.label")); - searchOptions.add( - UIUtil.createOptionLine( - new JComponent[]{ - jLabel, - fileTypes, - (JComponent)Box.createHorizontalStrut(8), - jLabel2, - contexts, - (JComponent)Box.createHorizontalStrut(8), - jLabel3, - dialects, - } - ) - ); - - jLabel.setLabelFor(fileTypes); - jLabel2.setLabelFor(contexts); - jLabel3.setLabelFor(dialects); - - detectFileTypeAndDialect(); - - fileTypes.setSelectedItem(ourFtSearchVariant); - fileTypes.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) initiateValidation(); - } - }); - - dialects.setSelectedItem(ourDialect); - contexts.setSelectedItem(ourContext); - - updateDialectsAndContexts(); - } - - private void updateEditor() { - if (myContentPanel != null) { - if (myEditorPanel != null) { - myContentPanel.remove(myEditorPanel); - } - disposeEditorContent(); - myEditorPanel = createEditorContent(); - myContentPanel.add(myEditorPanel, BorderLayout.CENTER); - myContentPanel.revalidate(); - } - } - - private void updateDialectsAndContexts() { - final FileType fileType = (FileType)fileTypes.getSelectedItem(); - if (fileType instanceof LanguageFileType) { - Language language = ((LanguageFileType)fileType).getLanguage(); - Language[] languageDialects = LanguageUtil.getLanguageDialects(language); - Arrays.sort(languageDialects, new Comparator<Language>() { - @Override - public int compare(Language o1, Language o2) { - return o1.getDisplayName().compareTo(o2.getDisplayName()); - } - }); - Language[] variants = new Language[languageDialects.length + 1]; - variants[0] = null; - System.arraycopy(languageDialects, 0, variants, 1, languageDialects.length); - dialects.setModel(new DefaultComboBoxModel(variants)); - dialects.setEnabled(variants.length > 1); - } - - final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(fileType); - - if (profile instanceof StructuralSearchProfileBase) { - final String[] contextNames = ((StructuralSearchProfileBase)profile).getContextNames(); - if (contextNames.length > 0) { - contexts.setModel(new DefaultComboBoxModel(contextNames)); - contexts.setSelectedItem(contextNames[0]); - contexts.setEnabled(true); - return; - } - } - contexts.setSelectedItem(null); - contexts.setEnabled(false); - } - - private void detectFileTypeAndDialect() { - final PsiFile file = searchContext.getFile(); - if (file != null) { - PsiElement context = null; - - if (searchContext.getEditor() != null) { - context = file.findElementAt(searchContext.getEditor().getCaretModel().getOffset()); - if (context != null) { - context = context.getParent(); - } - } - if (context == null) { - context = file; - } - - FileType detectedFileType = null; - - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(context); - if (profile != null) { - FileType fileType = profile.detectFileType(context); - if (fileType != null) { - detectedFileType = fileType; - } - } - - if (detectedFileType == null) { - for (FileType fileType : StructuralSearchUtil.getSuitableFileTypes()) { - if (fileType instanceof LanguageFileType && ((LanguageFileType)fileType).getLanguage().equals(context.getLanguage())) { - detectedFileType = fileType; - break; - } - } - } - - ourFtSearchVariant = detectedFileType != null ? - detectedFileType : - StructuralSearchUtil.getDefaultFileType(); - - // todo: detect dialect - - /*if (file.getLanguage() == StdLanguages.HTML || - (file.getFileType() == StdFileTypes.JSP && - contextLanguage == StdLanguages.HTML - ) - ) { - ourFileType = "html"; - } - else if (file.getLanguage() == StdLanguages.XHTML || - (file.getFileType() == StdFileTypes.JSPX && - contextLanguage == StdLanguages.HTML - )) { - ourFileType = "xml"; - } - else { - ourFileType = DEFAULT_TYPE_NAME; - }*/ - } - } - - protected boolean isRecursiveSearchEnabled() { - return true; - } - - public void setValuesFromConfig(Configuration configuration) { - //searchCriteriaEdit.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, configuration); - - setDialogTitle(configuration); - final MatchOptions matchOptions = configuration.getMatchOptions(); - - UIUtil.setContent( - searchCriteriaEdit, - matchOptions.getSearchPattern(), - 0, - searchCriteriaEdit.getDocument().getTextLength(), - searchContext.getProject() - ); - - model.getConfig().getMatchOptions().setSearchPattern( - matchOptions.getSearchPattern() - ); - - recursiveMatching.setSelected( - isRecursiveSearchEnabled() && matchOptions.isRecursiveSearch() - ); - - caseSensitiveMatch.setSelected( - matchOptions.isCaseSensitiveMatch() - ); - - model.getConfig().getMatchOptions().clearVariableConstraints(); - if (matchOptions.hasVariableConstraints()) { - for (Iterator<String> i = matchOptions.getVariableConstraintNames(); i.hasNext(); ) { - final MatchVariableConstraint constraint = (MatchVariableConstraint)matchOptions.getVariableConstraint(i.next()).clone(); - model.getConfig().getMatchOptions().addVariableConstraint(constraint); - } - } - - MatchOptions options = configuration.getMatchOptions(); - StructuralSearchProfile profile = StructuralSearchUtil.getProfileByFileType(options.getFileType()); - assert profile != null; - fileTypes.setSelectedItem(options.getFileType()); - dialects.setSelectedItem(options.getDialect()); - if (options.getPatternContext() != null) { - contexts.setSelectedItem(options.getPatternContext()); - } - } - - private void setDialogTitle(final Configuration configuration) { - setTitle(getDefaultTitle() + " - " + configuration.getName()); - } - - @Override - public Configuration createConfiguration() { - SearchConfiguration configuration = new SearchConfiguration(); - configuration.setName(USER_DEFINED); - return configuration; - } - - protected void addOrReplaceSelection(final String selection) { - addOrReplaceSelectionForEditor(selection, searchCriteriaEdit); - } - - protected final void addOrReplaceSelectionForEditor(final String selection, Editor editor) { - final Project project = searchContext.getProject(); - UIUtil.setContent(editor, selection, 0, -1, project); - final Document document = editor.getDocument(); - editor.getSelectionModel().setSelection(0, document.getTextLength()); - final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project); - documentManager.commitDocument(document); - final PsiFile file = documentManager.getPsiFile(document); - if (file == null) return; - - new WriteCommandAction(project, file) { - @Override protected void run(@NotNull Result result) throws Throwable { - CodeStyleManager.getInstance(project).adjustLineIndent(file, new TextRange(0, document.getTextLength())); - } - }.execute(); - } - - protected void runAction(final Configuration config, final SearchContext searchContext) { - createUsageView(searchContext, config); - } - - protected void createUsageView(final SearchContext searchContext, final Configuration config) { - UsageViewManager manager = UsageViewManager.getInstance(searchContext.getProject()); - - final UsageViewContext context = createUsageViewContext(config); - final UsageViewPresentation presentation = new UsageViewPresentation(); - presentation.setOpenInNewTab(openInNewTab.isSelected()); - presentation.setScopeText(config.getMatchOptions().getScope().getDisplayName()); - context.configure(presentation); - - final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation); - processPresentation.setShowNotFoundMessage(true); - processPresentation.setShowPanelIfOnlyOneUsage(true); - - processPresentation.setProgressIndicatorFactory( - new Factory<ProgressIndicator>() { - @Override - public ProgressIndicator create() { - return new FindProgressIndicator(searchContext.getProject(), presentation.getScopeText()) { - @Override - public void cancel() { - context.getCommand().stopAsyncSearch(); - super.cancel(); - } - }; - } - } - ); - - PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); - - manager.searchAndShowUsages( - new UsageTarget[]{ - context.getTarget() - }, - new Factory<UsageSearcher>() { - @Override - public UsageSearcher create() { - return new UsageSearcher() { - @Override - public void generate(@NotNull final Processor<Usage> processor) { - context.getCommand().findUsages(processor); - } - }; - } - }, - processPresentation, - presentation, - new UsageViewManager.UsageViewStateListener() { - @Override - public void usageViewCreated(@NotNull UsageView usageView) { - context.setUsageView(usageView); - context.configureActions(); - } - - @Override - public void findingUsagesFinished(final UsageView usageView) { - } - } - ); - } - - protected String getDefaultTitle() { - return SSRBundle.message("structural.search.title"); - } - - protected JComponent createEditorContent() { - JPanel result = new JPanel(new BorderLayout()); - - result.add(BorderLayout.NORTH, new JLabel(SSRBundle.message("search.template"))); - searchCriteriaEdit = createEditor(searchContext, mySavedEditorText != null ? mySavedEditorText : ""); - result.add(BorderLayout.CENTER, searchCriteriaEdit.getComponent()); - result.setMinimumSize(new Dimension(150, 100)); - - return result; - } - - protected int getRowsCount() { - return 4; - } - - @Override - protected JComponent createCenterPanel() { - myContentPanel = new JPanel(new BorderLayout()); - myEditorPanel = createEditorContent(); - myContentPanel.add(BorderLayout.CENTER, myEditorPanel); - myContentPanel.add(BorderLayout.SOUTH, Box.createVerticalStrut(8)); - JComponent centerPanel = new JPanel(new BorderLayout()); - { - JPanel panel = new JPanel(new BorderLayout()); - panel.add(BorderLayout.CENTER, myContentPanel); - panel.add(BorderLayout.SOUTH, createTemplateManagementButtons()); - centerPanel.add(BorderLayout.CENTER, panel); - } - - JPanel optionsContent = new JPanel(new BorderLayout()); - centerPanel.add(BorderLayout.SOUTH, optionsContent); - - JPanel searchOptions = new JPanel(); - searchOptions.setLayout(new GridLayout(getRowsCount(), 1, 0, 0)); - searchOptions.setBorder(IdeBorderFactory.createTitledBorder(SSRBundle.message("ssdialog.options.group.border"), - true)); - - myScopeChooserCombo = new ScopeChooserCombo( - searchContext.getProject(), - true, - false, - FindSettings.getInstance().getDefaultScopeName() - ); - Disposer.register(myDisposable, myScopeChooserCombo); - JPanel allOptions = new JPanel(new BorderLayout()); - if (myShowScopePanel) { - JPanel scopePanel = new JPanel(new GridBagLayout()); - - TitledSeparator separator = new TitledSeparator(SSRBundle.message("search.dialog.scope.label"), myScopeChooserCombo.getComboBox()); - scopePanel.add(separator, new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, - new Insets(5, 0, 0, 0), 0, 0)); - - scopePanel.add(myScopeChooserCombo, new GridBagConstraints(0, 1, 1, 1, 1, 1, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, - new Insets(0, 10, 0, 0), 0, 0)); - - allOptions.add( - scopePanel, - BorderLayout.SOUTH - ); - - myScopeChooserCombo.getComboBox().addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - initiateValidation(); - } - }); - } - - buildOptions(searchOptions); - - allOptions.add(searchOptions, BorderLayout.CENTER); - optionsContent.add(allOptions, BorderLayout.CENTER); - - if (myRunFindActionOnClose) { - JPanel panel = new JPanel(new BorderLayout()); - panel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0)); - openInNewTab = new JCheckBox(FindBundle.message("find.open.in.new.tab.checkbox")); - openInNewTab.setSelected(ourOpenInNewTab); - ToolWindow findWindow = ToolWindowManager.getInstance(searchContext.getProject()).getToolWindow(ToolWindowId.FIND); - openInNewTab.setEnabled(findWindow != null && findWindow.isAvailable()); - panel.add(openInNewTab, BorderLayout.EAST); - - optionsContent.add(BorderLayout.SOUTH, panel); - } - - updateEditor(); - return centerPanel; - } - - - @Override - protected JComponent createSouthPanel() { - final JPanel statusPanel = new JPanel(new BorderLayout(5, 0)); - statusPanel.add(super.createSouthPanel(), BorderLayout.NORTH); - statusPanel.add(statusText = new JLabel(SSRBundle.message("status.message")), BorderLayout.WEST); - statusPanel.add(status = new JLabel(), BorderLayout.CENTER); - return statusPanel; - } - - private JPanel createTemplateManagementButtons() { - JPanel panel = new JPanel(null); - panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); - panel.add(Box.createHorizontalGlue()); - - panel.add( - createJButtonForAction(new AbstractAction() { - { - putValue(NAME, SSRBundle.message("save.template.text.button")); - } - - @Override - public void actionPerformed(ActionEvent e) { - String name = showSaveTemplateAsDialog(); - - if (name != null) { - final Project project = searchContext.getProject(); - final ConfigurationManager configurationManager = StructuralSearchPlugin.getInstance(project).getConfigurationManager(); - final Collection<Configuration> configurations = configurationManager.getConfigurations(); - - if (configurations != null) { - name = ConfigurationManager.findAppropriateName(configurations, name, project); - if (name == null) return; - } - - model.getConfig().setName(name); - setValuesToConfig(model.getConfig()); - setDialogTitle(model.getConfig()); - - if (model.getShadowConfig() == null || - model.getShadowConfig().isPredefined()) { - existingTemplatesComponent.addConfigurationToUserTemplates(model.getConfig()); - } - else { // ??? - setValuesToConfig(model.getShadowConfig()); - model.getShadowConfig().setName(name); - } - } - } - }) - ); - - panel.add( - Box.createHorizontalStrut(8) - ); - - panel.add( - createJButtonForAction( - new AbstractAction() { - { - putValue(NAME, SSRBundle.message("edit.variables.button")); - } - - @Override - public void actionPerformed(ActionEvent e) { - EditVarConstraintsDialog.setProject(searchContext.getProject()); - new EditVarConstraintsDialog( - searchContext.getProject(), - model, getVariablesFromListeners(), - isReplaceDialog(), - (FileType)fileTypes.getSelectedItem() - ).show(); - initiateValidation(); - EditVarConstraintsDialog.setProject(null); - } - } - ) - ); - - panel.add( - Box.createHorizontalStrut(8) - ); - - panel.add( - createJButtonForAction( - new AbstractAction() { - { - putValue(NAME, SSRBundle.message("history.button")); - } - - @Override - public void actionPerformed(ActionEvent e) { - SelectTemplateDialog dialog = new SelectTemplateDialog(searchContext.getProject(), true, isReplaceDialog()); - dialog.show(); - - if (!dialog.isOK()) { - return; - } - Configuration[] configurations = dialog.getSelectedConfigurations(); - if (configurations.length == 1) { - setSearchPattern(configurations[0]); - } - } - } - ) - ); - - panel.add( - Box.createHorizontalStrut(8) - ); - - panel.add( - createJButtonForAction( - new AbstractAction() { - { - putValue(NAME, SSRBundle.message("copy.existing.template.button")); - } - - @Override - public void actionPerformed(ActionEvent e) { - SelectTemplateDialog dialog = new SelectTemplateDialog(searchContext.getProject(), false, isReplaceDialog()); - dialog.show(); - - if (!dialog.isOK()) { - return; - } - Configuration[] configurations = dialog.getSelectedConfigurations(); - if (configurations.length == 1) { - setSearchPattern(configurations[0]); - } - } - } - ) - ); - - return panel; - } - - protected List<Variable> getVariablesFromListeners() { - return getVarsFrom(searchCriteriaEdit); - } - - protected static ArrayList<Variable> getVarsFrom(Editor searchCriteriaEdit) { - SubstitutionShortInfoHandler handler = searchCriteriaEdit.getUserData(UIUtil.LISTENER_KEY); - return new ArrayList<Variable>(handler.getVariables()); - } - - public final Project getProject() { - return searchContext.getProject(); - } - - public String showSaveTemplateAsDialog() { - return ConfigurationManager.showSaveTemplateAsDialog( - model.getShadowConfig() != null ? model.getShadowConfig().getName() : SSRBundle.message("user.defined.category"), - searchContext.getProject() - ); - } - - protected boolean isReplaceDialog() { - return false; - } - - @Override - public void show() { - StructuralSearchPlugin.getInstance(getProject()).setDialogVisible(true); - Configuration.setActiveCreator(this); - searchCriteriaEdit.putUserData( - SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, - model.getConfig() - ); - - if (!useLastConfiguration) { - final Editor editor = FileEditorManager.getInstance(searchContext.getProject()).getSelectedTextEditor(); - boolean setSomeText = false; - - if (editor != null) { - final SelectionModel selectionModel = editor.getSelectionModel(); - - if (selectionModel.hasSelection()) { - addOrReplaceSelection(selectionModel.getSelectedText()); - existingTemplatesComponent.getPatternTree().setSelectionPath(null); - existingTemplatesComponent.getHistoryList().setSelectedIndex(-1); - setSomeText = true; - } - } - - if (!setSomeText) { - int selection = existingTemplatesComponent.getHistoryList().getSelectedIndex(); - if (selection != -1) { - setValuesFromConfig( - (Configuration)existingTemplatesComponent.getHistoryList().getSelectedValue() - ); - } - } - } - - initiateValidation(); - - super.show(); - } - - @Override - public JComponent getPreferredFocusedComponent() { - return searchCriteriaEdit.getContentComponent(); - } - - // Performs ok action - @Override - protected void doOKAction() { - SearchScope selectedScope = getSelectedScope(); - if (selectedScope == null) return; - - myDoingOkAction = true; - boolean result = isValid(); - myDoingOkAction = false; - if (!result) return; - - myAlarm.cancelAllRequests(); - super.doOKAction(); - if (!myRunFindActionOnClose) return; - - FindSettings.getInstance().setDefaultScopeName(selectedScope.getDisplayName()); - ourOpenInNewTab = openInNewTab.isSelected(); - - try { - if (model.getShadowConfig() != null) { - if (model.getShadowConfig().isPredefined()) { - model.getConfig().setName( - model.getShadowConfig().getName() - ); - } //else { - // // user template, save it - // setValuesToConfig(model.getShadowConfig()); - //} - } - existingTemplatesComponent.addConfigurationToHistory(model.getConfig()); - - runAction(model.getConfig(), searchContext); - } - catch (MalformedPatternException ex) { - reportMessage("this.pattern.is.malformed.message", searchCriteriaEdit, ex.getMessage()); - } - } - - public Configuration getConfiguration() { - return model.getConfig(); - } - - private SearchScope getSelectedScope() { - return myScopeChooserCombo.getSelectedScope(); - } - - protected boolean isValid() { - setValuesToConfig(model.getConfig()); - boolean result = true; - - try { - MatcherImpl.validate(searchContext.getProject(), model.getConfig().getMatchOptions()); - } - catch (MalformedPatternException ex) { - if (myRunFindActionOnClose) { - reportMessage( - "this.pattern.is.malformed.message", - searchCriteriaEdit, - ex.getMessage() != null ? ex.getMessage() : "" - ); - result = false; - } - } - catch (UnsupportedPatternException ex) { - reportMessage("this.pattern.is.unsupported.message", searchCriteriaEdit, ex.getMessage()); - result = false; - } - - //getOKAction().setEnabled(result); - return result; - } - - protected void reportMessage(@NonNls String messageId, Editor editor, Object... params) { - final String message = messageId != null ? SSRBundle.message(messageId, params) : ""; - status.setText(message); - status.setToolTipText(message); - status.revalidate(); - statusText.setLabelFor(editor != null ? editor.getContentComponent() : null); - } - - protected void setValuesToConfig(Configuration config) { - - MatchOptions options = config.getMatchOptions(); - - boolean searchWithinHierarchy = IdeBundle.message("scope.class.hierarchy").equals(myScopeChooserCombo.getSelectedScopeName()); - // We need to reset search within hierarchy scope during online validation since the scope works with user participation - options.setScope( - searchWithinHierarchy && !myDoingOkAction ? GlobalSearchScope.projectScope(getProject()) : myScopeChooserCombo.getSelectedScope()); - options.setLooseMatching(true); - options.setRecursiveSearch(isRecursiveSearchEnabled() && recursiveMatching.isSelected()); - - ourFtSearchVariant = (FileType)fileTypes.getSelectedItem(); - ourDialect = (Language)dialects.getSelectedItem(); - ourContext = (String)contexts.getSelectedItem(); - FileType fileType = ourFtSearchVariant; - options.setFileType(fileType); - options.setDialect(ourDialect); - options.setPatternContext(ourContext); - - options.setSearchPattern(searchCriteriaEdit.getDocument().getText()); - options.setCaseSensitiveMatch(caseSensitiveMatch.isSelected()); - } - - @Override - protected String getDimensionServiceKey() { - return "#com.intellij.structuralsearch.plugin.ui.SearchDialog"; - } - - @Override - public void dispose() { - Configuration.setActiveCreator(null); - disposeEditorContent(); - - myAlarm.cancelAllRequests(); - - super.dispose(); - StructuralSearchPlugin.getInstance(getProject()).setDialogVisible(false); - } - - protected void disposeEditorContent() { - mySavedEditorText = searchCriteriaEdit.getDocument().getText(); - - // this will remove from myExcludedSet - final PsiFile file = PsiDocumentManager.getInstance(searchContext.getProject()).getPsiFile(searchCriteriaEdit.getDocument()); - if (file != null) { - DaemonCodeAnalyzer.getInstance(searchContext.getProject()).setHighlightingEnabled(file, true); - } - - EditorFactory.getInstance().releaseEditor(searchCriteriaEdit); - } - - @Override - protected String getHelpId() { - return "find.structuredSearch"; - } - - public SearchContext getSearchContext() { - return searchContext; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchModel.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchModel.java deleted file mode 100644 index 812ca6b0dc9b..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SearchModel.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 25, 2004 - * Time: 1:33:10 PM - * To change this template use File | Settings | File Templates. - */ -public class SearchModel { - private final Configuration config; - private Configuration shadowConfig; - - public SearchModel(Configuration config) { - this.config = config; - } - - public Configuration getConfig() { - return config; - } - - public void setShadowConfig(Configuration shadowConfig) { - this.shadowConfig = shadowConfig; - } - - public Configuration getShadowConfig() { - return shadowConfig; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SelectTemplateDialog.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SelectTemplateDialog.java deleted file mode 100644 index b74715ecf07a..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SelectTemplateDialog.java +++ /dev/null @@ -1,294 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.codeInsight.template.TemplateContextType; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.DialogWrapper; -import com.intellij.openapi.ui.Splitter; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreePath; -import java.awt.*; -import java.util.ArrayList; -import java.util.Collection; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Apr 23, 2004 - * Time: 5:03:52 PM - * To change this template use File | Settings | File Templates. - */ -public class SelectTemplateDialog extends DialogWrapper { - private final boolean showHistory; - private Editor searchPatternEditor; - private Editor replacePatternEditor; - private final boolean replace; - private final Project project; - private final ExistingTemplatesComponent existingTemplatesComponent; - - private MySelectionListener selectionListener; - private CardLayout myCardLayout; - private JPanel myPreviewPanel; - @NonNls private static final String PREVIEW_CARD = "Preview"; - @NonNls private static final String SELECT_TEMPLATE_CARD = "SelectCard"; - - public SelectTemplateDialog(Project project, boolean showHistory, boolean replace) { - super(project, false); - - this.project = project; - this.showHistory = showHistory; - this.replace = replace; - existingTemplatesComponent = ExistingTemplatesComponent.getInstance(this.project); - - setTitle(SSRBundle.message(this.showHistory ? "used.templates.history.dialog.title" : "existing.templates.dialog.title")); - init(); - - if (this.showHistory) { - final int selection = existingTemplatesComponent.getHistoryList().getSelectedIndex(); - if (selection != -1) { - setPatternFromList(selection); - } - } - else { - final TreePath selection = existingTemplatesComponent.getPatternTree().getSelectionPath(); - if (selection != null) { - setPatternFromNode((DefaultMutableTreeNode)selection.getLastPathComponent()); - } - else { - showPatternPreviewFromConfiguration(null); - } - } - - setupListeners(); - } - - class MySelectionListener implements TreeSelectionListener, ListSelectionListener { - public void valueChanged(TreeSelectionEvent e) { - if (e.getNewLeadSelectionPath() != null) { - setPatternFromNode( - (DefaultMutableTreeNode)e.getNewLeadSelectionPath().getLastPathComponent() - ); - } - } - - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting() || e.getLastIndex() == -1) return; - int selectionIndex = existingTemplatesComponent.getHistoryList().getSelectedIndex(); - if (selectionIndex != -1) { - setPatternFromList(selectionIndex); - } - } - } - - private void setPatternFromList(int index) { - showPatternPreviewFromConfiguration( - (Configuration)existingTemplatesComponent.getHistoryList().getModel().getElementAt(index) - ); - } - - protected JComponent createCenterPanel() { - final JPanel centerPanel = new JPanel(new BorderLayout()); - Splitter splitter; - - centerPanel.add(BorderLayout.CENTER, splitter = new Splitter(false, 0.3f)); - centerPanel.add(splitter); - - splitter.setFirstComponent( - showHistory ? - existingTemplatesComponent.getHistoryPanel() : - existingTemplatesComponent.getTemplatesPanel() - ); - final JPanel panel; - splitter.setSecondComponent( - panel = new JPanel(new BorderLayout()) - ); - - searchPatternEditor = UIUtil.createEditor( - EditorFactory.getInstance().createDocument(""), - project, - false, - true, - ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), TemplateContextType.class) - ); - - JComponent centerComponent; - - if (replace) { - replacePatternEditor = UIUtil.createEditor( - EditorFactory.getInstance().createDocument(""), - project, - false, - true, - ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), TemplateContextType.class) - ); - centerComponent = new Splitter(true); - ((Splitter)centerComponent).setFirstComponent(searchPatternEditor.getComponent()); - ((Splitter)centerComponent).setSecondComponent(replacePatternEditor.getComponent()); - } - else { - centerComponent = searchPatternEditor.getComponent(); - } - - myCardLayout = new CardLayout(); - myPreviewPanel = new JPanel(myCardLayout); - myPreviewPanel.add(centerComponent, PREVIEW_CARD); - JPanel selectPanel = new JPanel(new GridBagLayout()); - GridBagConstraints gb = new GridBagConstraints(0,0,0,0,0,0,GridBagConstraints.CENTER,GridBagConstraints.NONE, new Insets(0,0,0,0),0,0); - selectPanel.add(new JLabel(SSRBundle.message("selecttemplate.template.label.please.select.template")), gb); - myPreviewPanel.add(selectPanel, SELECT_TEMPLATE_CARD); - - panel.add(BorderLayout.CENTER, myPreviewPanel); - - panel.add(BorderLayout.NORTH, new JLabel(SSRBundle.message("selecttemplate.template.preview"))); - return centerPanel; - } - - public void dispose() { - EditorFactory.getInstance().releaseEditor(searchPatternEditor); - if (replacePatternEditor != null) EditorFactory.getInstance().releaseEditor(replacePatternEditor); - removeListeners(); - super.dispose(); - } - - public JComponent getPreferredFocusedComponent() { - return showHistory ? - existingTemplatesComponent.getHistoryList() : - existingTemplatesComponent.getPatternTree(); - } - - protected String getDimensionServiceKey() { - return "#com.intellij.structuralsearch.plugin.ui.SelectTemplateDialog"; - } - - private void setupListeners() { - existingTemplatesComponent.setOwner(this); - selectionListener = new MySelectionListener(); - - if (showHistory) { - existingTemplatesComponent.getHistoryList().getSelectionModel().addListSelectionListener( - selectionListener - ); - } - else { - existingTemplatesComponent.getPatternTree().getSelectionModel().addTreeSelectionListener( - selectionListener - ); - } - } - - private void removeListeners() { - existingTemplatesComponent.setOwner(null); - if (showHistory) { - existingTemplatesComponent.getHistoryList().getSelectionModel().removeListSelectionListener( - selectionListener - ); - } - else { - existingTemplatesComponent.getPatternTree().getSelectionModel().removeTreeSelectionListener(selectionListener); - } - } - - private void setPatternFromNode(DefaultMutableTreeNode node) { - if (node == null) return; - final Object userObject = node.getUserObject(); - final Configuration configuration; - - // root could be without search template - if (userObject instanceof Configuration) { - configuration = (Configuration)userObject; - } - else { - configuration = null; - } - - showPatternPreviewFromConfiguration(configuration); - } - - private void showPatternPreviewFromConfiguration(@Nullable final Configuration configuration) { - if (configuration == null) { - myCardLayout.show(myPreviewPanel, SELECT_TEMPLATE_CARD); - return; - } - else { - myCardLayout.show(myPreviewPanel, PREVIEW_CARD); - } - final MatchOptions matchOptions = configuration.getMatchOptions(); - - UIUtil.setContent( - searchPatternEditor, - matchOptions.getSearchPattern(), - 0, - searchPatternEditor.getDocument().getTextLength(), - project - ); - - searchPatternEditor.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, configuration); - - if (replace) { - String replacement; - - if (configuration instanceof ReplaceConfiguration) { - replacement = ((ReplaceConfiguration)configuration).getOptions().getReplacement(); - } - else { - replacement = configuration.getMatchOptions().getSearchPattern(); - } - - UIUtil.setContent( - replacePatternEditor, - replacement, - 0, - replacePatternEditor.getDocument().getTextLength(), - project - ); - - replacePatternEditor.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, configuration); - } - } - - @NotNull public Configuration[] getSelectedConfigurations() { - if (showHistory) { - Object[] selectedValues = existingTemplatesComponent.getHistoryList().getSelectedValues(); - if (selectedValues == null) { - return new Configuration[0]; - } - Collection<Configuration> configurations = new ArrayList<Configuration>(); - for (Object selectedValue : selectedValues) { - if (selectedValue instanceof Configuration) { - configurations.add((Configuration)selectedValue); - } - } - return configurations.toArray(new Configuration[configurations.size()]); - } - else { - TreePath[] paths = existingTemplatesComponent.getPatternTree().getSelectionModel().getSelectionPaths(); - if (paths == null) { - return new Configuration[0]; - } - Collection<Configuration> configurations = new ArrayList<Configuration>(); - for (TreePath path : paths) { - - DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); - final Object userObject = node.getUserObject(); - if (userObject instanceof Configuration) { - configurations.add((Configuration)userObject); - } - } - return configurations.toArray(new Configuration[configurations.size()]); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SubstitutionShortInfoHandler.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SubstitutionShortInfoHandler.java deleted file mode 100644 index 32f1302336f3..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/SubstitutionShortInfoHandler.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.codeInsight.hint.TooltipGroup; -import com.intellij.codeInsight.template.impl.TemplateImplUtil; -import com.intellij.codeInsight.template.impl.Variable; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.LogicalPosition; -import com.intellij.openapi.editor.event.*; -import com.intellij.openapi.util.Key; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Apr 23, 2004 - * Time: 5:20:56 PM - * To change this template use File | Settings | File Templates. - */ -public class SubstitutionShortInfoHandler implements DocumentListener, EditorMouseMotionListener, CaretListener { - private static final TooltipGroup SS_INFO_TOOLTIP_GROUP = new TooltipGroup("SS_INFO_TOOLTIP_GROUP", 0); - - private long modificationTimeStamp; - private final ArrayList<Variable> variables = new ArrayList<Variable>(); - private final Editor editor; - public static final Key<Configuration> CURRENT_CONFIGURATION_KEY = Key.create("SS.CurrentConfiguration"); - - SubstitutionShortInfoHandler(@NotNull Editor _editor) { - editor = _editor; - } - - public void beforeDocumentChange(DocumentEvent event) { - } - - public void documentChanged(DocumentEvent event) { - } - - public void mouseMoved(EditorMouseEvent e) { - LogicalPosition position = editor.xyToLogicalPosition( e.getMouseEvent().getPoint() ); - - handleInputFocusMovement(position); - } - - private void handleInputFocusMovement(LogicalPosition position) { - checkModelValidity(); - String text = ""; - final int offset = editor.logicalPositionToOffset(position); - final int length = editor.getDocument().getTextLength(); - final CharSequence elements = editor.getDocument().getCharsSequence(); - - int start = offset-1; - int end = -1; - while(start >=0 && Character.isJavaIdentifierPart(elements.charAt(start)) && elements.charAt(start)!='$') start--; - - if (start >=0 && elements.charAt(start)=='$') { - end = offset; - - while(end < length && Character.isJavaIdentifierPart(elements.charAt(end)) && elements.charAt(end)!='$') end++; - if (end < length && elements.charAt(end)=='$') { - String varname = elements.subSequence(start + 1, end).toString(); - Variable foundVar = null; - - for(Iterator<Variable> i=variables.iterator();i.hasNext();) { - final Variable var = i.next(); - - if (var.getName().equals(varname)) { - foundVar = var; - break; - } - } - - if (foundVar!=null) { - text = UIUtil.getShortParamString(editor.getUserData(CURRENT_CONFIGURATION_KEY),varname); - } - } - } - - if (text.length() > 0) { - UIUtil.showTooltip(editor, start, end, text, SS_INFO_TOOLTIP_GROUP); - } - } - - private void checkModelValidity() { - Document document = editor.getDocument(); - if (modificationTimeStamp != document.getModificationStamp()) { - variables.clear(); - variables.addAll(TemplateImplUtil.parseVariables(document.getCharsSequence()).values()); - modificationTimeStamp = document.getModificationStamp(); - } - } - - public void mouseDragged(EditorMouseEvent e) { - } - - public void caretPositionChanged(CaretEvent e) { - handleInputFocusMovement(e.getNewPosition()); - } - - @Override - public void caretAdded(CaretEvent e) { - } - - @Override - public void caretRemoved(CaretEvent e) { - } - - public ArrayList<Variable> getVariables() { - checkModelValidity(); - return variables; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java deleted file mode 100644 index aa3ca82725b0..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UIUtil.java +++ /dev/null @@ -1,241 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.codeInsight.hint.TooltipController; -import com.intellij.codeInsight.hint.TooltipGroup; -import com.intellij.codeInsight.template.TemplateContextType; -import com.intellij.codeInsight.template.impl.TemplateContext; -import com.intellij.codeInsight.template.impl.TemplateEditorUtil; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.command.CommandProcessor; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.editor.EditorFactory; -import com.intellij.openapi.editor.EditorSettings; -import com.intellij.openapi.editor.colors.EditorColors; -import com.intellij.openapi.editor.colors.EditorColorsManager; -import com.intellij.openapi.editor.colors.EditorColorsScheme; -import com.intellij.openapi.editor.ex.EditorEx; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.OpenFileDescriptor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.*; -import com.intellij.structuralsearch.*; -import com.intellij.structuralsearch.plugin.StructuralReplaceAction; -import com.intellij.structuralsearch.plugin.StructuralSearchAction; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceConfiguration; -import com.intellij.structuralsearch.plugin.util.SmartPsiPointer; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import java.awt.*; - -/** - * @author Maxim.Mossienko - * Date: Apr 21, 2004 - * Time: 7:50:48 PM - */ -public class UIUtil { - static Key<SubstitutionShortInfoHandler> LISTENER_KEY = Key.create("sslistener.key"); - private static final String MODIFY_EDITOR_CONTENT = SSRBundle.message("modify.editor.content.command.name"); - @NonNls private static final String SS_GROUP = "structuralsearchgroup"; - - @NotNull - public static Editor createEditor(Document doc, final Project project, boolean editable, @Nullable TemplateContextType contextType) { - return createEditor(doc, project, editable, false, contextType); - } - - @NotNull - public static Editor createEditor(@NotNull Document doc, - final Project project, - boolean editable, - boolean addToolTipForVariableHandler, - @Nullable TemplateContextType contextType) { - final Editor editor = - editable ? EditorFactory.getInstance().createEditor(doc, project) : EditorFactory.getInstance().createViewer(doc, project); - - EditorSettings editorSettings = editor.getSettings(); - editorSettings.setVirtualSpace(false); - editorSettings.setLineMarkerAreaShown(false); - editorSettings.setIndentGuidesShown(false); - editorSettings.setLineNumbersShown(false); - editorSettings.setFoldingOutlineShown(false); - - EditorColorsScheme scheme = editor.getColorsScheme(); - scheme.setColor(EditorColors.CARET_ROW_COLOR, null); - if (!editable) { - final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme(); - Color c = globalScheme.getColor(EditorColors.READONLY_BACKGROUND_COLOR); - - if (c == null) { - c = globalScheme.getDefaultBackground(); - } - - ((EditorEx)editor).setBackgroundColor(c); - } - else { - ((EditorEx)editor).setEmbeddedIntoDialogWrapper(true); - } - - if (contextType != null) { - TemplateContext context = new TemplateContext(); - context.setEnabled(contextType, true); - TemplateEditorUtil.setHighlighter(editor, context); - } - - if (addToolTipForVariableHandler) { - SubstitutionShortInfoHandler handler = new SubstitutionShortInfoHandler(editor); - editor.addEditorMouseMotionListener(handler); - editor.getDocument().addDocumentListener(handler); - editor.getCaretModel().addCaretListener(handler); - editor.putUserData(LISTENER_KEY, handler); - } - - return editor; - } - - public static JComponent createOptionLine(JComponent[] options) { - JPanel tmp = new JPanel(); - - tmp.setLayout(new BoxLayout(tmp, BoxLayout.X_AXIS)); - for (int i = 0; i < options.length; i++) { - if (i != 0) { - tmp.add(Box.createHorizontalStrut(com.intellij.util.ui.UIUtil.DEFAULT_HGAP)); - } - tmp.add(options[i]); - } - tmp.add(Box.createHorizontalGlue()); - - return tmp; - } - - public static JComponent createOptionLine(JComponent option) { - return createOptionLine(new JComponent[]{option}); - } - - public static void setContent(final Editor editor, String val, final int from, final int end, final Project project) { - final String value = val != null ? val : ""; - - CommandProcessor.getInstance().executeCommand(project, new Runnable() { - public void run() { - ApplicationManager.getApplication().runWriteAction(new Runnable() { - public void run() { - editor.getDocument().replaceString(from, (end == -1) ? editor.getDocument().getTextLength() : end, value); - } - }); - } - }, MODIFY_EDITOR_CONTENT, SS_GROUP); - } - - static String getShortParamString(Configuration config, String varname) { - if (config == null) return ""; - final MatchOptions options = config.getMatchOptions(); - - - final MatchVariableConstraint constraint = options == null ? null : options.getVariableConstraint(varname); - NamedScriptableDefinition namedScriptableDefinition = constraint; - - final ReplacementVariableDefinition replacementVariableDefinition = - config instanceof ReplaceConfiguration ? ((ReplaceConfiguration)config).getOptions().getVariableDefinition(varname) : null; - if (replacementVariableDefinition != null) namedScriptableDefinition = replacementVariableDefinition; - - if (constraint == null && replacementVariableDefinition == null) { - return SSRBundle.message("no.constraints.specified.tooltip.message"); - } - - final StringBuilder buf = new StringBuilder(); - - if (constraint != null) { - if (constraint.isPartOfSearchResults()) { - append(buf, SSRBundle.message("target.tooltip.message")); - } - if (constraint.getRegExp() != null && constraint.getRegExp().length() > 0) { - append(buf, SSRBundle.message("text.tooltip.message", constraint.isInvertRegExp() ? SSRBundle.message("not.tooltip.message") : "", - constraint.getRegExp(), - constraint.isWithinHierarchy() || constraint.isStrictlyWithinHierarchy() ? - SSRBundle.message("within.hierarchy.tooltip.message") : "")); - } - - if (constraint.getNameOfExprType() != null && constraint.getNameOfExprType().length() > 0) { - append(buf, SSRBundle.message("exprtype.tooltip.message", - constraint.isInvertExprType() ? SSRBundle.message("not.tooltip.message") : "", - constraint.getNameOfExprType(), - constraint.isExprTypeWithinHierarchy() ? SSRBundle.message("within.hierarchy.tooltip.message") : "")); - } - - if (constraint.getMinCount() == constraint.getMaxCount()) { - append(buf, SSRBundle.message("occurs.tooltip.message", constraint.getMinCount())); - } - else { - append(buf, SSRBundle.message("min.occurs.tooltip.message", constraint.getMinCount(), - constraint.getMaxCount() == Integer.MAX_VALUE ? - StringUtil.decapitalize(SSRBundle.message("editvarcontraints.unlimited")) : - constraint.getMaxCount())); - } - } - - final String script = namedScriptableDefinition.getScriptCodeConstraint(); - if (script != null && script.length() > 2) { - final String str = SSRBundle.message("script.tooltip.message", StringUtil.stripQuotesAroundValue(script)); - append(buf, str); - } - - return buf.toString(); - } - - private static void append(final StringBuilder buf, final String str) { - if (buf.length() > 0) buf.append(", "); - buf.append(str); - } - - public static void navigate(PsiElement result) { - FileEditorManager.getInstance(result.getProject()).openTextEditor( - new OpenFileDescriptor(result.getProject(), result.getContainingFile().getVirtualFile(), result.getTextOffset()), true); - } - - public static void navigate(MatchResult result) { - final SmartPsiPointer ref = result.getMatchRef(); - - FileEditorManager.getInstance(ref.getProject()) - .openTextEditor(new OpenFileDescriptor(ref.getProject(), ref.getFile(), ref.getOffset()), true); - } - - public static void invokeAction(Configuration config, SearchContext context) { - if (config instanceof SearchConfiguration) { - StructuralSearchAction.triggerAction(config, context); - } - else { - StructuralReplaceAction.triggerAction(config, context); - } - } - - static void showTooltip(@NotNull Editor editor, final int start, int end, @NotNull String text, @NotNull TooltipGroup group) { - Rectangle visibleArea = editor.getScrollingModel().getVisibleArea(); - Point top = editor.logicalPositionToXY(editor.offsetToLogicalPosition(start)); - final int documentLength = editor.getDocument().getTextLength(); - if (end >= documentLength) end = documentLength; - Point bottom = editor.logicalPositionToXY(editor.offsetToLogicalPosition(end)); - - Point bestPoint = new Point(top.x, bottom.y + editor.getLineHeight()); - - if (!visibleArea.contains(bestPoint)) { - int defaultOffset = editor.logicalPositionToOffset(editor.xyToLogicalPosition(new Point(0, 0))); - bestPoint = editor.logicalPositionToXY(editor.offsetToLogicalPosition(defaultOffset)); - } - - Point p = SwingUtilities.convertPoint(editor.getContentComponent(), bestPoint, editor.getComponent().getRootPane().getLayeredPane()); - TooltipController.getInstance().showTooltip(editor, p, text, false, group); - } - - public static void updateHighlighter(Editor editor, StructuralSearchProfile profile) { - final TemplateContextType contextType = profile.getTemplateContextType(); - if (contextType != null) { - TemplateContext context = new TemplateContext(); - context.setEnabled(contextType, true); - TemplateEditorUtil.setHighlighter(editor, context); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UsageViewContext.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UsageViewContext.java deleted file mode 100644 index a55a16d4c379..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/UsageViewContext.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui; - -import com.intellij.navigation.ItemPresentation; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.KeyboardShortcut; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileEditor.FileEditor; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiFile; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.plugin.replace.ui.ReplaceCommand; -import com.intellij.usages.*; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.util.Set; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 9, 2005 - * Time: 2:47:49 PM - * To change this template use File | Settings | File Templates. - */ -public class UsageViewContext { - protected final SearchContext mySearchContext; - private UsageView myUsageView; - protected final Configuration myConfiguration; - private Set<Usage> myExcludedSet; - private SearchCommand myCommand; - - protected UsageViewContext(SearchContext _searchContext,Configuration _configuration) { - myConfiguration = _configuration; - mySearchContext = _searchContext; - } - - public boolean isExcluded(Usage usage) { - if (myExcludedSet == null) myExcludedSet = myUsageView.getExcludedUsages(); - return myExcludedSet.contains(usage); - } - - public UsageView getUsageView() { - return myUsageView; - } - - public void setUsageView(final UsageView usageView) { - myUsageView = usageView; - } - - public Configuration getConfiguration() { - return myConfiguration; - } - - public SearchCommand getCommand() { - if (myCommand == null) myCommand = createCommand(); - return myCommand; - } - - protected SearchCommand createCommand() { - return new SearchCommand(mySearchContext.getProject(), this); - } - - protected String _getPresentableText() { - return myConfiguration.getMatchOptions().getSearchPattern(); - } - - public UsageTarget getTarget() { - return new MyUsageTarget(_getPresentableText()); - } - - public void configure(@NotNull UsageViewPresentation presentation) { - String s = _getPresentableText(); - if (s.length() > 15) s = s.substring(0,15) + "..."; - final String usagesString = SSRBundle.message("occurrences.of", s); - presentation.setUsagesString(usagesString); - presentation.setTabText(StringUtil.capitalize(usagesString)); - presentation.setUsagesWord(SSRBundle.message("occurrence")); - presentation.setCodeUsagesString(SSRBundle.message("found.occurrences")); - } - - protected void configureActions() {} - - private class MyUsageTarget implements ConfigurableUsageTarget,ItemPresentation { - private final String myPresentableText; - - MyUsageTarget(String str) { - myPresentableText = str; - } - - @Override - public String getPresentableText() { - return myPresentableText; - } - - @Override - public String getLocationString() { - //noinspection HardCodedStringLiteral - return "Do Not Know Where"; - } - - @Override - public Icon getIcon(boolean open) { - return null; - } - - @Override - public void findUsages() { - throw new UnsupportedOperationException(); - } - - @Override - public void findUsagesInEditor(@NotNull FileEditor editor) { - throw new UnsupportedOperationException(); - } - - @Override - public void highlightUsages(@NotNull PsiFile file, @NotNull Editor editor, boolean clearHighlights) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isValid() { - return true; - } - - @Override - public boolean isReadOnly() { - return true; - } - - @Override - public VirtualFile[] getFiles() { - return null; - } - - @Override - public void update() { - } - - @Override - public String getName() { - //noinspection HardCodedStringLiteral - return "my name"; - } - - @Override - public ItemPresentation getPresentation() { - return this; - } - - @Override - public void navigate(boolean requestFocus) { - throw new UnsupportedOperationException(); - } - - @Override - public boolean canNavigate() { - return false; - } - - @Override - public boolean canNavigateToSource() { - return false; - } - - @Override - public void showSettings() { - UIUtil.invokeAction(myConfiguration, mySearchContext); - } - - @Override - public KeyboardShortcut getShortcut() { - return ActionManager.getInstance().getKeyboardShortcut(getCommand() instanceof ReplaceCommand ? "StructuralSearchPlugin.StructuralReplaceAction":"StructuralSearchPlugin.StructuralSearchAction"); - } - - @NotNull - @Override - public String getLongDescriptiveName() { - return _getPresentableText(); - } - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/VarConstraints.form b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/VarConstraints.form deleted file mode 100644 index 20094b213e64..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/VarConstraints.form +++ /dev/null @@ -1,350 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.structuralsearch.plugin.ui.EditVarConstraintsDialog"> - <grid id="53af4" binding="mainForm" layout-manager="GridLayoutManager" row-count="8" 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> - <xy x="24" y="82" width="889" height="681"/> - </constraints> - <properties/> - <border type="none"/> - <children> - <grid id="33d30" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="8" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/> - </clientProperties> - <border type="none" title-resource-bundle="messages/SSRBundle" title-key="var.constraints.variables.border"/> - <children> - <grid id="d6a7" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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"/> - </constraints> - <properties/> - <border type="none"/> - <children> - <component id="e85ba" class="com.intellij.ui.components.JBList" binding="parameterList"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false"> - <preferred-size width="150" height="50"/> - </grid> - </constraints> - <properties/> - </component> - </children> - </grid> - </children> - </grid> - <grid id="4cae8" binding="textConstraintsPanel" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> - <constraints> - <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> - </clientProperties> - <border type="none" title-resource-bundle="messages/SSRBundle" title-key="var.constraints.text.constraints.border"/> - <children> - <component id="cc210" class="javax.swing.JLabel"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/SSRBundle" key="editvarcontraints.text.regular.expression"/> - </properties> - </component> - <component id="3b03c" class="com.intellij.ui.EditorTextField" binding="regexp" custom-create="true"> - <constraints> - <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> - <preferred-size width="150" height="-1"/> - </grid> - </constraints> - <properties/> - </component> - <component id="f7d70" class="javax.swing.JCheckBox" binding="applyWithinTypeHierarchy"> - <constraints> - <grid row="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.apply.constraint.within.type.hierarchy"/> - </properties> - </component> - <component id="b766f" class="javax.swing.JCheckBox" binding="notRegexp"> - <constraints> - <grid row="0" column="2" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.invert.condition"/> - </properties> - </component> - <component id="51cbf" class="javax.swing.JCheckBox" binding="wholeWordsOnly"> - <constraints> - <grid row="1" column="2" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.whole.words.only"/> - </properties> - </component> - </children> - </grid> - <grid id="bb81f" binding="expressionConstraints" layout-manager="GridLayoutManager" row-count="6" 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="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> - </clientProperties> - <border type="none" title-resource-bundle="messages/SSRBundle" title-key="var.constraints.expression.constraints.border"/> - <children> - <component id="2bdb4" class="javax.swing.JCheckBox" binding="read"> - <constraints> - <grid row="0" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.value.is.read"/> - </properties> - </component> - <component id="aba7e" class="javax.swing.JCheckBox" binding="write"> - <constraints> - <grid row="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.value.is.written"/> - </properties> - </component> - <component id="5698c" class="javax.swing.JCheckBox" binding="notRead"> - <constraints> - <grid row="0" column="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.invert.condition"/> - </properties> - </component> - <component id="79e72" class="javax.swing.JCheckBox" binding="notWrite"> - <constraints> - <grid row="1" column="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.invert.condition"/> - </properties> - </component> - <component id="e9391" class="com.intellij.ui.EditorTextField" binding="regexprForExprType" custom-create="true"> - <constraints> - <grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> - <preferred-size width="150" height="-1"/> - </grid> - </constraints> - <properties/> - </component> - <component id="59512" class="javax.swing.JCheckBox" binding="exprTypeWithinHierarchy"> - <constraints> - <grid row="3" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.apply.constraint.within.type.hierarchy"/> - </properties> - </component> - <component id="17342" class="javax.swing.JCheckBox" binding="notExprType"> - <constraints> - <grid row="3" column="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.invert.condition"/> - </properties> - </component> - <component id="4d6d0" class="javax.swing.JLabel"> - <constraints> - <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/SSRBundle" key="editvarcontraints.text.regular.expression.for.java.expression.type"/> - </properties> - </component> - <component id="a97fa" 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="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/SSRBundle" key="editvarcontraints.text.regular.expression.for.formal.argument.type.of.the.method"/> - </properties> - </component> - <component id="d02c2" class="com.intellij.ui.EditorTextField" binding="formalArgType" custom-create="true"> - <constraints> - <grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> - <preferred-size width="150" height="-1"/> - </grid> - </constraints> - <properties/> - </component> - <component id="bc6d0" class="javax.swing.JCheckBox" binding="invertFormalArgType"> - <constraints> - <grid row="5" column="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.invert.condition"/> - </properties> - </component> - <component id="2b0ea" class="javax.swing.JCheckBox" binding="formalArgTypeWithinHierarchy"> - <constraints> - <grid row="5" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.apply.constraint.within.type.hierarchy"/> - </properties> - </component> - </children> - </grid> - <component id="9a3a8" class="javax.swing.JCheckBox" binding="partOfSearchResults"> - <constraints> - <grid row="6" column="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.this.variable.is.target.of.the.search"/> - </properties> - </component> - <vspacer id="d06dd"> - <constraints> - <grid row="7" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/> - </constraints> - </vspacer> - <grid id="2a918" 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="5" 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"/> - <children> - <grid id="964fd" 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="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"/> - </constraints> - <properties/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> - </clientProperties> - <border type="none" title-resource-bundle="messages/SSRBundle" title-key="var.constraints.script.constraints.border"/> - <children> - <component id="cdf9" class="javax.swing.JLabel"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/SSRBundle" key="script.option.text"/> - </properties> - </component> - <component id="e7633" class="com.intellij.openapi.ui.ComponentWithBrowseButton" binding="customScriptCode" custom-create="true"> - <constraints> - <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> - <preferred-size width="150" height="-1"/> - </grid> - </constraints> - <properties/> - </component> - </children> - </grid> - </children> - </grid> - <grid id="d8664" binding="occurencePanel" layout-manager="GridLayoutManager" row-count="2" 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="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> - </clientProperties> - <border type="none" title-resource-bundle="messages/SSRBundle" title-key="var.constraints.occurrences.count.border"/> - <children> - <component id="e4b4a" class="javax.swing.JLabel"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/SSRBundle" key="editvarcontraints.minimum.count"/> - </properties> - </component> - <component id="f6a1a" class="javax.swing.JTextField" binding="minoccurs"> - <constraints> - <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> - <preferred-size width="50" height="-1"/> - <maximum-size width="50" height="-1"/> - </grid> - </constraints> - <properties> - <text value="1"/> - </properties> - </component> - <component id="881e7" class="javax.swing.JLabel"> - <constraints> - <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties> - <text resource-bundle="messages/SSRBundle" key="editvarcontraints.maximum.count"/> - </properties> - </component> - <component id="42" class="javax.swing.JTextField" binding="maxoccurs"> - <constraints> - <grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> - <preferred-size width="50" height="-1"/> - </grid> - </constraints> - <properties> - <columns value="0"/> - <text value="1"/> - </properties> - </component> - <component id="7c33b" class="javax.swing.JCheckBox" binding="maxoccursUnlimited"> - <constraints> - <grid row="1" column="3" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.unlimited"/> - </properties> - </component> - </children> - </grid> - <grid id="463bd" binding="containedInConstraints" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1"> - <margin top="0" left="0" bottom="0" right="0"/> - <constraints> - <grid row="2" 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/> - <clientProperties> - <BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/> - </clientProperties> - <border type="none" title="Contained in constraints"/> - <children> - <component id="7003f" class="com.intellij.ui.ComboboxWithBrowseButton" binding="withinCombo"> - <constraints> - <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - </component> - <component id="896c2" class="javax.swing.JCheckBox" binding="invertWithinIn"> - <constraints> - <grid row="1" 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 resource-bundle="messages/SSRBundle" key="editvarcontraints.invert.condition"/> - </properties> - </component> - </children> - </grid> - <component id="ce461" class="javax.swing.JLabel" binding="myRegExHelpLabel" custom-create="true"> - <constraints> - <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/> - </constraints> - <properties/> - </component> - </children> - </grid> -</form> diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/actions/DoSearchAction.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/actions/DoSearchAction.java deleted file mode 100644 index ed0da3a3f391..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/ui/actions/DoSearchAction.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.intellij.structuralsearch.plugin.ui.actions; - -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.*; -import com.intellij.openapi.project.Project; - -/** - * Does the search action - */ -public class DoSearchAction { - public static void execute(final Project project, MatchResultSink sink, - final Configuration configuration) { - final MatchOptions options = configuration.getMatchOptions(); - - final Matcher matcher = new Matcher(project); - try { - matcher.findMatches(sink, options); - } - finally { - sink.matchingFinished(); - } - } - -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/util/CollectingMatchResultSink.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/util/CollectingMatchResultSink.java deleted file mode 100644 index 4caff77bdc06..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/util/CollectingMatchResultSink.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.intellij.structuralsearch.plugin.util; - -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.psi.PsiFile; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.MatchResultSink; -import com.intellij.structuralsearch.MatchingProcess; -import org.jetbrains.annotations.NotNull; - -import java.util.LinkedList; -import java.util.List; - -public class CollectingMatchResultSink implements MatchResultSink { - private final List<MatchResult> matches = new LinkedList<MatchResult>(); - - public void newMatch(MatchResult result) { - matches.add(result); - } - - /* Notifies sink about starting the matching for given element - * @param element the current file - */ - public void processFile(PsiFile element) { - } - - public void matchingFinished() { - } - - public ProgressIndicator getProgressIndicator() { - return null; - } - - public void setMatchingProcess(MatchingProcess process) { - } - - @NotNull - public List<MatchResult> getMatches() { - return matches; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/util/SmartPsiPointer.java b/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/util/SmartPsiPointer.java deleted file mode 100644 index 0fee846c77b0..000000000000 --- a/plugins/structuralsearch/source/com/intellij/structuralsearch/plugin/util/SmartPsiPointer.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.intellij.structuralsearch.plugin.util; - -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiElement; -import com.intellij.psi.SmartPointerManager; -import com.intellij.psi.SmartPsiElementPointer; - -/** - * Reference to element have been matched - */ -public class SmartPsiPointer { - private SmartPsiElementPointer pointer; - - public SmartPsiPointer(PsiElement element) { - pointer = element != null ? SmartPointerManager.getInstance(element.getProject()).createSmartPsiElementPointer(element):null; - } - - public VirtualFile getFile() { - return pointer != null ? pointer.getVirtualFile():null; - } - - public int getOffset() { - return pointer != null ? pointer.getElement().getTextRange().getStartOffset():-1; - } - - public int getLength() { - return pointer != null ? pointer.getElement().getTextRange().getEndOffset():0; - } - - public PsiElement getElement() { - return pointer != null ? pointer.getElement():null; - } - - public void clear() { - pointer = null; - } - - public Project getProject() { - return pointer != null ? pointer.getElement().getProject():null; - } - - public boolean equals(Object o) { - if (o instanceof SmartPsiPointer) { - final SmartPsiPointer ref = ((SmartPsiPointer)o); - return ref.getFile().equals(getFile()) && - ref.getOffset() == getOffset() && - ref.getLength() == getLength(); - } - return false; - } - - public int hashCode() { - return pointer != null ? getElement().hashCode():0; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/AnonymToken.java b/plugins/structuralsearch/source/com/intellij/tokenindex/AnonymToken.java deleted file mode 100644 index c364ccc3f9c5..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/AnonymToken.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.intellij.tokenindex; - -/** - * @author Eugene.Kudelevsky - */ -public class AnonymToken extends Token { - private final byte myType; - - public AnonymToken(byte type, int start, int end) { - super(start, end); - myType = type; - } - - public byte getType() { - return myType; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - AnonymToken that = (AnonymToken)o; - - if (myType != that.myType) return false; - - return true; - } - - @Override - public int hashCode() { - return myType; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/IndentToken.java b/plugins/structuralsearch/source/com/intellij/tokenindex/IndentToken.java deleted file mode 100644 index 9409d185c808..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/IndentToken.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.intellij.tokenindex; - -/** - * @author Eugene.Kudelevsky - */ -public class IndentToken extends Token { - public IndentToken(int start, int end) { - super(start, end); - } - - @Override - public boolean equals(Object obj) { - return obj instanceof IndentToken; - } - - @Override - public int hashCode() { - return getClass().hashCode(); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/LanguageTokenizer.java b/plugins/structuralsearch/source/com/intellij/tokenindex/LanguageTokenizer.java deleted file mode 100644 index 7e8986b25ada..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/LanguageTokenizer.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.intellij.tokenindex; - -import com.intellij.lang.LanguageExtension; - -/** - * @author Eugene.Kudelevsky - */ -public class LanguageTokenizer extends LanguageExtension<Tokenizer> { - public static final LanguageTokenizer INSTANCE = new LanguageTokenizer(); - - private LanguageTokenizer() { - super("com.intellij.tokenindex.tokenizer", null); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/PathMarkerToken.java b/plugins/structuralsearch/source/com/intellij/tokenindex/PathMarkerToken.java deleted file mode 100644 index f74590f46bb1..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/PathMarkerToken.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.intellij.tokenindex; - -import org.jetbrains.annotations.NotNull; - -/** - * @author Eugene.Kudelevsky - */ -public class PathMarkerToken extends Token { - private final String myPath; - - public PathMarkerToken(@NotNull String path) { - super(-1, -1); - myPath = path; - } - - public String getPath() { - return myPath; - } - - @Override - public String toString() { - return myPath; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PathMarkerToken that = (PathMarkerToken)o; - - if (!myPath.equals(that.myPath)) return false; - - return true; - } - - @Override - public int hashCode() { - return myPath.hashCode(); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/PsiMarkerToken.java b/plugins/structuralsearch/source/com/intellij/tokenindex/PsiMarkerToken.java deleted file mode 100644 index c2e7c8b3cf89..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/PsiMarkerToken.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.intellij.tokenindex; - -import com.intellij.psi.PsiFile; - -/** - * @author Eugene.Kudelevsky - */ -public class PsiMarkerToken extends Token { - private final PsiFile myFile; - - public PsiMarkerToken(PsiFile file) { - super(-1, -1); - myFile = file; - } - - public PsiFile getFile() { - return myFile; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/RecursiveTokenizingVisitor.java b/plugins/structuralsearch/source/com/intellij/tokenindex/RecursiveTokenizingVisitor.java deleted file mode 100644 index 013f804a8225..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/RecursiveTokenizingVisitor.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.intellij.tokenindex; - -import com.intellij.lang.Language; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiRecursiveElementWalkingVisitor; -import com.intellij.structuralsearch.StructuralSearchProfile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.util.containers.HashSet; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -/** - * @author Eugene.Kudelevsky - */ -public class RecursiveTokenizingVisitor extends PsiRecursiveElementWalkingVisitor { - private final int myBaseOffset; - private final List<Token> myTokens; - private final Set<String> myLanguages = new HashSet<String>(); - private final Set<Language> myAcceptableLanguages; - - private Language myLastLanguage; - private StructuralSearchProfile myLastProfile; - - public RecursiveTokenizingVisitor(List<Token> tokens, Set<Language> acceptableLanguages, int baseOffset) { - super(true); - myTokens = tokens; - myAcceptableLanguages = acceptableLanguages; - myBaseOffset = baseOffset; - } - - public RecursiveTokenizingVisitor(List<Token> tokens, Set<Language> acceptableLanguages) { - this(tokens, acceptableLanguages, 0); - } - - public RecursiveTokenizingVisitor() { - this(new ArrayList<Token>(), null); - } - - public List<Token> getTokens() { - return myTokens; - } - - public void addToken(Token token) { - myTokens.add(token); - } - - public Set<String> getLanguages() { - return myLanguages; - } - - @Override - public void visitElement(PsiElement element) { - Language language = element.getLanguage(); - if (language != myLastLanguage) { - myLastLanguage = language; - myLastProfile = StructuralSearchUtil.getProfileByPsiElement(element); - } - if (myLastProfile != null) { - language = myLastProfile.getLanguage(element); - } - if (myAcceptableLanguages == null || myAcceptableLanguages.contains(language)) { - Tokenizer tokenizer = StructuralSearchUtil.getTokenizerForLanguage(language); - if (tokenizer != null) { - myLanguages.add(language.getID()); - if (!tokenizer.visit(element, this)) { - return; - } - } - } - super.visitElement(element); - } - - @Override - protected void elementFinished(PsiElement element) { - Tokenizer tokenizer = StructuralSearchUtil.getTokenizerForLanguage(element.getLanguage()); - if (tokenizer != null) { - tokenizer.elementFinished(element, this); - } - } - - public int getBaseOffset() { - return myBaseOffset; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/TextToken.java b/plugins/structuralsearch/source/com/intellij/tokenindex/TextToken.java deleted file mode 100644 index 729491935cfe..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/TextToken.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.intellij.tokenindex; - -/** - * @author Eugene.Kudelevsky - */ -public class TextToken extends Token { - private final int myHash; - - public TextToken(int hash, int start, int end) { - super(start, end); - myHash = hash; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TextToken textToken = (TextToken)o; - - if (myHash != textToken.myHash) return false; - - return true; - } - - @Override - public String toString() { - return Integer.toString(myHash); - } - - @Override - public int hashCode() { - return myHash; - } - - public int getHash() { - return myHash; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/Token.java b/plugins/structuralsearch/source/com/intellij/tokenindex/Token.java deleted file mode 100644 index 2b5428d31826..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/Token.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.intellij.tokenindex; - -/** - * @author Eugene.Kudelevsky - */ -public abstract class Token { - private final int myStart; - private final int myEnd; - - public Token(int start, int end) { - myStart = start; - myEnd = end; - } - - public int getStart() { - return myStart; - } - - public int getEnd() { - return myEnd; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndex.java b/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndex.java deleted file mode 100644 index 4547092eb58f..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndex.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.intellij.tokenindex; - -import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.vfs.JarFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.structuralsearch.StructuralSearchUtil; -import com.intellij.util.containers.HashMap; -import com.intellij.util.indexing.*; -import com.intellij.util.io.DataExternalizer; -import com.intellij.util.io.KeyDescriptor; -import org.jetbrains.annotations.NotNull; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -/** - * @author Eugene.Kudelevsky - */ -public class TokenIndex extends FileBasedIndexExtension<TokenIndexKey, List<Token>> { - private static final int FILE_BLOCK_SIZE = 100; - - public static final ID<TokenIndexKey, List<Token>> INDEX_ID = ID.create("token.index"); - - private static final int VERSION = 3; - - private final KeyDescriptor<TokenIndexKey> myKeyDescriptor = new TokenIndexKeyDescriptor(); - - private static final int ANONYM_TOKEN_ID = 0; - private static final int TEXT_TOKEN_ID = 1; - private static final int MARKER_TOKEN_ID = 2; - private static final int INDENT_TOKEN_ID = 3; - - private final DataExternalizer<List<Token>> myDataExternalizer = new DataExternalizer<List<Token>>() { - @Override - public void save(@NotNull DataOutput out, List<Token> value) throws IOException { - out.writeInt(value.size()); - for (Token token : value) { - if (token instanceof AnonymToken) { - out.writeByte(ANONYM_TOKEN_ID); - out.writeInt(token.getStart()); - out.writeInt(token.getEnd()); - out.writeByte(((AnonymToken)token).getType()); - } - else if (token instanceof TextToken) { - out.writeByte(TEXT_TOKEN_ID); - out.writeInt(token.getStart()); - out.writeInt(token.getEnd()); - out.writeInt(((TextToken)token).getHash()); - } - else if (token instanceof PathMarkerToken) { - out.writeByte(MARKER_TOKEN_ID); - out.writeUTF(((PathMarkerToken)token).getPath()); - } - else if (token instanceof IndentToken) { - out.writeByte(INDENT_TOKEN_ID); - out.writeInt(token.getStart()); - out.writeInt(token.getEnd()); - } - else { - assert false : "Unsupported token type " + token.getClass(); - } - } - } - - @Override - public List<Token> read(@NotNull DataInput in) throws IOException { - List<Token> result = new ArrayList<Token>(); - int n = in.readInt(); - for (int i = 0; i < n; i++) { - byte tokenTypeId = in.readByte(); - switch (tokenTypeId) { - case ANONYM_TOKEN_ID: { - int start = in.readInt(); - int end = in.readInt(); - byte anonymTokenTypeValue = in.readByte(); - result.add(new AnonymToken(anonymTokenTypeValue, start, end)); - break; - } - case TEXT_TOKEN_ID: { - int start = in.readInt(); - int end = in.readInt(); - int hash = in.readInt(); - result.add(new TextToken(hash, start, end)); - break; - } - case MARKER_TOKEN_ID: { - String path = in.readUTF(); - result.add(new PathMarkerToken(path)); - break; - } - case INDENT_TOKEN_ID: - int start = in.readInt(); - int end = in.readInt(); - result.add(new IndentToken(start, end)); - break; - } - } - return result; - } - }; - - @NotNull - @Override - public ID<TokenIndexKey, List<Token>> getName() { - return INDEX_ID; - } - - private static int getBlockId(String filePath) { - int h = filePath.hashCode(); - if (h < 0) { - h = -h; - } - return h % FILE_BLOCK_SIZE; - } - - @NotNull - @Override - public DataIndexer<TokenIndexKey, List<Token>, FileContent> getIndexer() { - return new DataIndexer<TokenIndexKey, List<Token>, FileContent>() { - @Override - @NotNull - public Map<TokenIndexKey, List<Token>> map(@NotNull FileContent inputData) { - if (true) return Collections.EMPTY_MAP; // TODO: Eugene index is VERY unefficient and leads to OME - Map<TokenIndexKey, List<Token>> result = new HashMap<TokenIndexKey, List<Token>>(1); - RecursiveTokenizingVisitor visitor = new RecursiveTokenizingVisitor(); - inputData.getPsiFile().accept(visitor); - List<Token> tokens = visitor.getTokens(); - if (tokens.size() > 0) { - String path = inputData.getFile().getPath(); - tokens.add(new PathMarkerToken(path)); - TokenIndexKey key = new TokenIndexKey(visitor.getLanguages(), getBlockId(path)); - result.put(key, tokens); - } - return result; - } - }; - } - - @NotNull - @Override - public KeyDescriptor<TokenIndexKey> getKeyDescriptor() { - return myKeyDescriptor; - } - - @NotNull - @Override - public DataExternalizer<List<Token>> getValueExternalizer() { - return myDataExternalizer; - } - - @NotNull - @Override - public FileBasedIndex.InputFilter getInputFilter() { - return new FileBasedIndex.InputFilter() { - @Override - public boolean acceptInput(@NotNull VirtualFile file) { - if (file.getFileSystem() instanceof JarFileSystem) return false; - return file.getFileType() instanceof LanguageFileType; - } - }; - } - - @Override - public boolean dependsOnFileContent() { - return true; - } - - @Override - public int getVersion() { - return VERSION; - } - - @Override - public int getCacheSize() { - return 1; - } - - public static boolean supports(Language language) { - return StructuralSearchUtil.getTokenizerForLanguage(language) != null; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java b/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java deleted file mode 100644 index 8c6ec1d93875..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndexKey.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.intellij.tokenindex; - -import org.jetbrains.annotations.NotNull; - -import java.util.Set; - -/** - * @author Eugene.Kudelevsky - */ -public class TokenIndexKey { - private final Set<String> myLanguages; - private final int myBlockId; - - public TokenIndexKey(@NotNull Set<String> languages, int blockId) { - myLanguages = languages; - myBlockId = blockId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TokenIndexKey that = (TokenIndexKey)o; - - if (myBlockId != that.myBlockId) return false; - if (!myLanguages.equals(that.myLanguages)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = myLanguages.hashCode(); - result = 31 * result + myBlockId; - return result; - } - - @Override - public String toString() { - return myLanguages + ": " + myBlockId; - } - - public Set<String> getLanguages() { - return myLanguages; - } - - public boolean containsLanguage(String languageId) { - for (String language : myLanguages) { - if (language.contains(languageId)) { - return true; - } - } - return false; - } - - public int getBlockId() { - return myBlockId; - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndexKeyDescriptor.java b/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndexKeyDescriptor.java deleted file mode 100644 index 901508ce371d..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/TokenIndexKeyDescriptor.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.intellij.tokenindex; - -import com.intellij.util.containers.HashSet; -import com.intellij.util.io.KeyDescriptor; -import org.jetbrains.annotations.NotNull; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.util.Set; - -/** - * @author Eugene.Kudelevsky - */ -public class TokenIndexKeyDescriptor implements KeyDescriptor<TokenIndexKey> { - public int getHashCode(TokenIndexKey value) { - return value.hashCode(); - } - - public boolean isEqual(TokenIndexKey val1, TokenIndexKey val2) { - return val1.equals(val2); - } - - public void save(@NotNull DataOutput out, TokenIndexKey value) throws IOException { - Set<String> languages = value.getLanguages(); - out.writeInt(languages.size()); - for (String language : languages) { - out.writeUTF(language); - } - out.writeInt(value.getBlockId()); - } - - public TokenIndexKey read(@NotNull DataInput in) throws IOException { - int languagesCount = in.readInt(); - Set<String> languages = new HashSet<String>(); - for (int i = 0; i < languagesCount; i++) { - String languageId = in.readUTF(); - languages.add(languageId); - } - int blockId = in.readInt(); - return new TokenIndexKey(languages, blockId); - } -} diff --git a/plugins/structuralsearch/source/com/intellij/tokenindex/Tokenizer.java b/plugins/structuralsearch/source/com/intellij/tokenindex/Tokenizer.java deleted file mode 100644 index c1ce0c70e264..000000000000 --- a/plugins/structuralsearch/source/com/intellij/tokenindex/Tokenizer.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.intellij.tokenindex; - -import com.intellij.psi.PsiElement; -import org.jetbrains.annotations.NotNull; - -/** - * @author Eugene.Kudelevsky - */ -public interface Tokenizer { - boolean visit(@NotNull PsiElement element, RecursiveTokenizingVisitor globalVisitor); - - void elementFinished(@NotNull PsiElement element, RecursiveTokenizingVisitor globalVisitor); -} diff --git a/plugins/structuralsearch/source/inspectionDescriptions/SSBasedInspection.html b/plugins/structuralsearch/source/inspectionDescriptions/SSBasedInspection.html deleted file mode 100644 index b013f6beba4b..000000000000 --- a/plugins/structuralsearch/source/inspectionDescriptions/SSBasedInspection.html +++ /dev/null @@ -1,9 +0,0 @@ -<html> -<body> -<p>This inspection allows to configure number of <b>Structural Search/Structural Replace</b> templates to be applied to the file you are editing. -</p> -<p>All matches are highlighted with the template name you have configured. -If you configured <b>Structural Replace</b> pattern, corresponding replace would appear as a quick fix. -</p> -</body> -</html>
\ No newline at end of file diff --git a/plugins/structuralsearch/source/messages/SSRBundle.properties b/plugins/structuralsearch/source/messages/SSRBundle.properties deleted file mode 100644 index 488c96e84435..000000000000 --- a/plugins/structuralsearch/source/messages/SSRBundle.properties +++ /dev/null @@ -1,240 +0,0 @@ -search.produced.too.many.results.message=Search produced too many results, stopping the search process - -structuralreplace.action=StructuralReplaceAction -structuralsearch.action=StructuralSearchAction - -#replacement dialog preview -structural.replace.preview.dialog.title=Structural Replace Preview -replace.preview.oktext=&Replace -replacement.code=Replacement code - -# Search Dialog specific titles/options -structural.search.title=Structural Search -search.template=Search template: -template.name.button=Template name - -save.template.description.button=Save Template -save.template.text.button=S&ave template... -ssdialog.options.group.border=Options -new.template.defaultname=user defined - -recursive.matching.checkbox=&Recursive matching - -edit.variables.button=E&dit variables... -history.button=&History... -copy.existing.template.button=Co&py existing template... - -open.in.new.tab.checkbox=Open in new &tab - -search.dialog.scope.label=&Scope -search.dialog.file.type.label=File t&ype: -search.dialog.context.label=C&ontext: -search.dialog.file.dialect.label=D&ialect: - -#search usage view specific -looking.in.progress.message=Looking in {0} -found.progress.message=Found {0} occurrences -occurrences.of=occurrences of {0} -occurrence=occurrence -found.occurrences=Found occurrence - -# search dialog messages -this.pattern.is.malformed.message=This pattern is malformed\n {0} -this.pattern.is.unsupported.message=This pattern is unsupported -incorrect.pattern.message=Incorrect pattern - -used.templates.history.dialog.title=Used Templates History -existing.templates.dialog.title=Existing Templates -selecttemplate.template.preview=Template preview: -selecttemplate.template.label.please.select.template=<html><body><center>Please select template in the tree on the left.</center></body></html> - -# Replace Dialog specific titles/options -structural.replace.title=Structural Replace -shorten.fully.qualified.names.checkbox=Sh&orten fully qualified names -format.according.to.style.checkbox=Fo&rmat according to style -replacement.template.label=Replacement template: - -# Replace validation messages -unsupported.replacement.pattern.message=Unsupported Replacement Pattern {0} -malformed.replacement.pattern.message=Malformed Replacement Pattern {0} - -#replacement usage view specific -preview.replacement.button=&Preview Replacement -do.replace.all.button=Replace &All -replace.selected.button=&Replace Selected -replaceusageview.text={0} by {1} - -# predefined configuration categories -expressions.category=expressions -user.defined.category=user defined -xml_html.category=xml/html -generics.category=generics -misc.category=miscellaneous -metadata.category=comments, javadoc and metadata -class.category=class-based -operators.category=operators -j2ee.category=j2ee -interesting.category=interesting -used.templates=Used templates: - -# predefined configuration names - -predefined.configuration.method.calls=method calls -predefined.configuration.struts.1.1.actions=Struts 1.1 actions -predefined.configuration.ejb.interface=ejb interface -predefined.configuration.servlets=servlets -predefined.configuration.unboxing.in.method.calls=unboxing in method calls -predefined.configuration.boxing.in.method.calls=boxing in method calls -predefined.configuration.unboxing.in.declarations=unboxing in declarations -predefined.configuration.boxing.in.declarations=boxing in declarations -predefined.configuration.filters=filters -predefined.configuration.session.ejb=session ejb -predefined.configuration.fields.variables.read=fields/variables read -predefined.configuration.symbol=symbol -predefined.configuration.inner.classes=inner classes -predefined.configuration.]junit.test.cases=junit test cases -predefined.configuration.ifs=if's -predefined.configuration.anonymous.classes=anonymous classes -predefined.configuration.javadoc.tags=javadoc tags -predefined.configuration.all.methods.of.the.class.within.hierarchy=all methods of the class (within hierarchy) -predefined.configuration.similar.methods.structure=similar methods structure -predefined.configuration.class.implements.two.interfaces=class implementing two interfaces -predefined.configuration.bean.info.classes=Bean info classes -predefined.configuration.all.expressions.of.some.type=all expressions of some type -predefined.configuration.variables.of.generic.types=variables of generic types -predefined.configuration.comments=comments -predefined.configuration.fields_variables.with.given.name.pattern.updated=fields/variables with given name pattern updated -predefined.configuration.trys=try's -predefined.configuration.block.dcls=block dcls -predefined.configuration.methods.of.the.class=methods of the class -predefined.configuration.instanceof=instanceof -predefined.configuration.implementors.of.interface.within.hierarchy=implementors of interface (within hierarchy) -predefined.configuration.generic.casts=generic casts -predefined.configuration.field.selections=field selections -predefined.configuration.fields.of.the.class=fields of the class -predefined.configuration.array.access=array access -predefined.configuration.usage.of.derived.type.in.cast=usage of derived type in cast -predefined.configuration.annotated.methods=annotated methods -predefined.configuration.not.annotated.methods=not annotated methods -predefined.configuration.annotation.declarations=annotation declarations -predefined.configuration.annotated.class=annotated class -predefined.configuration.entity.ejb=entity ejb -predefined.configuration.generic.methods=generic methods -predefined.configuration.cloneable.implementations=Cloneable implementations -predefined.configuration.xdoclet.metadata=XDoclet metadata -predefined.configuration.type.var.substitutions.in.intanceof.with.generic.types=type var substitutions in intanceof with generic types -predefined.configuration.singletons=singletons -predefined.configuration.switches=switches -predefined.configuration.foreaches=foreach loops -predefined.configuration.interfaces=interfaces -predefined.configuration.string.literals=string literals -predefined.configuration.all.inner.classes.within.hierarchy=all inner classes (within hierarchy) -predefined.configuration.direct.subclasses=direct subclasses -predefined.configuration.javadoc.annotated.methods=javadoc annotated methods -predefined.configuration.javadoc.annotated.fields=javadoc annotated fields -predefined.configuration.assignments=assignments -predefined.configuration.casts=casts -predefined.configuration.serializable.classes.and.their.serialization.implementation=Serializable classes and their serialization implementation -predefined.configuration.annotated.fields=annotated fields -predefined.configuration.generic.classes=generic classes -predefined.configuration.javadoc.annotated.class=javadoc annotated class -predefined.configuration.constructors.of.the.class=constructors of the class -predefined.configuration.typed.symbol=typed symbol -predefined.configuration.all.fields.of.the.class=all fields of the class -predefined.configuration.instance.fields.of.the.class=instance fields of the class -predefined.configuration.packagelocal.fields.of.the.class=package local fields of the class -predefined.configuration.classes=classes -predefined.configuration.new.expressions=new expressions -predefined.configuration.lambdas=lambdas - -# edit variable constraint dialog options -invalid.regular.expression=Invalid regular expression -invalid.occurence.count=Invalid occurrence count -editvarcontraints.this.variable.is.target.of.the.search=This variable is target of the search -editvarcontraints.unlimited=Unlimited -editvarcontraints.maximum.count=Maximum count\: -editvarcontraints.minimum.count=Minimum count\: -editvarcontraints.apply.constraint.within.type.hierarchy=Apply constraint within type hierarchy -editvarcontraints.invert.condition=Invert condition -editvarcontraints.text.regular.expression.for.formal.argument.type.of.the.method=Text/regexp for formal argument type of the method\: -editvarcontraints.text.regular.expression.for.java.expression.type=Text/regexp for java expression type\: -editvarcontraints.value.is.written=Value is written -editvarcontraints.value.is.read=Value is read -editvarcontraints.whole.words.only=Whole words only -editvarcontraints.text.regular.expression=Text/regexp\: -editvarcontraints.edit.variables=Edit Variables - -# tooltip message fragment on ss variables -no.constraints.specified.tooltip.message=no constraints specified -script.option.text=Script text\: -occurs.tooltip.message=occurs: {0} -min.occurs.tooltip.message=min occurs: {0}, max occurs: {1} -target.tooltip.message=target -text.tooltip.message={0} like: {1}{2} -exprtype.tooltip.message={0} like: {1}{2} -not.tooltip.message=not -within.hierarchy.tooltip.message=\ within hierarchy -script.tooltip.message=script: {0} -replacement.variable.is.not.defined.message=Replacement variable {0} is not defined. -replacement.variable.is.not.valid=Replacement variable {0} has script code problem {1} -replacement.template.is.not.expression.error.message=The search template is a well formed expression, but the replacement template is not an expression. -replacement.template.expression.not.supported=Replacement of expression is not supported for {0} -replacement.not.supported.for.filetype=Replacement is not supported for {0} file type -search.template.is.not.expression.error.message=The search template is not an expression, but the replacement template is a well formed expression. -create.template.action.name=Create Template -remove.template.action.name=Remove Template - -modify.editor.content.command.name=modify editor content -var.constraints.variables.border=Variables -var.constraints.occurrences.count.border=Occurrences count -var.constraints.script.constraints.border=Script constraints -var.constraints.expression.constraints.border=Expression constraints -var.constraints.text.constraints.border=Text constraints -different.strategies.for.top.level.nodes.error.message=Different strategies for top level nodes -option.is.not.recognized.error.message={0} condition is not recognized -reg.exp.should.be.delimited.with.spaces.error.message=Reg exp should be delimited with spaces -reg.exp.in.expr.type.should.be.delimited.with.spaces.error.message=Reg exp in expr type should be delimited with spaces -reg.exp.in.formal.arg.type.should.be.delimited.with.spaces.error.message=Reg exp in formal arg type should be delimited with spaces -no.reg.exp.specified.error.message=Missing regular expression -script.should.be.delimited.with.spaces.error.message=Script should be delimited with spaces - -error.two.different.type.constraints=Two different type constraints -error.incorrect.regexp.constraint=Incorrect reg exp constraint:{0} for {1} -error.expected.character=Character expected after single quote -error.overflow=Value overflow -error.expected.brace1="Digit, '}' or ',' expected" -error.expected.brace2="Digit or '}' expected" -error.expected.condition=Condition expected after ''{0}'' -error.expected.condition.or.bracket=Condition or ']' expected -invalid.modifier.type=Invalid modifier type {0} - -SSRInspection.replace.with=Replace with ''{0}'' -SSRInspection.family.name=Replace Structurally -SSRInspection.display.name=Structural Search Inspection -SSRInspection.add.search.template.button=Add Search template... -SSRInspection.add.replace.template.button=Add Replace template... -SSRInspection.selected.templates=Selected templates: -status.message=Status: -overwrite.message=Confirm overwrite configuration with the same name -overwrite.title=Confirm Overwrite Saved Configuration -ssr.will.not.find.anything=It does not match anything in selected scope -predefined.configuration.class.static.blocks=static blocks in class -predefined.configuration.class.instance.initialization.blocks=instance initialization blocks -predefined.configuration.class.any.initialization.blocks=any class initialization block -predefined.configuration.logging.without.if=logging without if -predefined.configuration.class.with.parameterless.constructors=classes with parameterless constructors -predefined.configuration.static.fields.without.final=static fields that are not final -invalid.groovy.script=Invalid Groovy Script -groovy.script.error=Groovy Script execution error: {0} -template.problem=Structural Search Inspection problem in template ''{0}'' -problem=Structural Search problem: {0} -complete.match.variable.name=Complete Match -predefined.configuration.sample.method.invokation.with.constant.argument=sample method invocation with constant parameter -predefined.configuration.interfaces.having.no.descendants=interface that is not implemented or extended -action.StructuralSearchPlugin.StructuralSearchAction.text=Search S_tructurally... -action.StructuralSearchPlugin.StructuralSearchAction.description=Structural Search -action.StructuralSearchPlugin.StructuralReplaceAction.text=Repla_ce Structurally... -action.StructuralSearchPlugin.StructuralReplaceAction.description=Structural Replace -predefined.configuration.enums=enums -regular.expression.help.label=Regular Expressions Help -edit.groovy.script.constraint.title=Edit Groovy Script Constraint diff --git a/plugins/structuralsearch/structuralsearch-java/src/META-INF/java.xml b/plugins/structuralsearch/structuralsearch-java/src/META-INF/java.xml deleted file mode 100644 index 56c3329f4867..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/META-INF/java.xml +++ /dev/null @@ -1,6 +0,0 @@ -<idea-plugin url="http://www.jetbrains.com/idea"> - <extensions defaultExtensionNs="com.intellij"> - <structuralsearch.profile implementation="com.intellij.structuralsearch.JavaStructuralSearchProfile"/> - <structuralsearch.matchPredicateProvider implementation="com.intellij.structuralsearch.impl.matcher.JavaMatchPredicateProvider"/> - </extensions> -</idea-plugin> diff --git a/plugins/structuralsearch/structuralsearch-java/src/META-INF/plugin.xml b/plugins/structuralsearch/structuralsearch-java/src/META-INF/plugin.xml deleted file mode 100644 index c95376c06f13..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/META-INF/plugin.xml +++ /dev/null @@ -1,48 +0,0 @@ -<idea-plugin> - <name>Structural Search</name> - <description>Searching / replacing source code in terms of syntax (query / replace code by example :-). - </description> - <version>9.0</version> - <vendor>JetBrains</vendor> - <depends>com.intellij.modules.lang</depends> - <depends optional="true" config-file="java.xml">com.intellij.java-i18n</depends> - - <extensionPoints> - <extensionPoint qualifiedName="com.intellij.structuralsearch.profile" - interface="com.intellij.structuralsearch.StructuralSearchProfile"/> - <extensionPoint qualifiedName="com.intellij.tokenindex.tokenizer" beanClass="com.intellij.lang.LanguageExtensionPoint"/> - <extensionPoint qualifiedName="com.intellij.structuralsearch.matchPredicateProvider" - interface="com.intellij.structuralsearch.impl.matcher.MatchPredicateProvider"/> - </extensionPoints> - - <extensions defaultExtensionNs="com.intellij"> - <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/> - <localInspection shortName="SSBasedInspection" bundle="messages.SSRBundle" key="SSRInspection.display.name" groupName="General" - enabledByDefault="false" level="WARNING" - implementationClass="com.intellij.structuralsearch.inspection.highlightTemplate.SSBasedInspection"/> - <postStartupActivity - implementation="com.intellij.structuralsearch.inspection.highlightTemplate.SSBasedInspectionCompiledPatternsCache"/> - <!--<fileBasedIndex implementation="com.intellij.tokenindex.TokenIndex"/>--> - <structuralsearch.profile implementation="com.intellij.structuralsearch.XmlStructuralSearchProfile"/> - </extensions> - - <resource-bundle>messages.SSRBundle</resource-bundle> - <project-components> - <component> - <implementation-class>com.intellij.structuralsearch.plugin.StructuralSearchPlugin</implementation-class> - <option name="workspace" value="true"/> - </component> - </project-components> - - <actions> - <group id="StructuralSearchActions"> - <action id="StructuralSearchPlugin.StructuralSearchAction" class="com.intellij.structuralsearch.plugin.StructuralSearchAction"> - <add-to-group group-id="FindMenuGroup" anchor="after" relative-to-action="ReplaceInPath"/> - </action> - - <action id="StructuralSearchPlugin.StructuralReplaceAction" class="com.intellij.structuralsearch.plugin.StructuralReplaceAction"> - <add-to-group group-id="FindMenuGroup" anchor="after" relative-to-action="StructuralSearchPlugin.StructuralSearchAction"/> - </action> - </group> - </actions> -</idea-plugin> diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java deleted file mode 100644 index a82c941c0fa2..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaPredefinedConfigurations.java +++ /dev/null @@ -1,296 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.structuralsearch.plugin.ui.Configuration; - -import static com.intellij.structuralsearch.PredefinedConfigurationUtil.createSearchTemplateInfo; -import static com.intellij.structuralsearch.PredefinedConfigurationUtil.createSearchTemplateInfoSimple; - -/** -* @author Bas Leijdekkers -*/ -class JavaPredefinedConfigurations { - - private static final String EXPRESSION_TYPE = SSRBundle.message("expressions.category"); - private static final String INTERESTING_TYPE = SSRBundle.message("interesting.category"); - private static final String J2EE_TYPE = SSRBundle.message("j2ee.category"); - private static final String OPERATOR_TYPE = SSRBundle.message("operators.category"); - private static final String CLASS_TYPE = SSRBundle.message("class.category"); - private static final String METADATA_TYPE = SSRBundle.message("metadata.category"); - private static final String MISC_TYPE = SSRBundle.message("misc.category"); - private static final String GENERICS_TYPE = SSRBundle.message("generics.category"); - - public static Configuration[] createPredefinedTemplates() { - return new Configuration[] { - // Expression patterns - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.method.calls"), "'_Instance?.'MethodCall('_Parameter*)", EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.new.expressions"), "new 'Constructor('_Argument*)", EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.lambdas"), "('_Parameter) -> ", EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.field.selections"),"'_Instance?.'Field",EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.array.access"),"'_Field['_Index]",EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.assignments"),"'_Inst = '_Expr",EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.casts"),"('_Type)'_Expr",EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.instanceof"),"'_Expr instanceof '_Type",EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.string.literals"),"\"'_String\"",EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.all.expressions.of.some.type"),"'_Expression:[exprtype( SomeType )]",EXPRESSION_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.sample.method.invokation.with.constant.argument"),"Integer.parseInt('_a:[script( \"com.intellij.psi.util.PsiUtil.isConstantExpression(__context__)\" )])",EXPRESSION_TYPE), - - // Operators - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.block.dcls"),"{\n '_Type+ 'Var+ = '_Init*;\n '_BlockStatements*;\n}",OPERATOR_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.trys"),"try {\n '_TryStatement+;\n} catch('_ExceptionType '_ExceptionDcl) {\n '_CatchStatement*;\n}",OPERATOR_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.ifs"),"if ('_Condition) {\n '_ThenStatement*;\n} else {\n '_ElseStatement*;\n}",OPERATOR_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.switches"),"switch('_Condition) {\n '_Statement*;\n}",OPERATOR_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.foreaches"), "for ('_Type '_Variable : '_Expression) {\n '_Statement*;\n}", OPERATOR_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.logging.without.if"),"LOG.debug('_params*:[!within( \"if('_a) { '_st*; }\" )]);",OPERATOR_TYPE), - - // Class based - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.methods.of.the.class"), - "class '_Class { \n '_ReturnType+ 'MethodName+('_ParameterType* '_Parameter*);\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.fields.of.the.class"), - "class '_Class { \n '_FieldType+ 'FieldName+ = '_Init*;\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.all.methods.of.the.class.within.hierarchy"), - "class '_ { \n '_ReturnType+ 'MethodName+:* ('_ParameterType* '_Parameter*);\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.all.fields.of.the.class"), - "class '_Class { \n '_FieldType+ 'FieldName+:* = '_Init*;\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.instance.fields.of.the.class"), - "class '_Class { \n @Modifier(\"Instance\") '_FieldType+ 'FieldName+ = '_Init*;\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.packagelocal.fields.of.the.class"), - "class '_Class { \n @Modifier(\"packageLocal\") '_FieldType+ 'FieldName+ = '_Init*;\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.constructors.of.the.class"), - "class 'Class {\n 'Class+('_ParameterType* '_ParameterName*) {\n '_Statement*;\n }\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.classes"), - "class 'Class {}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.direct.subclasses"), - "class 'Class extends '_Parent {}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.implementors.of.interface.within.hierarchy"), - "class 'Class implements 'Interface:* {}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.interfaces"), - "interface 'Interface {}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.inner.classes"), - "class '_ {\n class 'InnerClass+ {}\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.all.inner.classes.within.hierarchy"), - "class '_Class {\n class 'InnerClass+:* {}\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.anonymous.classes"), - "new 'AnonymousClass() {}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.class.implements.two.interfaces"), - "class 'A implements '_Interface1:[regex( *java\\.lang\\.Cloneable )], '_Interface2:*java\\.io\\.Serializable {\n" +"}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.class.static.blocks"), - "class '_A {\n static {\n 'Statement*;\n }\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.class.instance.initialization.blocks"), - "class '_A {\n @Modifier(\"Instance\") {\n 'Statement*;\n }\n}", - CLASS_TYPE - ), - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.class.any.initialization.blocks"), - "class '_A {\n {\n 'Statement*;\n }\n}", - CLASS_TYPE - ), - - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.enums"), - "enum 'Enum {}", - CLASS_TYPE - ), - - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.class.with.parameterless.constructors"), - "class 'Class {\n '_Method{0,0}:[ script( \"__context__.constructor\" ) ]('_ParamType+ '_ParameterName+);\n}", - CLASS_TYPE - ), - - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.static.fields.without.final"), - "class '_Class {\n static '_Type 'Variable+:[ script( \"!__context__.hasModifierProperty(\"final\")\" ) ] = '_Init?;\n}", - CLASS_TYPE - ), - - createSearchTemplateInfo( - SSRBundle.message("predefined.configuration.interfaces.having.no.descendants"), - "interface 'A:[script( \"com.intellij.psi.search.searches.ClassInheritorsSearch.search(__context__).findFirst() == null\" )] {}", - CLASS_TYPE - ), - - // Generics - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.generic.classes"),"class 'GenericClass<'_TypeParameter+> {} ", GENERICS_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.generic.methods"),"class '_Class {\n <'_TypeParameter+> '_Type+ 'Method+('_ParameterType* '_ParameterDcl*);\n}", GENERICS_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.typed.symbol"),"'Symbol <'_GenericArgument+>", GENERICS_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.generic.casts"),"( '_Type <'_GenericArgument+> ) '_Expr", GENERICS_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.type.var.substitutions.in.intanceof.with.generic.types"),"'_Expr instanceof '_Type <'Substitutions+> ", GENERICS_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.variables.of.generic.types"),"'_Type <'_GenericArgument+> 'Var = 'Init?;", GENERICS_TYPE), - - // Add comments and metadata - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.comments"),"/* 'CommentContent */", METADATA_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.annotated.class"),"/** @'_Tag+ '_TagValue* */\nclass '_Class {\n}", METADATA_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.annotated.methods"),"class '_Class {\n /** @'_Tag+ '_TagValue* */\n '_Type+ 'Method+('_ParameterType* '_ParameterDcl*);\n}", METADATA_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.annotated.fields"),"class '_Class {\n /** @'_Tag+ '_TagValue* */\n '_Type+ 'Field+ = '_Init*;\n}", METADATA_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.javadoc.tags"),"/** @'Tag+ '_TagValue* */", METADATA_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.xdoclet.metadata"),"/** @'Tag \n '_Property+\n*/", METADATA_TYPE), - - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.annotated.class"), - "@'_Annotation( )\n" + - "class 'Class {}", METADATA_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.annotated.fields"), - "class '_Class {\n" + - " @'_Annotation+( )\n" + - " '_FieldType+ 'FieldName+ = '_FieldInitial*;\n" + - "}", METADATA_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.annotated.methods"), - "class '_Class {\n" + - " @'_Annotation+( )\n" + - " '_MethodType+ 'MethodName+('_ParameterType* '_ParameterName*);\n" + - "}", METADATA_TYPE), - - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.not.annotated.methods"), - "class '_Class {\n" + - " @'_Annotation{0,0}\n" + - " '_MethodType+ 'MethodName+('_ParameterType* '_ParameterName*);\n" + - "}", METADATA_TYPE), - - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.annotation.declarations"), - "@interface 'Interface {}", METADATA_TYPE), - - // J2EE templates - createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.struts.1.1.actions"),"public class 'StrutsActionClass extends '_ParentClass*:Action {\n" + - " public ActionForward 'AnActionMethod:*execute (ActionMapping '_action,\n" + - " ActionForm '_form,\n" + - " HttpServletRequest '_request,\n" + - " HttpServletResponse '_response);\n" + - "}",J2EE_TYPE), - createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.entity.ejb"),"class 'EntityBean implements EntityBean {\n" + - " EntityContext '_Context?;\n\n" + - " public void setEntityContext(EntityContext '_Context2);\n\n" + - " public '_RetType ejbCreate('_CreateType* '_CreateDcl*);\n" + - " public void ejbActivate();\n\n" + - " public void ejbLoad();\n\n" + - " public void ejbPassivate();\n\n" + - " public void ejbRemove();\n\n" + - " public void ejbStore();\n" + - "}", J2EE_TYPE), - createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.session.ejb"),"class 'SessionBean implements SessionBean {\n" + - " SessionContext '_Context?;\n\n" + - " public void '_setSessionContext(SessionContext '_Context2);\n\n" + - " public '_RetType ejbCreate('_CreateParameterType* '_CreateParameterDcl*);\n" + - " public void ejbActivate();\n\n" + - " public void ejbPassivate();\n\n" + - " public void ejbRemove();\n" + - "}", J2EE_TYPE), - createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.ejb.interface"),"interface 'EjbInterface extends EJBObject {\n" + - " 'Type+ 'Method+('ParamType* 'ParamName*);\n" + - "}", J2EE_TYPE), - createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.servlets"),"public class 'Servlet extends '_ParentClass:*HttpServlet {\n" + - " public void '_InitServletMethod?:init ();\n" + - " public void '_DestroyServletMethod?:destroy ();\n" + - " void '_ServiceMethod?:*service (HttpServletRequest '_request, HttpServletResponse '_response);\n" + - " void '_SpecificServiceMethod*:do.* (HttpServletRequest '_request2, HttpServletResponse '_response2); \n" + - "}", J2EE_TYPE), - createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.filters"),"public class 'Filter implements Filter {\n" + - " public void '_DestroyFilterMethod?:*destroy ();\n" + - " public void '_InitFilterMethod?:*init ();\n" + - " public void '_FilteringMethod:*doFilter (ServletRequest '_request,\n" + - " ServletResponse '_response,FilterChain '_chain);\n" + - "}", J2EE_TYPE), - - // Misc types - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.serializable.classes.and.their.serialization.implementation"), - "class '_Class implements '_Serializable:*Serializable {\n" + - " static final long 'VersionField?:serialVersionUID = '_VersionFieldInit?;\n" + - " private static final ObjectStreamField[] '_persistentFields?:serialPersistentFields = '_persistentFieldInitial?; \n" + - " private void 'SerializationWriteHandler?:writeObject (ObjectOutputStream '_stream) throws IOException;\n" + - " private void 'SerializationReadHandler?:readObject (ObjectInputStream '_stream2) throws IOException, ClassNotFoundException;\n" + - " Object 'SpecialSerializationReadHandler?:readResolve () throws ObjectStreamException;\n" + - " Object 'SpecialSerializationWriteHandler?:writeReplace () throws ObjectStreamException;\n" + - "}",MISC_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.cloneable.implementations"), - "class '_Class implements '_Interface:*Cloneable {\n" + - " Object 'CloningMethod:*clone ();\n" + - "}",MISC_TYPE), - createSearchTemplateInfoSimple(SSRBundle.message("predefined.configuration.]junit.test.cases"),"public class 'TestCase extends 'TestCaseClazz:*TestCase {\n" + - " public void '_testMethod+:test.* ();\n" + - "}", MISC_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.singletons"),"class 'Class {\n" + - " private 'Class('_ParameterType* '_ParameterDcl*) {\n" + - " '_ConstructorStatement*;\n" + - " }\n"+ - " private static '_Class:* '_Instance;\n" + - " static '_Class:* '_GetInstance() {\n" + - " '_SomeStatement*;\n" + - " return '_Instance;\n" + - " }\n"+ - "}",MISC_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.similar.methods.structure"),"class '_Class {\n" + - " '_RetType 'Method+('_ParameterType* '_Parameter) throws 'ExceptionType {\n" + - " try {\n" + - " '_OtherStatements+;\n" + - " } catch('_SomeException '_ExceptionDcl) {\n" + - " '_CatchStatement*;\n" + - " throw new 'ExceptionType('_ExceptionConstructorArgs*);\n" + - " }\n" + - " }\n" + - "}",MISC_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.bean.info.classes"),"class 'A implements '_:*java\\.beans\\.BeanInfo {\n" + - "}",MISC_TYPE), - - // interesting types - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.symbol"),"'Symbol",INTERESTING_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.fields.variables.read"),"'Symbol:[read]",INTERESTING_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.fields_variables.with.given.name.pattern.updated"),"'Symbol:[regex( name ) && write]",INTERESTING_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.usage.of.derived.type.in.cast"),"('CastType:*Base ) 'Expr",INTERESTING_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.boxing.in.declarations"),"'_Type:Integer|Boolean|Long|Character|Short|Byte 'Var = '_Value:[formal( int|boolean|long|char|short|byte )]",INTERESTING_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.unboxing.in.declarations"),"'_Type:int|boolean|long|char|short|byte 'Var = '_Value:[formal( Integer|Boolean|Long|Character|Short|Byte )]",INTERESTING_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.boxing.in.method.calls"),"'_Instance?.'Call('_BeforeParam*,'_Param:[ exprtype( int|boolean|long|char|short|byte ) && formal( Integer|Boolean|Long|Character|Short|Byte )],'_AfterParam*)",INTERESTING_TYPE), - createSearchTemplateInfo(SSRBundle.message("predefined.configuration.unboxing.in.method.calls"), "'_Instance?.'Call('_BeforeParam*,'_Param:[ formal( int|boolean|long|char|short|byte ) && exprtype( Integer|Boolean|Long|Character|Short|Byte )],'_AfterParam*)",INTERESTING_TYPE), - //createSearchTemplateInfo("methods called","'_?.'_:[ref('Method)] ('_*)", INTERESTING_TYPE), - //createSearchTemplateInfo("fields selected","'_?.'_:[ref('Field)] ", INTERESTING_TYPE), - //createSearchTemplateInfo("symbols used","'_:[ref('Symbol)] ", INTERESTING_TYPE), - //createSearchTemplateInfo("types used","'_:[ref('Type)] '_;", INTERESTING_TYPE), - }; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java deleted file mode 100644 index 36b8fff26afb..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaReplaceHandler.java +++ /dev/null @@ -1,500 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.*; -import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.xml.XmlText; -import com.intellij.structuralsearch.impl.matcher.JavaMatchingVisitor; -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; -import com.intellij.structuralsearch.impl.matcher.PatternTreeContext; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.ReplacementInfo; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementContext; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacerUtil; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.Nullable; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author Eugene.Kudelevsky - */ -public class JavaReplaceHandler extends StructuralReplaceHandler { - private final ReplacementContext myContext; - private PsiCodeBlock codeBlock; - - public JavaReplaceHandler(ReplacementContext context) { - this.myContext = context; - } - - private PsiCodeBlock getCodeBlock() throws IncorrectOperationException { - if (codeBlock == null) { - PsiCodeBlock search; - search = (PsiCodeBlock)MatcherImplUtil.createTreeFromText( - myContext.getOptions().getMatchOptions().getSearchPattern(), - PatternTreeContext.Block, - myContext.getOptions().getMatchOptions().getFileType(), - myContext.getProject() - )[0].getParent(); - - codeBlock = search; - } - return codeBlock; - } - - private static PsiElement findRealSubstitutionElement(PsiElement el) { - if (el instanceof PsiIdentifier) { - // matches are tokens, identifiers, etc - el = el.getParent(); - } - - if (el instanceof PsiReferenceExpression && - el.getParent() instanceof PsiMethodCallExpression - ) { - // method - el = el.getParent(); - } - - if (el instanceof PsiDeclarationStatement && ((PsiDeclarationStatement)el).getDeclaredElements()[0] instanceof PsiClass) { - el = ((PsiDeclarationStatement)el).getDeclaredElements()[0]; - } - return el; - } - - private static boolean isListContext(PsiElement el) { - boolean listContext = false; - final PsiElement parent = el.getParent(); - - if (parent instanceof PsiParameterList || - parent instanceof PsiExpressionList || - parent instanceof PsiCodeBlock || - parent instanceof PsiClass || - parent instanceof XmlText || - (parent instanceof PsiIfStatement && - (((PsiIfStatement)parent).getThenBranch() == el || - ((PsiIfStatement)parent).getElseBranch() == el - ) - ) || - (parent instanceof PsiLoopStatement && - ((PsiLoopStatement)parent).getBody() == el - ) - ) { - listContext = true; - } - - return listContext; - } - - @Nullable - private PsiNamedElement getSymbolReplacementTarget(final PsiElement el) - throws IncorrectOperationException { - if (myContext.getOptions().getMatchOptions().getFileType() != StdFileTypes.JAVA) return null; //? - final PsiStatement[] searchStatements = getCodeBlock().getStatements(); - if (searchStatements.length > 0 && - searchStatements[0] instanceof PsiExpressionStatement) { - final PsiExpression expression = ((PsiExpressionStatement)searchStatements[0]).getExpression(); - - if (expression instanceof PsiReferenceExpression && - ((PsiReferenceExpression)expression).getQualifierExpression() == null - ) { - // looks like symbol replacements, namely replace AAA by BBB, so lets do the best - if (el instanceof PsiNamedElement) { - return (PsiNamedElement)el; - } - } - } - - return null; - } - - private static PsiElement getMatchExpr(PsiElement replacement, PsiElement elementToReplace) { - if (replacement instanceof PsiExpressionStatement && - !(replacement.getLastChild() instanceof PsiJavaToken) && - !(replacement.getLastChild() instanceof PsiComment) - ) { - // replacement is expression (and pattern should be so) - // assert ... - replacement = ((PsiExpressionStatement)replacement).getExpression(); - } - else if (replacement instanceof PsiDeclarationStatement && - ((PsiDeclarationStatement)replacement).getDeclaredElements().length == 1 - ) { - return ((PsiDeclarationStatement)replacement).getDeclaredElements()[0]; - } - else if (replacement instanceof PsiBlockStatement && - elementToReplace instanceof PsiCodeBlock - ) { - return ((PsiBlockStatement)replacement).getCodeBlock(); - } - - return replacement; - } - - private boolean isSymbolReplacement(final PsiElement el) throws IncorrectOperationException { - return getSymbolReplacementTarget(el) != null; - } - - @SuppressWarnings({"unchecked", "ConstantConditions"}) - private void handleModifierList(final PsiElement el, final PsiElement replacement) throws IncorrectOperationException { - // We want to copy all comments, including doc comments and modifier lists - // that are present in matched nodes but not present in search/replace - - Map<String, String> newNameToSearchPatternNameMap = myContext.getNewName2PatternNameMap(); - - ModifierListOwnerCollector collector = new ModifierListOwnerCollector(); - el.accept(collector); - Map<String, PsiNamedElement> originalNamedElements = (Map<String, PsiNamedElement>)collector.namedElements.clone(); - collector.namedElements.clear(); - - replacement.accept(collector); - Map<String, PsiNamedElement> replacedNamedElements = (Map<String, PsiNamedElement>)collector.namedElements.clone(); - collector.namedElements.clear(); - - if (originalNamedElements.size() == 0 && replacedNamedElements.size() == 0) { - Replacer.handleComments(el, replacement, myContext); - return; - } - - final PsiStatement[] statements = getCodeBlock().getStatements(); - if (statements.length > 0) { - statements[0].getParent().accept(collector); - } - - Map<String, PsiNamedElement> searchedNamedElements = (Map<String, PsiNamedElement>)collector.namedElements.clone(); - collector.namedElements.clear(); - - for (String name : originalNamedElements.keySet()) { - PsiNamedElement originalNamedElement = originalNamedElements.get(name); - PsiNamedElement replacementNamedElement = replacedNamedElements.get(name); - String key = newNameToSearchPatternNameMap.get(name); - if (key == null) key = name; - PsiNamedElement searchNamedElement = searchedNamedElements.get(key); - - if (replacementNamedElement == null && originalNamedElements.size() == 1 && replacedNamedElements.size() == 1) { - replacementNamedElement = replacedNamedElements.entrySet().iterator().next().getValue(); - } - - PsiElement comment = null; - - if (originalNamedElement instanceof PsiDocCommentOwner) { - comment = ((PsiDocCommentOwner)originalNamedElement).getDocComment(); - if (comment == null) { - PsiElement prevElement = originalNamedElement.getPrevSibling(); - if (prevElement instanceof PsiWhiteSpace) { - prevElement = prevElement.getPrevSibling(); - } - if (prevElement instanceof PsiComment) { - comment = prevElement; - } - } - } - - if (replacementNamedElement != null && searchNamedElement != null) { - Replacer.handleComments(originalNamedElement, replacementNamedElement, myContext); - } - - if (comment != null && replacementNamedElement instanceof PsiDocCommentOwner && - !(replacementNamedElement.getFirstChild() instanceof PsiDocComment) - ) { - final PsiElement nextSibling = comment.getNextSibling(); - PsiElement prevSibling = comment.getPrevSibling(); - replacementNamedElement.addRangeBefore( - prevSibling instanceof PsiWhiteSpace ? prevSibling : comment, - nextSibling instanceof PsiWhiteSpace ? nextSibling : comment, - replacementNamedElement.getFirstChild() - ); - } - - if (originalNamedElement instanceof PsiModifierListOwner && - replacementNamedElement instanceof PsiModifierListOwner - ) { - PsiModifierList modifierList = ((PsiModifierListOwner)originalNamedElements.get(name)).getModifierList(); - - if (searchNamedElement instanceof PsiModifierListOwner) { - PsiModifierList modifierListOfSearchedElement = ((PsiModifierListOwner)searchNamedElement).getModifierList(); - final PsiModifierListOwner modifierListOwner = ((PsiModifierListOwner)replacementNamedElement); - PsiModifierList modifierListOfReplacement = modifierListOwner.getModifierList(); - - if (modifierListOfSearchedElement.getTextLength() == 0 && - modifierListOfReplacement.getTextLength() == 0 && - modifierList.getTextLength() > 0 - ) { - PsiElement space = modifierList.getNextSibling(); - if (!(space instanceof PsiWhiteSpace)) { - space = createWhiteSpace(space); - } - - modifierListOfReplacement.replace(modifierList); - // copy space after modifier list - if (space instanceof PsiWhiteSpace) { - modifierListOwner.addRangeAfter(space, space, modifierListOwner.getModifierList()); - } - } else if (modifierListOfSearchedElement.getTextLength() == 0 && modifierList.getTextLength() > 0) { - modifierListOfReplacement.addRange(modifierList.getFirstChild(), modifierList.getLastChild()); - } - } - } - } - } - - private PsiElement handleSymbolReplacemenent(PsiElement replacement, final PsiElement el) throws IncorrectOperationException { - PsiNamedElement nameElement = getSymbolReplacementTarget(el); - if (nameElement != null) { - PsiElement oldReplacement = replacement; - replacement = el.copy(); - ((PsiNamedElement)replacement).setName(oldReplacement.getText()); - } - - return replacement; - } - - public void replace(final ReplacementInfo info, ReplaceOptions options) { - PsiElement elementToReplace = info.getMatch(0); - PsiElement elementParent = elementToReplace.getParent(); - String replacementToMake = info.getReplacement(); - Project project = myContext.getProject(); - PsiElement el = findRealSubstitutionElement(elementToReplace); - boolean listContext = isListContext(el); - - if (el instanceof PsiAnnotation && !StringUtil.startsWithChar(replacementToMake, '@')) { - replacementToMake = "@" + replacementToMake; - } - - PsiElement[] statements = ReplacerUtil - .createTreeForReplacement(replacementToMake, el instanceof PsiMember && !isSymbolReplacement(el) ? - PatternTreeContext.Class : - PatternTreeContext.Block, myContext); - - if (listContext) { - if (statements.length > 1) { - elementParent.addRangeBefore(statements[0], statements[statements.length - 1], elementToReplace); - } - else if (statements.length == 1) { - PsiElement replacement = getMatchExpr(statements[0], elementToReplace); - - handleModifierList(el, replacement); - replacement = handleSymbolReplacemenent(replacement, el); - - if (replacement instanceof PsiTryStatement) { - final List<PsiCatchSection> unmatchedCatchSections = el.getUserData(JavaMatchingVisitor.UNMATCHED_CATCH_SECTION_CONTENT_VAR_KEY); - final PsiCatchSection[] catches = ((PsiTryStatement)replacement).getCatchSections(); - - if (unmatchedCatchSections != null) { - for (int i = unmatchedCatchSections.size() - 1; i >= 0; --i) { - final PsiParameter parameter = unmatchedCatchSections.get(i).getParameter(); - final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory(); - final PsiCatchSection catchSection = elementFactory.createCatchSection(parameter.getType(), parameter.getName(), null); - - catchSection.getCatchBlock().replace( - unmatchedCatchSections.get(i).getCatchBlock() - ); - replacement.addAfter( - catchSection, catches[catches.length - 1] - ); - replacement.addBefore(createWhiteSpace(replacement), replacement.getLastChild()); - } - } - } - - try { - final PsiElement inserted = elementParent.addBefore(replacement, elementToReplace); - - if (replacement instanceof PsiComment && - (elementParent instanceof PsiIfStatement || - elementParent instanceof PsiLoopStatement - ) - ) { - elementParent.addAfter(createSemicolon(replacement), inserted); - } - } - catch (IncorrectOperationException e) { - elementToReplace.replace(replacement); - } - } - } - else if (statements.length > 0) { - PsiElement replacement = ReplacerUtil.copySpacesAndCommentsBefore(elementToReplace, statements, replacementToMake, elementParent); - - replacement = getMatchExpr(replacement, elementToReplace); - - if (replacement instanceof PsiStatement && - !(replacement.getLastChild() instanceof PsiJavaToken) && - !(replacement.getLastChild() instanceof PsiComment) - ) { - // assert w/o ; - final PsiElement prevLastChildInParent = replacement.getLastChild().getPrevSibling(); - - if (prevLastChildInParent != null) { - elementParent.addRangeBefore(replacement.getFirstChild(), prevLastChildInParent, el); - } - else { - elementParent.addBefore(replacement.getFirstChild(), el); - } - - el.getNode().getTreeParent().removeChild(el.getNode()); - } - else { - // preserve comments - handleModifierList(el, replacement); - - if (replacement instanceof PsiClass) { - // modifier list - final PsiStatement[] searchStatements = getCodeBlock().getStatements(); - if (searchStatements.length > 0 && - searchStatements[0] instanceof PsiDeclarationStatement && - ((PsiDeclarationStatement)searchStatements[0]).getDeclaredElements()[0] instanceof PsiClass - ) { - final PsiClass replaceClazz = (PsiClass)replacement; - final PsiClass queryClazz = (PsiClass)((PsiDeclarationStatement)searchStatements[0]).getDeclaredElements()[0]; - final PsiClass clazz = (PsiClass)el; - - if (replaceClazz.getExtendsList().getTextLength() == 0 && - queryClazz.getExtendsList().getTextLength() == 0 && - clazz.getExtendsList().getTextLength() != 0 - ) { - replaceClazz.addBefore(clazz.getExtendsList().getPrevSibling(), replaceClazz.getExtendsList()); // whitespace - replaceClazz.getExtendsList().addRange( - clazz.getExtendsList().getFirstChild(), clazz.getExtendsList().getLastChild() - ); - } - - if (replaceClazz.getImplementsList().getTextLength() == 0 && - queryClazz.getImplementsList().getTextLength() == 0 && - clazz.getImplementsList().getTextLength() != 0 - ) { - replaceClazz.addBefore(clazz.getImplementsList().getPrevSibling(), replaceClazz.getImplementsList()); // whitespace - replaceClazz.getImplementsList().addRange( - clazz.getImplementsList().getFirstChild(), - clazz.getImplementsList().getLastChild() - ); - } - - if (replaceClazz.getTypeParameterList().getTextLength() == 0 && - queryClazz.getTypeParameterList().getTextLength() == 0 && - clazz.getTypeParameterList().getTextLength() != 0 - ) { - // skip < and > - replaceClazz.getTypeParameterList().replace( - clazz.getTypeParameterList() - ); - } - } - } - - replacement = handleSymbolReplacemenent(replacement, el); - - el.replace(replacement); - } - } - else { - final PsiElement nextSibling = el.getNextSibling(); - el.delete(); - if (nextSibling instanceof PsiWhiteSpace && nextSibling.isValid()) { - nextSibling.delete(); - } - } - - if (listContext) { - final int matchSize = info.getMatchesCount(); - - for (int i = 0; i < matchSize; ++i) { - PsiElement matchElement = info.getMatch(i); - PsiElement element = findRealSubstitutionElement(matchElement); - - if (element == null) continue; - PsiElement firstToDelete = element; - PsiElement lastToDelete = element; - PsiElement prevSibling = element.getPrevSibling(); - PsiElement nextSibling = element.getNextSibling(); - - if (prevSibling instanceof PsiWhiteSpace) { - firstToDelete = prevSibling; - prevSibling = prevSibling != null ? prevSibling.getPrevSibling() : null; - } - else if (prevSibling == null && nextSibling instanceof PsiWhiteSpace) { - lastToDelete = nextSibling; - } - - if (nextSibling instanceof XmlText && i + 1 < matchSize) { - final PsiElement next = info.getMatch(i + 1); - if (next != null && next == nextSibling.getNextSibling()) { - lastToDelete = nextSibling; - } - } - - if (element instanceof PsiExpression) { - final PsiElement parent = element.getParent().getParent(); - if ((parent instanceof PsiCall || - parent instanceof PsiAnonymousClass - ) && - prevSibling instanceof PsiJavaToken && - ((PsiJavaToken)prevSibling).getTokenType() == JavaTokenType.COMMA - ) { - firstToDelete = prevSibling; - } - } - else if (element instanceof PsiParameter && - prevSibling instanceof PsiJavaToken && - ((PsiJavaToken)prevSibling).getTokenType() == JavaTokenType.COMMA - ) { - firstToDelete = prevSibling; - } - - element.getParent().deleteChildRange(firstToDelete, lastToDelete); - } - } - - if (options.isToShortenFQN() && elementParent.isValid()) { - JavaCodeStyleManager.getInstance(project).shortenClassReferences(elementParent, 0, elementParent.getTextLength()); - } - } - - @Nullable - private static PsiElement createSemicolon(final PsiElement space) throws IncorrectOperationException { - final PsiStatement text = JavaPsiFacade.getInstance(space.getProject()).getElementFactory().createStatementFromText(";", null); - return text.getFirstChild(); - } - - private static PsiElement createWhiteSpace(final PsiElement space) throws IncorrectOperationException { - return PsiParserFacade.SERVICE.getInstance(space.getProject()).createWhiteSpaceFromText(" "); - } - - private static class ModifierListOwnerCollector extends JavaRecursiveElementWalkingVisitor { - HashMap<String, PsiNamedElement> namedElements = new HashMap<String, PsiNamedElement>(1); - - @Override - public void visitClass(PsiClass aClass) { - if (aClass instanceof PsiAnonymousClass) return; - handleNamedElement(aClass); - } - - private void handleNamedElement(final PsiNamedElement named) { - String name = named.getName(); - - assert name != null; - - if (StructuralSearchUtil.isTypedVariable(name)) { - name = name.substring(1, name.length() - 1); - } - - if (!namedElements.containsKey(name)) namedElements.put(name, named); - named.acceptChildren(this); - } - - @Override - public void visitVariable(PsiVariable var) { - handleNamedElement(var); - } - - @Override - public void visitMethod(PsiMethod method) { - handleNamedElement(method); - } - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java deleted file mode 100644 index c738b55b85ae..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/JavaStructuralSearchProfile.java +++ /dev/null @@ -1,675 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer; -import com.intellij.codeInsight.template.JavaCodeContextType; -import com.intellij.codeInsight.template.TemplateContextType; -import com.intellij.codeInsight.template.TemplateManager; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.lang.Language; -import com.intellij.lang.StdLanguages; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.LanguageFileType; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.*; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.util.PsiUtilCore; -import com.intellij.structuralsearch.impl.matcher.*; -import com.intellij.structuralsearch.impl.matcher.compiler.GlobalCompilingVisitor; -import com.intellij.structuralsearch.impl.matcher.compiler.JavaCompilingVisitor; -import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler; -import com.intellij.structuralsearch.impl.matcher.filters.JavaLexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.impl.ParameterInfo; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementBuilder; -import com.intellij.structuralsearch.plugin.replace.impl.ReplacementContext; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchContext; -import com.intellij.structuralsearch.plugin.ui.UIUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.*; - -/** - * @author Eugene.Kudelevsky - */ -public class JavaStructuralSearchProfile extends StructuralSearchProfile { - private JavaLexicalNodesFilter myJavaLexicalNodesFilter; - - public String getText(PsiElement match, int start,int end) { - if (match instanceof PsiIdentifier) { - PsiElement parent = match.getParent(); - if (parent instanceof PsiJavaCodeReferenceElement && !(parent instanceof PsiExpression)) { - match = parent; // care about generic - } - } - final String matchText = match.getText(); - if (start==0 && end==-1) return matchText; - return matchText.substring(start,end == -1? matchText.length():end); - } - - public Class getElementContextByPsi(PsiElement element) { - if (element instanceof PsiIdentifier) { - element = element.getParent(); - } - - if (element instanceof PsiMember) { - return PsiMember.class; - } else { - return PsiExpression.class; - } - } - - public String getTypedVarString(final PsiElement element) { - String text; - - if (element instanceof PsiNamedElement) { - text = ((PsiNamedElement)element).getName(); - } - else if (element instanceof PsiAnnotation) { - PsiJavaCodeReferenceElement referenceElement = ((PsiAnnotation)element).getNameReferenceElement(); - text = referenceElement == null ? null : referenceElement.getQualifiedName(); - } - else if (element instanceof PsiNameValuePair) { - text = ((PsiNameValuePair)element).getName(); - } - else { - text = element.getText(); - if (StringUtil.startsWithChar(text, '@')) { - text = text.substring(1); - } - if (StringUtil.endsWithChar(text, ';')) text = text.substring(0, text.length() - 1); - else if (element instanceof PsiExpressionStatement) { - int i = text.indexOf(';'); - if (i != -1) text = text.substring(0, i); - } - } - - if (text==null) text = element.getText(); - - return text; - } - - @Override - public String getMeaningfulText(PsiElement element) { - if (element instanceof PsiReferenceExpression && - ((PsiReferenceExpression)element).getQualifierExpression() != null) { - final PsiElement resolve = ((PsiReferenceExpression)element).resolve(); - if (resolve instanceof PsiClass) return element.getText(); - - final PsiElement referencedElement = ((PsiReferenceExpression)element).getReferenceNameElement(); - String text = referencedElement != null ? referencedElement.getText() : ""; - - if (resolve == null && text.length() > 0 && Character.isUpperCase(text.charAt(0))) { - return element.getText(); - } - return text; - } - return super.getMeaningfulText(element); - } - - @Override - public PsiElement updateCurrentNode(PsiElement targetNode) { - if (targetNode instanceof PsiCodeBlock && ((PsiCodeBlock)targetNode).getStatements().length == 1) { - PsiElement targetNodeParent = targetNode.getParent(); - if (targetNodeParent instanceof PsiBlockStatement) { - targetNodeParent = targetNodeParent.getParent(); - } - - if (targetNodeParent instanceof PsiIfStatement || targetNodeParent instanceof PsiLoopStatement) { - targetNode = targetNodeParent; - } - } - return targetNode; - } - - @Override - public PsiElement extendMatchedByDownUp(PsiElement targetNode) { - if (targetNode instanceof PsiIdentifier) { - targetNode = targetNode.getParent(); - final PsiElement parent = targetNode.getParent(); - if (parent instanceof PsiTypeElement || parent instanceof PsiStatement) targetNode = parent; - } - return targetNode; - } - - @Override - public PsiElement extendMatchOnePsiFile(PsiElement file) { - if (file instanceof PsiIdentifier) { - // Searching in previous results - file = file.getParent(); - } - return file; - } - - public void compile(PsiElement[] elements, @NotNull GlobalCompilingVisitor globalVisitor) { - elements[0].getParent().accept(new JavaCompilingVisitor(globalVisitor)); - } - - @NotNull - public PsiElementVisitor createMatchingVisitor(@NotNull GlobalMatchingVisitor globalVisitor) { - return new JavaMatchingVisitor(globalVisitor); - } - - @NotNull - @Override - public PsiElementVisitor getLexicalNodesFilter(@NotNull LexicalNodesFilter filter) { - if (myJavaLexicalNodesFilter == null) { - myJavaLexicalNodesFilter = new JavaLexicalNodesFilter(filter); - } - return myJavaLexicalNodesFilter; - } - - @NotNull - public CompiledPattern createCompiledPattern() { - return new JavaCompiledPattern(); - } - - @Override - public boolean canProcess(@NotNull FileType fileType) { - return fileType == StdFileTypes.JAVA; - } - - public boolean isMyLanguage(@NotNull Language language) { - return language == StdLanguages.JAVA; - } - - @Override - public StructuralReplaceHandler getReplaceHandler(@NotNull ReplacementContext context) { - return new JavaReplaceHandler(context); - } - - @NotNull - @Override - public PsiElement[] createPatternTree(@NotNull String text, - @NotNull PatternTreeContext context, - @NotNull FileType fileType, - @Nullable Language language, - String contextName, @Nullable String extension, - @NotNull Project project, - boolean physical) { - if (physical) { - throw new UnsupportedOperationException(getClass() + " cannot create physical PSI"); - } - PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory(); - if (context == PatternTreeContext.Block) { - PsiElement element = elementFactory.createStatementFromText("{\n" + text + "\n}", null); - final PsiElement[] children = ((PsiBlockStatement)element).getCodeBlock().getChildren(); - final int extraChildCount = 4; - - if (children.length > extraChildCount) { - PsiElement[] result = new PsiElement[children.length - extraChildCount]; - final int extraChildStart = 2; - System.arraycopy(children, extraChildStart, result, 0, children.length - extraChildCount); - return result; - } - else { - return PsiElement.EMPTY_ARRAY; - } - } - else if (context == PatternTreeContext.Class) { - PsiElement element = elementFactory.createStatementFromText("class A {\n" + text + "\n}", null); - PsiClass clazz = (PsiClass)((PsiDeclarationStatement)element).getDeclaredElements()[0]; - PsiElement startChild = clazz.getLBrace(); - if (startChild != null) startChild = startChild.getNextSibling(); - - PsiElement endChild = clazz.getRBrace(); - if (endChild != null) endChild = endChild.getPrevSibling(); - if (startChild == endChild) return PsiElement.EMPTY_ARRAY; // nothing produced - - final List<PsiElement> result = new ArrayList<PsiElement>(3); - assert startChild != null; - for (PsiElement el = startChild.getNextSibling(); el != endChild && el != null; el = el.getNextSibling()) { - if (el instanceof PsiErrorElement) continue; - result.add(el); - } - - return PsiUtilCore.toPsiElementArray(result); - } - else { - return PsiFileFactory.getInstance(project).createFileFromText("__dummy.java", text).getChildren(); - } - } - - @NotNull - @Override - public Editor createEditor(@NotNull SearchContext searchContext, - @NotNull FileType fileType, - Language dialect, - String text, - boolean useLastConfiguration) { - // provides autocompletion - - PsiElement element = searchContext.getFile(); - - if (element != null && !useLastConfiguration) { - final Editor selectedEditor = FileEditorManager.getInstance(searchContext.getProject()).getSelectedTextEditor(); - - if (selectedEditor != null) { - int caretPosition = selectedEditor.getCaretModel().getOffset(); - PsiElement positionedElement = searchContext.getFile().findElementAt(caretPosition); - - if (positionedElement == null) { - positionedElement = searchContext.getFile().findElementAt(caretPosition + 1); - } - - if (positionedElement != null) { - element = PsiTreeUtil.getParentOfType( - positionedElement, - PsiClass.class, PsiCodeBlock.class - ); - } - } - } - - final PsiManager psimanager = PsiManager.getInstance(searchContext.getProject()); - final Project project = psimanager.getProject(); - final PsiCodeFragment file = createCodeFragment(project, text, element); - final Document doc = PsiDocumentManager.getInstance(searchContext.getProject()).getDocument(file); - DaemonCodeAnalyzer.getInstance(searchContext.getProject()).setHighlightingEnabled(file, false); - return UIUtil.createEditor(doc, searchContext.getProject(), true, true, getTemplateContextType()); - } - - @Override - public Class<? extends TemplateContextType> getTemplateContextTypeClass() { - return JavaCodeContextType.class; - } - - public PsiCodeFragment createCodeFragment(Project project, String text, PsiElement context) { - final JavaCodeFragmentFactory factory = JavaCodeFragmentFactory.getInstance(project); - return factory.createCodeBlockCodeFragment(text, context, true); - } - - @Override - public void checkSearchPattern(Project project, MatchOptions options) { - class ValidatingVisitor extends JavaRecursiveElementWalkingVisitor { - private PsiElement myCurrent; - - @Override public void visitAnnotation(PsiAnnotation annotation) { - final PsiJavaCodeReferenceElement nameReferenceElement = annotation.getNameReferenceElement(); - - if (nameReferenceElement == null || - !nameReferenceElement.getText().equals(MatchOptions.MODIFIER_ANNOTATION_NAME)) { - return; - } - - for(PsiNameValuePair pair:annotation.getParameterList().getAttributes()) { - final PsiAnnotationMemberValue value = pair.getValue(); - - if (value instanceof PsiArrayInitializerMemberValue) { - for(PsiAnnotationMemberValue v:((PsiArrayInitializerMemberValue)value).getInitializers()) { - final String name = StringUtil.stripQuotesAroundValue(v.getText()); - checkModifier(name); - } - - } else if (value != null) { - final String name = StringUtil.stripQuotesAroundValue(value.getText()); - checkModifier(name); - } - } - } - - private void checkModifier(final String name) { - if (!MatchOptions.INSTANCE_MODIFIER_NAME.equals(name) && - !PsiModifier.PACKAGE_LOCAL.equals(name) && - Arrays.binarySearch(JavaMatchingVisitor.MODIFIERS, name) < 0 - ) { - throw new MalformedPatternException(SSRBundle.message("invalid.modifier.type",name)); - } - } - - @Override - public void visitErrorElement(PsiErrorElement element) { - super.visitErrorElement(element); - //final PsiElement parent = element.getParent(); - //if (parent != myCurrent || !"';' expected".equals(element.getErrorDescription())) { - // throw new MalformedPatternException(element.getErrorDescription()); - //} - } - - public void setCurrent(PsiElement current) { - myCurrent = current; - } - } - ValidatingVisitor visitor = new ValidatingVisitor(); - final CompiledPattern compiledPattern = PatternCompiler.compilePattern(project, options); - final int nodeCount = compiledPattern.getNodeCount(); - final NodeIterator nodes = compiledPattern.getNodes(); - while (nodes.hasNext()) { - final PsiElement current = nodes.current(); - visitor.setCurrent(nodeCount == 1 && current instanceof PsiExpressionStatement ? current : null); - current.accept(visitor); - nodes.advance(); - } - nodes.reset(); - } - - @Override - public void checkReplacementPattern(Project project, ReplaceOptions options) { - MatchOptions matchOptions = options.getMatchOptions(); - FileType fileType = matchOptions.getFileType(); - PsiElement[] statements = MatcherImplUtil.createTreeFromText( - matchOptions.getSearchPattern(), - PatternTreeContext.Block, - fileType, - project - ); - final boolean searchIsExpression = statements.length == 1 && statements[0].getLastChild() instanceof PsiErrorElement; - - PsiElement[] statements2 = MatcherImplUtil.createTreeFromText( - options.getReplacement(), - PatternTreeContext.Block, - fileType, - project - ); - final boolean replaceIsExpression = statements2.length == 1 && statements2[0].getLastChild() instanceof PsiErrorElement; - - if (searchIsExpression != replaceIsExpression) { - throw new UnsupportedPatternException( - searchIsExpression ? SSRBundle.message("replacement.template.is.not.expression.error.message") : - SSRBundle.message("search.template.is.not.expression.error.message") - ); - } - } - - @Override - public LanguageFileType getDefaultFileType(LanguageFileType currentDefaultFileType) { - return StdFileTypes.JAVA; - } - - @Override - Configuration[] getPredefinedTemplates() { - return JavaPredefinedConfigurations.createPredefinedTemplates(); - } - - @Override - public void provideAdditionalReplaceOptions(@NotNull PsiElement node, final ReplaceOptions options, final ReplacementBuilder builder) { - final String templateText = TemplateManager.getInstance(node.getProject()).createTemplate("", "", options.getReplacement()).getTemplateText(); - node.accept(new JavaRecursiveElementWalkingVisitor() { - @Override - public void visitReferenceExpression(PsiReferenceExpression expression) { - visitElement(expression); - } - - @Override - public void visitVariable(PsiVariable field) { - super.visitVariable(field); - - final PsiExpression initializer = field.getInitializer(); - - if (initializer != null) { - final String initText = initializer.getText(); - - if (StructuralSearchUtil.isTypedVariable(initText)) { - final ParameterInfo initInfo = builder.findParameterization(Replacer.stripTypedVariableDecoration(initText)); - - if (initInfo != null) { - initInfo.setVariableInitialContext(true); - } - } - } - } - - @Override - public void visitClass(PsiClass aClass) { - super.visitClass(aClass); - - MatchVariableConstraint constraint = - options.getMatchOptions().getVariableConstraint(CompiledPattern.ALL_CLASS_UNMATCHED_CONTENT_VAR_ARTIFICIAL_NAME); - if (constraint != null) { - ParameterInfo e = new ParameterInfo(); - e.setName(CompiledPattern.ALL_CLASS_UNMATCHED_CONTENT_VAR_ARTIFICIAL_NAME); - e.setStartIndex(templateText.lastIndexOf('}')); - builder.addParametrization(e); - } - } - - @Override - public void visitMethod(PsiMethod method) { - super.visitMethod(method); - - String name = method.getName(); - if (StructuralSearchUtil.isTypedVariable(name)) { - name = Replacer.stripTypedVariableDecoration(name); - - ParameterInfo methodInfo = builder.findParameterization(name); - methodInfo.setScopeParameterization(true); - //if (scopedParameterizations != null) scopedParameterizations.put(method.getTextRange(), methodInfo); - } - } - - @Override - public void visitParameter(PsiParameter parameter) { - super.visitParameter(parameter); - - String name = parameter.getName(); - String type = parameter.getType().getCanonicalText(); - - if (StructuralSearchUtil.isTypedVariable(name)) { - name = Replacer.stripTypedVariableDecoration(name); - - if (StructuralSearchUtil.isTypedVariable(type)) { - type = Replacer.stripTypedVariableDecoration(type); - } - ParameterInfo nameInfo = builder.findParameterization(name); - ParameterInfo typeInfo = builder.findParameterization(type); - - if (nameInfo != null && typeInfo != null && !(parameter.getParent() instanceof PsiCatchSection)) { - nameInfo.setParameterContext(false); - typeInfo.setParameterContext(false); - typeInfo.setMethodParameterContext(true); - nameInfo.setMethodParameterContext(true); - typeInfo.setElement(parameter.getTypeElement()); - } - } - } - }); - } - - @Override - public int handleSubstitution(final ParameterInfo info, - MatchResult match, - StringBuilder result, - int offset, - HashMap<String, MatchResult> matchMap) { - if (info.getName().equals(match.getName())) { - String replacementString = match.getMatchImage(); - boolean forceAddingNewLine = false; - - if (info.isMethodParameterContext()) { - StringBuilder buf = new StringBuilder(); - handleMethodParameter(buf, info, matchMap); - replacementString = buf.toString(); - } - else if (match.getAllSons().size() > 0 && !match.isScopeMatch()) { - // compound matches - StringBuilder buf = new StringBuilder(); - MatchResult r = null; - - for (final MatchResult matchResult : match.getAllSons()) { - MatchResult previous = r; - r = matchResult; - - final PsiElement currentElement = r.getMatch(); - - if (buf.length() > 0) { - final PsiElement parent = currentElement.getParent(); - if (info.isStatementContext()) { - final PsiElement previousElement = previous.getMatchRef().getElement(); - - if (!(previousElement instanceof PsiComment) && - ( buf.charAt(buf.length() - 1) != '}' || - previousElement instanceof PsiDeclarationStatement - ) - ) { - buf.append(';'); - } - - final PsiElement prevSibling = currentElement.getPrevSibling(); - - if (prevSibling instanceof PsiWhiteSpace && - prevSibling.getPrevSibling() == previous.getMatch() - ) { - // consequent statements matched so preserve whitespacing - buf.append(prevSibling.getText()); - } - else { - buf.append('\n'); - } - } - else if (info.isParameterContext()) { - buf.append(','); - } - else if (parent instanceof PsiClass) { - final PsiElement prevSibling = PsiTreeUtil.skipSiblingsBackward(currentElement, PsiWhiteSpace.class); - if (prevSibling instanceof PsiJavaToken && JavaTokenType.COMMA.equals(((PsiJavaToken)prevSibling).getTokenType())) { - buf.append(','); - } - else { - buf.append('\n'); - } - } - else if (parent instanceof PsiReferenceList) { - buf.append(','); - } - else { - buf.append(' '); - } - } - - buf.append(r.getMatchImage()); - removeExtraSemicolonForSingleVarInstanceInMultipleMatch(info, r, buf); - forceAddingNewLine = currentElement instanceof PsiComment; - } - - replacementString = buf.toString(); - } else { - StringBuilder buf = new StringBuilder(); - if (info.isStatementContext()) { - forceAddingNewLine = match.getMatch() instanceof PsiComment; - } - buf.append(replacementString); - removeExtraSemicolonForSingleVarInstanceInMultipleMatch(info, match, buf); - replacementString = buf.toString(); - } - - offset = Replacer.insertSubstitution(result, offset, info, replacementString); - offset = removeExtraSemicolon(info, offset, result, match); - if (forceAddingNewLine && info.isStatementContext()) { - result.insert(info.getStartIndex() + offset + 1, '\n'); - offset ++; - } - } - return offset; - } - - @Override - public int processAdditionalOptions(ParameterInfo info, int offset, StringBuilder result, MatchResult r) { - if (info.isStatementContext()) { - return removeExtraSemicolon(info, offset, result, r); - } - return offset; - } - - @Override - public boolean isIdentifier(PsiElement element) { - return element instanceof PsiIdentifier; - } - - @Override - public Collection<String> getReservedWords() { - return Collections.singleton(PsiModifier.PACKAGE_LOCAL); - } - - @Override - public boolean isDocCommentOwner(PsiElement match) { - return match instanceof PsiMember; - } - - private static void handleMethodParameter(StringBuilder buf, ParameterInfo info, HashMap<String, MatchResult> matchMap) { - if(info.getElement() ==null) { - // no specific handling for name of method parameter since it is handled with type - return; - } - - String name = ((PsiParameter)info.getElement().getParent()).getName(); - name = StructuralSearchUtil.isTypedVariable(name) ? Replacer.stripTypedVariableDecoration(name):name; - - final MatchResult matchResult = matchMap.get(name); - if (matchResult == null) return; - - if (matchResult.isMultipleMatch()) { - for (MatchResult result : matchResult.getAllSons()) { - if (buf.length() > 0) { - buf.append(','); - } - - appendParameter(buf, result); - } - } else { - appendParameter(buf, matchResult); - } - } - - private static void appendParameter(final StringBuilder buf, final MatchResult _matchResult) { - for(Iterator<MatchResult> j = _matchResult.getAllSons().iterator();j.hasNext();) { - buf.append(j.next().getMatchImage()).append(' ').append(j.next().getMatchImage()); - } - } - - private static void removeExtraSemicolonForSingleVarInstanceInMultipleMatch(final ParameterInfo info, MatchResult r, StringBuilder buf) { - if (info.isStatementContext()) { - final PsiElement element = r.getMatchRef().getElement(); - - // remove extra ; - if (buf.charAt(buf.length()-1)==';' && - r.getMatchImage().charAt(r.getMatchImage().length()-1)==';' && - ( element instanceof PsiReturnStatement || - element instanceof PsiDeclarationStatement || - element instanceof PsiExpressionStatement || - element instanceof PsiAssertStatement || - element instanceof PsiBreakStatement || - element instanceof PsiContinueStatement || - element instanceof PsiMember || - element instanceof PsiIfStatement && !(((PsiIfStatement)element).getThenBranch() instanceof PsiBlockStatement) || - element instanceof PsiLoopStatement && !(((PsiLoopStatement)element).getBody() instanceof PsiBlockStatement) - ) - ) { - // contains extra ; - buf.deleteCharAt(buf.length()-1); - } - } - } - - private static int removeExtraSemicolon(ParameterInfo info, int offset, StringBuilder result, MatchResult match) { - if (info.isStatementContext()) { - int index = offset+ info.getStartIndex(); - if (result.charAt(index)==';' && - ( match == null || - ( result.charAt(index-1)=='}' && - !(match.getMatch() instanceof PsiDeclarationStatement) && // array init in dcl - !(match.getMatch() instanceof PsiNewExpression) // array initializer - ) || - ( !match.isMultipleMatch() && // ; in comment - match.getMatch() instanceof PsiComment - ) || - ( match.isMultipleMatch() && // ; in comment - match.getAllSons().get( match.getAllSons().size() - 1 ).getMatch() instanceof PsiComment - ) - ) - ) { - result.deleteCharAt(index); - --offset; - } - } - - return offset; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaCompiledPattern.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaCompiledPattern.java deleted file mode 100644 index 9a6330bb799b..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaCompiledPattern.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.openapi.util.Key; -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.strategies.ExprMatchingStrategy; -import org.jetbrains.annotations.Nullable; - -/** -* @author Eugene.Kudelevsky -*/ -public class JavaCompiledPattern extends CompiledPattern { - private static final String TYPED_VAR_PREFIX = "__$_"; - - private boolean requestsSuperFields; - private boolean requestsSuperMethods; - private boolean requestsSuperInners; - - public JavaCompiledPattern() { - setStrategy(ExprMatchingStrategy.getInstance()); - } - - public String[] getTypedVarPrefixes() { - return new String[] {TYPED_VAR_PREFIX}; - } - - public boolean isTypedVar(final String str) { - if (str.charAt(0)=='@') { - return str.regionMatches(1,TYPED_VAR_PREFIX,0,TYPED_VAR_PREFIX.length()); - } else { - return str.startsWith(TYPED_VAR_PREFIX); - } - } - - @Override - public boolean isToResetHandler(PsiElement element) { - return !(element instanceof PsiJavaToken) && - !(element instanceof PsiJavaCodeReferenceElement && element.getParent() instanceof PsiAnnotation); - } - - @Nullable - @Override - public String getAlternativeTextToMatch(PsiElement node, String previousText) { - // Short class name is matched with fully qualified name - if(node instanceof PsiJavaCodeReferenceElement || node instanceof PsiClass) { - PsiElement element = (node instanceof PsiJavaCodeReferenceElement)? - ((PsiJavaCodeReferenceElement)node).resolve(): - node; - - if (element instanceof PsiClass) { - String text = ((PsiClass)element).getQualifiedName(); - if (text != null && text.equals(previousText)) { - text = ((PsiClass)element).getName(); - } - - if (text != null) { - return text; - } - } - } else if (node instanceof PsiLiteralExpression) { - return node.getText(); - } - return null; - } - - public static final Key<String> ALL_CLASS_CONTENT_VAR_NAME_KEY = Key.create("AllClassContent"); - - public boolean isRequestsSuperFields() { - return requestsSuperFields; - } - - public void setRequestsSuperFields(boolean requestsSuperFields) { - this.requestsSuperFields = requestsSuperFields; - } - - public boolean isRequestsSuperInners() { - return requestsSuperInners; - } - - public void setRequestsSuperInners(boolean requestsSuperInners) { - this.requestsSuperInners = requestsSuperInners; - } - - public boolean isRequestsSuperMethods() { - return requestsSuperMethods; - } - - public void setRequestsSuperMethods(boolean requestsSuperMethods) { - this.requestsSuperMethods = requestsSuperMethods; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchPredicateProvider.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchPredicateProvider.java deleted file mode 100644 index 042912e0354c..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchPredicateProvider.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.MatchVariableConstraint; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.impl.matcher.predicates.*; - -import java.util.Set; - -public class JavaMatchPredicateProvider extends MatchPredicateProvider{ - @Override - public void collectPredicates(MatchVariableConstraint constraint, String name, MatchOptions options, Set<MatchPredicate> predicates) { - if (constraint.isReadAccess()) { - MatchPredicate predicate = new ReadPredicate(); - - if (constraint.isInvertReadAccess()) { - predicate = new NotPredicate(predicate); - } - predicates.add(predicate); - } - - if (constraint.isWriteAccess()) { - MatchPredicate predicate = new WritePredicate(); - - if (constraint.isInvertWriteAccess()) { - predicate = new NotPredicate(predicate); - } - predicates.add(predicate); - } - - if (!StringUtil.isEmptyOrSpaces(constraint.getNameOfExprType())) { - MatchPredicate predicate = new ExprTypePredicate( - constraint.getNameOfExprType(), - name, - constraint.isExprTypeWithinHierarchy(), - options.isCaseSensitiveMatch(), - constraint.isPartOfSearchResults() - ); - - if (constraint.isInvertExprType()) { - predicate = new NotPredicate(predicate); - } - predicates.add(predicate); - } - - if (!StringUtil.isEmptyOrSpaces(constraint.getNameOfFormalArgType())) { - MatchPredicate predicate = new FormalArgTypePredicate( - constraint.getNameOfFormalArgType(), - name, - constraint.isFormalArgTypeWithinHierarchy(), - options.isCaseSensitiveMatch(), - constraint.isPartOfSearchResults() - ); - if (constraint.isInvertFormalType()) { - predicate = new NotPredicate(predicate); - } - predicates.add(predicate); - } - - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java deleted file mode 100644 index 38e77c796281..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/JavaMatchingVisitor.java +++ /dev/null @@ -1,1640 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher; - -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.psi.*; -import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.javadoc.PsiDocTag; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.util.PsiUtil; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.MatchResult; -import com.intellij.structuralsearch.impl.matcher.filters.LexicalNodesFilter; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchingHandler; -import com.intellij.structuralsearch.impl.matcher.handlers.SubstitutionHandler; -import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator; -import com.intellij.structuralsearch.impl.matcher.iterators.DocValuesIterator; -import com.intellij.structuralsearch.impl.matcher.iterators.HierarchyNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.structuralsearch.impl.matcher.predicates.NotPredicate; -import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate; -import com.intellij.util.containers.ContainerUtil; - -import java.util.*; - -/** - * @author Eugene.Kudelevsky - */ -public class JavaMatchingVisitor extends JavaElementVisitor { - public static final String[] MODIFIERS = { - PsiModifier.PUBLIC, PsiModifier.PROTECTED, PsiModifier.PRIVATE, PsiModifier.STATIC, PsiModifier.ABSTRACT, PsiModifier.FINAL, - PsiModifier.NATIVE, PsiModifier.SYNCHRONIZED, PsiModifier.STRICTFP, PsiModifier.TRANSIENT, PsiModifier.VOLATILE, PsiModifier.DEFAULT - }; - public static final Key<List<PsiCatchSection>> UNMATCHED_CATCH_SECTION_CONTENT_VAR_KEY = Key.create("UnmatchedCatchSection"); - private final GlobalMatchingVisitor myMatchingVisitor; - private PsiClass myClazz; - - static { - Arrays.sort(MODIFIERS); - } - - public JavaMatchingVisitor(GlobalMatchingVisitor matchingVisitor) { - this.myMatchingVisitor = matchingVisitor; - } - - @Override - public void visitComment(PsiComment comment) { - PsiElement comment2 = null; - - if (!(myMatchingVisitor.getElement() instanceof PsiComment)) { - if (myMatchingVisitor.getElement() instanceof PsiMember) { - final PsiElement[] children = myMatchingVisitor.getElement().getChildren(); - if (children[0] instanceof PsiComment) { - comment2 = children[0]; - } - } - } - else { - comment2 = myMatchingVisitor.getElement(); - } - - if (comment2 == null) { - myMatchingVisitor.setResult(false); - return; - } - - final Object userData = comment.getUserData(CompiledPattern.HANDLER_KEY); - - if (userData instanceof String) { - String str = (String)userData; - int end = comment2.getTextLength(); - - if (((PsiComment)comment2).getTokenType() == JavaTokenType.C_STYLE_COMMENT) { - end -= 2; - } - myMatchingVisitor.setResult(((SubstitutionHandler)myMatchingVisitor.getMatchContext().getPattern().getHandler(str)).handle( - comment2, - 2, - end, - myMatchingVisitor.getMatchContext() - )); - } - else if (userData instanceof MatchingHandler) { - myMatchingVisitor.setResult(((MatchingHandler)userData).match(comment, comment2, myMatchingVisitor.getMatchContext())); - } - else { - myMatchingVisitor.setResult(comment.getText().equals(comment2.getText())); - } - } - - @Override - public void visitDocTagValue(final PsiDocTagValue value) { - final PsiDocTagValue value2 = (PsiDocTagValue)myMatchingVisitor.getElement(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(value); - - if (isTypedVar) { - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(value, value2)); - } - else { - myMatchingVisitor.setResult(value.textMatches(value2)); - } - } - - private static boolean isNotInstanceModifier(final PsiModifierList list2) { - return list2.hasModifierProperty(PsiModifier.STATIC) || - list2.hasModifierProperty(PsiModifier.ABSTRACT); - } - - @Override - public final void visitModifierList(final PsiModifierList list) { - final PsiModifierList list2 = (PsiModifierList)myMatchingVisitor.getElement(); - - for (@PsiModifier.ModifierConstant String modifier : MODIFIERS) { - if (list.hasModifierProperty(modifier) && !list2.hasModifierProperty(modifier)) { - myMatchingVisitor.setResult(false); - return; - } - } - - final PsiAnnotation[] annotations = list.getAnnotations(); - if (annotations.length > 0) { - HashSet<PsiAnnotation> set = new HashSet<PsiAnnotation>(Arrays.asList(annotations)); - - for (PsiAnnotation annotation : annotations) { - final PsiJavaCodeReferenceElement nameReferenceElement = annotation.getNameReferenceElement(); - - if (nameReferenceElement != null && MatchOptions.MODIFIER_ANNOTATION_NAME.equals(nameReferenceElement.getText())) { - final PsiAnnotationParameterList parameterList = annotation.getParameterList(); - final PsiNameValuePair[] attributes = parameterList.getAttributes(); - - for (PsiNameValuePair pair : attributes) { - final PsiAnnotationMemberValue value = pair.getValue(); - if (value == null) continue; - - if (value instanceof PsiArrayInitializerMemberValue) { - boolean matchedOne = false; - - for (PsiAnnotationMemberValue v : ((PsiArrayInitializerMemberValue)value).getInitializers()) { - @PsiModifier.ModifierConstant String name = StringUtil.stripQuotesAroundValue(v.getText()); - if (MatchOptions.INSTANCE_MODIFIER_NAME.equals(name)) { - if (isNotInstanceModifier(list2)) { - myMatchingVisitor.setResult(false); - return; - } - else { - matchedOne = true; - } - } - else if (list2.hasModifierProperty(name)) { - matchedOne = true; - break; - } - } - - if (!matchedOne) { - myMatchingVisitor.setResult(false); - return; - } - } - else { - @PsiModifier.ModifierConstant String name = StringUtil.stripQuotesAroundValue(value.getText()); - if (MatchOptions.INSTANCE_MODIFIER_NAME.equals(name)) { - if (isNotInstanceModifier(list2)) { - myMatchingVisitor.setResult(false); - return; - } - } - else if (!list2.hasModifierProperty(name)) { - myMatchingVisitor.setResult(false); - return; - } - } - } - - set.remove(annotation); - } - } - - myMatchingVisitor.setResult(set.isEmpty() || myMatchingVisitor - .matchInAnyOrder(set.toArray(new PsiAnnotation[set.size()]), list2.getAnnotations())); - } - else { - myMatchingVisitor.setResult(true); - } - } - - @Override - public void visitDocTag(final PsiDocTag tag) { - final PsiDocTag tag2 = (PsiDocTag)myMatchingVisitor.getElement(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(tag.getNameElement()); - - myMatchingVisitor.setResult(isTypedVar || tag.getName().equals(tag2.getName())); - - PsiElement psiDocTagValue = tag.getValueElement(); - boolean isTypedValue = false; - - if (myMatchingVisitor.getResult() && psiDocTagValue != null) { - final PsiElement[] children = psiDocTagValue.getChildren(); - if (children.length == 1) { - psiDocTagValue = children[0]; - } - isTypedValue = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(psiDocTagValue); - - if (isTypedValue) { - if (tag2.getValueElement() != null) { - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(psiDocTagValue, tag2.getValueElement())); - } - else { - myMatchingVisitor.setResult(allowsAbsenceOfMatch(psiDocTagValue)); - } - } - } - - if (myMatchingVisitor.getResult() && !isTypedValue) { - myMatchingVisitor.setResult(myMatchingVisitor.matchInAnyOrder( - new DocValuesIterator(tag.getFirstChild()), - new DocValuesIterator(tag2.getFirstChild()) - )); - } - - if (myMatchingVisitor.getResult() && isTypedVar) { - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(tag.getNameElement(), tag2.getNameElement())); - } - } - - private boolean allowsAbsenceOfMatch(final PsiElement element) { - MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(element); - - if (handler instanceof SubstitutionHandler && - ((SubstitutionHandler)handler).getMinOccurs() == 0) { - return true; - } - return false; - } - - @Override - public void visitDocComment(final PsiDocComment comment) { - PsiDocComment comment2; - - if (myMatchingVisitor.getElement() instanceof PsiDocCommentOwner) { - comment2 = ((PsiDocCommentOwner)myMatchingVisitor.getElement()).getDocComment(); - - if (comment2 == null) { - // doc comment are not collapsed for inner classes! - myMatchingVisitor.setResult(false); - return; - } - } - else { - comment2 = (PsiDocComment)myMatchingVisitor.getElement(); - - if (myMatchingVisitor.getElement().getParent() instanceof PsiDocCommentOwner) { - myMatchingVisitor.setResult(false); - return; // we should matched the doc before - } - } - - if (comment.getTags().length > 0) { - myMatchingVisitor.setResult(myMatchingVisitor.matchInAnyOrder(comment.getTags(), comment2.getTags())); - } - else { - visitComment(comment); - } - } - - @Override - public void visitElement(PsiElement el) { - myMatchingVisitor.setResult(el.textMatches(myMatchingVisitor.getElement())); - } - - @Override - public void visitArrayInitializerExpression(PsiArrayInitializerExpression expression) { - final PsiArrayInitializerExpression expr2 = (PsiArrayInitializerExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.matchSequentially( - new ArrayBackedNodeIterator(expression.getInitializers()), - new ArrayBackedNodeIterator(expr2.getInitializers()) - )); - } - - @Override - public void visitClassInitializer(PsiClassInitializer initializer) { - PsiClassInitializer initializer2 = (PsiClassInitializer)myMatchingVisitor.getElement(); - myMatchingVisitor.setResult(myMatchingVisitor.match(initializer.getModifierList(), initializer2.getModifierList()) && - myMatchingVisitor.match(initializer.getBody(), initializer2.getBody())); - } - - @Override - public void visitCodeBlock(PsiCodeBlock block) { - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(block, myMatchingVisitor.getElement())); - } - - @Override - public void visitJavaToken(final PsiJavaToken token) { - PsiElement element = myMatchingVisitor.getElement(); - boolean result; - - if (!(element instanceof PsiJavaToken)) { - result = token.textMatches(element); - } else { - final PsiJavaToken anotherToken = (PsiJavaToken)element; - - result = token.getTokenType() == anotherToken.getTokenType() && token.textMatches(anotherToken); - } - - myMatchingVisitor.setResult(result); - } - - @Override - public void visitAnnotation(PsiAnnotation annotation) { - final PsiAnnotation psiAnnotation = (PsiAnnotation)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(annotation.getNameReferenceElement(), psiAnnotation.getNameReferenceElement()) && - myMatchingVisitor - .matchInAnyOrder(annotation.getParameterList().getAttributes(), - psiAnnotation.getParameterList().getAttributes())); - } - - @Override - public void visitNameValuePair(PsiNameValuePair pair) { - final PsiIdentifier nameIdentifier = pair.getNameIdentifier(); - if (nameIdentifier == null) { - myMatchingVisitor.setResult(true); - return; - } - - final PsiNameValuePair elementNameValuePair = (PsiNameValuePair)myMatchingVisitor.getElement(); - PsiIdentifier matchedNameValuePair = elementNameValuePair.getNameIdentifier(); - - PsiAnnotationMemberValue annotationInitializer = pair.getValue(); - boolean isTypedInitializer = annotationInitializer != null && - myMatchingVisitor.getMatchContext().getPattern().isTypedVar(annotationInitializer) && - annotationInitializer instanceof PsiReferenceExpression; - - myMatchingVisitor.setResult(myMatchingVisitor.match(annotationInitializer, elementNameValuePair.getValue()) || - (isTypedInitializer && - elementNameValuePair.getValue() == null && - allowsAbsenceOfMatch(annotationInitializer) - )); - if (myMatchingVisitor.getResult()) { - final MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(nameIdentifier); - - if (handler instanceof SubstitutionHandler) { - myMatchingVisitor - .setResult(((SubstitutionHandler)handler).handle(matchedNameValuePair, - myMatchingVisitor.getMatchContext())); - } - else { - myMatchingVisitor - .setResult(myMatchingVisitor.match(nameIdentifier, matchedNameValuePair)); - } - } - } - - private boolean checkHierarchy(PsiMember element, PsiMember patternElement) { - final MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(patternElement); - if (handler instanceof SubstitutionHandler) { - final SubstitutionHandler handler2 = (SubstitutionHandler)handler; - - if (!handler2.isSubtype()) { - if (handler2.isStrictSubtype()) { - // check if element is declared not in current class (in ancestors) - return element.getContainingClass() != myClazz; - } - } - else { - return true; - } - } - - // check if element is declared in current class (not in ancestors) - return element.getContainingClass() == myClazz; - } - - @Override - public void visitField(PsiField psiField) { - if (!checkHierarchy((PsiField)myMatchingVisitor.getElement(), psiField)) { - myMatchingVisitor.setResult(false); - return; - } - super.visitField(psiField); - } - - @Override - public void visitAnonymousClass(final PsiAnonymousClass clazz) { - final PsiAnonymousClass clazz2 = (PsiAnonymousClass)myMatchingVisitor.getElement(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(clazz.getFirstChild()); - - myMatchingVisitor.setResult((myMatchingVisitor.match(clazz.getBaseClassReference(), clazz2.getBaseClassReference()) || isTypedVar) && - myMatchingVisitor.matchSons(clazz.getArgumentList(), clazz2.getArgumentList()) && - compareClasses(clazz, clazz2)); - - if (myMatchingVisitor.getResult() && isTypedVar) { - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(clazz.getFirstChild(), clazz2.getFirstChild())); - } - } - - @Override - public void visitLambdaExpression(PsiLambdaExpression expression) { - final PsiLambdaExpression expression2 = (PsiLambdaExpression)myMatchingVisitor.getElement(); - boolean result = true; - final PsiParameterList parameterList1 = expression.getParameterList(); - if (parameterList1.getParametersCount() != 0) { - result = myMatchingVisitor.matchSons(parameterList1, expression2.getParameterList()); - } - final PsiElement body1 = getElementToMatch(expression.getBody()); - if (body1 != null) { - result = myMatchingVisitor.matchSequentially(body1, getElementToMatch(expression2.getBody())); - } - myMatchingVisitor.setResult(result); - } - - private static PsiElement getElementToMatch(PsiElement element) { - if (element instanceof PsiCodeBlock) { - element = PsiTreeUtil.getChildOfAnyType(element, PsiStatement.class, PsiComment.class); - } - if (element instanceof PsiExpressionStatement) { - element = ((PsiExpressionStatement)element).getExpression(); - } - if (element instanceof PsiReturnStatement) { - element = ((PsiReturnStatement)element).getReturnValue(); - } - return element; - } - - protected boolean matchInAnyOrder(final PsiReferenceList elements, final PsiReferenceList elements2, GlobalMatchingVisitor visitor) { - if ((elements == null && visitor.isLeftLooseMatching()) || - elements == elements2 // null - ) { - return true; - } - - return visitor.matchInAnyOrder( - elements.getReferenceElements(), - (elements2 != null) ? elements2.getReferenceElements() : PsiElement.EMPTY_ARRAY - ); - } - - private boolean compareClasses(final PsiClass clazz, final PsiClass clazz2) { - final PsiClass saveClazz = this.myClazz; - final MatchContext.MatchedElementsListener oldListener = myMatchingVisitor.getMatchContext().getMatchedElementsListener(); - - this.myClazz = clazz2; - - final CompiledPattern pattern = myMatchingVisitor.getMatchContext().getPattern(); - assert pattern instanceof JavaCompiledPattern; - final JavaCompiledPattern javaPattern = (JavaCompiledPattern)pattern; - - final String unmatchedHandlerName = clazz.getUserData(JavaCompiledPattern.ALL_CLASS_CONTENT_VAR_NAME_KEY); - final MatchingHandler allRemainingClassContentElementHandler = unmatchedHandlerName != null ? pattern.getHandler(unmatchedHandlerName) : null; - MatchContext.MatchedElementsListener newListener = null; - - assert javaPattern instanceof JavaCompiledPattern; - if (allRemainingClassContentElementHandler != null) { - myMatchingVisitor.getMatchContext().setMatchedElementsListener( - newListener = new MatchContext.MatchedElementsListener() { - private Set<PsiElement> myMatchedElements; - - public void matchedElements(Collection<PsiElement> matchedElements) { - if (matchedElements == null) return; - if (myMatchedElements == null) { - myMatchedElements = new HashSet<PsiElement>(matchedElements); - } - else { - myMatchedElements.addAll(matchedElements); - } - } - - public void commitUnmatched() { - final SubstitutionHandler handler = (SubstitutionHandler)allRemainingClassContentElementHandler; - - for (PsiElement el = clazz2.getFirstChild(); el != null; el = el.getNextSibling()) { - if (el instanceof PsiMember && (myMatchedElements == null || !myMatchedElements.contains(el))) { - handler.handle(el, myMatchingVisitor.getMatchContext()); - } - } - } - } - ); - } - - boolean result = false; - try { - final boolean templateIsInterface = clazz.isInterface(); - if (templateIsInterface != clazz2.isInterface()) return false; - if (templateIsInterface && clazz.isAnnotationType() && !clazz2.isAnnotationType()) return false; - final boolean templateIsEnum = clazz.isEnum(); - if (templateIsEnum && !clazz2.isEnum()) return false; - - if (!matchInAnyOrder(clazz.getExtendsList(), clazz2.getExtendsList(), myMatchingVisitor)) { - return false; - } - - // check if implements is in extended classes implements - final PsiReferenceList implementsList = clazz.getImplementsList(); - if (implementsList != null) { - if (!matchInAnyOrder(implementsList, clazz2.getImplementsList(), myMatchingVisitor)) { - final PsiReferenceList anotherExtendsList = clazz2.getExtendsList(); - final PsiJavaCodeReferenceElement[] referenceElements = implementsList.getReferenceElements(); - - boolean accepted = false; - - if (referenceElements.length > 0 && anotherExtendsList != null) { - final HierarchyNodeIterator iterator = new HierarchyNodeIterator(clazz2, true, true, false); - - accepted = myMatchingVisitor.matchInAnyOrder(new ArrayBackedNodeIterator(referenceElements), iterator); - } - - if (!accepted) return false; - } - } - - final PsiField[] fields = clazz.getFields(); - - if (fields.length > 0) { - final PsiField[] fields2 = javaPattern.isRequestsSuperFields() ? - clazz2.getAllFields() : - clazz2.getFields(); - - if (!myMatchingVisitor.matchInAnyOrder(fields, fields2)) { - return false; - } - } - - final PsiMethod[] methods = clazz.getMethods(); - - if (methods.length > 0) { - final PsiMethod[] methods2 = javaPattern.isRequestsSuperMethods() ? - clazz2.getAllMethods() : - clazz2.getMethods(); - - if (!myMatchingVisitor.matchInAnyOrder(methods, methods2)) { - return false; - } - } - - final PsiClass[] nestedClasses = clazz.getInnerClasses(); - - if (nestedClasses.length > 0) { - final PsiClass[] nestedClasses2 = javaPattern.isRequestsSuperInners() ? - clazz2.getAllInnerClasses() : - clazz2.getInnerClasses(); - - if (!myMatchingVisitor.matchInAnyOrder(nestedClasses, nestedClasses2)) { - return false; - } - } - - final PsiClassInitializer[] initializers = clazz.getInitializers(); - if (initializers.length > 0) { - final PsiClassInitializer[] initializers2 = clazz2.getInitializers(); - - if (!myMatchingVisitor.matchInAnyOrder(initializers, initializers2)) { - return false; - } - } - - result = true; - return result; - } - finally { - if (result && newListener != null) newListener.commitUnmatched(); - this.myClazz = saveClazz; - myMatchingVisitor.getMatchContext().setMatchedElementsListener(oldListener); - } - } - - private boolean compareBody(final PsiElement el1, final PsiElement el2) { - PsiElement compareElement1 = el1; - PsiElement compareElement2 = el2; - - if (myMatchingVisitor.getMatchContext().getOptions().isLooseMatching()) { - if (el1 instanceof PsiBlockStatement) { - compareElement1 = ((PsiBlockStatement)el1).getCodeBlock().getFirstChild(); - } - - if (el2 instanceof PsiBlockStatement) { - compareElement2 = ((PsiBlockStatement)el2).getCodeBlock().getFirstChild(); - } - } - - return myMatchingVisitor.matchSequentially(compareElement1, compareElement2); - } - - @Override - public void visitArrayAccessExpression(final PsiArrayAccessExpression slice) { - final PsiArrayAccessExpression slice2 = (PsiArrayAccessExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(slice.getArrayExpression(), slice2.getArrayExpression()) && - myMatchingVisitor.match(slice.getIndexExpression(), slice2.getIndexExpression())); - } - - @Override - public void visitMethodReferenceExpression(PsiMethodReferenceExpression expression) { - final PsiElement element = myMatchingVisitor.getElement(); - if (!(element instanceof PsiMethodReferenceExpression)) { - myMatchingVisitor.setResult(false); - return; - } - super.visitMethodReferenceExpression(expression); - } - - @Override - public void visitReferenceExpression(final PsiReferenceExpression reference) { - final PsiExpression qualifier = reference.getQualifierExpression(); - - final PsiElement nameElement = reference.getReferenceNameElement(); - final MatchContext context = myMatchingVisitor.getMatchContext(); - MatchingHandler _handler = nameElement != null ? context.getPattern().getHandlerSimple(nameElement) : null; - if (!(_handler instanceof SubstitutionHandler)) _handler = context.getPattern().getHandlerSimple(reference); - - final PsiElement element = myMatchingVisitor.getElement(); - PsiElement other = element instanceof PsiExpression && context.getOptions().isLooseMatching() ? - PsiUtil.skipParenthesizedExprDown((PsiExpression)element) : - element; - if (_handler instanceof SubstitutionHandler && - !(context.getPattern().getHandlerSimple(qualifier) instanceof SubstitutionHandler) && - !(qualifier instanceof PsiThisExpression) - ) { - if (other instanceof PsiReferenceExpression) { - final PsiReferenceExpression psiReferenceExpression = (PsiReferenceExpression)other; - - final PsiExpression qualifier2 = psiReferenceExpression.getQualifierExpression(); - if (qualifier2 == null || (context.getOptions().isLooseMatching() && qualifier2 instanceof PsiThisExpression)) { - other = psiReferenceExpression.getReferenceNameElement(); - } - } - - final SubstitutionHandler handler = (SubstitutionHandler)_handler; - if (handler.isSubtype() || handler.isStrictSubtype()) { - myMatchingVisitor.setResult(checkMatchWithingHierarchy(other, handler, reference)); - } - else { - myMatchingVisitor.setResult(handler.handle(other, context)); - } - - return; - } - - if (!(other instanceof PsiReferenceExpression)) { - myMatchingVisitor.setResult(false); - return; - } - - final PsiReferenceExpression reference2 = (PsiReferenceExpression)other; - - // just variable - final PsiExpression reference2Qualifier = reference2.getQualifierExpression(); - if (qualifier == null && reference2Qualifier == null) { - myMatchingVisitor.setResult(reference.getReferenceNameElement().textMatches(reference2.getReferenceNameElement())); - return; - } - - // handle field selection - if (!(other.getParent() instanceof PsiMethodCallExpression) && qualifier != null) { - final PsiElement referenceElement = reference.getReferenceNameElement(); - final PsiElement referenceElement2 = reference2.getReferenceNameElement(); - - if (context.getPattern().isTypedVar(referenceElement)) { - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(referenceElement, referenceElement2)); - } - else { - myMatchingVisitor.setResult( - (referenceElement2 != null && referenceElement != null && referenceElement.textMatches(referenceElement2)) || - referenceElement == referenceElement2); - } - - if (!myMatchingVisitor.getResult()) { - return; - } - if (reference2Qualifier != null) { - myMatchingVisitor.setResult(myMatchingVisitor.match(qualifier, reference2Qualifier)); - } - else { - final PsiElement referencedElement = MatchUtils.getReferencedElement(other); - if (referencedElement instanceof PsiField) { - final PsiField field = (PsiField)referencedElement; - if (qualifier instanceof PsiThisExpression) { - myMatchingVisitor.setResult(!field.hasModifierProperty(PsiModifier.STATIC)); - return; - } - } - final MatchingHandler handler = context.getPattern().getHandler(qualifier); - matchImplicitQualifier(handler, referencedElement, context); - } - - return; - } - - myMatchingVisitor.setResult(false); - } - - private static int countCStyleArrayDeclarationDims(final PsiElement type2) { - if (type2 != null) { - final PsiElement parentElement = type2.getParent(); - - if (parentElement instanceof PsiVariable) { - final PsiIdentifier psiIdentifier = ((PsiVariable)parentElement).getNameIdentifier(); - if (psiIdentifier == null) return 0; - - int count = 0; - for (PsiElement sibling = psiIdentifier.getNextSibling(); sibling != null; sibling = sibling.getNextSibling()) { - if (sibling instanceof PsiJavaToken) { - final IElementType tokenType = ((PsiJavaToken)sibling).getTokenType(); - if (tokenType == JavaTokenType.LBRACKET) ++count; - else if (tokenType != JavaTokenType.RBRACKET) break; - } - } - - return count; - } - } - return 0; - } - - private void copyResults(final MatchResultImpl ourResult) { - if (ourResult.hasSons()) { - for (MatchResult son : ourResult.getAllSons()) { - myMatchingVisitor.getMatchContext().getResult().addSon((MatchResultImpl)son); - } - } - } - - private boolean matchType(final PsiElement _type, final PsiElement _type2) { - PsiElement el = _type; - PsiElement el2 = _type2; - PsiType type1 = null; - PsiType type2 = null; - - // check for generics - if (_type instanceof PsiTypeElement && - ((PsiTypeElement)_type).getInnermostComponentReferenceElement() != null - ) { - el = ((PsiTypeElement)_type).getInnermostComponentReferenceElement(); - type1 = ((PsiTypeElement)_type).getType(); - } - - if (_type2 instanceof PsiTypeElement && - ((PsiTypeElement)_type2).getInnermostComponentReferenceElement() != null - ) { - el2 = ((PsiTypeElement)_type2).getInnermostComponentReferenceElement(); - type2 = ((PsiTypeElement)_type2).getType(); - } - - PsiElement[] typeparams = null; - if (el2 instanceof PsiJavaCodeReferenceElement) { - typeparams = ((PsiJavaCodeReferenceElement)el2).getParameterList().getTypeParameterElements(); - if (typeparams.length > 0) { - el2 = ((PsiJavaCodeReferenceElement)el2).getReferenceNameElement(); - } - } - else if (el2 instanceof PsiTypeParameter) { - el2 = ((PsiTypeParameter)el2).getNameIdentifier(); - } - else if (el2 instanceof PsiClass && ((PsiClass)el2).hasTypeParameters() - ) { - typeparams = ((PsiClass)el2).getTypeParameters(); - el2 = ((PsiClass)el2).getNameIdentifier(); - } - else if (el2 instanceof PsiMethod && ((PsiMethod)el2).hasTypeParameters() - ) { - typeparams = ((PsiMethod)_type2).getTypeParameters(); - el2 = ((PsiMethod)_type2).getNameIdentifier(); - } - - PsiReferenceParameterList list = null; - if (el instanceof PsiJavaCodeReferenceElement) { - list = ((PsiJavaCodeReferenceElement)el).getParameterList(); - } - - if (list != null && list.getTypeParameterElements().length > 0) { - boolean result = typeparams != null && - myMatchingVisitor.matchInAnyOrder( - list.getTypeParameterElements(), - typeparams - ); - - if (!result) return false; - el = ((PsiJavaCodeReferenceElement)el).getReferenceNameElement(); - } - else { - if (_type2 instanceof PsiTypeElement) { - type2 = ((PsiTypeElement)_type2).getType(); - - if (typeparams == null || typeparams.length == 0) { - final PsiJavaCodeReferenceElement innermostComponentReferenceElement = - ((PsiTypeElement)_type2).getInnermostComponentReferenceElement(); - if (innermostComponentReferenceElement != null) el2 = innermostComponentReferenceElement; - } - else { - el2 = _type2; - } - } - } - - final int array2Dims = (type2 != null ? type2.getArrayDimensions() : 0) + countCStyleArrayDeclarationDims(_type2); - final int arrayDims = (type1 != null ? type1.getArrayDimensions() : 0) + countCStyleArrayDeclarationDims(_type); - - if (myMatchingVisitor.getMatchContext().getPattern().isTypedVar(el)) { - final SubstitutionHandler handler = (SubstitutionHandler)myMatchingVisitor.getMatchContext().getPattern().getHandler(el); - - RegExpPredicate regExpPredicate = null; - - if (arrayDims != 0) { - if (arrayDims != array2Dims) { - return false; - } - } - else if (array2Dims != 0) { - regExpPredicate = MatchingHandler.getSimpleRegExpPredicate(handler); - - if (regExpPredicate != null) { - regExpPredicate.setNodeTextGenerator(new RegExpPredicate.NodeTextGenerator() { - public String getText(PsiElement element) { - StringBuilder builder = new StringBuilder(RegExpPredicate.getMeaningfulText(element)); - for (int i = 0; i < array2Dims; ++i) builder.append("[]"); - return builder.toString(); - } - }); - } - } - - try { - if (handler.isSubtype() || handler.isStrictSubtype()) { - return checkMatchWithingHierarchy(el2, handler, el); - } - else { - return handler.handle(el2, myMatchingVisitor.getMatchContext()); - } - } - finally { - if (regExpPredicate != null) regExpPredicate.setNodeTextGenerator(null); - } - } - - if (array2Dims != arrayDims) { - return false; - } - - if (el instanceof PsiIdentifier) { - final PsiElement parent = el.getParent(); - if (parent instanceof PsiJavaCodeReferenceElement) { - el = parent; - } - } - if (el2 instanceof PsiIdentifier) { - final PsiElement parent = el2.getParent(); - if (parent instanceof PsiJavaCodeReferenceElement) { - el2 = parent; - } - } - final String text = stripTypeParameters(el.getText()); - if (text.indexOf('.') == -1 || !(el2 instanceof PsiJavaReference)) { - return MatchUtils.compareWithNoDifferenceToPackage(text, stripTypeParameters(el2.getText())); - } - else { - PsiElement element2 = ((PsiJavaReference)el2).resolve(); - - if (element2 != null) { - return text.equals(((PsiClass)element2).getQualifiedName()); - } - else { - return MatchUtils.compareWithNoDifferenceToPackage(text, el2.getText()); - } - } - } - - private static String stripTypeParameters(String string) { - final int index = string.indexOf('<'); - if (index == -1) { - return string; - } - return string.substring(0, index); - } - - private boolean checkMatchWithingHierarchy(PsiElement el2, SubstitutionHandler handler, PsiElement context) { - boolean includeInterfaces = true; - boolean includeClasses = true; - final PsiElement contextParent = context.getParent(); - - if (contextParent instanceof PsiReferenceList) { - final PsiElement grandParentContext = contextParent.getParent(); - - if (grandParentContext instanceof PsiClass) { - final PsiClass psiClass = (PsiClass)grandParentContext; - - if (contextParent == psiClass.getExtendsList()) { - includeInterfaces = psiClass.isInterface(); - } - else if (contextParent == psiClass.getImplementsList()) { - includeClasses = false; - } - } - } - - // is type2 is (strict) subtype of type - final NodeIterator node = new HierarchyNodeIterator(el2, includeClasses, includeInterfaces); - - if (handler.isStrictSubtype()) { - node.advance(); - } - - final boolean notPredicate = handler.getPredicate() instanceof NotPredicate; - while (node.hasNext() && !handler.validate(node.current(), 0, -1, myMatchingVisitor.getMatchContext())) { - if (notPredicate) return false; - node.advance(); - } - - if (node.hasNext()) { - handler.addResult(el2, 0, -1, myMatchingVisitor.getMatchContext()); - return true; - } - else { - return false; - } - } - - @Override - public void visitConditionalExpression(final PsiConditionalExpression cond) { - final PsiConditionalExpression cond2 = (PsiConditionalExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(cond.getCondition(), cond2.getCondition()) && - myMatchingVisitor.matchSons(cond, cond2)); - } - - @Override - public void visitPolyadicExpression(PsiPolyadicExpression expression) { - PsiPolyadicExpression expr2 = (PsiPolyadicExpression)myMatchingVisitor.getElement(); - - boolean result = expression.getOperationTokenType().equals(expr2.getOperationTokenType()); - if (result) { - PsiExpression[] operands1 = expression.getOperands(); - PsiExpression[] operands2 = expr2.getOperands(); - if (operands1.length != operands2.length) { - result = false; - } - else { - for (int i = 0; i < operands1.length; i++) { - PsiExpression e1 = operands1[i]; - PsiExpression e2 = operands2[i]; - if (!myMatchingVisitor.match(e1, e2)) { - result = false; - break; - } - } - } - } - - myMatchingVisitor.setResult(result); - } - - @Override - public void visitVariable(final PsiVariable var) { - myMatchingVisitor.getMatchContext().pushResult(); - final PsiIdentifier nameIdentifier = var.getNameIdentifier(); - - boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(nameIdentifier); - boolean isTypedInitializer = var.getInitializer() != null && - myMatchingVisitor.getMatchContext().getPattern().isTypedVar(var.getInitializer()) && - var.getInitializer() instanceof PsiReferenceExpression; - final PsiVariable var2 = (PsiVariable)myMatchingVisitor.getElement(); - - try { - myMatchingVisitor.setResult((var.getName().equals(var2.getName()) || isTypedVar) && - ((var.getParent() instanceof PsiClass && ((PsiClass)var.getParent()).isInterface()) || - myMatchingVisitor.match(var.getModifierList(), var2.getModifierList()))); - if (myMatchingVisitor.getResult()) { - final PsiTypeElement typeElement1 = var.getTypeElement(); - if (typeElement1 != null) { - PsiTypeElement typeElement2 = var2.getTypeElement(); - if (typeElement2 == null) { - typeElement2 = JavaPsiFacade.getElementFactory(var2.getProject()).createTypeElement(var2.getType()); - } - myMatchingVisitor.setResult(myMatchingVisitor.match(typeElement1, typeElement2)); - } - } - - if (myMatchingVisitor.getResult()) { - // Check initializer - final PsiExpression var2Initializer = var2.getInitializer(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(var.getInitializer(), var2Initializer) || - (isTypedInitializer && - var2Initializer == null && - allowsAbsenceOfMatch(var.getInitializer()) - )); - } - - if (myMatchingVisitor.getResult() && var instanceof PsiParameter && var.getParent() instanceof PsiCatchSection) { - myMatchingVisitor.setResult(myMatchingVisitor.match( - ((PsiCatchSection)var.getParent()).getCatchBlock(), - ((PsiCatchSection)var2.getParent()).getCatchBlock() - )); - } - - if (myMatchingVisitor.getResult() && isTypedVar) { - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(nameIdentifier, var2.getNameIdentifier())); - } - } - finally { - saveOrDropResult(nameIdentifier, isTypedVar, var2.getNameIdentifier()); - } - } - - private void matchArrayDims(final PsiNewExpression new1, final PsiNewExpression new2) { - final PsiExpression[] arrayDims = new1.getArrayDimensions(); - final PsiExpression[] arrayDims2 = new2.getArrayDimensions(); - - if (arrayDims.length == arrayDims2.length && arrayDims.length != 0) { - for (int i = 0; i < arrayDims.length; ++i) { - myMatchingVisitor.setResult(myMatchingVisitor.match(arrayDims[i], arrayDims2[i])); - if (!myMatchingVisitor.getResult()) return; - } - } - else { - myMatchingVisitor.setResult((arrayDims == arrayDims2) && myMatchingVisitor.matchSons(new1.getArgumentList(), new2.getArgumentList())); - } - } - - private void saveOrDropResult(final PsiIdentifier methodNameNode, final boolean typedVar, final PsiIdentifier methodNameNode2) { - MatchResultImpl ourResult = myMatchingVisitor.getMatchContext().hasResult() ? myMatchingVisitor.getMatchContext().getResult() : null; - myMatchingVisitor.getMatchContext().popResult(); - - if (myMatchingVisitor.getResult()) { - if (typedVar) { - final SubstitutionHandler handler = - (SubstitutionHandler)myMatchingVisitor.getMatchContext().getPattern().getHandler(methodNameNode); - if (ourResult != null) ourResult.setScopeMatch(true); - handler.setNestedResult(ourResult); - myMatchingVisitor.setResult(handler.handle(methodNameNode2, myMatchingVisitor.getMatchContext())); - - if (handler.getNestedResult() != null) { // some constraint prevent from adding - handler.setNestedResult(null); - copyResults(ourResult); - } - } - else if (ourResult != null) { - copyResults(ourResult); - } - } - } - - private void matchImplicitQualifier(MatchingHandler matchingHandler, PsiElement target, MatchContext context) { - if (!(matchingHandler instanceof SubstitutionHandler)) { - myMatchingVisitor.setResult(false); - return; - } - final SubstitutionHandler substitutionHandler = (SubstitutionHandler)matchingHandler; - final MatchPredicate predicate = substitutionHandler.getPredicate(); - if (substitutionHandler.getMinOccurs() != 0) { - myMatchingVisitor.setResult(false); - return; - } - if (predicate == null) { - myMatchingVisitor.setResult(true); - return; - } - if (target == null) { - myMatchingVisitor.setResult(false); - return; - } - if (target instanceof PsiModifierListOwner && ((PsiModifierListOwner)target).hasModifierProperty(PsiModifier.STATIC)) { - myMatchingVisitor.setResult(predicate.match(null, PsiTreeUtil.getParentOfType(target, PsiClass.class), context)); - } else { - final PsiElementFactory factory = JavaPsiFacade.getElementFactory(target.getProject()); - final PsiExpression implicitReference = factory.createExpressionFromText("this", target); - myMatchingVisitor.setResult(predicate.match(null, implicitReference, context)); - } - } - - @Override - public void visitMethodCallExpression(final PsiMethodCallExpression mcall) { - final PsiElement element = myMatchingVisitor.getElement(); - if (!(element instanceof PsiMethodCallExpression)) { - myMatchingVisitor.setResult(false); - return; - } - final PsiMethodCallExpression mcall2 = (PsiMethodCallExpression)element; - final PsiReferenceExpression mcallRef1 = mcall.getMethodExpression(); - final PsiReferenceExpression mcallRef2 = mcall2.getMethodExpression(); - - final String mcallname1 = mcallRef1.getReferenceName(); - final String mcallname2 = mcallRef2.getReferenceName(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(mcallRef1.getReferenceNameElement()); - - if (mcallname1 != null && !mcallname1.equals(mcallname2) && !isTypedVar) { - myMatchingVisitor.setResult(false); - return; - } - - final PsiExpression qualifier = mcallRef1.getQualifierExpression(); - final PsiExpression elementQualifier = mcallRef2.getQualifierExpression(); - if (qualifier != null) { - - if (elementQualifier != null) { - myMatchingVisitor.setResult(myMatchingVisitor.match(qualifier, elementQualifier)); - if (!myMatchingVisitor.getResult()) return; - } - else { - final PsiMethod method = mcall2.resolveMethod(); - if (method != null) { - if (qualifier instanceof PsiThisExpression) { - myMatchingVisitor.setResult(!method.hasModifierProperty(PsiModifier.STATIC)); - return; - } - } - final MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(qualifier); - matchImplicitQualifier(handler, method, myMatchingVisitor.getMatchContext()); - if (!myMatchingVisitor.getResult()) { - return; - } - } - } - else if (elementQualifier != null) { - myMatchingVisitor.setResult(false); - return; - } - - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(mcall.getArgumentList(), mcall2.getArgumentList())); - - if (myMatchingVisitor.getResult() && isTypedVar) { - boolean res = myMatchingVisitor.getResult(); - res &= myMatchingVisitor.handleTypedElement(mcallRef1.getReferenceNameElement(), mcallRef2.getReferenceNameElement()); - myMatchingVisitor.setResult(res); - } - } - - @Override - public void visitExpressionStatement(final PsiExpressionStatement expr) { - final PsiExpressionStatement expr2 = (PsiExpressionStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(expr.getExpression(), expr2.getExpression())); - } - - @Override - public void visitLiteralExpression(final PsiLiteralExpression const1) { - final PsiLiteralExpression const2 = (PsiLiteralExpression)myMatchingVisitor.getElement(); - - MatchingHandler handler = (MatchingHandler)const1.getUserData(CompiledPattern.HANDLER_KEY); - - if (handler instanceof SubstitutionHandler) { - int offset = 0; - int length = const2.getTextLength(); - final String text = const2.getText(); - - if (length > 2 && text.charAt(0) == '"' && text.charAt(length - 1) == '"') { - length--; - offset++; - } - myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(const2, offset, length, myMatchingVisitor.getMatchContext())); - } - else if (handler != null) { - myMatchingVisitor.setResult(handler.match(const1, const2, myMatchingVisitor.getMatchContext())); - } - else { - myMatchingVisitor.setResult(const1.textMatches(const2)); - } - } - - @Override - public void visitAssignmentExpression(final PsiAssignmentExpression assign) { - final PsiAssignmentExpression assign2 = (PsiAssignmentExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(assign.getOperationTokenType().equals(assign2.getOperationTokenType()) && - myMatchingVisitor.match(assign.getLExpression(), assign2.getLExpression()) && - myMatchingVisitor.match(assign.getRExpression(), assign2.getRExpression())); - } - - @Override - public void visitIfStatement(final PsiIfStatement if1) { - final PsiIfStatement if2 = (PsiIfStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(if1.getCondition(), if2.getCondition()) && - compareBody(if1.getThenBranch(), if2.getThenBranch()) && - compareBody(if1.getElseBranch(), if2.getElseBranch())); - } - - @Override - public void visitSwitchStatement(final PsiSwitchStatement switch1) { - final PsiSwitchStatement switch2 = (PsiSwitchStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(switch1.getExpression(), switch2.getExpression()) && - myMatchingVisitor.matchSons(switch1.getBody(), switch2.getBody())); - } - - @Override - public void visitForStatement(final PsiForStatement for1) { - final PsiForStatement for2 = (PsiForStatement)myMatchingVisitor.getElement(); - - final PsiStatement initialization = for1.getInitialization(); - MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(initialization); - - myMatchingVisitor.setResult(handler.match(initialization, for2.getInitialization(), myMatchingVisitor.getMatchContext()) && - myMatchingVisitor.match(for1.getCondition(), for2.getCondition()) && - myMatchingVisitor.match(for1.getUpdate(), for2.getUpdate()) && - compareBody(for1.getBody(), for2.getBody())); - } - - @Override - public void visitForeachStatement(PsiForeachStatement for1) { - final PsiForeachStatement for2 = (PsiForeachStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(for1.getIterationParameter(), for2.getIterationParameter()) && - myMatchingVisitor.match(for1.getIteratedValue(), for2.getIteratedValue()) && - compareBody(for1.getBody(), for2.getBody())); - } - - @Override - public void visitWhileStatement(final PsiWhileStatement while1) { - final PsiWhileStatement while2 = (PsiWhileStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(while1.getCondition(), while2.getCondition()) && - compareBody(while1.getBody(), while2.getBody())); - } - - @Override - public void visitBlockStatement(final PsiBlockStatement block) { - if (myMatchingVisitor.getElement() instanceof PsiCodeBlock && - !(myMatchingVisitor.getElement().getParent() instanceof PsiBlockStatement) - ) { - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(block.getCodeBlock(), myMatchingVisitor.getElement())); - } - else { - final PsiBlockStatement block2 = (PsiBlockStatement)myMatchingVisitor.getElement(); - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(block, block2)); - } - } - - @Override - public void visitDeclarationStatement(final PsiDeclarationStatement dcl) { - final PsiDeclarationStatement declaration = (PsiDeclarationStatement)myMatchingVisitor.getElement(); - myMatchingVisitor.setResult(myMatchingVisitor.matchInAnyOrder(dcl.getDeclaredElements(), declaration.getDeclaredElements())); - } - - @Override - public void visitDoWhileStatement(final PsiDoWhileStatement while1) { - final PsiDoWhileStatement while2 = (PsiDoWhileStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(while1.getCondition(), while2.getCondition()) && - compareBody(while1.getBody(), while2.getBody())); - } - - @Override - public void visitReturnStatement(final PsiReturnStatement return1) { - final PsiReturnStatement return2 = (PsiReturnStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(return1.getReturnValue(), return2.getReturnValue())); - } - - @Override - public void visitPostfixExpression(final PsiPostfixExpression postfix) { - final PsiPostfixExpression postfix2 = (PsiPostfixExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(postfix.getOperationTokenType().equals(postfix2.getOperationTokenType()) - && myMatchingVisitor.match(postfix.getOperand(), postfix2.getOperand())); - } - - @Override - public void visitPrefixExpression(final PsiPrefixExpression prefix) { - final PsiPrefixExpression prefix2 = (PsiPrefixExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(prefix.getOperationTokenType().equals(prefix2.getOperationTokenType()) - && myMatchingVisitor.match(prefix.getOperand(), prefix2.getOperand())); - } - - @Override - public void visitAssertStatement(final PsiAssertStatement assert1) { - final PsiAssertStatement assert2 = (PsiAssertStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(assert1.getAssertCondition(), assert2.getAssertCondition()) && - myMatchingVisitor.match(assert1.getAssertDescription(), assert2.getAssertDescription())); - } - - @Override - public void visitBreakStatement(final PsiBreakStatement break1) { - final PsiBreakStatement break2 = (PsiBreakStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(break1.getLabelIdentifier(), break2.getLabelIdentifier())); - } - - @Override - public void visitContinueStatement(final PsiContinueStatement continue1) { - final PsiContinueStatement continue2 = (PsiContinueStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(continue1.getLabelIdentifier(), continue2.getLabelIdentifier())); - } - - @Override - public void visitSuperExpression(final PsiSuperExpression super1) { - myMatchingVisitor.setResult(true); - } - - @Override - public void visitThisExpression(final PsiThisExpression this1) { - myMatchingVisitor.setResult(myMatchingVisitor.getElement() instanceof PsiThisExpression); - } - - @Override - public void visitSynchronizedStatement(final PsiSynchronizedStatement synchronized1) { - final PsiSynchronizedStatement synchronized2 = (PsiSynchronizedStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(synchronized1.getLockExpression(), synchronized2.getLockExpression()) && - myMatchingVisitor.matchSons(synchronized1.getBody(), synchronized2.getBody())); - } - - @Override - public void visitThrowStatement(final PsiThrowStatement throw1) { - final PsiThrowStatement throw2 = (PsiThrowStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(throw1.getException(), throw2.getException())); - } - - @Override - public void visitParenthesizedExpression(PsiParenthesizedExpression expr) { - if (myMatchingVisitor.getElement() instanceof PsiParenthesizedExpression) { - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(expr, myMatchingVisitor.getElement())); - } - else { - myMatchingVisitor.setResult(false); - } - } - - @Override - public void visitCatchSection(final PsiCatchSection section) { - final PsiCatchSection section2 = (PsiCatchSection)myMatchingVisitor.getElement(); - final PsiParameter parameter = section.getParameter(); - if (parameter != null) { - myMatchingVisitor.setResult(myMatchingVisitor.match(parameter, section2.getParameter())); - } - else { - myMatchingVisitor.setResult(myMatchingVisitor.match(section.getCatchBlock(), section2.getCatchBlock())); - } - } - - @Override - public void visitTryStatement(final PsiTryStatement try1) { - final PsiTryStatement try2 = (PsiTryStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(try1.getTryBlock(), try2.getTryBlock())); - - if (!myMatchingVisitor.getResult()) return; - - final PsiResourceList resourceList1 = try1.getResourceList(); - final PsiCatchSection[] catches1 = try1.getCatchSections(); - final PsiCodeBlock finally1 = try1.getFinallyBlock(); - - final PsiResourceList resourceList2 = try2.getResourceList(); - final PsiCatchSection[] catches2 = try2.getCatchSections(); - final PsiCodeBlock finally2 = try2.getFinallyBlock(); - - final boolean looseMatching = myMatchingVisitor.getMatchContext().getOptions().isLooseMatching(); - if (!looseMatching && - ((catches1.length == 0 && catches2.length != 0) || - (finally1 == null && finally2 != null) || - (resourceList1 == null && resourceList2 != null)) - ) { - myMatchingVisitor.setResult(false); - } - else { - if (resourceList1 != null) { - if (resourceList2 == null) { - myMatchingVisitor.setResult(false); - return; - } - final List<PsiResourceVariable> resourceVariables1 = resourceList1.getResourceVariables(); - final List<PsiResourceVariable> resourceVariables2 = resourceList2.getResourceVariables(); - myMatchingVisitor.setResult(myMatchingVisitor.matchInAnyOrder( - resourceVariables1.toArray(new PsiResourceVariable[resourceVariables1.size()]), - resourceVariables2.toArray(new PsiResourceVariable[resourceVariables2.size()]))); - if (!myMatchingVisitor.getResult()) return; - } - - final List<PsiCatchSection> unmatchedCatchSections = new ArrayList<PsiCatchSection>(); - - ContainerUtil.addAll(unmatchedCatchSections, catches2); - - for (int i = 0, j; i < catches1.length; ++i) { - MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(catches1[i]); - final PsiElement pinnedNode = handler.getPinnedNode(null); - - if (pinnedNode != null) { - myMatchingVisitor.setResult(handler.match(catches1[i], pinnedNode, myMatchingVisitor.getMatchContext())); - if (!myMatchingVisitor.getResult()) return; - } - else { - for (j = 0; j < unmatchedCatchSections.size(); ++j) { - if (handler.match(catches1[i], unmatchedCatchSections.get(j), myMatchingVisitor.getMatchContext())) { - unmatchedCatchSections.remove(j); - break; - } - } - - if (j == catches2.length) { - myMatchingVisitor.setResult(false); - return; - } - } - } - - if (finally1 != null) { - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(finally1, finally2)); - } - - if (myMatchingVisitor.getResult() && unmatchedCatchSections.size() > 0 && !looseMatching) { - try2.putUserData(UNMATCHED_CATCH_SECTION_CONTENT_VAR_KEY, unmatchedCatchSections); - } - } - } - - @Override - public void visitSwitchLabelStatement(final PsiSwitchLabelStatement case1) { - final PsiSwitchLabelStatement case2 = (PsiSwitchLabelStatement)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(case1.isDefaultCase() == case2.isDefaultCase() && - myMatchingVisitor.match(case1.getCaseValue(), case2.getCaseValue())); - } - - @Override - public void visitInstanceOfExpression(final PsiInstanceOfExpression instanceOf) { - final PsiInstanceOfExpression instanceOf2 = (PsiInstanceOfExpression)myMatchingVisitor.getElement(); - myMatchingVisitor.setResult(myMatchingVisitor.match(instanceOf.getOperand(), instanceOf2.getOperand()) && - matchType(instanceOf.getCheckType(), instanceOf2.getCheckType())); - } - - @Override - public void visitNewExpression(final PsiNewExpression new1) { - if (myMatchingVisitor.getElement() instanceof PsiArrayInitializerExpression && - myMatchingVisitor.getElement().getParent() instanceof PsiVariable && - new1.getArrayDimensions().length == 0 && - new1.getArrayInitializer() != null - ) { - myMatchingVisitor.setResult( - myMatchingVisitor.match(new1.getClassReference(), ((PsiVariable)myMatchingVisitor.getElement().getParent()).getTypeElement())); - myMatchingVisitor.matchSons(new1.getArrayInitializer(), myMatchingVisitor.getElement()); - return; - } - - if (!(myMatchingVisitor.getElement() instanceof PsiNewExpression)) { - myMatchingVisitor.setResult(false); - return; - } - final PsiNewExpression new2 = (PsiNewExpression)myMatchingVisitor.getElement(); - - if (new1.getClassReference() != null) { - if (new2.getClassReference() != null) { - myMatchingVisitor.setResult(myMatchingVisitor.match(new1.getClassReference(), new2.getClassReference()) && - myMatchingVisitor.matchSons(new1.getArrayInitializer(), new2.getArrayInitializer())); - - if (myMatchingVisitor.getResult()) { - // matching dims - matchArrayDims(new1, new2); - } - return; - } - else { - // match array of primitive by new 'T(); - final PsiKeyword newKeyword = PsiTreeUtil.getChildOfType(new2, PsiKeyword.class); - final PsiElement element = PsiTreeUtil.getNextSiblingOfType(newKeyword, PsiWhiteSpace.class); - - if (element != null && element.getNextSibling() instanceof PsiKeyword) { - ((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(true); - - myMatchingVisitor.setResult(myMatchingVisitor.match(new1.getClassReference(), element.getNextSibling()) && - myMatchingVisitor.matchSons(new1.getArrayInitializer(), new2.getArrayInitializer())); - - ((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(false); - if (myMatchingVisitor.getResult()) { - // matching dims - matchArrayDims(new1, new2); - } - - return; - } - } - } - - if (new1.getClassReference() == new2.getClassReference()) { - // probably anonymous class or array of primitive type - ((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(true); - myMatchingVisitor.setResult(myMatchingVisitor.matchSons(new1, new2)); - ((LexicalNodesFilter)LexicalNodesFilter.getInstance()).setCareKeyWords(false); - } - else if (new1.getAnonymousClass() == null && - new1.getClassReference() != null && - new2.getAnonymousClass() != null) { - // allow matching anonymous class without pattern - myMatchingVisitor.setResult(myMatchingVisitor.match(new1.getClassReference(), new2.getAnonymousClass().getBaseClassReference()) && - myMatchingVisitor.matchSons(new1.getArgumentList(), new2.getArgumentList())); - } - else { - myMatchingVisitor.setResult(false); - } - } - - @Override - public void visitKeyword(PsiKeyword keyword) { - myMatchingVisitor.setResult(keyword.textMatches(myMatchingVisitor.getElement())); - } - - @Override - public void visitTypeCastExpression(final PsiTypeCastExpression cast) { - final PsiTypeCastExpression cast2 = (PsiTypeCastExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(cast.getCastType(), cast2.getCastType()) && - myMatchingVisitor.match(cast.getOperand(), cast2.getOperand())); - } - - @Override - public void visitClassObjectAccessExpression(final PsiClassObjectAccessExpression expr) { - final PsiClassObjectAccessExpression expr2 = (PsiClassObjectAccessExpression)myMatchingVisitor.getElement(); - - myMatchingVisitor.setResult(myMatchingVisitor.match(expr.getOperand(), expr2.getOperand())); - } - - @Override - public void visitReferenceElement(final PsiJavaCodeReferenceElement ref) { - myMatchingVisitor.setResult(matchType(ref, myMatchingVisitor.getElement())); - } - - @Override - public void visitTypeElement(final PsiTypeElement typeElement) { - myMatchingVisitor.setResult(matchType(typeElement, myMatchingVisitor.getElement())); - } - - @Override - public void visitTypeParameter(PsiTypeParameter psiTypeParameter) { - final PsiTypeParameter parameter = (PsiTypeParameter)myMatchingVisitor.getElement(); - final PsiElement[] children = psiTypeParameter.getChildren(); - final PsiElement[] children2 = parameter.getChildren(); - - final MatchingHandler handler = myMatchingVisitor.getMatchContext().getPattern().getHandler(children[0]); - - if (handler instanceof SubstitutionHandler) { - myMatchingVisitor.setResult(((SubstitutionHandler)handler).handle(children2[0], myMatchingVisitor.getMatchContext())); - } - else { - myMatchingVisitor.setResult(children[0].textMatches(children2[0])); - } - - if (myMatchingVisitor.getResult() && children.length > 2) { - // constraint present - if (children2.length == 2) { - myMatchingVisitor.setResult(false); - return; - } - - if (!children[2].getFirstChild().textMatches(children2[2].getFirstChild())) { - // constraint type (extends) - myMatchingVisitor.setResult(false); - return; - } - myMatchingVisitor.setResult(myMatchingVisitor.matchInAnyOrder(children[2].getChildren(), children2[2].getChildren())); - } - } - - @Override - public void visitClass(PsiClass clazz) { - if (clazz.hasTypeParameters()) { - myMatchingVisitor - .setResult( - myMatchingVisitor.match(clazz.getTypeParameterList(), ((PsiClass)myMatchingVisitor.getElement()).getTypeParameterList())); - - if (!myMatchingVisitor.getResult()) return; - } - - PsiClass clazz2; - - if (myMatchingVisitor.getElement() instanceof PsiDeclarationStatement && - myMatchingVisitor.getElement().getFirstChild() instanceof PsiClass - ) { - clazz2 = (PsiClass)myMatchingVisitor.getElement().getFirstChild(); - } - else { - clazz2 = (PsiClass)myMatchingVisitor.getElement(); - } - - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(clazz.getNameIdentifier()); - - if (clazz.getModifierList().getTextLength() > 0) { - if (!myMatchingVisitor.match(clazz.getModifierList(), clazz2.getModifierList())) { - myMatchingVisitor.setResult(false); - return; - } - } - - myMatchingVisitor.setResult((clazz.getName().equals(clazz2.getName()) || isTypedVar) && - compareClasses(clazz, clazz2)); - - if (myMatchingVisitor.getResult() && isTypedVar) { - PsiElement id = clazz2.getNameIdentifier(); - if (id == null) id = clazz2; - myMatchingVisitor.setResult(myMatchingVisitor.handleTypedElement(clazz.getNameIdentifier(), id)); - } - } - - @Override - public void visitTypeParameterList(PsiTypeParameterList psiTypeParameterList) { - myMatchingVisitor.setResult(myMatchingVisitor.matchSequentially( - psiTypeParameterList.getFirstChild(), - myMatchingVisitor.getElement().getFirstChild() - )); - } - - @Override - public void visitMethod(PsiMethod method) { - final PsiIdentifier methodNameNode = method.getNameIdentifier(); - final boolean isTypedVar = myMatchingVisitor.getMatchContext().getPattern().isTypedVar(methodNameNode); - final PsiMethod method2 = (PsiMethod)myMatchingVisitor.getElement(); - - myMatchingVisitor.getMatchContext().pushResult(); - - try { - if (method.hasTypeParameters()) { - myMatchingVisitor.setResult( - myMatchingVisitor.match(method.getTypeParameterList(), ((PsiMethod)myMatchingVisitor.getElement()).getTypeParameterList())); - - if (!myMatchingVisitor.getResult()) return; - } - - if (!checkHierarchy(method2, method)) { - myMatchingVisitor.setResult(false); - return; - } - - myMatchingVisitor.setResult((method.getName().equals(method2.getName()) || isTypedVar) && - myMatchingVisitor.match(method.getModifierList(), method2.getModifierList()) && - myMatchingVisitor.matchSons(method.getParameterList(), method2.getParameterList()) && - myMatchingVisitor.match(method.getReturnTypeElement(), method2.getReturnTypeElement()) && - matchInAnyOrder(method.getThrowsList(), method2.getThrowsList(), myMatchingVisitor) && - myMatchingVisitor.matchSonsOptionally(method.getBody(), method2.getBody())); - } - finally { - final PsiIdentifier methodNameNode2 = method2.getNameIdentifier(); - - saveOrDropResult(methodNameNode, isTypedVar, methodNameNode2); - } - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/compiler/JavaCompilingVisitor.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/compiler/JavaCompilingVisitor.java deleted file mode 100644 index 271f1c468b0b..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/compiler/JavaCompilingVisitor.java +++ /dev/null @@ -1,589 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.psi.*; -import com.intellij.psi.javadoc.PsiDocComment; -import com.intellij.psi.javadoc.PsiDocTag; -import com.intellij.psi.search.*; -import com.intellij.psi.search.searches.ClassInheritorsSearch; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.MatchVariableConstraint; -import com.intellij.structuralsearch.SSRBundle; -import com.intellij.structuralsearch.UnsupportedPatternException; -import com.intellij.structuralsearch.impl.matcher.CompiledPattern; -import com.intellij.structuralsearch.impl.matcher.JavaCompiledPattern; -import com.intellij.structuralsearch.impl.matcher.filters.*; -import com.intellij.structuralsearch.impl.matcher.handlers.*; -import com.intellij.structuralsearch.impl.matcher.iterators.DocValuesIterator; -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.structuralsearch.impl.matcher.predicates.RegExpPredicate; -import com.intellij.structuralsearch.impl.matcher.strategies.*; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author Eugene.Kudelevsky - */ -public class JavaCompilingVisitor extends JavaRecursiveElementWalkingVisitor { - private final GlobalCompilingVisitor myCompilingVisitor; - - @NonNls private static final String COMMENT = "\\s*(__\\$_\\w+)\\s*"; - private static final Pattern ourPattern = Pattern.compile("//" + COMMENT, Pattern.DOTALL); - private static final Pattern ourPattern2 = Pattern.compile("/\\*" + COMMENT + "\\*/", Pattern.DOTALL); - private static final Pattern ourPattern3 = Pattern.compile("/\\*\\*" + COMMENT + "\\*/", Pattern.DOTALL); - - public JavaCompilingVisitor(GlobalCompilingVisitor compilingVisitor) { - this.myCompilingVisitor = compilingVisitor; - } - - @Override - public void visitDocTag(PsiDocTag psiDocTag) { - super.visitDocTag(psiDocTag); - - NodeIterator sons = new DocValuesIterator(psiDocTag.getFirstChild()); - while (sons.hasNext()) { - myCompilingVisitor.setHandler(sons.current(), new DocDataHandler()); - sons.advance(); - } - } - - @Override - public void visitComment(PsiComment comment) { - super.visitComment(comment); - - final String text = comment.getText(); - Matcher matcher = ourPattern.matcher(text); - boolean matches = false; - if (!matcher.matches()) { - matcher = ourPattern2.matcher(text); - - if (!matcher.matches()) { - matcher = ourPattern3.matcher(text); - } - else { - matches = true; - } - } - else { - matches = true; - } - - if (matches || matcher.matches()) { - String str = matcher.group(1); - comment.putUserData(CompiledPattern.HANDLER_KEY, str); - - GlobalCompilingVisitor.setFilter( - myCompilingVisitor.getContext().getPattern().getHandler(comment), - CommentFilter.getInstance() - ); - - SubstitutionHandler handler = (SubstitutionHandler)myCompilingVisitor.getContext().getPattern().getHandler(str); - - if (handler.getPredicate() != null) { - ((RegExpPredicate)handler.getPredicate()).setMultiline(true); - } - - RegExpPredicate predicate = MatchingHandler.getSimpleRegExpPredicate(handler); - if (GlobalCompilingVisitor.isSuitablePredicate(predicate, handler)) { - myCompilingVisitor.processTokenizedName(predicate.getRegExp(), true, GlobalCompilingVisitor.OccurenceKind.COMMENT); - } - - matches = true; - } - - if (!matches) { - MatchingHandler handler = myCompilingVisitor.processPatternStringWithFragments(text, GlobalCompilingVisitor.OccurenceKind.COMMENT); - if (handler != null) comment.putUserData(CompiledPattern.HANDLER_KEY, handler); - } - } - - @Override - public void visitLiteralExpression(PsiLiteralExpression expression) { - String value = expression.getText(); - - if (value.length() > 2 && value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { - @Nullable MatchingHandler handler = - myCompilingVisitor.processPatternStringWithFragments(value, GlobalCompilingVisitor.OccurenceKind.LITERAL); - - if (handler != null) { - expression.putUserData(CompiledPattern.HANDLER_KEY, handler); - } - } - super.visitLiteralExpression(expression); - } - - @Override - public void visitClassInitializer(final PsiClassInitializer initializer) { - super.visitClassInitializer(initializer); - PsiStatement[] psiStatements = initializer.getBody().getStatements(); - if (psiStatements.length == 1 && psiStatements[0] instanceof PsiExpressionStatement) { - MatchingHandler handler = myCompilingVisitor.getContext().getPattern().getHandler(psiStatements[0]); - - if (handler instanceof SubstitutionHandler) { - myCompilingVisitor.getContext().getPattern().setHandler(initializer, new SubstitutionHandler((SubstitutionHandler)handler)); - } - } - } - - @Override - public void visitField(PsiField psiField) { - super.visitField(psiField); - CompiledPattern pattern = myCompilingVisitor.getContext().getPattern(); - final MatchingHandler handler = pattern.getHandler(psiField); - - if (needsSupers(psiField, handler)) { - assert pattern instanceof JavaCompiledPattern; - ((JavaCompiledPattern)pattern).setRequestsSuperFields(true); - } - } - - @Override - public void visitMethod(PsiMethod psiMethod) { - super.visitMethod(psiMethod); - CompiledPattern pattern = myCompilingVisitor.getContext().getPattern(); - final MatchingHandler handler = pattern.getHandler(psiMethod); - - if (needsSupers(psiMethod, handler)) { - assert pattern instanceof JavaCompiledPattern; - ((JavaCompiledPattern)pattern).setRequestsSuperMethods(true); - } - - GlobalCompilingVisitor.setFilter(handler, MethodFilter.getInstance()); - handleReferenceText(psiMethod.getName(), myCompilingVisitor.getContext()); - } - - @Override - public void visitReferenceExpression(PsiReferenceExpression reference) { - visitElement(reference); - - boolean typedVarProcessed = false; - final PsiElement referenceParent = reference.getParent(); - - if ((myCompilingVisitor.getContext().getPattern().isRealTypedVar(reference)) && - reference.getQualifierExpression() == null && - !(referenceParent instanceof PsiExpressionStatement) - ) { - // typed var for expression (but not top level) - MatchingHandler handler = myCompilingVisitor.getContext().getPattern().getHandler(reference); - GlobalCompilingVisitor.setFilter(handler, ExpressionFilter.getInstance()); - typedVarProcessed = true; - } - - if (!(referenceParent instanceof PsiMethodCallExpression)) { - handleReference(reference); - } - - MatchingHandler handler = myCompilingVisitor.getContext().getPattern().getHandler(reference); - - // We want to merge qname related to class to find it in any form - final String referencedName = reference.getReferenceName(); - - if (!typedVarProcessed && - !(handler instanceof SubstitutionHandler)) { - final PsiElement resolve = reference.resolve(); - - PsiElement referenceQualifier = reference.getQualifier(); - if (resolve instanceof PsiClass || - (resolve == null && - ((referencedName != null && Character.isUpperCase(referencedName.charAt(0))) || - referenceQualifier == null - ) - ) - ) { - boolean hasNoNestedSubstitutionHandlers = false; - PsiExpression qualifier; - PsiReferenceExpression currentReference = reference; - - while ((qualifier = currentReference.getQualifierExpression()) != null) { - if (!(qualifier instanceof PsiReferenceExpression) || - myCompilingVisitor.getContext().getPattern().getHandler(qualifier) instanceof SubstitutionHandler - ) { - hasNoNestedSubstitutionHandlers = true; - break; - } - currentReference = (PsiReferenceExpression)qualifier; - } - if (!hasNoNestedSubstitutionHandlers) { - createAndSetSubstitutionHandlerFromReference( - reference, - resolve != null ? ((PsiClass)resolve).getQualifiedName() : reference.getText(), - referenceParent instanceof PsiExpression - ); - } - } - else if (referenceQualifier != null && reference.getParent() instanceof PsiExpressionStatement) { - //Handler qualifierHandler = context.pattern.getHandler(referenceQualifier); - //if (qualifierHandler instanceof SubstitutionHandler && - // !context.pattern.isRealTypedVar(reference) - // ) { - // createAndSetSubstitutionHandlerFromReference(reference, referencedName); - // - // SubstitutionHandler substitutionHandler = (SubstitutionHandler)qualifierHandler; - // RegExpPredicate expPredicate = Handler.getSimpleRegExpPredicate(substitutionHandler); - // //if (expPredicate != null) - // // substitutionHandler.setPredicate(new ExprTypePredicate(expPredicate.getRegExp(), null, true, true, false)); - //} - } - } - } - - @Override - public void visitMethodCallExpression(PsiMethodCallExpression expression) { - handleReference(expression.getMethodExpression()); - super.visitMethodCallExpression(expression); - } - - @Override - public void visitBlockStatement(PsiBlockStatement psiBlockStatement) { - super.visitBlockStatement(psiBlockStatement); - myCompilingVisitor.getContext().getPattern().getHandler(psiBlockStatement).setFilter(BlockFilter.getInstance()); - } - - @Override - public void visitVariable(PsiVariable psiVariable) { - super.visitVariable(psiVariable); - myCompilingVisitor.getContext().getPattern().getHandler(psiVariable).setFilter(VariableFilter.getInstance()); - handleReferenceText(psiVariable.getName(), myCompilingVisitor.getContext()); - } - - @Override - public void visitDeclarationStatement(PsiDeclarationStatement psiDeclarationStatement) { - super.visitDeclarationStatement(psiDeclarationStatement); - - if (psiDeclarationStatement.getFirstChild() instanceof PsiTypeElement) { - // search for expression or symbol - final PsiJavaCodeReferenceElement reference = - ((PsiTypeElement)psiDeclarationStatement.getFirstChild()).getInnermostComponentReferenceElement(); - - if (reference != null && - (myCompilingVisitor.getContext().getPattern().isRealTypedVar(reference.getReferenceNameElement())) && - reference.getParameterList().getTypeParameterElements().length > 0 - ) { - myCompilingVisitor.setHandler(psiDeclarationStatement, new TypedSymbolHandler()); - final MatchingHandler handler = myCompilingVisitor.getContext().getPattern().getHandler(psiDeclarationStatement); - // typed symbol - handler.setFilter( - TypedSymbolNodeFilter.getInstance() - ); - - final PsiTypeElement[] params = reference.getParameterList().getTypeParameterElements(); - for (PsiTypeElement param : params) { - if (param.getInnermostComponentReferenceElement() != null && - (myCompilingVisitor.getContext().getPattern().isRealTypedVar( - param.getInnermostComponentReferenceElement().getReferenceNameElement())) - ) { - myCompilingVisitor.getContext().getPattern().getHandler(param).setFilter( - TypeParameterFilter.getInstance() - ); - } - } - - return; - } - } - - final MatchingHandler handler = new DeclarationStatementHandler(); - myCompilingVisitor.getContext().getPattern().setHandler(psiDeclarationStatement, handler); - PsiElement previousNonWhiteSpace = psiDeclarationStatement.getPrevSibling(); - - while (previousNonWhiteSpace instanceof PsiWhiteSpace) { - previousNonWhiteSpace = previousNonWhiteSpace.getPrevSibling(); - } - - if (previousNonWhiteSpace instanceof PsiComment) { - ((DeclarationStatementHandler)handler) - .setCommentHandler(myCompilingVisitor.getContext().getPattern().getHandler(previousNonWhiteSpace)); - - myCompilingVisitor.getContext().getPattern().setHandler( - previousNonWhiteSpace, - handler - ); - } - - // detect typed symbol, it will have no variable - handler.setFilter(DeclarationFilter.getInstance()); - } - - @Override - public void visitDocComment(PsiDocComment psiDocComment) { - super.visitDocComment(psiDocComment); - myCompilingVisitor.getContext().getPattern().getHandler(psiDocComment).setFilter(JavaDocFilter.getInstance()); - } - - @Override - public void visitReferenceElement(PsiJavaCodeReferenceElement reference) { - super.visitReferenceElement(reference); - - if (reference.getParent() != null && - reference.getParent().getParent() instanceof PsiClass) { - GlobalCompilingVisitor.setFilter(myCompilingVisitor.getContext().getPattern().getHandler(reference), TypeFilter.getInstance()); - } - - handleReference(reference); - } - - @Override - public void visitClass(PsiClass psiClass) { - super.visitClass(psiClass); - - CompiledPattern pattern = myCompilingVisitor.getContext().getPattern(); - final MatchingHandler handler = pattern.getHandler(psiClass); - - if (needsSupers(psiClass, handler)) { - ((JavaCompiledPattern)pattern).setRequestsSuperInners(true); - } - handleReferenceText(psiClass.getName(), myCompilingVisitor.getContext()); - - GlobalCompilingVisitor.setFilter(handler, ClassFilter.getInstance()); - - boolean hasSubstitutionHandler = false; - for (PsiElement element = psiClass.getFirstChild(); element != null; element = element.getNextSibling()) { - if (element instanceof PsiTypeElement && element.getNextSibling() instanceof PsiErrorElement) { - // found match that - MatchingHandler unmatchedSubstitutionHandler = pattern.getHandler(element); - if (unmatchedSubstitutionHandler != null) { - psiClass.putUserData(JavaCompiledPattern.ALL_CLASS_CONTENT_VAR_NAME_KEY, pattern.getTypedVarString(element)); - hasSubstitutionHandler = true; - } - } - } - - if (!hasSubstitutionHandler) { - String name = CompiledPattern.ALL_CLASS_UNMATCHED_CONTENT_VAR_ARTIFICIAL_NAME; - psiClass.putUserData(JavaCompiledPattern.ALL_CLASS_CONTENT_VAR_NAME_KEY, name); - MatchOptions options = myCompilingVisitor.getContext().getOptions(); - if (options.getVariableConstraint(name) == null) { - pattern.createSubstitutionHandler(name, name, false, 0, Integer.MAX_VALUE, true); - MatchVariableConstraint constraint = new MatchVariableConstraint(true); - constraint.setName(name); - constraint.setMinCount(0); - constraint.setMaxCount(Integer.MAX_VALUE); - options.addVariableConstraint(constraint); - } - } - } - - private SubstitutionHandler createAndSetSubstitutionHandlerFromReference(final PsiElement expr, final String referenceText, - boolean classQualifier) { - final SubstitutionHandler substitutionHandler = - new SubstitutionHandler("__" + referenceText.replace('.', '_'), false, classQualifier ? 0 : 1, 1, false); - substitutionHandler.setPredicate(new RegExpPredicate(referenceText.replaceAll("\\.", "\\\\."), true, null, false, false)); - myCompilingVisitor.getContext().getPattern().setHandler(expr, substitutionHandler); - return substitutionHandler; - } - - @Override - public void visitExpressionStatement(PsiExpressionStatement expr) { - myCompilingVisitor.handle(expr); - - super.visitExpressionStatement(expr); - - final PsiElement child = expr.getLastChild(); - if (!(child instanceof PsiJavaToken) && !(child instanceof PsiComment)) { - // search for expression or symbol - final PsiElement reference = expr.getFirstChild(); - MatchingHandler referenceHandler = myCompilingVisitor.getContext().getPattern().getHandler(reference); - - if (referenceHandler instanceof SubstitutionHandler && - (reference instanceof PsiReferenceExpression) - ) { - // symbol - myCompilingVisitor.getContext().getPattern().setHandler(expr, referenceHandler); - referenceHandler.setFilter( - SymbolNodeFilter.getInstance() - ); - - myCompilingVisitor.setHandler(expr, new SymbolHandler((SubstitutionHandler)referenceHandler)); - } - else if (reference instanceof PsiLiteralExpression) { - MatchingHandler handler = new ExpressionHandler(); - myCompilingVisitor.setHandler(expr, handler); - handler.setFilter(ConstantFilter.getInstance()); - } - else { - // just expression - MatchingHandler handler; - myCompilingVisitor.setHandler(expr, handler = new ExpressionHandler()); - - handler.setFilter(ExpressionFilter.getInstance()); - } - } - else if (expr.getExpression() instanceof PsiReferenceExpression && - (myCompilingVisitor.getContext().getPattern().isRealTypedVar(expr.getExpression()))) { - // search for statement - final MatchingHandler exprHandler = myCompilingVisitor.getContext().getPattern().getHandler(expr); - if (exprHandler instanceof SubstitutionHandler) { - SubstitutionHandler handler = (SubstitutionHandler)exprHandler; - handler.setFilter(new StatementFilter()); - handler.setMatchHandler(new StatementHandler()); - } - } - } - - @Override - public void visitElement(PsiElement element) { - myCompilingVisitor.handle(element); - super.visitElement(element); - } - - - private void handleReference(PsiJavaCodeReferenceElement reference) { - handleReferenceText(reference.getReferenceName(), myCompilingVisitor.getContext()); - } - - private static void handleReferenceText(String refname, CompileContext compileContext) { - if (refname == null) return; - - if (compileContext.getPattern().isTypedVar(refname)) { - SubstitutionHandler handler = (SubstitutionHandler)compileContext.getPattern().getHandler(refname); - RegExpPredicate predicate = MatchingHandler.getSimpleRegExpPredicate(handler); - if (!GlobalCompilingVisitor.isSuitablePredicate(predicate, handler)) { - return; - } - - refname = predicate.getRegExp(); - - if (handler.isStrictSubtype() || handler.isSubtype()) { - final OptimizingSearchHelper searchHelper = compileContext.getSearchHelper(); - if (addDescendantsOf(refname, handler.isSubtype(), searchHelper, compileContext)) { - searchHelper.endTransaction(); - } - - return; - } - } - - GlobalCompilingVisitor.addFilesToSearchForGivenWord(refname, true, GlobalCompilingVisitor.OccurenceKind.CODE, compileContext); - } - - - public static boolean addDescendantsOf(final String refname, final boolean subtype, OptimizingSearchHelper searchHelper, CompileContext context) { - final List<PsiClass> classes = buildDescendants(refname, subtype, searchHelper, context); - - for (final PsiClass aClass : classes) { - if (aClass instanceof PsiAnonymousClass) { - searchHelper.addWordToSearchInCode(((PsiAnonymousClass)aClass).getBaseClassReference().getReferenceName()); - } - else { - searchHelper.addWordToSearchInCode(aClass.getName()); - } - } - - return classes.size() > 0; - } - - private static List<PsiClass> buildDescendants(String className, - boolean includeSelf, - OptimizingSearchHelper searchHelper, - CompileContext context) { - if (!searchHelper.doOptimizing()) return Collections.emptyList(); - final SearchScope scope = context.getOptions().getScope(); - if (!(scope instanceof GlobalSearchScope)) return Collections.emptyList(); - - final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(context.getProject()); - final PsiClass[] classes = cache.getClassesByName(className, (GlobalSearchScope)scope); - final List<PsiClass> results = new ArrayList<PsiClass>(); - - final PsiElementProcessor<PsiClass> processor = new PsiElementProcessor<PsiClass>() { - public boolean execute(@NotNull PsiClass element) { - results.add(element); - return true; - } - - }; - - for (PsiClass aClass : classes) { - ClassInheritorsSearch.search(aClass, scope, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor)); - } - - if (includeSelf) { - Collections.addAll(results, classes); - } - - return results; - } - - - @Override - public void visitCodeBlock(PsiCodeBlock block) { - myCompilingVisitor.setCodeBlockLevel(myCompilingVisitor.getCodeBlockLevel() + 1); - MatchingStrategy strategy = null; - - for (PsiElement el = block.getFirstChild(); el != null; el = el.getNextSibling()) { - if (GlobalCompilingVisitor.getFilter().accepts(el)) { - if (el instanceof PsiWhiteSpace) { - myCompilingVisitor.addLexicalNode(el); - } - } - else { - el.accept(this); - if (myCompilingVisitor.getCodeBlockLevel() == 1) { - MatchingStrategy newstrategy = findStrategy(el); - final MatchingHandler matchingHandler = myCompilingVisitor.getContext().getPattern().getHandler(el); - myCompilingVisitor.getContext().getPattern().setHandler(el, new TopLevelMatchingHandler(matchingHandler)); - - if (strategy == null || (strategy instanceof JavaDocMatchingStrategy)) { - strategy = newstrategy; - } - else { - if (strategy.getClass() != newstrategy.getClass()) { - if (!(strategy instanceof CommentMatchingStrategy)) { - throw new UnsupportedPatternException(SSRBundle.message("different.strategies.for.top.level.nodes.error.message")); - } - strategy = newstrategy; - } - } - } - } - } - - if (myCompilingVisitor.getCodeBlockLevel() == 1) { - if (strategy == null) { - // this should happen only for error patterns - strategy = ExprMatchingStrategy.getInstance(); - } - myCompilingVisitor.getContext().getPattern().setStrategy(strategy); - } - myCompilingVisitor.setCodeBlockLevel(myCompilingVisitor.getCodeBlockLevel() - 1); - } - - private MatchingStrategy findStrategy(PsiElement el) { - // identify matching strategy - final MatchingHandler handler = myCompilingVisitor.getContext().getPattern().getHandler(el); - - //if (handler instanceof SubstitutionHandler) { - // final SubstitutionHandler shandler = (SubstitutionHandler) handler; - if (handler.getFilter() instanceof SymbolNodeFilter || - handler.getFilter() instanceof TypedSymbolNodeFilter - ) { - return SymbolMatchingStrategy.getInstance(); - } - //} - - if (el instanceof PsiDocComment) { - return JavaDocMatchingStrategy.getInstance(); - } - else if (el instanceof PsiComment) { - return CommentMatchingStrategy.getInstance(); - } - - return ExprMatchingStrategy.getInstance(); - } - - private static boolean needsSupers(final PsiElement element, final MatchingHandler handler) { - if (element.getParent() instanceof PsiClass && - handler instanceof SubstitutionHandler - ) { - final SubstitutionHandler handler2 = (SubstitutionHandler)handler; - - return (handler2.isStrictSubtype() || handler2.isSubtype()); - } - return false; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/BlockFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/BlockFilter.java deleted file mode 100644 index 5cef7ffaf3c8..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/BlockFilter.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiBlockStatement; -import com.intellij.psi.PsiCodeBlock; -import com.intellij.psi.PsiElement; - -/** - * Filters block related nodes - */ -public class BlockFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } - - @Override - public void visitBlockStatement(PsiBlockStatement psiBlockStatement) { - result = true; - } - - @Override - public void visitCodeBlock(PsiCodeBlock psiCodeBlock) { - result = true; - } - - private BlockFilter() { - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new BlockFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ClassFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ClassFilter.java deleted file mode 100644 index 6e68b08d70da..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ClassFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiAnonymousClass; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 26.12.2003 - * Time: 19:37:13 - * To change this template use Options | File Templates. - */ -public class ClassFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitAnonymousClass(PsiAnonymousClass psiAnonymousClass) { - result = true; - } - - @Override public void visitClass(PsiClass psiClass) { - result = true; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new ClassFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private ClassFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/CommentFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/CommentFilter.java deleted file mode 100644 index c2d974c9754e..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/CommentFilter.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Apr 22, 2004 - * Time: 9:13:12 PM - * To change this template use File | Settings | File Templates. - */ -public class CommentFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitComment(PsiComment comment) { - result = true; - } - - @Override public void visitField(PsiField field) { - result = true; - } - - @Override public void visitMethod(PsiMethod method) { - result = true; - } - - @Override public void visitClass(PsiClass clazz) { - result = true; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new CommentFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private CommentFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ConstantFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ConstantFilter.java deleted file mode 100644 index 401e3c15e365..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ConstantFilter.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiLiteralExpression; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Apr 27, 2004 - * Time: 7:55:40 PM - * To change this template use File | Settings | File Templates. - */ -public class ConstantFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitLiteralExpression(PsiLiteralExpression psiLiteral) { - result = true; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new ConstantFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private ConstantFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/DeclarationFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/DeclarationFilter.java deleted file mode 100644 index d5f5ef5bf36e..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/DeclarationFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 26.12.2003 - * Time: 19:23:24 - * To change this template use Options | File Templates. - */ -public class DeclarationFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitDeclarationStatement(PsiDeclarationStatement dcl) { - result = true; - } - - @Override public void visitVariable(PsiVariable psiVar) { - result = true; - } - - @Override public void visitClass(PsiClass psiClass) { - result = true; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new DeclarationFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private DeclarationFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ExpressionFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ExpressionFilter.java deleted file mode 100644 index 632cc403eabb..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/ExpressionFilter.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiExpression; -import com.intellij.psi.PsiReferenceExpression; - -/** - * Filters expression nodes - */ -public class ExpressionFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitReferenceExpression(PsiReferenceExpression psiReferenceExpression) { - result = true; - } - - @Override public void visitExpression(PsiExpression psiExpression) { - result = true; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new ExpressionFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private ExpressionFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/JavaDocFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/JavaDocFilter.java deleted file mode 100644 index d12e9cbd0440..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/JavaDocFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.PsiDocCommentOwner; -import com.intellij.psi.PsiElement; -import com.intellij.psi.javadoc.PsiDocComment; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 26.12.2003 - * Time: 19:08:26 - * To change this template use Options | File Templates. - */ -public class JavaDocFilter implements NodeFilter { - protected boolean result; - - public boolean accepts(PsiElement element) { - return element instanceof PsiDocCommentOwner || - element instanceof PsiDocComment; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new JavaDocFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private JavaDocFilter() { - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/JavaLexicalNodesFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/JavaLexicalNodesFilter.java deleted file mode 100644 index 1c86acda3e83..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/JavaLexicalNodesFilter.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.psi.*; -import com.intellij.psi.javadoc.PsiDocComment; - -/** -* @author Eugene.Kudelevsky -*/ -public class JavaLexicalNodesFilter extends JavaElementVisitor { - private final LexicalNodesFilter myLexicalNodesFilter; - - public JavaLexicalNodesFilter(LexicalNodesFilter lexicalNodesFilter) { - this.myLexicalNodesFilter = lexicalNodesFilter; - } - - @Override public void visitJavaToken(final PsiJavaToken t) { - myLexicalNodesFilter.setResult(true); - } - - @Override public void visitComment(final PsiComment comment) { - } - - @Override public void visitDocComment(final PsiDocComment comment) { - } - - @Override public void visitKeyword(PsiKeyword keyword) { - myLexicalNodesFilter.setResult(!myLexicalNodesFilter.isCareKeyWords()); - } - - @Override public void visitWhiteSpace(final PsiWhiteSpace space) { - myLexicalNodesFilter.setResult(true); - } - - @Override public void visitErrorElement(final PsiErrorElement element) { - myLexicalNodesFilter.setResult(true); - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/MethodFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/MethodFilter.java deleted file mode 100644 index 00888bb86c5a..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/MethodFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiMethod; - -/** - * Filters method nodes - */ -public class MethodFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitMethod(PsiMethod psiMethod) { - result = true; - } - - private MethodFilter() {} - - private static class NodeFilterHolder { - private static final NodeFilter instance = new MethodFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/StatementFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/StatementFilter.java deleted file mode 100644 index 91abc96139e1..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/StatementFilter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 26.12.2003 - * Time: 17:46:10 - * To change this template use Options | File Templates. - */ -public class StatementFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitReferenceExpression(PsiReferenceExpression psiReferenceExpression) { - result = false; - } - - @Override public void visitStatement(PsiStatement psiStatement) { - result = true; - } - - @Override public void visitComment(PsiComment comment) { - result = true; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/SymbolNodeFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/SymbolNodeFilter.java deleted file mode 100644 index 3e461b6738b6..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/SymbolNodeFilter.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; - -/** - * Tree filter for searching symbols ('T) - */ -public class SymbolNodeFilter extends JavaElementVisitor implements NodeFilter { - private boolean result; - - @Override public void visitExpression(PsiExpression expr) { - result = true; - } - - @Override public void visitLiteralExpression(PsiLiteralExpression psiLiteralExpression) { - result = true; - } - - @Override public void visitReferenceExpression(PsiReferenceExpression psiReferenceExpression) { - result = true; - } - - @Override public void visitAnnotation(final PsiAnnotation annotation) { - result = true; - } - - @Override public void visitAnnotationMethod(final PsiAnnotationMethod method) { - result = true; - } - - @Override public void visitNameValuePair(final PsiNameValuePair pair) { - result = true; - } - - @Override public void visitMethod(PsiMethod psiMethod) { - result = true; - } - - @Override public void visitClass(PsiClass psiClass) { - result = true; - } - - @Override public void visitReferenceElement(PsiJavaCodeReferenceElement psiJavaCodeReferenceElement) { - result = true; - } - - @Override public void visitVariable(PsiVariable psiVar) { - result = true; - } - - @Override public void visitTypeParameter(PsiTypeParameter psiTypeParameter) { - result = true; - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new SymbolNodeFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private SymbolNodeFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypeFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypeFilter.java deleted file mode 100644 index 14dd452b0b7a..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypeFilter.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiJavaCodeReferenceElement; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 23.01.2004 - * Time: 1:07:09 - * To change this template use File | Settings | File Templates. - */ -public class TypeFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitClass(PsiClass aClass) { - result = true; - } - - @Override public void visitReferenceElement(PsiJavaCodeReferenceElement psiMethod) { - result = true; - } - - private TypeFilter() {} - - private static class NodeFilterHolder { - private static final NodeFilter instance = new TypeFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypeParameterFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypeParameterFilter.java deleted file mode 100644 index 2f81c8b3980f..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypeParameterFilter.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 03.01.2004 - * Time: 1:06:23 - * To change this template use Options | File Templates. - */ -public class TypeParameterFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - @Override public void visitTypeElement(PsiTypeElement psiTypeElement) { - result = true; - } - - @Override public void visitTypeParameter(PsiTypeParameter psiTypeParameter) { - result = true; - } - - @Override public void visitReferenceElement(PsiJavaCodeReferenceElement psiJavaCodeReferenceElement) { - result = true; - } - - private TypeParameterFilter() {} - - private static class NodeFilterHolder { - private static final NodeFilter instance = new TypeParameterFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypedSymbolNodeFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypedSymbolNodeFilter.java deleted file mode 100644 index 4416b8b7db24..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/TypedSymbolNodeFilter.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; - -/** - * Filter for typed symbols - */ -public class TypedSymbolNodeFilter extends JavaElementVisitor implements NodeFilter { - private boolean result; - - @Override public void visitMethod(PsiMethod psiMethod) { - result = psiMethod.hasTypeParameters(); - } - - @Override public void visitClass(PsiClass psiClass) { - result = psiClass.hasTypeParameters(); - } - - @Override public void visitReferenceElement(PsiJavaCodeReferenceElement psiJavaCodeReferenceElement) { - result = psiJavaCodeReferenceElement.getParameterList().getTypeParameterElements().length > 0; - } - - @Override public void visitTypeParameter(PsiTypeParameter parameter) { - // we need this since TypeParameter instanceof PsiClass (?) - } - - private static class NodeFilterHolder { - private static final NodeFilter instance = new TypedSymbolNodeFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - private TypedSymbolNodeFilter() { - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/VariableFilter.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/VariableFilter.java deleted file mode 100644 index e1907ecaf556..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/filters/VariableFilter.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.filters; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.JavaElementVisitor; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiReferenceExpression; -import com.intellij.psi.PsiVariable; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 26.12.2003 - * Time: 19:52:57 - * To change this template use Options | File Templates. - */ -public class VariableFilter extends JavaElementVisitor implements NodeFilter { - protected boolean result; - - public void visitReferenceExpression(final PsiReferenceExpression expression) { - } - - @Override public void visitVariable(PsiVariable psiVariable) { - result = true; - } - - private VariableFilter() {} - - private static class NodeFilterHolder { - private static final NodeFilter instance = new VariableFilter(); - } - - public static NodeFilter getInstance() { - return NodeFilterHolder.instance; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/DeclarationStatementHandler.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/DeclarationStatementHandler.java deleted file mode 100644 index 7342e96758f0..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/DeclarationStatementHandler.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.dupLocator.iterators.ArrayBackedNodeIterator; -import com.intellij.dupLocator.iterators.CountingNodeIterator; -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.GlobalMatchingVisitor; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.iterators.SsrFilteringNodeIterator; - -/** - * Created by IntelliJ IDEA. - * User: maxim - * Date: 31.12.2004 - * Time: 12:01:29 - * To change this template use File | Settings | File Templates. - */ -public class DeclarationStatementHandler extends MatchingHandler { - private MatchingHandler myCommentHandler; - - public boolean match(PsiElement patternNode,PsiElement matchedNode, MatchContext context) { - if (patternNode instanceof PsiComment) { - //if (matchedNode instanceof PsiComment || matchedNode instanceof PsiClass || matchedNode instanceof PsiField) - return myCommentHandler.match(patternNode, matchedNode, context); - //return false; - } - - if (!super.match(patternNode,matchedNode,context)) return false; - boolean result; - PsiDeclarationStatement dcl = (PsiDeclarationStatement)patternNode; - - if (matchedNode instanceof PsiDeclarationStatement) { - result = GlobalMatchingVisitor.continueMatchingSequentially( - new SsrFilteringNodeIterator(patternNode.getFirstChild()), - new SsrFilteringNodeIterator(matchedNode.getFirstChild()), - context - ); - } else { - final PsiElement[] declared = dcl.getDeclaredElements(); - - // declaration statement could wrap class or dcl - if (declared.length >0 && - ( ( declared[0] instanceof PsiVariable && matchedNode instanceof PsiVariable) || - ( declared[0] instanceof PsiClass && matchedNode instanceof PsiClass) - ) && - !(matchedNode.getParent() instanceof PsiDeclarationStatement) // skip twice matching for child - ) { - result = GlobalMatchingVisitor.continueMatchingSequentially( - new ArrayBackedNodeIterator(declared), - new CountingNodeIterator( - declared.length, - new SsrFilteringNodeIterator(matchedNode) - ), - context - ); - - if (result && - declared[0] instanceof PsiVariable && matchedNode instanceof PsiField - ) { - // we may have comments behind to match! - final PsiElement[] children = dcl.getChildren(); - - final PsiElement lastChild = children[children.length - 1]; - if (lastChild instanceof PsiComment) { - final PsiElement[] fieldChildren = matchedNode.getChildren(); - - result = context.getPattern().getHandler(lastChild).match( - lastChild, - fieldChildren[fieldChildren.length-1], - context - ); - } - } - } else { - result = false; - } - } - - return result; - } - - public boolean shouldAdvanceTheMatchFor(PsiElement patternElement, PsiElement matchedElement) { - if (patternElement instanceof PsiComment && - ( matchedElement instanceof PsiField || - matchedElement instanceof PsiClass - ) - ) { - return false; - } - - return super.shouldAdvanceTheMatchFor(patternElement,matchedElement); - } - - public void setCommentHandler(final MatchingHandler commentHandler) { - myCommentHandler = commentHandler; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/DocDataHandler.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/DocDataHandler.java deleted file mode 100644 index dbc97ce67f75..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/DocDataHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.JavaDocTokenType; -import com.intellij.psi.PsiElement; -import com.intellij.psi.javadoc.PsiDocTagValue; -import com.intellij.psi.javadoc.PsiDocToken; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import org.jetbrains.annotations.NonNls; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Handler for doc nodes - */ -public class DocDataHandler extends MatchingHandler { - @NonNls private static final String P_STR = "^\\s*((?:\\w|_|\\-|\\$)+)\\s*(?:=\\s*\"(.*)\"\\s*)?$"; - private static final Pattern p = Pattern.compile( - P_STR, - Pattern.CASE_INSENSITIVE - ); - - public boolean match(PsiElement node, PsiElement match, MatchContext context) { - String text1 = node.getText(); - - text1 = getTextFromNode(node, text1); - - Matcher m1 = p.matcher(text1); - - String text2 = match.getText(); - text2 = getTextFromNode(match, text2); - - Matcher m2 = p.matcher(text2); - - if (m1.matches() && m2.matches()) { - String name = m1.group(1); - String name2 = m2.group(1); - boolean isTypedName = context.getPattern().isTypedVar(name); - - if (name.equals(name2) || isTypedName) { - String value = m1.group(2); - String value2 = m2.group(2); - - if (value!=null) { - if (value2 == null || !value2.matches(value)) return false; - } - if (isTypedName) { - SubstitutionHandler handler = (SubstitutionHandler) context.getPattern().getHandler(name); - return handler.handle(match,context); - } - return true; - } - } - return text1.equals(text2); - } - - // since doctag value may be inside doc comment we specially build text including skipped nodes - private static String getTextFromNode(final PsiElement node, String text1) { - PsiElement nextSibling = node.getNextSibling(); - if (nextSibling instanceof PsiDocTagValue) { - text1 += nextSibling.getText(); - - nextSibling = nextSibling.getNextSibling(); - if (nextSibling instanceof PsiDocToken && ((PsiDocToken)nextSibling).getTokenType() == JavaDocTokenType.DOC_COMMENT_DATA) { - text1 += nextSibling.getText(); - } - } - return text1; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/ExpressionHandler.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/ExpressionHandler.java deleted file mode 100644 index 6437c148dd0d..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/ExpressionHandler.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiExpressionStatement; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * Handler for substitution expression search - */ -public class ExpressionHandler extends MatchingHandler { - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - if (!super.match(patternNode,matchedNode,context)) { - return false; - } - - return context.getMatcher().match( - ((PsiExpressionStatement)patternNode).getExpression(), - matchedNode - ); - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/StatementHandler.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/StatementHandler.java deleted file mode 100644 index c6361e2ad4e7..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/handlers/StatementHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.handlers; - -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.MatchContext; - -/** - * Handler for statement search - */ -public class StatementHandler extends MatchingHandler { - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - // filtering is done on SubstituionHandler level - if (patternNode==null) return false; - patternNode = ((PsiExpressionStatement)patternNode).getExpression(); - - /*if (matchedNode instanceof PsiExpressionStatement) { - //matchedNode = ((PsiExpressionStatement)matchedNode).getExpression(); - } else*/ if (( !(matchedNode instanceof PsiStatement) && - !(matchedNode instanceof PsiComment) // comments to be matched as statements - ) || - ( matchedNode instanceof PsiBlockStatement && - !(matchedNode.getParent() instanceof PsiBlockStatement) && - !(matchedNode.getParent().getParent() instanceof PsiSwitchStatement) - )) { - // typed statement does not match this things - // (BlockStatement could be nontop level in if, etc) - return false; - } - - return context.getMatcher().match(patternNode,matchedNode); - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/iterators/DocValuesIterator.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/iterators/DocValuesIterator.java deleted file mode 100644 index c1323abd0951..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/iterators/DocValuesIterator.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.iterators; - -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.psi.JavaDocTokenType; -import com.intellij.psi.PsiElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.javadoc.PsiDocToken; -import com.intellij.psi.javadoc.PsiDocTagValue; - -import java.util.ArrayList; - -/** - * Iterates over java doc values tag - */ -public class DocValuesIterator extends NodeIterator { - private int index; - private final ArrayList<PsiElement> tokens = new ArrayList<PsiElement>(2); - private static final IElementType tokenType = JavaDocTokenType.DOC_COMMENT_DATA; - - public DocValuesIterator(PsiElement start) { - for(PsiElement e = start; e != null; e = e.getNextSibling()) { - if (e instanceof PsiDocTagValue) tokens.add(e); - else if (e instanceof PsiDocToken && ((PsiDocToken)e).getTokenType() == tokenType) { - tokens.add(e); - e = advanceToNext(e); - } - } - } - - // since doctag value may be inside doc comment we specially skip that nodes from list - static PsiElement advanceToNext(PsiElement e) { - PsiElement nextSibling = e.getNextSibling(); - if (nextSibling instanceof PsiDocTagValue) e = nextSibling; - - nextSibling = e.getNextSibling(); - - if (nextSibling instanceof PsiDocToken && - ((PsiDocToken)nextSibling).getTokenType() == tokenType - ) { - e = nextSibling; - } - return e; - } - - public boolean hasNext() { - return index >=0 && index < tokens.size(); - } - - public PsiElement current() { - return hasNext() ? tokens.get(index) : null; - } - - public void advance() { - if (index < tokens.size()) ++ index; - } - - public void rewind() { - if (index >= 0) --index; - } - - public void reset() { - index = 0; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/iterators/HierarchyNodeIterator.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/iterators/HierarchyNodeIterator.java deleted file mode 100644 index 324528435cb6..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/iterators/HierarchyNodeIterator.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.iterators; - -import com.intellij.dupLocator.iterators.NodeIterator; -import com.intellij.psi.*; -import com.intellij.psi.impl.PsiClassImplUtil; -import com.intellij.structuralsearch.impl.matcher.MatchUtils; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; - -/** - * Passes the hierarchy - */ -public class HierarchyNodeIterator extends NodeIterator { - private int index; - private ArrayList<PsiElement> remaining; - private boolean objectTaken; - private boolean firstElementTaken; - private final boolean acceptClasses; - private final boolean acceptInterfaces; - private final boolean acceptFirstElement; - - private void build(PsiElement current, Set<PsiElement> visited) { - - if (current!=null) { - final String str = current instanceof PsiClass ? ((PsiClass)current).getName():current.getText(); - - if (MatchUtils.compareWithNoDifferenceToPackage(str,"Object")) { - if(objectTaken) return; - objectTaken = true; - } - - PsiElement element = MatchUtils.getReferencedElement(current); - - if (element instanceof PsiClass) { - if (visited.contains(element)) return; - final PsiClass clazz = (PsiClass)element; - - if (acceptInterfaces || !clazz.isInterface() ) visited.add(element); - - if (!firstElementTaken && acceptFirstElement || firstElementTaken) remaining.add(clazz); - firstElementTaken = true; - - if (clazz instanceof PsiAnonymousClass) { - build(((PsiAnonymousClass)clazz).getBaseClassReference(),visited); - return; - } - - if (acceptClasses) { - processClasses(clazz, visited); - - if (!objectTaken) { - build(PsiClassImplUtil.getSuperClass(clazz), visited); - } - } - - if (acceptInterfaces) { - final PsiReferenceList implementsList = clazz.getImplementsList(); - - if (implementsList != null) { - final PsiElement[] implementsListElements = implementsList.getReferenceElements(); - - for (PsiElement anImplementsList : implementsListElements) { - build(anImplementsList,visited); - } - } - - if (!acceptClasses) processClasses(clazz, visited); - } - } else { - remaining.add(current); - } - } - } - - private void processClasses(final PsiClass clazz, final Set<PsiElement> visited) { - final PsiReferenceList clazzExtendsList = clazz.getExtendsList(); - final PsiElement[] extendsList = (clazzExtendsList != null)?clazzExtendsList.getReferenceElements():null; - - if (extendsList != null) { - for (PsiElement anExtendsList : extendsList) { - build(anExtendsList,visited); - } - } - } - - public HierarchyNodeIterator(PsiElement reference, boolean acceptClasses, boolean acceptInterfaces) { - this(reference, acceptClasses, acceptInterfaces, true); - } - - public HierarchyNodeIterator(PsiElement reference, boolean acceptClasses, boolean acceptInterfaces, boolean acceptFirstElement) { - remaining = new ArrayList<PsiElement>(); - this.acceptClasses = acceptClasses; - this.acceptInterfaces = acceptInterfaces; - this.acceptFirstElement = acceptFirstElement; - - if (reference instanceof PsiIdentifier) { - reference = reference.getParent(); - } - - build(reference,new HashSet<PsiElement>()); - } - - public boolean hasNext() { - return index < remaining.size(); - } - - public PsiElement current() { - return remaining.get(index); - } - - public void advance() { - if (index!=remaining.size()) { - ++index; - } - } - - public void rewind() { - if (index > 0) { - --index; - } - } - - public void reset() { - index = 0; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/ExprTypePredicate.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/ExprTypePredicate.java deleted file mode 100644 index d66db76c272d..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/ExprTypePredicate.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.impl.matcher.iterators.HierarchyNodeIterator; -import com.intellij.dupLocator.iterators.NodeIterator; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 23, 2004 - * Time: 6:37:15 PM - * To change this template use File | Settings | File Templates. - */ -public class ExprTypePredicate extends MatchPredicate { - private final RegExpPredicate delegate; - private final boolean withinHierarchy; - - public ExprTypePredicate(String type, String baseName, boolean _withinHierarchy, boolean caseSensitiveMatch,boolean target) { - delegate = new RegExpPredicate(type,caseSensitiveMatch,baseName,false,target); - withinHierarchy = _withinHierarchy; - } - - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - return match(patternNode, matchedNode, 0, -1, context); - } - - public boolean match(PsiElement node, PsiElement match, int start, int end, MatchContext context) { - if (match instanceof PsiIdentifier) { - // since we pickup tokens - match = match.getParent(); - } - - if (match instanceof PsiExpression) { - final PsiType type = evalType((PsiExpression)match,context); - if (type==null) return false; - - return doMatchWithTheType(type, context, match); - } else { - return false; - } - } - - protected PsiType evalType(PsiExpression match, MatchContext context) { - PsiType type = null; - - if (match instanceof PsiReferenceExpression && - match.getParent() instanceof PsiMethodCallExpression) { - PsiMethod method = ((PsiMethodCallExpression)match.getParent()).resolveMethod(); - if (method!=null) type = method.getReturnType(); - } - - if (type==null) type = match.getType(); - return type; - } - - private boolean doMatchWithTheType(final PsiType type, MatchContext context, PsiElement matchedNode) { - if (type instanceof PsiClassType) { - PsiClass clazz = ((PsiClassType)type).resolve(); - - if (clazz!=null) return checkClass(clazz, context); - } - - if (type!=null) { - final String presentableText = type.getPresentableText(); - boolean result = delegate.doMatch(presentableText,context, matchedNode); - - if (!result && type instanceof PsiArrayType && ((PsiArrayType)type).getComponentType() instanceof PsiClassType) { - PsiClass clazz = ((PsiClassType)((PsiArrayType)type).getComponentType()).resolve(); - - if (clazz!=null) { // presentable text for array is not qualified! - result = delegate.doMatch(clazz.getQualifiedName()+"[]",context, matchedNode); - } - } - return result; - } else { - return false; - } - } - - public boolean checkClass(PsiClass clazz, MatchContext context) { - if (withinHierarchy) { - final NodeIterator parents = new HierarchyNodeIterator(clazz,true,true); - - while(parents.hasNext() && !delegate.match(null,parents.current(),context)) { - parents.advance(); - } - - return parents.hasNext(); - } else { - return delegate.match(null,clazz,context); - } - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/FormalArgTypePredicate.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/FormalArgTypePredicate.java deleted file mode 100644 index 02f1ee7d08e0..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/FormalArgTypePredicate.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.psi.*; -import com.intellij.psi.util.PsiTreeUtil; - -/** - * Created by IntelliJ IDEA. - * User: Maxim.Mossienko - * Date: Mar 23, 2004 - * Time: 6:37:15 PM - * To change this template use File | Settings | File Templates. - */ -public class FormalArgTypePredicate extends ExprTypePredicate { - - public FormalArgTypePredicate(String type, String baseName, boolean _withinHierarchy, boolean caseSensitiveMatch,boolean target) { - super(type, baseName, _withinHierarchy, caseSensitiveMatch, target); - } - - protected PsiType evalType(PsiExpression match, MatchContext context) { - final PsiMethodCallExpression expr = PsiTreeUtil.getParentOfType(match,PsiMethodCallExpression.class); - if (expr == null) return null; - - // find our parent in parameters of the method - final PsiMethod psiMethod = expr.resolveMethod(); - if (psiMethod == null) return null; - final PsiParameter[] methodParameters = psiMethod.getParameterList().getParameters(); - final PsiExpression[] expressions = expr.getArgumentList().getExpressions(); - - for(int i = 0;i < methodParameters.length; ++i) { - if (expressions[i] == match) { - if (i < methodParameters.length) return methodParameters[i].getType(); - break; - } - } - return null; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/ReadPredicate.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/ReadPredicate.java deleted file mode 100644 index ce25b998ba9b..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/ReadPredicate.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.MatchUtils; - -/** - * Handler for value read - */ -public final class ReadPredicate extends MatchPredicate { - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - if (matchedNode instanceof PsiIdentifier) { - matchedNode = matchedNode.getParent(); - } - if (matchedNode instanceof PsiReferenceExpression && - ( !(matchedNode.getParent() instanceof PsiMethodCallExpression) && - ( !(matchedNode.getParent() instanceof PsiAssignmentExpression) || - ((PsiAssignmentExpression)matchedNode.getParent()).getLExpression() != matchedNode - ) - ) && - MatchUtils.getReferencedElement(matchedNode) instanceof PsiVariable - ) { - return true; - } - return false; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/WritePredicate.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/WritePredicate.java deleted file mode 100644 index e0d86824a920..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/predicates/WritePredicate.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.predicates; - -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.handlers.MatchPredicate; -import com.intellij.structuralsearch.impl.matcher.MatchContext; -import com.intellij.structuralsearch.impl.matcher.MatchUtils; - -/** - * Handler for reading - */ -public final class WritePredicate extends MatchPredicate { - public boolean match(PsiElement patternNode, PsiElement matchedNode, MatchContext context) { - if (matchedNode instanceof PsiIdentifier) { - matchedNode = matchedNode.getParent(); - } - if (( matchedNode instanceof PsiReferenceExpression && - matchedNode.getParent() instanceof PsiAssignmentExpression && - ((PsiAssignmentExpression)matchedNode.getParent()).getLExpression() == matchedNode && - MatchUtils.getReferencedElement(matchedNode) instanceof PsiVariable - ) || - ( - matchedNode instanceof PsiVariable && - ((PsiVariable)matchedNode).getInitializer()!=null - ) || - matchedNode.getParent() instanceof PsiPostfixExpression || - matchedNode.getParent() instanceof PsiPrefixExpression - ) { - return true; - } else { - return false; - } - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/CommentMatchingStrategy.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/CommentMatchingStrategy.java deleted file mode 100644 index 7bba3250b768..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/CommentMatchingStrategy.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.strategies; - -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiClassInitializer; -import com.intellij.psi.PsiComment; -import com.intellij.psi.PsiMethod; - -/** - * Java doc matching strategy - */ -public final class CommentMatchingStrategy extends MatchingStrategyBase { - @Override public void visitClass(final PsiClass clazz) { - result = true; - } - - @Override public void visitClassInitializer(final PsiClassInitializer clazzInit) { - result = true; - } - - @Override public void visitMethod(final PsiMethod method) { - result = true; - } - - @Override public void visitComment(final PsiComment comment) { - result = true; - } - - private CommentMatchingStrategy() {} - - private static class CommentMatchingStrategyHolder { - private static final CommentMatchingStrategy instance = new CommentMatchingStrategy(); - } - - public static MatchingStrategy getInstance() { - return CommentMatchingStrategyHolder.instance; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/ExprMatchingStrategy.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/ExprMatchingStrategy.java deleted file mode 100644 index c892badb85be..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/ExprMatchingStrategy.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.strategies; - -import com.intellij.psi.*; - -/** - * Expression matching strategy - */ -public class ExprMatchingStrategy extends MatchingStrategyBase { - @Override public void visitExpression(final PsiExpression expr) { - result = true; - } - - @Override public void visitVariable(final PsiVariable field) { - result = true; - } - - @Override public void visitClass(final PsiClass clazz) { - result = true; - } - - @Override public void visitClassInitializer(final PsiClassInitializer clazzInit) { - result = true; - } - - @Override public void visitMethod(final PsiMethod method) { - result = true; - } - - @Override public void visitExpressionList(final PsiExpressionList list) { - result = true; - } - - @Override public void visitJavaFile(final PsiJavaFile file) { - result = true; - } - - // finding parameters - @Override public void visitParameterList(final PsiParameterList list) { - result = true; - } - - protected ExprMatchingStrategy() {} - - private static class ExprMatchingStrategyHolder { - private static final ExprMatchingStrategy instance = new ExprMatchingStrategy(); - } - - public static MatchingStrategy getInstance() { - return ExprMatchingStrategyHolder.instance; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/JavaDocMatchingStrategy.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/JavaDocMatchingStrategy.java deleted file mode 100644 index b65180eff650..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/JavaDocMatchingStrategy.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.strategies; - -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiClassInitializer; -import com.intellij.psi.PsiMethod; - -/** - * Java doc matching strategy - */ -public final class JavaDocMatchingStrategy extends MatchingStrategyBase { - @Override public void visitClass(final PsiClass clazz) { - result = true; - } - - @Override public void visitClassInitializer(final PsiClassInitializer clazzInit) { - result = true; - } - - @Override public void visitMethod(final PsiMethod method) { - result = true; - } - - private JavaDocMatchingStrategy() {} - - private static class JavaDocMatchingStrategyHolder { - private static final JavaDocMatchingStrategy instance = new JavaDocMatchingStrategy(); - } - - public static MatchingStrategy getInstance() { - return JavaDocMatchingStrategyHolder.instance; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/MatchingStrategyBase.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/MatchingStrategyBase.java deleted file mode 100644 index df6e0fd46832..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/MatchingStrategyBase.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.strategies; - -import com.intellij.dupLocator.util.NodeFilter; -import com.intellij.psi.*; - -/** - * Base filtering strategy to find statements - */ -public class MatchingStrategyBase extends JavaElementVisitor implements MatchingStrategy, NodeFilter { - protected boolean result; - - @Override public void visitReferenceExpression(final PsiReferenceExpression psiReferenceExpression) { - visitExpression(psiReferenceExpression); - } - - @Override public void visitCodeBlock(final PsiCodeBlock block) { - result = true; - } - - @Override public void visitCatchSection(final PsiCatchSection section) { - result = true; - } - - @Override public void visitStatement(final PsiStatement statement) { - result = true; - } - - public boolean continueMatching(final PsiElement start) { - return accepts(start); - } - - @Override - public boolean shouldSkip(PsiElement element, PsiElement elementToMatchWith) { - return false; - } - - public boolean accepts(PsiElement element) { - result = false; - if (element!=null) element.accept(this); - return result; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/SymbolMatchingStrategy.java b/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/SymbolMatchingStrategy.java deleted file mode 100644 index f31ee37e8aed..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/src/com/intellij/structuralsearch/impl/matcher/strategies/SymbolMatchingStrategy.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.strategies; - -import com.intellij.psi.*; - -/** - * CommonStrategy to match symbols - */ -public class SymbolMatchingStrategy extends ExprMatchingStrategy { - @Override public void visitReferenceList(final PsiReferenceList list) { - result = true; - } - - @Override public void visitAnnotation(final PsiAnnotation annotation) { - result = true; - } - - @Override public void visitAnnotationParameterList(final PsiAnnotationParameterList list) { - result = true; - } - - @Override public void visitModifierList(final PsiModifierList list) { - result = true; - } - - @Override public void visitNameValuePair(final PsiNameValuePair pair) { - result = true; - } - - @Override public void visitTypeParameterList(PsiTypeParameterList psiTypeParameterList) { - result = true; - } - - @Override public void visitTypeElement(PsiTypeElement psiTypeElement) { - result = true; - } - - @Override public void visitReferenceElement(PsiJavaCodeReferenceElement psiJavaCodeReferenceElement) { - result = true; - } - - @Override public void visitReferenceParameterList(PsiReferenceParameterList psiReferenceParameterList) { - result = true; - } - - private SymbolMatchingStrategy() {} - - private static class SymbolMatchingStrategyHolder { - private static final SymbolMatchingStrategy instance = new SymbolMatchingStrategy(); - } - - public static MatchingStrategy getInstance() { - return SymbolMatchingStrategyHolder.instance; - } -} diff --git a/plugins/structuralsearch/structuralsearch-java/structuralsearch-java.iml b/plugins/structuralsearch/structuralsearch-java/structuralsearch-java.iml deleted file mode 100644 index 4b2ec18c28e6..000000000000 --- a/plugins/structuralsearch/structuralsearch-java/structuralsearch-java.iml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="module" module-name="structuralsearch" /> - <orderEntry type="module" module-name="lang-impl" /> - <orderEntry type="module" module-name="openapi" /> - <orderEntry type="module" module-name="java-impl" /> - <orderEntry type="module" module-name="duplicates-analysis" /> - </component> -</module> - diff --git a/plugins/structuralsearch/structuralsearch-tests.iml b/plugins/structuralsearch/structuralsearch-tests.iml deleted file mode 100644 index a05a995fe450..000000000000 --- a/plugins/structuralsearch/structuralsearch-tests.iml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module relativePaths="true" type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$/testSource"> - <sourceFolder url="file://$MODULE_DIR$/testSource" isTestSource="true" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" name="Groovy" level="project" /> - <orderEntry type="module" module-name="structuralsearch" /> - <orderEntry type="module" module-name="testFramework-java" /> - <orderEntry type="module" module-name="xml" /> - <orderEntry type="module" module-name="structuralsearch-java" /> - <orderEntry type="module" module-name="java-i18n" /> - </component> -</module> - diff --git a/plugins/structuralsearch/structuralsearch.iml b/plugins/structuralsearch/structuralsearch.iml deleted file mode 100644 index 5bc64abd229c..000000000000 --- a/plugins/structuralsearch/structuralsearch.iml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module relativePaths="false" type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/source" isTestSource="false" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" scope="TEST" name="JUnit4" level="project" /> - <orderEntry type="module" module-name="util" /> - <orderEntry type="library" name="JDOM" level="project" /> - <orderEntry type="library" name="Trove4j" level="project" /> - <orderEntry type="module" module-name="xml" /> - <orderEntry type="library" name="Groovy" level="project" /> - <orderEntry type="module" module-name="platform-api" /> - <orderEntry type="module" module-name="lang-api" /> - <orderEntry type="module" module-name="openapi" /> - <orderEntry type="module" module-name="duplicates-analysis" /> - <orderEntry type="module" module-name="lang-impl" /> - </component> - <component name="copyright"> - <Base> - <setting name="state" value="1" /> - </Base> - </component> -</module> - diff --git a/plugins/structuralsearch/testData/java/DoNotFindReturn.java b/plugins/structuralsearch/testData/java/DoNotFindReturn.java deleted file mode 100644 index 2a97989b7564..000000000000 --- a/plugins/structuralsearch/testData/java/DoNotFindReturn.java +++ /dev/null @@ -1,43 +0,0 @@ -class X { - void foo() { - boolean completed = JobUtil.invokeConcurrentlyUnderProgress(files, new Processor<VirtualFile>() { - public boolean process(final VirtualFile vfile) { - final PsiFile file = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() { - public PsiFile compute() { - return myManager.findFile(vfile); - } - }); - if (file != null && !(file instanceof PsiBinaryFile)) { - file.getViewProvider().getContents(); // load contents outside readaction - ApplicationManager.getApplication().runReadAction(new Runnable() { - public void run() { - try { - PsiElement[] psiRoots = file.getPsiRoots(); - Set<PsiElement> processed = new HashSet<PsiElement>(psiRoots.length * 2, (float)0.5); - for (PsiElement psiRoot : psiRoots) { - if (progress != null) progress.checkCanceled(); - if (!processed.add(psiRoot)) continue; - if (!psiRootProcessor.process(psiRoot)) { - canceled.set(true); - return; - } - } - myManager.dropResolveCaches(); - } - catch (ProcessCanceledException e) { - canceled.set(true); - pceThrown.set(true); - } - } - }); - } - if (progress != null) { - double fraction = (double)counter.incrementAndGet() / size; - progress.setFraction(fraction); - } - return !canceled.get(); - } - }, false, progress); - - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_pattern.java b/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_pattern.java deleted file mode 100644 index 1200d6f9624f..000000000000 --- a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_pattern.java +++ /dev/null @@ -1 +0,0 @@ -assertTrue(StrictMath.abs('v1 - 'v2) < 't);
\ No newline at end of file diff --git a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_replacement.java b/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_replacement.java deleted file mode 100644 index 00a1012699b2..000000000000 --- a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_replacement.java +++ /dev/null @@ -1 +0,0 @@ -java.util.List.assertEquals($v2$, $v1$, $t$);
\ No newline at end of file diff --git a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_result.java b/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_result.java deleted file mode 100644 index 2084a8da5075..000000000000 --- a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_result.java +++ /dev/null @@ -1,204 +0,0 @@ -public class ForecastSummaryReportTest extends SOTestCase { - { - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - List.assertEquals(2, 1, 3); - } -} diff --git a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_source.java b/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_source.java deleted file mode 100644 index edb15cbfa968..000000000000 --- a/plugins/structuralsearch/testData/java/ReformatAndShortenClassRefPerformance_source.java +++ /dev/null @@ -1,204 +0,0 @@ -public class ForecastSummaryReportTest extends SOTestCase { - { - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - assertTrue(StrictMath.abs(1 - 2) < 3); - } -} diff --git a/plugins/structuralsearch/testData/java/after1.java b/plugins/structuralsearch/testData/java/after1.java deleted file mode 100644 index 156cc38f997a..000000000000 --- a/plugins/structuralsearch/testData/java/after1.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Created on Jan 30, 2004 - * - */ -package somepackage; - -/** - * Title: ForecastSummaryReportTest - */ -public class ForecastSummaryReportTest extends SOTestCase { - - ForecastSummaryReport oReport = null; - ScheduleGroupData oSkdgrp = null; - SODate oStart = null; - SODate oEnd = null; - SODateInterval oDateRange = null; - - - /** - * Constructor for ForecastSummaryReportTest. - * - * @param arg0 - */ - public ForecastSummaryReportTest(String arg0) { - super(arg0); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(ForecastSummaryReportTest.class); - } - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - try { - oSkdgrp = ScheduleGroupData.getScheduleGroupData(new Integer(1001)); - oDateRange = new SODateInterval(new SODate("01/23/2004"), new SODate("01/30/2004")); - oReport = new ForecastSummaryReport(oSkdgrp.getCorporateEntity(), oDateRange); - } catch (Exception e) { - System.out.println("Unhandled exception in Setup:" + e); - fail(); - } - - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - oReport = null; - } - - public void testForecastSummaryReport() { - try { - ForecastSummaryReport testReport = new ForecastSummaryReport(oSkdgrp.getCorporateEntity(), oDateRange); - assertNotNull(testReport); - } catch (RetailException e) { - e.printStackTrace(); - fail("RetailException: Could not create ForecastSummaryReport(CorporateEntity, SODateInterval)"); - } - } - - public void testSetIncludeSublocationsFlag() { - oReport.setIncludeSublocationsFlag(true); - assertTrue(oReport.isIncludeSublocationsFlagSet()); - } - - public void testIsIncludeSublocationsFlagSet() { - oReport.setIncludeSublocationsFlag(false); - assertFalse(oReport.isIncludeSublocationsFlagSet()); - oReport.setIncludeSublocationsFlag(true); - assertTrue(oReport.isIncludeSublocationsFlagSet()); - } - - public void testRefresh() throws RetailException { - oReport.refresh(); - assertNotNull(oReport); - } -} diff --git a/plugins/structuralsearch/testData/java/after2.java b/plugins/structuralsearch/testData/java/after2.java deleted file mode 100644 index 20974011a39b..000000000000 --- a/plugins/structuralsearch/testData/java/after2.java +++ /dev/null @@ -1,11 +0,0 @@ -public class Test { - int a; - @Override public void aaa() {} - int b; - @Override void aaa2() {} - int c; - @Override public void aaa3() {} - int d; - @Override void aaa4() {} - int e; -} diff --git a/plugins/structuralsearch/testData/java/before1.java b/plugins/structuralsearch/testData/java/before1.java deleted file mode 100644 index 948dc10eb3d8..000000000000 --- a/plugins/structuralsearch/testData/java/before1.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Created on Jan 30, 2004 - * - */ -package somepackage; - -/** - * Title: ForecastSummaryReportTest - * - * - */ -public class ForecastSummaryReportTest extends SOTestCase { - - ForecastSummaryReport oReport = null; - ScheduleGroupData oSkdgrp = null; - SODate oStart = null; - SODate oEnd = null; - SODateInterval oDateRange = null; - - - /** - * Constructor for ForecastSummaryReportTest. - * @param arg0 - */ - public ForecastSummaryReportTest(String arg0) { - super(arg0); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(ForecastSummaryReportTest.class); - } - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - try { - oSkdgrp = ScheduleGroupData.getScheduleGroupData(new Integer(1001)); - oDateRange = new SODateInterval(new SODate("01/23/2004"), new SODate("01/30/2004")); - oReport = new ForecastSummaryReport(oSkdgrp.getCorporateEntity(),oDateRange); - } catch (Exception e) { - System.out.println("Unhandled exception in Setup:" + e); - fail(); - } - - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - oReport = null; - } - - /* - * Cannot test protected methods from this location - */ - public void testGenerate() { - } - - public void testForecastSummaryReport() { - try { - ForecastSummaryReport testReport = new ForecastSummaryReport(oSkdgrp.getCorporateEntity(),oDateRange); - assertNotNull(testReport); - } catch (RetailException e) { - e.printStackTrace(); - fail("RetailException: Could not create ForecastSummaryReport(CorporateEntity, SODateInterval)"); - } - } - - public void testSetIncludeSublocationsFlag() { - oReport.setIncludeSublocationsFlag(true); - assertTrue(oReport.isIncludeSublocationsFlagSet()); - } - - public void testIsIncludeSublocationsFlagSet() { - oReport.setIncludeSublocationsFlag(false); - assertFalse(oReport.isIncludeSublocationsFlagSet()); - oReport.setIncludeSublocationsFlag(true); - assertTrue(oReport.isIncludeSublocationsFlagSet()); - } - - public void testRefresh() throws RetailException { - oReport.refresh(); - assertNotNull(oReport); - } -} diff --git a/plugins/structuralsearch/testData/java/before2.java b/plugins/structuralsearch/testData/java/before2.java deleted file mode 100644 index 371bbb3cbe30..000000000000 --- a/plugins/structuralsearch/testData/java/before2.java +++ /dev/null @@ -1,19 +0,0 @@ -public class Test { - int a; - public void aaa() { - int field; - } - int b; - void aaa2() { - int field2; - } - int c; - public void aaa3() { - int field3; - } - int d; - void aaa4() { - int field4; - } - int e; -} diff --git a/plugins/structuralsearch/testData/ssBased/ExpressionStatement.java b/plugins/structuralsearch/testData/ssBased/ExpressionStatement.java deleted file mode 100644 index 383f6d8a484c..000000000000 --- a/plugins/structuralsearch/testData/ssBased/ExpressionStatement.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.io.File; -import java.io.IOException; - -class Test{ - void foo() throws IOException { - File f = <warning descr="Forbid File.createTempFile">File.createTempFile("", "")</warning>; - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/testData/ssBased/TwoStatementPattern.java b/plugins/structuralsearch/testData/ssBased/TwoStatementPattern.java deleted file mode 100644 index e41879cd2f62..000000000000 --- a/plugins/structuralsearch/testData/ssBased/TwoStatementPattern.java +++ /dev/null @@ -1,13 +0,0 @@ -class Scratch { - - private String s = null; - - void foo() { - s = "1"; - <warning descr="silly null check">s = "2";</warning> - if (s == null) { - throw new IllegalStateException("drunk"); - } - } - -} diff --git a/plugins/structuralsearch/testData/ssBased/simple/expected.xml b/plugins/structuralsearch/testData/ssBased/simple/expected.xml deleted file mode 100644 index f2a97d264f8e..000000000000 --- a/plugins/structuralsearch/testData/ssBased/simple/expected.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<problems> - - <problem> - <file>X.java</file> - <line>5</line> - <problem_class>Structural Search Inspection</problem_class> - <description /> - </problem> - - <problem> - <file>X.java</file> - <line>7</line> - <problem_class>Structural Search Inspection</problem_class> - <description /> - </problem> - -</problems>
\ No newline at end of file diff --git a/plugins/structuralsearch/testData/ssBased/simple/src/x/X.java b/plugins/structuralsearch/testData/ssBased/simple/src/x/X.java deleted file mode 100644 index 3f5dc2f67974..000000000000 --- a/plugins/structuralsearch/testData/ssBased/simple/src/x/X.java +++ /dev/null @@ -1,10 +0,0 @@ -package x; - -class S { - public void f() { - int i; - int j; - f(); - int k; - } -} diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/OptimizedSearchScanTest.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/OptimizedSearchScanTest.java deleted file mode 100644 index f17c45bfcf3d..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/OptimizedSearchScanTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.structuralsearch.impl.matcher.compiler.PatternCompiler; -import com.intellij.idea.Bombed; - -import java.util.Calendar; - -/** - * @author Maxim.Mossienko - */ -@Bombed(day = 28, description = "support it", month = Calendar.JULY, user = "maxim.mossienko") -public abstract class OptimizedSearchScanTest extends StructuralSearchTestCase { - public void _testClassByQName() throws Exception { - String plan = findWordsToBeUsedWhenSearchingFor("A.f"); - assertEquals("[in code:f]", plan); - } - - private String findWordsToBeUsedWhenSearchingFor(final String s) { - findMatchesCount("{}",s); - return PatternCompiler.getLastFindPlan(); - } -} diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/SSBasedInspectionTest.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/SSBasedInspectionTest.java deleted file mode 100644 index 7971c1009fbd..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/SSBasedInspectionTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.codeInspection.ex.LocalInspectionToolWrapper; -import com.intellij.openapi.application.PluginPathManager; -import com.intellij.structuralsearch.inspection.highlightTemplate.SSBasedInspection; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchConfiguration; -import com.intellij.testFramework.InspectionTestCase; - -import java.util.ArrayList; -import java.util.List; - -public class SSBasedInspectionTest extends InspectionTestCase { - private LocalInspectionToolWrapper myWrapper; - - @Override - protected void setUp() throws Exception { - super.setUp(); - SSBasedInspection inspection = new SSBasedInspection(); - List<Configuration> configurations = new ArrayList<Configuration>(); - SearchConfiguration configuration = new SearchConfiguration(); - MatchOptions options = new MatchOptions(); - options.setSearchPattern("int i;"); - configuration.setMatchOptions(options); - configurations.add(configuration); - configuration = new SearchConfiguration(); - options = new MatchOptions(); - options.setSearchPattern("f();"); - configuration.setMatchOptions(options); - configurations.add(configuration); - inspection.setConfigurations(configurations, myProject); - inspection.projectOpened(getProject()); - myWrapper = new LocalInspectionToolWrapper(inspection); - } - - public void testSimple() throws Exception { - doTest(); - } - - private void doTest() throws Exception { - doTest("ssBased/" + getTestName(true), myWrapper,"java 1.5"); - } - - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("structuralsearch") + "/testData"; - } -} diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/SSRCodeInsightTest.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/SSRCodeInsightTest.java deleted file mode 100644 index 5031f821c581..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/SSRCodeInsightTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.openapi.application.PluginPathManager; -import com.intellij.structuralsearch.inspection.highlightTemplate.SSBasedInspection; -import com.intellij.structuralsearch.plugin.ui.Configuration; -import com.intellij.structuralsearch.plugin.ui.SearchConfiguration; -import com.intellij.testFramework.IdeaTestCase; -import com.intellij.testFramework.UsefulTestCase; -import com.intellij.testFramework.fixtures.*; -import com.intellij.testFramework.fixtures.impl.LightTempDirTestFixtureImpl; - -import java.util.Collections; - -public class SSRCodeInsightTest extends UsefulTestCase { - protected CodeInsightTestFixture myFixture; - private SSBasedInspection myInspection; - - public SSRCodeInsightTest() { - IdeaTestCase.initPlatformPrefix(); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - IdeaTestFixtureFactory factory = IdeaTestFixtureFactory.getFixtureFactory(); - TestFixtureBuilder<IdeaProjectTestFixture> fixtureBuilder = factory.createLightFixtureBuilder(new DefaultLightProjectDescriptor()); - final IdeaProjectTestFixture fixture = fixtureBuilder.getFixture(); - myFixture = IdeaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(fixture, - new LightTempDirTestFixtureImpl(true)); - myInspection = new SSBasedInspection(); - myFixture.enableInspections(myInspection); - myFixture.setUp(); - myFixture.setTestDataPath(getTestDataPath()); - } - - @Override - protected void tearDown() throws Exception { - myFixture.tearDown(); - myFixture = null; - myInspection = null; - super.tearDown(); - } - - public void testExpressionStatement() { - doTest("File.createTempFile($p1$, $p2$)", "Forbid File.createTempFile"); - } - - public void testTwoStatementPattern() { - doTest("$field$ = $something$;\n" + - "if ($field$ == null) {\n" + - " throw new $Exception$($msg$);\n" + - "}", - "silly null check"); - } - - private void doTest(final String searchPattern, final String patternName) { - final SearchConfiguration configuration = new SearchConfiguration(); - //display name - configuration.setName(patternName); - - //search pattern - final MatchOptions options = new MatchOptions(); - options.setSearchPattern(searchPattern); - configuration.setMatchOptions(options); - - myInspection.setConfigurations(Collections.<Configuration>singletonList(configuration), myFixture.getProject()); - myInspection.projectOpened(myFixture.getProject()); - - myFixture.testHighlighting(true, false, false, getTestName(false) + ".java"); - } - - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("structuralsearch") + "/testData/ssBased"; - } -} diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java deleted file mode 100644 index d5848b611867..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTest.java +++ /dev/null @@ -1,2133 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.openapi.application.PluginPathManager; -import com.intellij.psi.CommonClassNames; -import com.intellij.testFramework.PlatformTestUtil; -import com.intellij.util.ThrowableRunnable; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; - -/** - * @by Maxim.Mossienko - */ -@SuppressWarnings({"ALL"}) -public class StructuralReplaceTest extends StructuralReplaceTestCase { - public void testReplaceInLiterals() { - String s1 = "String ID_SPEED = \"Speed\";"; - String s2 = "String 'name = \"'string\";"; - String s2_2 = "String 'name = \"'string:[regex( .* )]\";"; - String s3 = "VSegAttribute $name$ = new VSegAttribute(\"$string$\");"; - String expectedResult = "VSegAttribute ID_SPEED = new VSegAttribute(\"Speed\");"; - - String actualResult = replacer.testReplace(s1,s2,s3,options); - assertEquals( - "Matching/replacing literals", - expectedResult, - actualResult - ); - - actualResult = replacer.testReplace(s1,s2_2,s3,options); - assertEquals( - "Matching/replacing literals", - expectedResult, - actualResult - ); - - String s4 = "params.put(\"BACKGROUND\", \"#7B528D\");"; - String s5 = "params.put(\"$FieldName$\", \"#$exp$\");"; - String s6 = "String $FieldName$ = \"$FieldName$\";\n" + - "params.put($FieldName$, \"$exp$\");"; - String expectedResult2 = "String BACKGROUND = \"BACKGROUND\";\n" + - "params.put(BACKGROUND, \"7B528D\");"; - - actualResult = replacer.testReplace(s4,s5,s6,options); - - assertEquals( - "string literal replacement 2", - expectedResult2, - actualResult - ); - - String s7 = "IconLoader.getIcon(\"/ant/property.png\");\n" + - "IconLoader.getIcon(\"/ant/another/property.png\");\n"; - String s8 = "IconLoader.getIcon(\"/'module/'name:[regex( \\w+ )].png\");"; - String s9 = "Icons.$module$.$name$;"; - String expectedResult3 = "Icons.ant.property;\n" + - "IconLoader.getIcon(\"/ant/another/property.png\");\n"; - - actualResult = replacer.testReplace(s7,s8,s9,options); - - assertEquals( - "string literal replacement 3", - expectedResult3, - actualResult - ); - - String s10 = "configureByFile(path + \"1.html\");\n" + - " checkResultByFile(path + \"1_after.html\");\n" + - " checkResultByFile(path + \"1_after2.html\");\n" + - " checkResultByFile(path + \"1_after3.html\");"; - String s11 = "\"'a.html\""; - String s12 = "\"$a$.\"+ext"; - String expectedResult4 = "configureByFile(path + \"1.\"+ext);\n" + - " checkResultByFile(path + \"1_after.\"+ext);\n" + - " checkResultByFile(path + \"1_after2.\"+ext);\n" + - " checkResultByFile(path + \"1_after3.\"+ext);"; - - actualResult = replacer.testReplace(s10,s11,s12,options); - assertEquals( - "string literal replacement 4", - expectedResult4, - actualResult - ); - } - - public void testReplace2() { - String s1 = "package com.www.xxx.yyy;\n" + - "\n" + - "import javax.swing.*;\n" + - "\n" + - "public class Test {\n" + - " public static void main(String[] args) {\n" + - " if (1==1)\n" + - " JOptionPane.showMessageDialog(null, \"MESSAGE\");\n" + - " }\n" + - "}"; - String s2 = "JOptionPane.'showDialog(null, 'msg);"; - String s3 = "//FIXME provide a parent frame\n" + - "JOptionPane.$showDialog$(null, $msg$);"; - - String expectedResult = "package com.www.xxx.yyy;\n" + - "\n" + - "import javax.swing.*;\n" + - "\n" + - "public class Test {\n" + - " public static void main(String[] args) {\n" + - " if (1==1)\n" + - " //FIXME provide a parent frame\n" + - "JOptionPane.showMessageDialog(null, \"MESSAGE\");\n" + - " }\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2,s3,options); - assertEquals( - "adding comment to statement inside the if body", - expectedResult, - actualResult - ); - - String s4 = "myButton.setText(\"Ok\");"; - String s5 = "'Instance.'MethodCall:[regex( setText )]('Parameter*:[regex( \"Ok\" )]);"; - String s6 = "$Instance$.$MethodCall$(\"OK\");"; - - String expectedResult2 = "myButton.setText(\"OK\");"; - - actualResult = replacer.testReplace(s4,s5,s6,options); - assertEquals( - "adding comment to statement inside the if body", - expectedResult2, - actualResult - ); - } - - public void testReplace() { - String str = "// searching for several constructions\n" + - " lastTest = \"several constructions match\";\n" + - " matches = testMatcher.findMatches(s5,s4, options);\n" + - " if (matches==null || matches.size()!=3) return false;\n" + - "\n" + - " // searching for several constructions\n" + - " lastTest = \"several constructions 2\";\n" + - " matches = testMatcher.findMatches(s5,s6, options);\n" + - " if (matches.size()!=0) return false;\n" + - "\n" + - " //options.setLooseMatching(true);\n" + - " // searching for several constructions\n" + - " lastTest = \"several constructions 3\";\n" + - " matches = testMatcher.findMatches(s7,s8, options);\n" + - " if (matches.size()!=2) return false;"; - - String str2=" lastTest = 'Descr;\n" + - " matches = testMatcher.findMatches('In,'Pattern, options);\n" + - " if (matches.size()!='Number) return false;"; - String str3 = "assertEquals($Descr$,testMatcher.findMatches($In$,$Pattern$, options).size(),$Number$);"; - String expectedResult1 = "// searching for several constructions\n" + - " lastTest = \"several constructions match\";\n" + - " matches = testMatcher.findMatches(s5, s4, options);\n" + - " if (matches == null || matches.size() != 3) return false;\n" + - "\n" + - " // searching for several constructions\n" + - " assertEquals(\"several constructions 2\", testMatcher.findMatches(s5, s6, options).size(), 0);\n" + - "\n" + - " //options.setLooseMatching(true);\n" + - " // searching for several constructions\n" + - " assertEquals(\"several constructions 3\", testMatcher.findMatches(s7, s8, options).size(), 2);"; - - String str4 = ""; - - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(str,str2,str3,options); - options.setToReformatAccordingToStyle(false); - assertEquals("Basic replacement with formatter",expectedResult1,actualResult); - - actualResult = replacer.testReplace(str,str2,str4,options); - String expectedResult2 = "// searching for several constructions\n" + - " lastTest = \"several constructions match\";\n" + - " matches = testMatcher.findMatches(s5,s4, options);\n" + - " if (matches==null || matches.size()!=3) return false;\n" + - "\n" + - " // searching for several constructions\n" + - "\n" + - " //options.setLooseMatching(true);\n" + - " // searching for several constructions"; - - assertEquals("Empty replacement",expectedResult2,actualResult); - - String str5 = "testMatcher.findMatches('In,'Pattern, options).size()"; - String str6 = "findMatchesCount($In$,$Pattern$)"; - String expectedResult3="// searching for several constructions\n" + - " lastTest = \"several constructions match\";\n" + - " matches = testMatcher.findMatches(s5, s4, options);\n" + - " if (matches == null || matches.size() != 3) return false;\n" + - "\n" + - " // searching for several constructions\n" + - " assertEquals(\"several constructions 2\", findMatchesCount(s5,s6), 0);\n" + - "\n" + - " //options.setLooseMatching(true);\n" + - " // searching for several constructions\n" + - " assertEquals(\"several constructions 3\", findMatchesCount(s7,s8), 2);"; - actualResult = replacer.testReplace(expectedResult1,str5,str6,options); - - assertEquals( "Expression replacement", expectedResult3,actualResult ); - - String str7 = "try { a.doSomething(); b.doSomething(); } catch(IOException ex) { ex.printStackTrace(); throw new RuntimeException(ex); }"; - String str8 = "try { 'Statements+; } catch('_ '_) { 'HandlerStatements+; }"; - String str9 = "$Statements$;"; - String expectedResult4 = "a.doSomething(); b.doSomething();"; - - actualResult = replacer.testReplace(str7,str8,str9,options); - assertEquals( "Multi line match in replacement", expectedResult4,actualResult ); - - String str10 = " parentNode.insert(compositeNode, i);\n" + - " if (asyncMode) {\n" + - " myTreeModel.nodesWereInserted(parentNode,new int[] {i} );\n" + - " }"; - String str11 = " 'parentNode.insert('newNode, 'i);\n" + - " if (asyncMode) {\n" + - " myTreeModel.nodesWereInserted('parentNode,new int[] {'i} );\n" + - " }"; - String str12 = "addChild($parentNode$,$newNode$, $i$);"; - String expectedResult5 = " addChild(parentNode,compositeNode, i);"; - - actualResult = replacer.testReplace(str10,str11,str12,options); - assertEquals( "Array initializer replacement", expectedResult5,actualResult); - - String str13 = " aaa(5,6,3,4,1,2);"; - String str14 = "aaa('t{2,2},3,4,'q{2,2});"; - String str15 = "aaa($q$,3,4,$t$);"; - String expectedResult6 = " aaa(1,2,3,4,5,6);"; - - actualResult = replacer.testReplace(str13,str14,str15,options); - assertEquals("Parameter multiple match",expectedResult6,actualResult); - - String str16 = " int c = a();"; - String str17 = "'t:a ('q*,'p*)"; - String str18 = "$t$($q$,1,$p$)"; - String expectedResult7 = " int c = a(1);"; - - actualResult = replacer.testReplace(str16,str17,str18,options); - assertEquals("Replacement of init in definition + empty substitution",expectedResult7,actualResult); - - String str19 = " aaa(bbb);"; - String str20 = "'t('_);"; - String str21 = "$t$(ccc);"; - String expectedResult8 = " aaa(ccc);"; - - actualResult = replacer.testReplace(str19,str20,str21,options); - assertEquals("One substition replacement",expectedResult8,actualResult); - - String str22 = " instance.setAAA(anotherInstance.getBBB());"; - String str23 = " 'i.'m:set(.+) ('a.'m2:get(.+) ());"; - String str24 = " $a$.set$m2_1$( $i$.get$m_1$() );"; - String expectedResult9 = " anotherInstance.setBBB( instance.getAAA() );"; - - actualResult = replacer.testReplace(str22,str23,str24,options); - assertEquals("Reg exp substitution replacement",expectedResult9,actualResult); - - String str25 = " LaterInvocator.invokeLater(new Runnable() {\n" + - " public void run() {\n" + - " LOG.info(\"refreshFilesAsync, modalityState=\" + ModalityState.current());\n" + - " myHandler.getFiles().refreshFilesAsync(new Runnable() {\n" + - " public void run() {\n" + - " semaphore.up();\n" + - " }\n" + - " });\n" + - " }\n" + - " });"; - String str26 = " LaterInvocator.invokeLater('Params{1,10});"; - String str27 = " com.intellij.openapi.application.ApplicationManager.getApplication().invokeLater($Params$);"; - String expectedResult10 = " com.intellij.openapi.application.ApplicationManager.getApplication().invokeLater(new Runnable() {\n" + - " public void run() {\n" + - " LOG.info(\"refreshFilesAsync, modalityState=\" + ModalityState.current());\n" + - " myHandler.getFiles().refreshFilesAsync(new Runnable() {\n" + - " public void run() {\n" + - " semaphore.up();\n" + - " }\n" + - " });\n" + - " }\n" + - " });"; - - actualResult = replacer.testReplace(str25,str26,str27,options); - assertEquals("Anonymous in parameter",expectedResult10,actualResult); - - String str28 = "UTElementNode elementNode = new UTElementNode(myProject, processedElement, psiFile,\n" + - " processedElement.getTextOffset(), true,\n" + - " !myUsageViewDescriptor.toMarkInvalidOrReadonlyUsages(), null);"; - String str29 = "new UTElementNode('param, 'directory, 'null, '0, 'true, !'descr.toMarkInvalidOrReadonlyUsages(),\n" + - " 'referencesWord)"; - String str30 = "new UTElementNode($param$, $directory$, $null$, $0$, $true$, true,\n" + - " $referencesWord$)"; - - String expectedResult11 = "UTElementNode elementNode = new UTElementNode(myProject, processedElement, psiFile, processedElement.getTextOffset(), true, true,\n" + - " null);"; - actualResult = replacer.testReplace(str28,str29,str30,options); - assertEquals("Replace in def initializer",expectedResult11,actualResult); - - String s31 = "a = b; b = c; a=a; c=c;"; - String s32 = "'a = 'a;"; - String s33 = "1 = 1;"; - String expectedResult12 = "a = b; b = c; 1 = 1; 1 = 1;"; - - actualResult = replacer.testReplace(s31,s32,s33,options); - assertEquals( - "replace silly assignments", - expectedResult12, - actualResult - ); - - String s34 = "ParamChecker.isTrue(1==1, \"!!!\");"; - String s35 = "ParamChecker.isTrue('expr, 'msg)"; - String s36 = "assert $expr$ : $msg$"; - - String expectedResult13 = "assert 1==1 : \"!!!\";"; - actualResult = replacer.testReplace(s34,s35,s36,options); - assertEquals( - "replace with assert", - expectedResult13, - actualResult - ); - - String s37 = "try { \n" + - " ParamChecker.isTrue(1==1, \"!!!\");\n \n" + - " // comment we want to leave\n \n" + - " ParamChecker.isTrue(2==2, \"!!!\");\n" + - "} catch(Exception ex) {}"; - String s38 = "try {\n" + - " 'Statement{0,100};\n" + - "} catch(Exception ex) {}"; - String s39 = "$Statement$;"; - - String expectedResult14 = "ParamChecker.isTrue(1==1, \"!!!\");\n \n" + - " // comment we want to leave\n \n" + - " ParamChecker.isTrue(2==2, \"!!!\");"; - actualResult = replacer.testReplace(s37,s38,s39,options); - assertEquals( - "remove try with comments inside", - expectedResult14, - actualResult - ); - - String s40 = "ParamChecker.instanceOf(queryKey, GroupBySqlTypePolicy.GroupKey.class);"; - String s41 = "ParamChecker.instanceOf('obj, 'class.class);"; - String s42 = "assert $obj$ instanceof $class$ : \"$obj$ is an instance of \" + $obj$.getClass() + \"; expected \" + $class$.class;"; - String expectedResult15 = "assert queryKey instanceof GroupBySqlTypePolicy.GroupKey : \"queryKey is an instance of \" + queryKey.getClass() + \"; expected \" + GroupBySqlTypePolicy.GroupKey.class;"; - - actualResult = replacer.testReplace(s40,s41,s42,options); - assertEquals( - "Matching/replacing .class literals", - expectedResult15, - actualResult - ); - - String s43 = "class Wpd {\n" + - " static final String TAG_BEAN_VALUE = \"\";\n" + - "}\n" + - "XmlTag beanTag = rootTag.findSubTag(Wpd.TAG_BEAN_VALUE);"; - String s44 = "'Instance?.findSubTag( 'Parameter:[exprtype( *String ) ])"; - String s45 = "jetbrains.fabrique.util.XmlApiUtil.findSubTag($Instance$, $Parameter$)"; - String expectedResult16 = "class Wpd {\n" + - " static final String TAG_BEAN_VALUE = \"\";\n" + - "}\n" + - "XmlTag beanTag = jetbrains.fabrique.util.XmlApiUtil.findSubTag(rootTag, Wpd.TAG_BEAN_VALUE);"; - - actualResult = replacer.testReplace(s43,s44,s45,options); - assertEquals( - "Matching/replacing static fields", - expectedResult16, - actualResult - ); - - String s46 = "Rectangle2D rec = new Rectangle2D.Double(\n" + - " drec.getX(),\n" + - " drec.getY(),\n" + - " drec.getWidth(),\n" + - " drec.getWidth());"; - String s47 = "$Instance$.$MethodCall$()"; - String s48 = "OtherClass.round($Instance$.$MethodCall$(),5)"; - String expectedResult17 = "Rectangle2D rec = new Rectangle2D.Double(\n" + - " OtherClass.round(drec.getX(),5),\n" + - " OtherClass.round(drec.getY(),5),\n" + - " OtherClass.round(drec.getWidth(),5),\n" + - " OtherClass.round(drec.getWidth(),5));"; - actualResult = replacer.testReplace(s46,s47,s48,options); - - assertEquals( - "Replace in constructor", - expectedResult17, - actualResult - ); - - String s49 = "class A {}\n" + - "class B extends A {}\n" + - "A a = new B();"; - String s50 = "A 'b = new 'B:*A ();"; - String s51 = "A $b$ = new $B$(\"$b$\");"; - String expectedResult18 = "class A {}\n" + - "class B extends A {}\n" + - "A a = new B(\"a\");"; - - actualResult = replacer.testReplace(s49,s50,s51,options); - - assertEquals( - "Class navigation", - expectedResult18, - actualResult - ); - - String s52 = "try {\n" + - " aaa();\n" + - "} finally {\n" + - " System.out.println();" + - "}\n" + - "try {\n" + - " aaa2();\n" + - "} catch(Exception ex) {\n" + - " aaa3();\n" + - "}\n" + - "finally {\n" + - " System.out.println();\n" + - "}\n" + - "try {\n" + - " aaa4();\n" + - "} catch(Exception ex) {\n" + - " aaa5();\n" + - "}\n"; - String s53 = "try { 'a; } finally {\n" + - " 'b;" + - "}"; - String s54 = "$a$;"; - String expectedResult19 = "aaa();\n" + - "try {\n" + - " aaa2();\n" + - "} catch(Exception ex) {\n" + - " aaa3();\n" + - "}\n" + - "finally {\n" + - " System.out.println();\n" + - "}\n" + - "try {\n" + - " aaa4();\n" + - "} catch(Exception ex) {\n" + - " aaa5();\n" + - "}\n"; - - actualResult = replacer.testReplace(s52,s53,s54,options); - - assertEquals( - "Try/ catch/ finally is replace with try/finally", - expectedResult19, - actualResult - ); - - String s55 = "for(Iterator<String> iterator = stringlist.iterator(); iterator.hasNext();) {\n" + - " String str = iterator.next();\n" + - " System.out.println( str );\n" + - "}"; - String s56 = "for (Iterator<$Type$> $variable$ = $container$.iterator(); $variable$.hasNext();) {\n" + - " $Type$ $var$ = $variable$.next();\n" + - " $Statements$;\n" + - "}"; - String s57 = "for($Type$ $var$:$container$) {\n" + - " $Statements$;\n" + - "}"; - String expectedResult20 = "for(String str :stringlist) {\n" + - " System.out.println( str );\n" + - "}"; - - actualResult = replacer.testReplace(s55,s56,s57,options); - - assertEquals( - "for with foreach", - expectedResult20, - actualResult - ); - - String s58 = "class A {\n" + - " static Set<String> b_MAP = new HashSet<String>();\n" + - " int c;\n" + - "}"; - String s59 = "'a:[ regex( (.*)_MAP ) ]"; - String s60 = "$a_1$_SET"; - String expectedResult21 = "class A {\n" + - " static Set<String> b_SET = new HashSet<String>();\n" + - " int c;\n" + - "}"; - - actualResult = replacer.testReplace(s58,s59,s60,options); - - assertEquals( - "replace symbol in definition", - expectedResult21, - actualResult - ); - - String s64 = "int x = 42;\n" + - "int y = 42; // Stuff"; - String s65 = "'Type 'Variable = 'Value; // 'Comment"; - String s66 = "/**\n" + - " *$Comment$\n" + - " */\n" + - "$Type$ $Variable$ = $Value$;"; - String expectedResult23 = "int x = 42;\n" + - "/**\n" + - " * Stuff\n" + - " */\n" + - "int y = 42;"; - - actualResult = replacer.testReplace(s64,s65,s66,options); - - assertEquals( - "Replacement of the comment with javadoc", - expectedResult23, - actualResult - ); - - String s61 = "try { 1=1; } catch(Exception e) { 1=1; } catch(Throwable t) { 2=2; }"; - String s62 = "try { 'a; } catch(Exception e) { 'b; }"; - String s63 = "try { $a$; } catch(Exception1 e) { $b$; } catch(Exception2 e) { $b$; }"; - String expectedResult22 = "try { 1=1; } catch(Exception1 e) { 1=1; } catch(Exception2 e) { 1=1; } catch (Throwable t) { 2=2; }"; - - actualResult = replacer.testReplace(s61,s62,s63,options); - - assertEquals( - "try replacement by another try will leave the unmatched catch", - expectedResult22, - actualResult - ); - - } - - public void testReplaceExpr() { - String s1 = "new SimpleDateFormat(\"yyyyMMddHHmmss\")"; - String s2 = "'expr"; - String s3 = "new AtomicReference<DateFormat>($expr$)"; - String expectedResult = "new AtomicReference<DateFormat>(new SimpleDateFormat(\"yyyyMMddHHmmss\"))"; - - actualResult = replacer.testReplace(s1, s2, s3, options); - - assertEquals("Replacement of top-level expression only", expectedResult, actualResult); - - String s4 = "get(\"smth\")"; - String s5 = "'expr"; - String s6 = "new Integer($expr$)"; - String expectedResult1 = "new Integer(get(\"smth\"))"; - - actualResult = replacer.testReplace(s4, s5, s6, options); - assertEquals("Replacement of top-level expression only", expectedResult1, actualResult); - } - - public void testReplaceParameter() { - String s1 = "class A { void b(int c, int d, int e) {} }"; - String s2 = "int d"; - String s3 = "int d2"; - String expectedResult = "class A { void b(int c, int d2, int e) {} }"; - - actualResult = replacer.testReplace(s1,s2,s3,options); - - assertEquals( - "replace method parameter", - expectedResult, - actualResult - ); - } - - public void testReplaceWithComments() { - String s1 = "map.put(key, value); // line 1"; - String s2 = "map.put(key, value); // line 1"; - String s3 = "map.put(key, value); // line 1"; - String expectedResult = "map.put(key, value); // line 1"; - - actualResult = replacer.testReplace(s1,s2,s3,options); - - assertEquals( - "replace self with comment after", - expectedResult, - actualResult - ); - - String s4 = "if (true) System.out.println(\"1111\"); else System.out.println(\"2222\");\n" + - "while(true) System.out.println(\"1111\");"; - String s5 = "System.out.println('Test);"; - String s6 = "/* System.out.println($Test$); */"; - actualResult = replacer.testReplace(s4,s5,s6,options); - String expectedResult2 = "if (true) /* System.out.println(\"1111\"); */; else /* System.out.println(\"2222\"); */;\n" + - "while(true) /* System.out.println(\"1111\"); */;"; - - assertEquals( - "replace with comment", - expectedResult2, - actualResult - ); - } - - public void testSeveralStatements() { - String s1 = "{\n" + - " System.out.println(1);\n" + - " System.out.println(2);\n" + - " System.out.println(3);\n" + - " }\n" + - "{\n" + - " System.out.println(1);\n" + - " System.out.println(2);\n" + - " System.out.println(3);\n" + - " }\n" + - "{\n" + - " System.out.println(1);\n" + - " System.out.println(2);\n" + - " System.out.println(3);\n" + - " }"; - String s2 = - " System.out.println(1);\n" + - " System.out.println(2);\n" + - " System.out.println(3);\n"; - String s3 = " System.out.println(3);\n" + - " System.out.println(2);\n" + - " System.out.println(1);\n"; - String expectedResult1 = " {\n" + - " System.out.println(3);\n" + - " System.out.println(2);\n" + - " System.out.println(1);\n" + - " }\n" + - " {\n" + - " System.out.println(3);\n" + - " System.out.println(2);\n" + - " System.out.println(1);\n" + - " }\n" + - " {\n" + - " System.out.println(3);\n" + - " System.out.println(2);\n" + - " System.out.println(1);\n" + - " }"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s1,s2,s3,options); - options.setToReformatAccordingToStyle(false); - assertEquals( - "three statements replacement", - expectedResult1, - actualResult - ); - - String s4 = "ProgressManager.getInstance().startNonCancelableAction();\n" + - " try {\n" + - " read(id, READ_PARENT);\n" + - " return myViewport.parent;\n" + - " }\n" + - " finally {\n" + - " ProgressManager.getInstance().finishNonCancelableAction();\n" + - " }"; - String s5 = "ProgressManager.getInstance().startNonCancelableAction();\n" + - " try {\n" + - " '_statement{2,2};\n" + - " }\n" + - " finally {\n" + - " ProgressManager.getInstance().finishNonCancelableAction();\n" + - " }"; - String s6 = "$statement$;"; - String expectedResult2 = "read(id, READ_PARENT);\n" + - " return myViewport.parent;"; - actualResult = replacer.testReplace(s4,s5,s6,options); - assertEquals( - "extra ;", - expectedResult2, - actualResult - ); - - String s7 = "public class A {\n" + - " void f() {\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " l();\n" + - " }\n" + - "\n" + - " private void l() {\n" + - " int i = 9;\n" + - " int j = 9;\n" + - " }\n" + - " };\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " l();\n" + - " }\n" + - "\n" + - " private void l() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - "}"; - String s8 = "new Runnable() {\n" + - " public void run() {\n" + - " 'l ();\n" + - " }\n" + - " private void 'l () {\n" + - " 'st{2,2};\n" + - " }\n" + - "};"; - String s9 = "new My() {\n" + - " public void f() {\n" + - " $st$;\n" + - " }\n" + - "};"; - - String expectedResult3 = "public class A {\n" + - " void f() {\n" + - " new My() {\n" + - " public void f() {\n" + - " int i = 9;\n" + - " int j = 9;\n" + - " }\n" + - " };\n" + - " new My() {\n" + - " public void f() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - " };\n" + - " }\n" + - "\n" + - "}"; - boolean formatAccordingToStyle = options.isToReformatAccordingToStyle(); - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s7,s8,s9,options); - assertEquals( - "extra ; 2", - expectedResult3, - actualResult - ); - - String s10 = "public class A {\n" + - " void f() {\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - " public void run2() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - "\n" + - " };\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - " public void run2() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - "\n" + - " };\n" + - "new Runnable() {\n" + - " public void run() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - " public void run2() {\n" + - " l2();\n" + - " l2();\n" + - " }\n" + - "\n" + - " };\n" + - " }\n" + - "\n" + - " private void l() {\n" + - " int i = 9;\n" + - " int j = 9;\n" + - " }\n" + - "}\n" + - "\n" + - "abstract class My {\n" + - " abstract void f();\n" + - "}"; - String s11 = "new Runnable() {\n" + - " public void run() {\n" + - " 'l{2,2};\n" + - " }\n" + - " public void run2() {\n" + - " 'l{2,2};\n" + - " }\n" + - "\n" + - " };"; - String s12 = "new My() {\n" + - " public void f() {\n" + - " $l$;\n" + - " }\n" + - " };"; - String expectedResult4 = "public class A {\n" + - " void f() {\n" + - " new My() {\n" + - " public void f() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - " };\n" + - " new My() {\n" + - " public void f() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - " };\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " l();\n" + - " l();\n" + - " }\n" + - "\n" + - " public void run2() {\n" + - " l2();\n" + - " l2();\n" + - " }\n" + - "\n" + - " };\n" + - " }\n" + - "\n" + - " private void l() {\n" + - " int i = 9;\n" + - " int j = 9;\n" + - " }\n" + - "}\n" + - "\n" + - "abstract class My {\n" + - " abstract void f();\n" + - "}"; - - actualResult = replacer.testReplace(s10,s11,s12,options); - assertEquals( - "same multiple occurences 2 times", - expectedResult4, - actualResult - ); - - options.setToReformatAccordingToStyle(formatAccordingToStyle); - - String s13 = " PsiLock.LOCK.acquire();\n" + - " try {\n" + - " return value;\n" + - " }\n" + - " finally {\n" + - " PsiLock.LOCK.release();\n" + - " }"; - String s13_2 = " PsiLock.LOCK.acquire();\n" + - " try {\n" + - " if (true) { return value; }\n" + - " }\n" + - " finally {\n" + - " PsiLock.LOCK.release();\n" + - " }"; - String s13_3 = " PsiLock.LOCK.acquire();\n" + - " try {\n" + - " if (true) { return value; }\n\n" + - " if (true) { return value; }\n" + - " }\n" + - " finally {\n" + - " PsiLock.LOCK.release();\n" + - " }"; - String s14 = " PsiLock.LOCK.acquire();\n" + - " try {\n" + - " 'T{1,1000};\n" + - " }\n" + - " finally {\n" + - " PsiLock.LOCK.release();\n" + - " }"; - String s15 = "synchronized(PsiLock.LOCK) {\n" + - " $T$;\n" + - "}"; - - String expectedResult5 = " synchronized (PsiLock.LOCK) {\n" + - " return value;\n" + - " }"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s13,s14,s15,options); - options.setToReformatAccordingToStyle(false); - - assertEquals( - "extra ; over return", - expectedResult5, - actualResult - ); - - String expectedResult6 = " synchronized (PsiLock.LOCK) {\n" + - " if (true) {\n" + - " return value;\n" + - " }\n" + - " }"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s13_2,s14,s15,options); - options.setToReformatAccordingToStyle(false); - - assertEquals( - "extra ; over if", - expectedResult6, - actualResult - ); - - String expectedResult7 = " synchronized (PsiLock.LOCK) {\n" + - " if (true) {\n" + - " return value;\n" + - " }\n" + - "\n" + - " if (true) {\n" + - " return value;\n" + - " }\n" + - " }"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s13_3,s14,s15,options); - options.setToReformatAccordingToStyle(false); - assertEquals( - "newlines in matches of several lines", - expectedResult7, - actualResult - ); - - String s16 = "public class SSTest {\n" + - " Object lock;\n" + - " public Object getProducts (String[] productNames) {\n" + - " synchronized (lock) {\n" + - " Object o = new Object ();\n" + - " assert o != null;\n" + - " return o;\n" + - " }\n" + - " }\n" + - "}"; - String s16_2 = "public class SSTest {\n" + - " Object lock;\n" + - " public void getProducts (String[] productNames) {\n" + - " synchronized (lock) {\n" + - " boolean[] v = {true};\n" + - " }\n" + - " }\n" + - "}"; - - String s17 = "synchronized(lock) {\n" + - " 'Statement*;\n" + - "}"; - - String s18 = "$Statement$;"; - String expectedResult8 = "public class SSTest {\n" + - " Object lock;\n" + - " public Object getProducts (String[] productNames) {\n" + - " Object o = new Object ();\n" + - " assert o != null;\n" + - " return o;\n" + - " }\n" + - "}"; - String expectedResult8_2 = "public class SSTest {\n" + - " Object lock;\n" + - " public void getProducts (String[] productNames) {\n" + - " boolean[] v = {true};\n" + - " }\n" + - "}"; - - actualResult = replacer.testReplace(s16,s17,s18,options); - assertEquals( - "extra ;", - expectedResult8, - actualResult - ); - - actualResult = replacer.testReplace(s16_2,s17,s18,options); - assertEquals( - "missed ;", - expectedResult8_2, - actualResult - ); - } - - public void testClassReplacement() { - boolean formatAccordingToStyle = options.isToReformatAccordingToStyle(); - options.setToReformatAccordingToStyle(true); - - String s1 = "class A { public void b() {} }"; - String s2 = "class 'a { 'Other* }"; - String s3 = "class $a$New { Logger LOG; $Other$ }"; - String expectedResult = " class ANew {\n" + - " Logger LOG;\n\n" + - " public void b() {\n" + - " }\n" + - " }"; - String actualResult; - actualResult = replacer.testReplace(s1,s2,s3,options); - assertEquals( - "Basic class replacement", - expectedResult, - actualResult - ); - - String s4 = "class A { class C {} public void b() {} int f; }"; - String s5 = "class 'a { 'Other* }"; - String s6 = "class $a$ { Logger LOG; $Other$ }"; - String expectedResult2 = " class A {\n" + - " Logger LOG;\n\n" + - " class C {\n" + - " }\n\n" + - " public void b() {\n" + - " }\n\n" + - " int f;\n" + - " }"; - - actualResult = replacer.testReplace(s4,s5,s6,options); - assertEquals( - "Order of members in class replacement", - expectedResult2, - actualResult - ); - - String s7 = "class A extends B { int c; void b() {} { a = 1; } }"; - String s8 = "class 'A extends B { 'Other* }"; - String s9 = "class $A$ extends B2 { $Other$ }"; - String expectedResult3 = " class A extends B2 {\n" + - " int c;\n\n" + - " void b() {\n" + - " }\n\n" + - " {\n" + - " a = 1;\n" + - " }\n" + - " }"; - - actualResult = replacer.testReplace(s7,s8,s9,options); - assertEquals("Unsupported pattern exception",actualResult,expectedResult3); - options.setToReformatAccordingToStyle(formatAccordingToStyle); - - String s10 = "/** @example */\n" + - "class A {\n" + - " class C {}\n" + - " public void b() {}\n" + - " int f;\n" + - "}"; - String s11 = "class 'a { 'Other* }"; - String s12 = "public class $a$ {\n" + - " $Other$\n" + - "}"; - String expectedResult4 = "/** @example */\n" + - " public class A {\n" + - " class C {\n" + - " }\n\n" + - " public void b() {\n" + - " }\n\n" + - " int f;\n" + - " }"; - - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s10,s11,s12,options); - options.setToReformatAccordingToStyle(false); - assertEquals("Make class public",expectedResult4,actualResult); - - String s13 = "class CustomThread extends Thread {\n" + - "public CustomThread(InputStream in, OutputStream out, boolean closeOutOnExit) {\n" + - " super(CustomThreadGroup.getThreadGroup(), \"CustomThread\");\n" + - " setDaemon(true);\n" + - " if (in instanceof BufferedInputStream) {\n" + - " bis = (BufferedInputStream)in;\n" + - " } else {\n" + - " bis = new BufferedInputStream(in);\n" + - " }\n" + - " this.out = out;\n" + - " this.closeOutOnExit = closeOutOnExit;\n" + - "}\n" + - "}"; - String s14 = "class 'Class extends Thread {\n" + - " 'Class('ParameterType* 'ParameterName*) {\n" + - "\t super (CustomThreadGroup.getThreadGroup(), 'superarg* );\n" + - " 'Statement*;\n" + - " }\n" + - "}"; - String s15 = "class $Class$ extends CustomThread {\n" + - " $Class$($ParameterType$ $ParameterName$) {\n" + - "\t super($superarg$);\n" + - " $Statement$;\n" + - " }\n" + - "}"; - - String expectedResult5 = " class CustomThread extends CustomThread {\n" + - " CustomThread(InputStream in, OutputStream out, boolean closeOutOnExit) {\n" + - " super(\"CustomThread\");\n" + - " setDaemon(true);\n" + - " if (in instanceof BufferedInputStream) {\n" + - " bis = (BufferedInputStream) in;\n" + - " } else {\n" + - " bis = new BufferedInputStream(in);\n" + - " }\n" + - " this.out = out;\n" + - " this.closeOutOnExit = closeOutOnExit;\n" + - " }\n" + - " }"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s13,s14,s15,options); - options.setToReformatAccordingToStyle(false); - assertEquals("Constructor replacement",expectedResult5,actualResult); - - String s16 = "public class A {}\n" + - "final class B {}"; - String s17 = "class 'A { 'Other* }"; - String s17_2 = "class 'A { private Log log = LogFactory.createLog(); 'Other* }"; - String s18 = "class $A$ { private Log log = LogFactory.createLog(); $Other$ }"; - String s18_2 = "class $A$ { $Other$ }"; - - actualResult = replacer.testReplace(s16,s17,s18,options); - String expectedResult6 = "public class A { private Log log = LogFactory.createLog(); }\n" + - "final class B { private Log log = LogFactory.createLog(); }"; - assertEquals("Modifier list for class",expectedResult6,actualResult); - - actualResult = replacer.testReplace(actualResult,s17_2,s18_2,options); - String expectedResult7 = "public class A { }\n" + - "final class B { }"; - assertEquals("Removing field",expectedResult7,actualResult); - - String s19 = "public class A extends Object implements Cloneable {}\n"; - String s20 = "class 'A { 'Other* }"; - String s21 = "class $A$ { private Log log = LogFactory.createLog(); $Other$ }"; - - actualResult = replacer.testReplace(s19,s20,s21,options); - String expectedResult8 = "public class A extends Object implements Cloneable { private Log log = LogFactory.createLog(); }\n"; - assertEquals("Extends / implements list for class",expectedResult8,actualResult); - - String s22 = "public class A<T> { int Afield; }\n"; - String s23 = "class 'A { 'Other* }"; - String s24 = "class $A$ { private Log log = LogFactory.createLog(); $Other$ }"; - - actualResult = replacer.testReplace(s22,s23,s24,options); - String expectedResult9 = "public class A<T> { private Log log = LogFactory.createLog(); int Afield; }\n"; - assertEquals("Type parameters for the class",expectedResult9,actualResult); - - String s25 = "class A {\n" + - " // comment before\n" + - " protected short a; // comment after\n" + - "}"; - String s26 = "short a;"; - String s27 = "Object a;"; - String expectedResult10 = "class A {\n" + - " // comment before\n" + - " protected Object a; // comment after\n" + - "}"; - - actualResult = replacer.testReplace(s25,s26,s27,options); - - assertEquals( - "Replacing dcl with saving access modifiers", - expectedResult10, - actualResult - ); - - String s28 = "aaa"; - String s29 = "class 'Class {\n" + - " 'Class('ParameterType 'ParameterName) {\n" + - " 'Class('ParameterName);\n" + - " }\n" + - "}"; - String s30 = "class $Class$ {\n" + - " $Class$($ParameterType$ $ParameterName$) {\n" + - " this($ParameterName$);\n" + - " }\n" + - "}"; - String expectedResult11 = "aaa"; - - actualResult = replacer.testReplace(s28,s29,s30,options); - - assertEquals( - "Complex class replacement", - expectedResult11, - actualResult - ); - - String s31 = "class A {\n" + - " int a; // comment\n" + - " char b;\n" + - " int c; // comment2\n" + - "}"; - - String s32 = "'Type 'Variable = 'Value?; //'Comment"; - String s33 = "/**$Comment$*/\n" + - "$Type$ $Variable$ = $Value$;"; - - String expectedResult12 = " class A {\n" + - " /**\n" + - " * comment\n" + - " */\n" + - " int a;\n" + - " char b;\n" + - " /**\n" + - " * comment2\n" + - " */\n" + - " int c;\n" + - " }"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s31,s32,s33,options); - options.setToReformatAccordingToStyle(false); - - assertEquals( - "Replacing comments with javadoc for fields", - expectedResult12, - actualResult - ); - - String s34 = "/**\n" + - " * This interface stores XXX\n" + - " * <p/>\n" + - " */\n" + - "public interface X {\n" + - " public static final String HEADER = Headers.HEADER;\n" + - "\n" + - "}"; - - String s35 = "public interface 'MessageInterface {\n" + - " public static final String 'X = 'VALUE;\n" + - " 'blah*" + - "}"; - String s36 = "public interface $MessageInterface$ {\n" + - " public static final String HEADER = $VALUE$;\n" + - " $blah$\n" + - "}"; - - String expectedResult13 = "/**\n" + - " * This interface stores XXX\n" + - " * <p/>\n" + - " */\n" + - "public interface X {\n" + - " public static final String HEADER = Headers.HEADER;\n" + - " \n" + - "}"; - - actualResult = replacer.testReplace(s34,s35,s36,options, true); - - assertEquals( - "Replacing interface with interface, saving comments properly", - expectedResult13, - actualResult - ); - } - - public void testClassReplacement3() { - if (true) return; - final String actualResult; - String s37 = "class A { int a = 1; void B() {} int C(char ch) { int z = 1; } int b = 2; }"; - - String s38 = "class 'A { 'T* 'M*('PT* 'PN*) { 'S*; } 'O* }"; - String s39 = "class $A$ { $T$ $M$($PT$ $PN$) { System.out.println(\"$M$\"); $S$; } $O$ }"; - - String expectedResult14 = "class A { int a = 1; void B( ) { System.out.println(\"B\"); } int C(char ch) { System.out.println(\"C\"); int z = 1; } int b = 2;}"; - String expectedResult14_2 = "class A { int a = 1; void B( ) { System.out.println(\"B\"); } int C(char ch) { System.out.println(\"C\"); int z = 1; } int b = 2;}"; - - actualResult = replacer.testReplace(s37,s38,s39,options, true); - - assertEquals( - "Multiple methods replacement", - expectedResult14, - actualResult - ); - } - - public void testClassReplacement4() { - final String actualResult; - String s1 = "class A {\n" + - " int a = 1;\n" + - " int b;\n" + - " private int c = 2;\n" + - "}"; - - String s2 = "@Modifier(\"PackageLocal\") 'Type 'Instance = 'Init?;"; - String s3 = "public $Type$ $Instance$ = $Init$;"; - - String expectedResult = "class A {\n" + - " public int a = 1;\n" + - " public int b ;\n" + - " private int c = 2;\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2,s3,options, true); - - assertEquals( - "Multiple fields replacement", - expectedResult, - actualResult - ); - } - - public void testClassReplacement5() { - final String actualResult; - String s1 = "public class X {\n" + - " /**\n" + - " * zzz\n" + - " */\n" + - " void f() {\n" + - "\n" + - " }\n" + - "}"; - - String s2 = "class 'c {\n" + - " /**\n" + - " * zzz\n" + - " */\n" + - " void f(){}\n" + - "}"; - String s3 = "class $c$ {\n" + - " /**\n" + - " * ppp\n" + - " */\n" + - " void f(){}\n" + - "}"; - - String expectedResult = "public class X {\n" + - " /**\n" + - " * ppp\n" + - " */\n" + - " void f(){}\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2,s3,options, true); - - assertEquals( - "Not preserving comment if it is present", - expectedResult, - actualResult - ); - } - - public void testClassReplacement6() { - String actualResult; - String s1 = "public class X {\n" + - " /**\n" + - " * zzz\n" + - " */\n" + - " private void f(int i) {\n" + - " //s\n" + - " }\n" + - "}"; - String s1_2 = "public class X {\n" + - " /**\n" + - " * zzz\n" + - " */\n" + - " private void f(int i) {\n" + - " int a = 1;\n" + - " //s\n" + - " }\n" + - "}"; - - String s2 = "class 'c {\n" + - " /**\n" + - " * zzz\n" + - " */\n" + - " void f('t 'p){'s+;}\n" + - "}"; - String s3 = "class $c$ {\n" + - " /**\n" + - " * ppp\n" + - " */\n" + - " void f($t$ $p$){$s$;}\n" + - "}"; - - String expectedResult = "public class X {\n" + - " /**\n" + - " * ppp\n" + - " */\n" + - " private void f(int i ){//s\n" + - "}\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2,s3,options); - - assertEquals( - "Correct class replacement", - expectedResult, - actualResult - ); - - String expectedResult2 = "public class X {\n" + - " /**\n" + - " * ppp\n" + - " */\n" + - " private void f(int i ){int a = 1;\n" + - " //s\n" + - "}\n" + - "}"; - - actualResult = replacer.testReplace(s1_2,s2,s3,options); - - assertEquals( - "Correct class replacement, 2", - expectedResult2, - actualResult - ); - } - - public void testClassReplacement7() { - String s1 = "/**\n" + - "* Created by IntelliJ IDEA.\n" + - "* User: cdr\n" + - "* Date: Nov 15, 2005\n" + - "* Time: 4:23:29 PM\n" + - "* To change this template use File | Settings | File Templates.\n" + - "*/\n" + - "public class CC {\n" + - " /** My Comment */ int a = 3; // aaa\n" + - " // bbb\n" + - " long c = 2;\n" + - " void f() {\n" + - " }\n" + - "}"; - String s2 = "/**\n" + - "* Created by IntelliJ IDEA.\n" + - "* User: 'USER\n" + - "* Date: 'DATE\n" + - "* Time: 'TIME\n" + - "* To change this template use File | Settings | File Templates.\n" + - "*/\n" + - "class 'c {\n" + - " 'other*\n" + - "}"; - String s3 = "/**\n" + - "* by: $USER$\n" + - "*/\n" + - "class $c$ {\n" + - " $other$\n" + - "}"; - String expectedResult = "/**\n" + - "* by: cdr\n" + - "*/\n" + - "public class CC {\n" + - " /** My Comment */ int a = 3; // aaa\n" + - "// bbb\n" + - " long c = 2;\n" + - "void f() {\n" + - " }\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2,s3,options,true); - - assertEquals( - "Class with comment replacement", - expectedResult, - actualResult - ); - } - - public void testClassReplacement8() { - String s1 = "public class CC {\n" + - " /** AAA*/ int b = 1; // comment\n" + - "}"; - String s2 = "int b = 1;"; - String s3 = "long c = 2;"; - String expectedResult = "public class CC {\n" + - " /** AAA*/ long c = 2; // comment\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2,s3,options,true); - - assertEquals( - "Class field replacement with simple pattern", - expectedResult, - actualResult - ); - } - - @NotNull - @Override - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("structuralsearch") + "/testData/"; - } - - public void testClassReplacement9() throws IOException { - String s1 = loadFile("before1.java"); - String s2 = "class 'A extends 'TestCaseCass:[regex( .*TestCase ) ] {\n" + - " 'OtherStatement*;\n" + - " public void 'testMethod*:[regex( test.* )] () {\n" + - " }\n" + - " 'OtherStatement2*;\n" + - "}"; - String s3 = "class $A$ extends $TestCaseCass$ {\n" + - " $OtherStatement$;\n" + - " $OtherStatement2$;\n" + - "}"; - String expectedResult = loadFile("after1.java"); - - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s1,s2,s3,options,true); - - assertEquals( - "Class replacement 9", - expectedResult, - actualResult - ); - } - - public void testReplaceReturnWithArrayInitializer() { - String searchIn = "return ( new String[]{CoreVars.CMUAudioPort + \"\"} );"; - String searchFor = "return ( 'A );"; - String replaceBy = "return $A$;"; - String expectedResult = "return new String[]{CoreVars.CMUAudioPort + \"\"};"; - - actualResult = replacer.testReplace(searchIn,searchFor,replaceBy,options); - - assertEquals( - "ReplaceReturnWithArrayInitializer", - expectedResult, - actualResult - ); - } - - public void _testClassReplacement10() throws IOException { - String s1 = loadFile("before2.java"); - String s2 = "class '_Class {\n" + - " '_ReturnType+ '_MethodName+('_ParameterType* '_Parameter*){\n" + - " '_content*;\n" + - " }\n" + - " '_remainingclass*" + - "}"; - String s3 = "class $Class$ {\n" + - " $remainingclass$\n" + - " @Override $ReturnType$ $MethodName$($ParameterType$ $Parameter$){\n" + - " $content$;\n" + - " }\n" + - "}"; - String expectedResult = loadFile("after2.java"); - - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s1,s2,s3,options,true); - - assertEquals( - "Class replacement 10", - expectedResult, - actualResult - ); - } - - public void testCatchReplacement() throws Exception { - String s1 = "try {\n" + - " aaa();\n" + - "} catch(Exception ex) {\n" + - " LOG.assertTrue(false);\n" + - "}"; - String s2 = "{ LOG.assertTrue(false); }"; - String s3 = "{ if (false) LOG.assertTrue(false); }"; - String expectedResult = "try {\n" + - " aaa();\n" + - "} catch (Exception ex) {\n" + - " if (false) LOG.assertTrue(false);\n" + - "}"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s1,s2,s3,options); - options.setToReformatAccordingToStyle(false); - - assertEquals( - "Catch replacement by block", - expectedResult, - actualResult - ); - } - - public void testSavingAccessModifiersDuringClassReplacement() { - String actualResult; - - String s43 = "public @Deprecated class Foo implements Comparable<Foo> {\n int x;\n void m(){}\n }"; - String s44 = "class 'Class implements 'Interface { 'Content* }"; - String s45 = "@MyAnnotation\n" + - "class $Class$ implements $Interface$ {$Content$}"; - String expectedResult16 = "@MyAnnotation public @Deprecated\n" + - "class Foo implements Comparable<Foo> {int x;\n" + - "void m(){}}"; - - actualResult = replacer.testReplace(s43,s44,s45,options, true); - assertEquals( - "Preserving var modifiers and generic information in type during replacement", - expectedResult16, - actualResult - ); - } - - public void testDontRequireSpecialVarsForUnmatchedContent() { - String actualResult; - - String s43 = "public @Deprecated class Foo implements Comparable<Foo> {\n int x;\n void m(){}\n }"; - String s44 = "class 'Class implements 'Interface {}"; - String s45 = "@MyAnnotation\n" + - "class $Class$ implements $Interface$ {}"; - String expectedResult16 = "@MyAnnotation public @Deprecated\n" + - "class Foo implements Comparable<Foo> {int x;\nvoid m(){}}"; - - actualResult = replacer.testReplace(s43,s44,s45,options, true); - assertEquals( - "Preserving class modifiers and generic information in type during replacement", - expectedResult16, - actualResult - ); - } - - public void _testClassReplacement2() { - final String actualResult; - String s40 = "class A {\n" + - " /* special comment*/\n" + - " private List<String> a = new ArrayList();\n" + - " static {\n" + - " int a = 1;" + - " }\n" + - "}"; - String s41 = "class 'Class {\n" + - " 'Stuff2*\n" + - " 'FieldType 'FieldName = 'Init?;\n" + - " static {\n" + - " 'Stmt*;\n" + - " }\n" + - " 'Stuff*\n" + - "}"; - String s42 = "class $Class$ {\n" + - " $Stuff2$\n" + - " $FieldType$ $FieldName$ = build$FieldName$Map();\n" + - " private static $FieldType$ build$FieldName$Map() {\n" + - " $FieldType$ $FieldName$ = $Init$;\n" + - " $Stmt$;\n" + - " return $FieldName$;\n" + - " }\n" + - " $Stuff$\n" + - "}"; - String expectedResult15 = "class A {\n" + - " \n" + - " /* special comment*/\n" + - " private List<String> a = buildaMap();\n" + - " private static List<String> buildaMap() {\n" + - " List<String> a = new ArrayList();\n" + - " int a = 1;\n" + - " return a;\n" + - " }\n" + - " \n" + - "}"; - - actualResult = replacer.testReplace(s40,s41,s42,options, true); - - assertEquals( - "Preserving var modifiers and generic information in type during replacement", - expectedResult15, - actualResult - ); - - String s46 = "class Foo { int xxx; void foo() { assert false; } void yyy() {}}"; - String s47 = "class 'Class { void 'foo:[regex( foo )](); }"; - String s48 = "class $Class$ { void $foo$(int a); }"; - String expectedResult17 = "class Foo { int xxx; void foo(int a) { assert false; } void yyy() {}}"; - - String actualResult2 = replacer.testReplace(s46,s47,s48,options, true); - assertEquals( - "Preserving method bodies", - expectedResult17, - actualResult2 - ); - } - - public void testReplaceExceptions() { - String s1 = "a=a;"; - String s2 = "'a"; - String s3 = "$b$"; - - try { - replacer.testReplace(s1,s2,s3,options); - assertTrue("Undefined replace variable is not checked",false); - } catch(UnsupportedPatternException ex) { - - } - - String s4 = "a=a;"; - String s5 = "a=a;"; - String s6 = "a=a"; - - try { - replacer.testReplace(s4,s5,s6,options); - assertTrue("Undefined no ; in replace",false); - } catch(UnsupportedPatternException ex) { - } - - try { - replacer.testReplace(s4,s6,s5,options); - assertTrue("Undefined no ; in search",false); - } catch(UnsupportedPatternException ex) { - } - } - - public void testActualParameterReplacementInConstructorInvokation() { - String s1 = "filterActions[0] = new Action(TEXT,\n" + - " LifeUtil.getIcon(\"search\")) {\n" + - " void test() {\n" + - " int a = 1;\n" + - " }\n" + - "};"; - String s2 = "LifeUtil.getIcon(\"search\")"; - String s3 = "StdIcons.SEARCH_LIFE"; - String expectedResult = "filterActions[0] = new Action(TEXT,\n" + - " StdIcons.SEARCH_LIFE) {\n" + - " void test() {\n" + - " int a = 1;\n" + - " }\n" + - "};"; - options.setToReformatAccordingToStyle(true); - options.setToShortenFQN(true); - - String actualResult = replacer.testReplace(s1, s2, s3, options); - assertEquals("Replace in anonymous class parameter", expectedResult, actualResult); - options.setToShortenFQN(false); - options.setToReformatAccordingToStyle(false); - } - - public void testRemove() { - String s1 = "class A {\n" + - " /* */\n" + - " void a() {\n" + - " }\n" + - " /*\n" + - " */\n" + - " int b = 1;\n" + - " /*\n" + - " *\n" + - " */\n" + - " class C {}\n" + - " {\n" + - " /* aaa */\n" + - " int a;\n" + - " /* */\n" + - " a = 1;\n" + - " }\n" + - "}"; - String s2 = "/* 'a:[regex( .* )] */"; - String s2_2 = "/* */"; - String s3 = ""; - String expectedResult = "class A {\n" + - " void a() {\n" + - " }\n" + - "\n" + - " int b = 1;\n" + - "\n" + - " class C {\n" + - " }\n" + - "\n" + - " {\n" + - " int a;\n" + - " a = 1;\n" + - " }\n" + - "}"; - options.setToReformatAccordingToStyle(true); - actualResult = replacer.testReplace(s1,s2,s3,options); - options.setToReformatAccordingToStyle(false); - - assertEquals( - "Removing comments", - expectedResult, - actualResult - ); - - String expectedResult2 = "class A {\n" + - " void a() {\n" + - " }\n" + - " /*\n" + - " */\n" + - " int b = 1;\n" + - " /*\n" + - " *\n" + - " */\n" + - " class C {}\n" + - " {\n" + - " /* aaa */\n" + - " int a;\n" + - " a = 1;\n" + - " }\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2_2,s3,options); - - assertEquals( - "Removing comments", - expectedResult2, - actualResult - ); - } - - public void testTryCatchInLoop() throws Exception { - String code = "for (int i = 0; i < MIMEHelper.MIME_MAP.length; i++)\n" + - "{\n" + - " String s = aFileNameWithOutExtention + MIMEHelper.MIME_MAP[i][0][0];\n" + - " try\n" + - " {\n" + - " if (ENABLE_Z107_READING)\n" + - " { in = aFileNameWithOutExtention.getClass().getResourceAsStream(s); }\n" + - " else\n" + - " { data = ResourceHelper.readResource(s); }\n" + - " mime = MIMEHelper.MIME_MAP[i][1][0];\n" + - " break;\n" + - " }\n" + - " catch (final Exception e)\n" + - " { continue; }\n" + - "}"; - String toFind = "try { 'TryStatement*; } catch(Exception 'ExceptionDcl) { 'CatchStatement*; }"; - String replacement = "try { $TryStatement$; }\n" + "catch(Throwable $ExceptionDcl$) { $CatchStatement$; }"; - String expectedResult = "for (int i = 0; i < MIMEHelper.MIME_MAP.length; i++)\n" + - "{\n" + - " String s = aFileNameWithOutExtention + MIMEHelper.MIME_MAP[i][0][0];\n" + - " try { if (ENABLE_Z107_READING)\n" + - " { in = aFileNameWithOutExtention.getClass().getResourceAsStream(s); }\n" + - " else\n" + - " { data = ResourceHelper.readResource(s); }\n" + - " mime = MIMEHelper.MIME_MAP[i][1][0];\n" + - " break; }\n" + - "catch(final Throwable e) { continue; }\n" + - "}"; - - actualResult = replacer.testReplace(code,toFind,replacement,options); - - assertEquals( - "Replacing try/catch in loop", - expectedResult, - actualResult - ); - } - - public void testReformatAndShortenClassRefPerformance() throws IOException { - final String testName = getTestName(false); - final String ext = "java"; - final String message = "Reformat And Shorten Class Ref Performance"; - - options.setToReformatAccordingToStyle(true); - options.setToShortenFQN(true); - - PlatformTestUtil.startPerformanceTest("SSR should work fast", 3500, new ThrowableRunnable() { - public void run() { - doTest(testName, ext, message); - } - } - ).cpuBound().assertTiming(); - - options.setToReformatAccordingToStyle(false); - options.setToShortenFQN(false); - } - - private void doTest(final String testName, final String ext, final String message) { - try { - String source = loadFile(testName + "_source." + ext); - String pattern = loadFile(testName + "_pattern." + ext); - String replacement = loadFile(testName + "_replacement." + ext); - String expected = loadFile(testName + "_result." + ext); - - actualResult = replacer.testReplace(source,pattern,replacement,options); - - assertEquals( - message, - expected, - actualResult - ); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - public void testLeastSurprise() { - String s1 = "@Nullable (a=String.class) @String class Test {\n" + - " void aaa(String t) {\n" + - " String a = String.valueOf(' ');" + - " String2 a2 = String2.valueOf(' ');" + - " }\n" + - "}"; - String s2 = "'String:String"; - String s2_2 = "String"; - String s2_3 = "'String:java\\.lang\\.String"; - String s2_4 = "java.lang.String"; - String replacement = CommonClassNames.JAVA_UTIL_LIST; - String expected = "@Nullable (a=java.util.List.class) @java.util.List class Test {\n" + - " void aaa(java.util.List t) {\n" + - " java.util.List a = java.util.List.valueOf(' ');" + - " String2 a2 = String2.valueOf(' ');" + - " }\n" + - "}"; - - actualResult = replacer.testReplace(s1,s2,replacement,options); - - assertEquals( - expected, - actualResult - ); - - actualResult = replacer.testReplace(s1,s2_2,replacement,options); - - assertEquals( - expected, - actualResult - ); - - actualResult = replacer.testReplace(s1,s2_3,replacement,options); - - assertEquals( - expected, - actualResult - ); - - actualResult = replacer.testReplace(s1,s2_4,replacement,options); - - assertEquals( - expected, - actualResult - ); - } - - public void testLeastSurprise2() { - String s1 = "class B { int s(int a) { a = 1; a = 2; c(a); } }"; - String s2 = "a"; - String replacement = "a2"; - String expected = "class B { int s(int a2) { a2 = 1; a2 = 2; c(a2); } }"; - - actualResult = replacer.testReplace(s1,s2,replacement,options); - - assertEquals( - expected, - actualResult - ); - } - - public void testReplaceTry() { - String s1 = "try {\n" + - " em.persist(p);\n" + - " } catch (PersistenceException e) {\n" + - " // good\n" + - " }"; - String s2 = "try { 'TryStatement; } catch('ExceptionType 'ExceptionDcl) { /* 'CommentContent */ }"; - String replacement = "try { $TryStatement$; } catch($ExceptionType$ $ExceptionDcl$) { _logger.warning(\"$CommentContent$\", $ExceptionDcl$); }"; - String expected = "try { em.persist(p); } catch(PersistenceException e) { _logger.warning(\" good\", e); }"; - - actualResult = replacer.testReplace(s1,s2,replacement,options); - - assertEquals( - expected, - actualResult - ); - } - - public void testReplaceExtraSemicolon() { - String s1 = "try {\n" + - " String[] a = {\"a\"};\n" + - " System.out.println(\"blah\");\n" + - "} finally {\n" + - "}\n"; - String s2 = "try {\n" + " 'statement*;\n" + "} finally {\n" + " \n" + "}"; - String replacement = "$statement$;"; - String expected = "String[] a = {\"a\"};\n" + - " System.out.println(\"blah\");\n"; - - actualResult = replacer.testReplace(s1,s2,replacement,options); - - assertEquals( - expected, - actualResult - ); - - String s1_2 = "try {\n" + - " if (args == null) return ;\n" + - " while(true) return ;\n" + - " System.out.println(\"blah2\");\n" + - "} finally {\n" + - "}"; - String expected_2 = "if (args == null) return ;\n" + - " while(true) return ;\n" + - " System.out.println(\"blah2\");"; - - actualResult = replacer.testReplace(s1_2,s2,replacement,options); - - assertEquals( - expected_2, - actualResult - ); - - String s1_3 = "{\n" + - " try {\n" + - " System.out.println(\"blah1\");\n" + - "\n" + - " System.out.println(\"blah2\");\n" + - " } finally {\n" + - " }\n" + - "}"; - String expected_3 = "{\n" + - " System.out.println(\"blah1\");\n" + - "\n" + - " System.out.println(\"blah2\");\n" + - "}"; - actualResult = replacer.testReplace(s1_3,s2,replacement,options); - - assertEquals( - expected_3, - actualResult - ); - - String s1_4 = "{\n" + - " try {\n" + - " System.out.println(\"blah1\");\n" + - " // indented comment\n" + - " System.out.println(\"blah2\");\n" + - " } finally {\n" + - " }\n" + - "}"; - String expected_4 = "{\n" + - " System.out.println(\"blah1\");\n" + - " // indented comment\n" + - " System.out.println(\"blah2\");\n" + - "}"; - actualResult = replacer.testReplace(s1_4,s2,replacement,options); - - assertEquals( - expected_4, - actualResult - ); - } - - public void _testReplaceFinalModifier() throws Exception { - String s1 = "class Foo {\n" + - " void foo(final int i,final int i2, final int i3) {\n" + - " final int x = 5;\n" + - " }\n" + - "}"; - String s2 = "final '_type 'var = '_init?"; - String s3 = "$type$ $var$ = $init$"; - - String expected = "2 = 1;\nint b = a;\nb2 = 3;"; - - actualResult = replacer.testReplace(s1,s2,s3,options); - - assertEquals( - expected, - actualResult - ); - } - - public void testRemovingRedundancy() throws Exception { - String s1 = "int a = 1;\n" + - "a = 2;\n" + - "int b = a;\n" + - "b2 = 3;"; - String s2 = "int 'a = 'i;\n" + - "'st*;\n" + - "'a = 'c;"; - String s3 = "$st$;\n" + - "$c$ = $i$;"; - - String expected = "2 = 1;\nint b = a;\nb2 = 3;"; - - actualResult = replacer.testReplace(s1,s2,s3,options); - - assertEquals( - expected, - actualResult - ); - - String s2_2 = "int 'a = 'i;\n" + - "'st*;\n" + - "int 'c = 'a;"; - String s3_2 = "$st$;\n" + - "int $c$ = $i$;"; - String expected_2 = "a = 2;\nint b = 1;\nb2 = 3;"; - - actualResult = replacer.testReplace(s1,s2_2,s3_2,options); - - assertEquals( - expected_2, - actualResult - ); - } - - public void testReplaceWithEmptyString() { - String source = "public class Peepers {\n public long serialVersionUID = 1L; \n}"; - String search = "long serialVersionUID = $value$;"; - String replace = ""; - String expectedResult = "public class Peepers { \n}"; - - String actualResult = replacer.testReplace(source, search, replace, options, true); - - assertEquals( - expectedResult, - actualResult - ); - } - - public void testReplaceMultipleFieldsInSingleDeclaration() { - String source = "abstract class MyClass implements java.util.List {\n private String a, b;\n}"; - String search = "class 'Name implements java.util.List {\n 'ClassContent*\n}"; - String replace = "class $Name$ {\n $ClassContent$\n}"; - String expectedResult = "abstract class MyClass {\n private String a,b;\n}"; - - String actualResult = replacer.testReplace(source, search, replace, options, true); - - assertEquals( - expectedResult, - actualResult - ); - } - - public void testReplaceInImplementsList() { - String source = "import java.io.Externalizable;\n" + - "import java.io.Serializable;\n" + - "abstract class MyClass implements Serializable, java.util.List, Externalizable {}"; - String search = "class 'TestCase implements java.util.List, 'others* {\n 'MyClassContent\n}"; - String replace = "class $TestCase$ implements $others$ {\n $MyClassContent$\n}"; - String expectedResult = "import java.io.Externalizable;\n" + - "import java.io.Serializable;\n" + - "abstract class MyClass implements Externalizable,Serializable {\n \n}"; - - String actualResult = replacer.testReplace(source, search, replace, options, true); - assertEquals( - expectedResult, - actualResult - ); - } - - public void testReplaceFieldWithEndOfLineComment() { - String source = "class MyClass {\n" + - " private String b;// comment\n" + - " public void foo() {\n" + - " }\n" + - "}"; - String search = "class 'Class {\n 'Content*\n}"; - String replace = "class $Class$ {\n" + - " void x() {}\n" + - " $Content$\n" + - " void bar() {}\n" + - "}"; - String expectedResult = "class MyClass {\n" + - " void x() {}\n" + - " private String b;// comment\n" + - "public void foo() {\n" + - " }\n" + - " void bar() {}\n" + - "}"; - - String actualResult = replacer.testReplace(source, search, replace, options, true); - assertEquals( - expectedResult, - actualResult - ); - } -}
\ No newline at end of file diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTestCase.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTestCase.java deleted file mode 100644 index 9a9fbb362a63..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralReplaceTestCase.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.openapi.util.io.FileUtilRt; -import com.intellij.openapi.vfs.CharsetToolkit; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; - -import java.io.File; -import java.io.IOException; - -/** - * Created by IntelliJ IDEA. - * User: maxim.mossienko - * Date: Oct 11, 2005 - * Time: 10:10:48 PM - * To change this template use File | Settings | File Templates. - */ -abstract class StructuralReplaceTestCase extends LightQuickFixTestCase { - protected Replacer replacer; - protected ReplaceOptions options; - protected String actualResult; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - StructuralSearchUtil.ourUseUniversalMatchingAlgorithm = false; - - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_4); - - options = new ReplaceOptions(); - options.setMatchOptions(new MatchOptions()); - replacer = new Replacer(getProject(), null); - } - - protected String loadFile(String fileName) throws IOException { - return FileUtilRt.loadFile(new File(getTestDataPath() + FileUtilRt.getExtension(fileName) + "/" + fileName), CharsetToolkit.UTF8, true); - } -} diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java deleted file mode 100644 index a3fecba980df..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java +++ /dev/null @@ -1,2938 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.idea.Bombed; -import com.intellij.openapi.application.PluginPathManager; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.psi.*; -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -/** - * @author Maxim.Mossienko - */ -@SuppressWarnings({"HardCodedStringLiteral"}) -public class StructuralSearchTest extends StructuralSearchTestCase { - private static final String s1 = - "debug(\"In action performed:\"+event);"+ - "project = (Project)event.getDataContext().getData(DataConstants.PROJECT);" + - "CodeEditorManager.getInstance(project).commitAllToPsiFile();" + - "file = (PsiFile) event.getDataContext().getData(\"psi.File\"); " + - "((dialog==null)?" + - " (dialog = new SearchDialog()):" + - " dialog" + - ").show();"; - - private static final String s2 = "((dialog==null)? (dialog = new SearchDialog()): dialog).show();"; - private static final String s3 = "dialog = new SearchDialog()"; - - private static final String s4 = - " do { " + - " pattern = pattern.getNextSibling(); " + - " } " + - " while (pattern!=null && filterLexicalNodes(pattern));"; - - private static final String s5 = - "{ System.out.println();" + - " while(false) { " + - " do { " + - " pattern = pattern.getNextSibling(); " + - " } " + - " while (pattern!=null && filterLexicalNodes(pattern)); " + - " } " + - " do { " + - " pattern = pattern.getNextSibling(); " + - " } while (pattern!=null && filterLexicalNodes(pattern));" + - " { { " + - " do { " + - " pattern = pattern.getNextSibling(); " + - " } while (pattern!=null && filterLexicalNodes(pattern));" + - " } }" + - "}"; - - private static final String s6 = - " do { " + - " pattern.getNextSibling(); " + - " } " + - " while (pattern!=null && filterLexicalNodes(pattern));"; - - private static final String s7 = - " if (true) throw new UnsupportedPatternException(statement.toString());" + - " if (true) { " + - " throw new UnsupportedPatternException(statement.toString());" + - " } "; - - private static final String s8 = - " if (true) { " + - " throw new UnsupportedPatternException(statement.toString());" + - " } "; - - private static final String s9 = " if (true) throw new UnsupportedPatternException(statement.toString());"; - - private static final String s10 = "listener.add(new Runnable() { public void run() {} });"; - private static final String s11 = " new XXX()"; - - private static final String s12 = - "new Runnable() {" + - " public void run() {" + - " matchContext.getSink().matchingFinished();" + - " } " + - " }"; - - private static final String s13 = "new Runnable() {}"; - private static final String s14_1 = "if (true) { aaa(var); }"; - private static final String s14_2 = "if (true) { aaa(var); bbb(var2); }\n if(1==1) { system.out.println('o'); }"; - private static final String s15 = "'T;"; - private static final String s16 = "if('_T) { '_T2; }"; - private static final String s17 = - "token.getText().equals(token2.getText());" + - "token.getText().equals(token2.getText2());" + - "token.a.equals(token2.b);" + - "token.a.equals(token2.a);"; - private static final String s18_1 = "'_T1.'_T2.equals('_T3.'_T2);"; - private static final String s18_2 = "'_T1.'_T2().equals('_T3.'_T2());"; - private static final String s18_3 = "'_T1.'_T2"; - private static final String s19 = "Aaa a = (Aaa)b; Aaa c = (Bbb)d;"; - private static final String s20 = "'_T1 'T2 = ('_T1)'_T3;"; - private static final String s20_2 = "'_T1 '_T2 = ('_T1)'_T3;"; - private static final String s21_1 = "'_T1:Aa* 'T2 = ('_T1)'_T3;"; - private static final String s21_2 = "'_T1:A* 'T2 = ( '_T1:A+ )'_T3;"; - private static final String s21_3 = "'_T1:Aa* 'T2 = ( '_T1:Aa* )'_T3;"; - - private static final String s22 = "Aaa a = (Aaa)b; Bbb c = (Bbb)d;"; - - private static final String s23 = "a[i] = 1; b[a[i]] = f(); if (a[i]==1) return b[c[i]];"; - private static final String s24_1 = "'T['_T2:.*i.* ] = '_T3;"; - private static final String s24_2 = "'T['_T2:.*i.* ]"; - private static final String s25 = "class MatcherImpl { void doMatch(int a) {} }\n" + - "class Matcher { abstract void doMatch(int a);}\n " + - "class Matcher2Impl { void doMatch(int a, int b) {} } "; - private static final String s26 = "class 'T:.*Impl { '_T2 '_T3('_T4 '_T5) {\n\n} } "; - private static final String s27 = "class A {} interface B {}"; - private static final String s28 = "interface 'T {}"; - - private static final String s29 = "class A { void B(int C) {} } class D { void E(double e) {} }"; - private static final String s30 = "class '_ { void '_('_:int '_); } "; - - private static final String s31 = "class A extends B { } class D extends B { } class C extends C {}"; - private static final String s32 = "class '_ extends B { } "; - - private static final String s33 = "class A implements B,C { } class D implements B,D { } class C2 implements C,B {}"; - private static final String s34 = "class '_ implements B,C { } "; - - private static final String s35 = "class A { int b; double c; void d() {} int e() {} } " + - "class A2 { int b; void d() {} }"; - private static final String s36 = "class '_ { double '_; int '_; int '_() {} void '_() {} } "; - - private static final String s37 = "class A { void d() throws B,C,D {} } class A2 { void d() throws B,C {} }"; - private static final String s38 = "class 'T { '_ '_() throws D,C {} } "; - - private static final String s39 = "class A extends B { } class A2 { }"; - private static final String s40 = "class 'T { } "; - - private static final String s41 = "class A extends B { int a = 1; } class B { int[] c= new int[2]; } " + - "class D { double e; } class E { int d; } "; - private static final String s42_1 = "class '_ { '_T '_T2 = '_T3; } "; - private static final String s42_2 = "class '_ { '_T '_T2; } "; - - private static final String s43 = "interface A extends B { int B = 1; } " + - "interface D { public final static double e = 1; } " + - "interface E { final static ind d = 2; } " + - "interface F { } "; - private static final String s44 = "interface '_ { '_T 'T2 = '_T3; } "; - private static final String s45 = "class A extends B { private static final int B = 1; } " + - "class C extends D { int B = 1; }" + - "class E { }"; - - private static final String s46 = "class '_ { final static private '_T 'T2 = '_T3; } "; - private static final String s46_2 = "class '_ { '_T 'T2 = '_T3; } "; - - private static final String s47 = "class C { java.lang.String t; } class B { BufferedString t2;} class A { String p;} "; - private static final String s48 = "class '_ { String '_; }"; - - private static final String s49 = "class C { void a() throws java.lang.RuntimeException {} } class B { BufferedString t2;}"; - private static final String s50 = "class '_ { '_ '_() throws RuntimeException; }"; - - private static final String s51 = "class C extends B { } class B extends A { } class E {}"; - private static final String s52 = "class '_ extends '_ { }"; - - private static final String s53 = "class C { " + - " String a = System.getProperty(\"abcd\"); " + - " static { String s = System.getProperty(a); }" + - " static void b() { String s = System.getProperty(a); }" + - " }"; - private static final String s54 = "System.getProperty('T)"; - - private static final String s55 = " a = b.class; "; - private static final String s56 = "'T.class"; - - private static final String s57 = "{ /** @author Maxim */ class C { " + - "} " + - "class D {" + - "/** @serializable */ private int value; " + - "/** @since 1.4 */ void a() {} "+ - "}" + - "class F { " + - "/** @since 1.4 */ void a() {} "+ - "/** @serializable */ private int value2; " + - "}" + - "class G { /** @param a*/ void a() {} } }"; - private static final String s57_2 = "/** @author Maxim */ class C { " + - "} " + - "class D {" + - "/** @serializable */ private int value; " + - "/** @since 1.4 */ void a() {} "+ - "}" + - "class F { " + - "/** @since 1.4 */ void a() {} "+ - "/** @serializable */ private int value2; " + - "}" + - "class G { /** @param a*/ void a() {} }"; - private static final String s58 = "/** @'T '_T2 */ class '_ { }"; - private static final String s58_2 = "class '_ { /** @serializable '_ */ '_ '_; }"; - private static final String s58_3 = "class '_ { /** @'T 1.4 */ '_ '_() {} }"; - private static final String s58_4 = "/** @'T '_T2 */"; - private static final String s58_5 = "/** @'T '_T2? */"; - - private static final String s59 = "interface A { void B(); }"; - private static final String s60 = "interface '_ { void '_(); }"; - - private static final String s61 = "{ a=b; c=d; return; } { e=f; } {}"; - private static final String s62_1 = "{ 'T*; }"; - private static final String s62_2 = "{ 'T+; }"; - private static final String s62_3 = "{ 'T?; }"; - - private static final String s62_4 = "{ '_*; }"; - private static final String s62_5 = "{ '_+; }"; - private static final String s62_6 = "{ '_?; }"; - - private static final String s63 = " class A { A() {} } class B { public void run() {} }"; - private static final String s63_2 = " class A { A() {} " + - "class B { public void run() {} } " + - "class D { public void run() {} } " + - "} " + - "class C {}"; - private static final String s64 = " class 'T { public void '_T2:run () {} }"; - private static final String s64_2 = "class '_ { class 'T { public void '_T2:run () {} } }"; - - private static final String s65 = " if (A instanceof B) {} else if (B instanceof C) {}"; - private static final String s66 = " '_T instanceof '_T2:B"; - - private static final String s67 = " buf.append((VirtualFile)a);"; - private static final String s68 = " (VirtualFile)'T"; - - private static final String s69 = " System.getProperties(); System.out.println(); java.lang.System.out.println(); some.other.System.out.println();"; - private static final String s70 = " System.out "; - private static final String s70_2 = " java.lang.System.out "; - - private static final String s71 = " class A { " + - "class D { D() { c(); } }" + - "void a() { c(); new MouseListenener() { void b() { c(); } } }" + - " }"; - private static final String s72 = " c(); "; - - private static final String s73 = " class A { int A; static int B=5; public abstract void a(int c); void q() { ind d=7; } }"; - private static final String s74 = " '_Type 'Var = '_Init?; "; - private static final String s75 = "{ /** @class aClass\n @author the author */ class A {}\n" + - " /** */ class B {}\n" + - " /** @class aClass */ class C {} }"; - private static final String s76 = " /** @'_tag+ '_value+ */"; - private static final String s76_2 = " /** @'_tag* '_value* */"; - private static final String s76_3 = " /** @'_tag? '_value? */ class 't {}"; - - private static final String s77 = " new ActionListener() {} "; - private static final String s78 = " class 'T:.*aaa {} "; - - private static final String s79 = " class A { static { int c; } void a() { int b; b=1; }} "; - private static final String s80 = " { '_T 'T3 = '_T2?; '_*; } "; - - private static final String s81 = "class Pair<First,Second> {" + - " <C,F> void a(B<C> b, D<F> e) throws C {" + - " P<Q> r = (S<T>)null;"+ - " Q q = null; "+ - " if (r instanceof S<T>) {}"+ - " } " + - "} class Q { void b() {} } "; - - private static final String s81_2 = "class Double<T> {} class T {} class Single<First extends A & B> {}"; - - private static final String s82 = "class '_<'T+> {}"; - private static final String s82_2 = "'_Expr instanceof '_Type<'_Parameter+>"; - private static final String s82_3 = "( '_Type<'_Parameter+> ) '_Expr"; - private static final String s82_4 = "'_Type<'_Parameter+> 'a = '_Init?;"; - private static final String s82_5 = "class '_ { <'_+> '_Type 'Method('_* '_*); }"; - private static final String s82_6 = "class '_<'_+ extends 'res+> {}"; - private static final String s82_7 = "'Type"; - - private static final String s83 = "/**\n" + - " * @hibernate.class\n" + - " * table=\"CATS\"\n" + - " */\n" + - "public class Cat {\n" + - " private Long id; // identifier\n" + - " private Date birthdate;\n" + - " /**\n" + - " * @hibernate.id\n" + - " * generator-class=\"native\"\n" + - " * column=\"CAT_ID\"\n" + - " */\n" + - " public Long getId() {\n" + - " return id;\n" + - " }\n" + - " private void setId(Long id) {\n" + - " this.id=id;\n" + - " }\n" + - "\n" + - " /**\n" + - " * @hibernate.property\n" + - " * column=\"BIRTH_DATE\"\n" + - " */\n" + - " public Date getBirthdate() {\n" + - " return birthdate;\n" + - " }\n" + - " void setBirthdate(Date date) {\n" + - " birthdate = date;\n" + - " }\n" + - " /**\n" + - " * @hibernate.property\n" + - " * column=\"SEX\"\n" + - " * not-null=\"true\"\n" + - " * update=\"false\"\n" + - " */\n" + - " public char getSex() {\n" + - " return sex;\n" + - " }\n" + - " void setSex(char sex) {\n" + - " this.sex=sex;\n" + - " }\n" + - "}"; - - private static final String s84 = " /**\n" + - " * @hibernate.property\n" + - " * 'Property+\n" + - " */\n"; - - private static final String s84_2 = " /**\n" + - " * @hibernate.property\n" + - " * update=\"fa.se\"\n" + - " */\n"; - - private static final String s85 = "{ int a; a=1; a=1; return a; }"; - private static final String s86 = "'T; 'T;"; - - private static final String s87 = " getSomething(\"1\"); a.call(); "; - private static final String s88 = " '_Instance.'Call('_*); "; - private static final String s88_2 = " 'Call('_*); "; - private static final String s88_3 = " '_Instance?.'Call('_*); "; - private static final String s89 = "{ a = 1; b = 2; c=3; }"; - private static final String s90 = "{ '_T*; '_T2*; }"; - private static final String s90_2 = " { '_T*; '_T2*; '_T3+; } "; - private static final String s90_3 = " { '_T+; '_T2+; '_T3+; '_T4+; } "; - private static final String s90_4 = " { '_T{1,3}; '_T2{2}; } "; - private static final String s90_5 = " { '_T{1}?; '_T2*?; '_T3+?; } "; - private static final String s90_6 = " { '_T{1}?; '_T2{1,2}?; '_T3+?; '_T4+?; } "; - - private static final String s91 = "class a {\n" + - " void b() {\n" + - " int c;\n" + - "\n" + - " c = 1;\n" + - " b();\n" + - " a a1;\n" + - " }\n" + - "}"; - private static final String s92 = "'T:a"; - private static final String s92_2 = "'T:b"; - private static final String s92_3 = "'T:c"; - - private static final String s93 = " class A {" + - "private int field;" + - "public void b() {}" + - "}"; - private static final String s94 = " class '_ {" + - "private void b() {}" + - "}"; - private static final String s94_2 = " class '_ {" + - "public void b() {}" + - "}"; - private static final String s94_3 = " class '_ {" + - "protected int field;" + - "}"; - private static final String s94_4 = " class '_ {" + - "private int field;" + - "}"; - - private static final String s95 = " class Clazz {" + - "private int field;" + - "private int field2;" + - "private int fiel-d2;" + - "}"; - - private static final String s96 = " class '_ {" + - "private int 'T+:field.* ;" + - "}"; - - public void testSearchExpressions() { - assertFalse("subexpr match",findMatchesCount(s2,s3)==0); - assertEquals("search for new ",findMatchesCount(s10,s11),0); - assertEquals("search for anonymous classes",findMatchesCount(s12,s13),1); - // expr in definition initializer - assertEquals( - "expr in def initializer", - 3, - findMatchesCount(s53,s54) - ); - - // a.class expression search - assertEquals( - "a.class pattern", - findMatchesCount(s55,s56), - 1 - ); - - String complexCode = "interface I { void b(); } interface I2 extends I {} class I3 extends I {} " + - "class A implements I2 { void b() {} } class B implements I3 { void b() {}} " + - "I2 a; I3 b; a.b(); b.b(); b.b(); A c; B d; c.b(); d.b(); d.b(); "; - - String exprTypePattern1 = "'t:[exprtype( I2 )].b();"; - String exprTypePattern2 = "'t:[!exprtype( I2 )].b();"; - - String exprTypePattern3 = "'t:[exprtype( *I2 )].b();"; - String exprTypePattern4 = "'t:[!exprtype( *I2 )].b();"; - - assertEquals( - "expr type condition", - findMatchesCount(complexCode,exprTypePattern1), - 1 - ); - - assertEquals( - "expr type condition 2", - 5, - findMatchesCount(complexCode,exprTypePattern2) - ); - - assertEquals( - "expr type condition 3", - findMatchesCount(complexCode,exprTypePattern3), - 2 - ); - - assertEquals( - "expr type condition 4", - findMatchesCount(complexCode,exprTypePattern4), - 4 - ); - - String complexCode2 = "enum X { XXX, YYY }\n class C { static void ordinal() {} void test() { C c; c.ordinal(); c.ordinal(); X.XXX.ordinal(); } }"; - assertEquals( - "expr type condition with enums", - findMatchesCount(complexCode2, "'t:[exprtype( *java\\.lang\\.Enum )].ordinal()"), - 1 - ); - - assertEquals( - "no smart detection of search target", - findMatchesCount("processInheritors(1,2,3,4); processInheritors(1,2,3); processInheritors(1,2,3,4,5,6);","'instance?.processInheritors('_param1{1,6});"), - 3 - ); - - String arrays = "int[] a = new int[20];\n" + - "byte[] b = new byte[30]"; - String arrayPattern = "new int[$a$]"; - assertEquals( - "Improper array search", - 1, - findMatchesCount(arrays,arrayPattern) - ); - - String someCode = "a *= 2; a+=2;"; - String otherCode = "a *= 2;"; - - assertEquals( - "Improper *= 2 search", - 1, - findMatchesCount(someCode,otherCode) - ); - - String s1 = "Thread t = new Thread(\"my thread\",\"my another thread\") {\n" + - " public void run() {\n" + - " // do stuff\n" + - " }\n" + - "}"; - String s2 = "new Thread('args*) { '_Other* }"; - - assertEquals( - "Find inner class parameters", - 2, - findMatchesCount(s1,s2) - ); - - String s3 = "Thread t = new Thread(\"my thread\") {\n" + - " public void run() {\n" + - " // do stuff\n" + - " }\n" + - "};"; - String s4 = "new Thread($args$)"; - - assertEquals( - "Find inner class by new", - 1, - findMatchesCount(s3,s4) - ); - - String s5 = "class A {\n" + - "public static <T> T[] copy(T[] array, Class<T> aClass) {\n" + - " int i = (int)0;\n" + - " int b = (int)0;\n" + - " return (T[])array.clone();\n" + - " }\n" + - "}"; - String s6 = "($T$[])$expr$"; - - assertEquals( - "Find cast to array", - 1, - findMatchesCount(s5,s6) - ); - - String s7 = "import java.math.BigDecimal;\n" + - "\n" + - "public class Prorator {\n" + - " public void prorate(BigDecimal[] array) {\n" + - " // do nothing\n" + - " }\n" + - " public void prorate2(java.math.BigDecimal[] array) {\n" + - " // do nothing\n" + - " }\n" + - " public void prorate(BigDecimal bd) {\n" + - " // do nothing\n" + - " }\n" + - "\n" + - " public static void main(String[] args) {\n" + - " BigDecimal[] something = new BigDecimal[2];\n" + - " java.math.BigDecimal[] something2 = new BigDecimal[2];\n" + - " something[0] = new BigDecimal(1.0);\n" + - " something[1] = new BigDecimal(1.0);\n" + - "\n" + - " Prorator prorator = new Prorator();\n" + - "\n" + - "// ---------------------------------------------------\n" + - "// the line below should've been found, in my opinion.\n" + - "// --------------------------------------------------\n" + - " prorator.prorate(something);\n" + - " prorator.prorate(something2);\n" + - - " prorator.prorate(something[0]);\n" + - " prorator.prorate(something[1]);\n" + - " prorator.prorate(something[0]);\n" + - " }\n" + - "}"; - String s8 = "'_Instance.'_MethodCall:[regex( prorate )]('_Param:[exprtype( BigDecimal\\[\\] )]) "; - - assertEquals( - "Find method call with array for parameter expr type", - 2, - findMatchesCount(s7,s8,true) - ); - - String s13 = "try { } catch(Exception e) { e.printStackTrace(); }"; - String s14 = "'_Instance.'_MethodCall('_Parameter*)"; - - assertEquals( - "Find statement in catch", - 1, - findMatchesCount(s13,s14) - ); - - String s9 = "int a[] = new int[] { 1,2,3,4};\n" + - "int b[] = { 2,3,4,5 };\n" + - "Object[] c = new Object[] { \"\", null};"; - String s10 = "new '_ []{ '_* }"; - String s10_2 = "new int []{ '_* }"; - - assertEquals( - "Find array instatiation", - 3, - findMatchesCount(s9,s10) - ); - - assertEquals( - "Find array instatiation, 2", - 2, - findMatchesCount(s9,s10_2) - ); - } - - public void testLiteral() { - String s = "class A {\n" + - " static String a = 1;\n" + - " static String s = \"aaa\";\n" + - " static String s2;\n" + - "}"; - String s2 = "static String '_FieldName = '_Init?:[!regex( \".*\" )];"; - String s2_2 = "static String '_FieldName = '_Init:[!regex( \".*\" )];"; - - assertEquals( - "Literal", - 2, - findMatchesCount(s,s2) - ); - - assertEquals( - "Literal, 2", - 1, - findMatchesCount(s,s2_2) - ); - } - - public void testCovariantArraySearch() { - String s1 = "String[] argv;"; - String s2 = "String argv;"; - String s3 = "'T[] argv;"; - String s3_2 = "'T:*Object [] argv;"; - - assertEquals( - "Find array types", - 0, - findMatchesCount(s1,s2) - ); - - assertEquals( - "Find array types, 2", - 0, - findMatchesCount(s2,s1) - ); - - assertEquals( - "Find array types, 3", - 0, - findMatchesCount(s2,s3) - ); - - assertEquals( - "Find array types, 3", - 1, - findMatchesCount(s1,s3_2) - ); - - String s11 = "class A {\n" + - " void main(String[] argv);" + - " void main(String argv[]);" + - " void main(String argv);" + - "}"; - String s12 = "'_t:[regex( *Object\\[\\] ) ] '_t2"; - String s12_2 = "'_t:[regex( *Object ) ] '_t2 []"; - String s12_3 = "'_t:[regex( *Object ) ] '_t2"; - - assertEquals( - "Find array covariant types", - 2, - findMatchesCount(s11,s12) - ); - - assertEquals( - "Find array covariant types, 2", - 2, - findMatchesCount(s11,s12_2) - ); - - assertEquals( - "Find array covariant types, 3", - 1, - findMatchesCount(s11,s12_3) - ); - - String source = "class A { String ss[][]; }"; - String target = "String[][] $s$;"; - assertEquals( - "should find multi dimensional c-style array declarations", - 1, - findMatchesCount(source, target) - ); - } - - // @todo support back references (\1 in another reg exp or as fild member) - //private static final String s1002 = " setSSS( instance.getSSS() ); " + - // " setSSS( instance.SSS ); "; - //private static final String s1003 = " 't:set(.+) ( '_.get't_1() ); "; - //private static final String s1003_2 = " 't:set(.+) ( '_.'t_1 ); "; - - public void testSearchStatements() { - assertEquals("statement search",findMatchesCount(s1,s2),1); - assertEquals("several constructions match",findMatchesCount(s5,s4),3); - assertFalse("several constructions 2",(findMatchesCount(s5,s6))!=0); - - assertEquals("several constructions 3",findMatchesCount(s7,s8),2); - assertEquals("several constructions 4",findMatchesCount(s7,s9),2); - - final String s1000 = "{ lastTest = \"search for parameterized pattern\";\n" + - " matches = testMatcher.findMatches(s14_1,s15, options);\n" + - " if (matches.size()!=2 ) return false;\n" + - "lastTest = \"search for parameterized pattern\";\n" + - " matches = testMatcher.findMatches(s14_1,s15, options);\n" + - " if (matches.size()!=2 ) return false; }"; - final String s1001 = "lastTest = '_Descr; " + - " matches = testMatcher.findMatches('_In,'_Pattern, options);\n" + - " if (matches.size()!='_Number ) return false;"; - - assertEquals("several operators 5",findMatchesCount(s1000,s1001),2); - - assertEquals( - "two the same statements search", - findMatchesCount(s85,s86), - 1 - ); - - assertEquals( - "search for simple call", - findMatchesCount(s87,s88), - 1 - ); - - assertEquals( - "search for simple call 2", - findMatchesCount(s87,s88_2), - 1 - ); - - assertEquals( - "search for simple call 3", - findMatchesCount(s87,s88_3), - 2 - ); - - String s10015 = "DocumentListener[] listeners = getCachedListeners();"; - String s10016 = "'_Type 'Var = '_Call();"; - - assertEquals( - "search for definition with init", - 1, - findMatchesCount(s10015,s10016) - ); - - String s10017 = "a = b; b = c; a=a; c=c;"; - String s10018 = "'_a = '_a;"; - - assertEquals( - "search silly assignments", - 2, - findMatchesCount(s10017,s10018) - ); - - String s10019 = "a.b(); a.b(null); a.b(null, 1);"; - String s10020 = "a.b(null);"; - - assertEquals( - "search parameter", - 1, - findMatchesCount(s10019,s10020) - ); - - String s1008 = "int a, b, c, d; int a,b,c; int c,d; int e;"; - String s1009 = "int '_a{3,4};"; - - assertEquals( - "search many declarations", - 2, - findMatchesCount(s1008,s1009) - ); - - String s1 = "super(1,1); call(1,1); call(2,2);"; - String s2 = "super('_t*);"; - - assertEquals( - "search super", - 1, - findMatchesCount(s1,s2) - ); - - String s10021 = "short a = 1;\n" + - "short b = 2;\n" + - "short c = a.b();"; - String s10022 = "short '_a = '_b.b();"; - - assertEquals( - "search def init bug", - 1, - findMatchesCount(s10021,s10022) - ); - - String s10023 = "abstract class A { public abstract short getType(); }\n" + - "A a;\n" + - "switch(a.getType()) {\n" + - " default:\n" + - " return 0;\n" + - "}\n" + - "switch(a.getType()) {\n" + - " case 1:\n" + - " { return 0; }\n" + - "}"; - String s10024 = "switch('_a:[exprtype( short )]) { '_statement*; }"; - assertEquals( - "finding switch", - 2, - findMatchesCount(s10023,s10024) - ); - - String s10025 = "A[] a;\n" + - "A b[];\n" + - "A c;"; - String s10026 = "A[] 'a;"; - String s10026_2 = "A 'a[];"; - - assertEquals( - "array types in dcl", - 2, - findMatchesCount(s10025,s10026) - ); - - assertEquals( - "array types in dcl 2", - 2, - findMatchesCount(s10025,s10026_2) - ); - - String s10027 = "try { a(); } catch(Exception ex) {}\n" + - "try { a(); } finally {}\n" + - "try { a(); } catch(Exception ex) {} finally {} \n"; - String s10028 = "try { a(); } finally {}\n"; - assertEquals( - "finally matching", - 2, - findMatchesCount(s10027,s10028) - ); - - String s10029 = "for(String a:b) { System.out.println(a); }"; - String s10030 = "for(String a:b) { '_a; }"; - assertEquals( - "for each matching", - 1, - findMatchesCount(s10029,s10030) - ); - - String s10031 = "try { a(); } catch(Exception ex) {} catch(Error error) { 1=1; }\n" + - "try { a(); } catch(Exception ex) {}"; - String s10032 = "try { a(); } catch('_Type+ 'Arg+) { 'Statements*; }\n"; - assertEquals( - "finally matching", - 2, - findMatchesCount(s10031,s10032) - ); - - String s10033 = "return x;\n" + - "return !x;\n" + - "return (x);\n" + - "return (x);\n" + - "return !(x);"; - String s10034 = "return ('a);"; - assertEquals("Find statement with parenthesized expr",2,findMatchesCount(s10033,s10034)); - } - - public void testSearchClass() { - // no modifier list in interface vars - assertEquals( - "no modifier for interface vars", - findMatchesCount(s43,s44), - 3 - ); - - // different order of access modifiers - assertEquals( - "different order of access modifiers", - findMatchesCount(s45,s46), - 1 - ); - - // no access modifiers - assertEquals( - "no access modifier", - findMatchesCount(s45,s46_2), - 2 - ); - - // type could differ with package - assertEquals( - "type differs with package", - findMatchesCount(s47,s48), - 2 - ); - - // reference element could differ in package - assertEquals( - "reference could differ in package", - findMatchesCount(s49,s50), - 1 - ); - - String s51 = "class C extends java.awt.List {} class A extends java.util.List {} class B extends java.awt.List {} "; - String s52 = "class 'B extends '_C:java\\.awt\\.List {}"; - - assertEquals( - "reference could differ in package 2", - findMatchesCount(s51,s52), - 2 - ); - - assertEquals( - "method access modifier", - findMatchesCount(s93,s94), - 0 - ); - - assertEquals( - "method access modifier 2", - findMatchesCount(s93,s94_2), - 1 - ); - - assertEquals( - "field access modifier", - findMatchesCount(s93,s94_3), - 0 - ); - - assertEquals( - "field access modifier 2", - findMatchesCount(s93,s94_4), - 1 - ); - - final String s127 = "class a { void b() { new c() {}; } }"; - final String s128 = "class 't {}"; - assertEquals( - "class finds anonymous class", - findMatchesCount(s127,s128), - 2 - ); - - final String s129 = "class a { public void run() {} }\n" + - "class a2 { public void run() { run(); } }\n" + - "class a3 { public void run() { run(); } }\n" + - "class a4 { public void run(); }"; - - final String s130 = "class 'a { public void run() {} }"; - final String s130_2 = "class 'a { public void run() { '_statement; } }"; - final String s130_3 = "class 'a { public void run(); }"; - - assertEquals( - "empty method finds empty method only", - findMatchesCount(s129,s130), - 1 - ); - - assertEquals( - "nonempty method finds nonempty method", - findMatchesCount(s129,s130_2), - 2 - ); - - assertEquals( - "nonempty method finds nonempty method", - findMatchesCount(s129,s130_3), - 4 - ); - - final String s133 = "class S {\n" + - "void cc() {\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " f();\n" + - " }\n" + - " private void f() {\n" + - " //To change body of created methods use File | Settings | File Templates.\n" + - " }\n" + - " };\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " f();\n" + - " }\n" + - " private void g() {\n" + - " //To change body of created methods use File | Settings | File Templates.\n" + - " }\n" + - " };\n" + - " new Runnable() {\n" + - " public void run() {\n" + - " f();\n" + - " }\n" + - " };\n" + - " }\n" + - " private void f() {\n" + - " //To change body of created methods use File | Settings | File Templates.\n" + - " }\n" + - "} "; - final String s134 = "new Runnable() {\n" + - " public void run() {\n" + - " '_f ();\n" + - " }\n" + - " private void '_f ();\n" + - " }"; - assertEquals( - "complex expr matching", - 1, - findMatchesCount(s133,s134) - ); - - final String s135 = "abstract class My {\n" + - " abstract void f();\n" + - "}\n" + - "abstract class My2 {\n" + - " abstract void f();\n" + - " void fg() {}\n" + - "}"; - final String s136 = "class 'm {\n" + - " void f();\n" + - " '_type '_method{0,0} ('_paramtype* '_paramname* );\n" + - "}"; - assertEquals( - "reject method with 0 max occurence", - findMatchesCount(s135,s136), - 1 - ); - - final String s137 = "abstract class My {\n" + - " int a;\n" + - "}\n" + - "abstract class My2 {\n" + - " Project b;\n" + - "}" + - "abstract class My3 {\n" + - " Class clazz;"+ - " Project b = null;\n" + - "}" + - "abstract class My {\n" + - " int a = 1;\n" + - "}\n"; - final String s138 = "class 'm {\n" + - " Project '_f{0,0} = '_t?;\n" + - "}"; - assertEquals( - "reject field with 0 max occurence", - findMatchesCount(s137,s138), - 2 - ); - - final String s139 = "class My { boolean equals(Object o); int hashCode(); }"; - final String s139_2 = "class My { boolean equals(Object o); }"; - final String s140 = "class 'A { boolean equals(Object '_o ); int '_hashCode{0,0}:hashCode (); }"; - - assertEquals( - "reject method with constraint", - findMatchesCount(s139,s140), - 0 - ); - - assertEquals( - "reject field with 0 max occurence", - findMatchesCount(s139_2,s140), - 1 - ); - - final String s141 = "class A { static { a = 10 } }\n" + - "class B { { a = 10; } }\n" + - "class C { { a = 10; } }"; - final String s142 = "class '_ { static { a = 10; } } "; - assertEquals( - "static block search", - findMatchesCount(s141,s142), - 1 - ); - } - - public void testParameterlessContructorSearch() { - final String s143 = "class A { A() {} };\n" + - "class B { B(int a) {} };\n" + - "class C { C() {} C(int a) {} };\n" + - "class D {}\n" + - "class E {}"; - final String s144 = "class '_a { '_d{0,0}:[ script( \"__context__.constructor\" ) ]('_b+ '_c+); }"; - assertEquals( - "parameterless contructor search", - 3, - findMatchesCount(s143,s144) - ); - } - - public void testCheckScriptValidation() { - final String s1 = ""; - final String s2 = "'_b:[script( \"^^^\" )]"; - - try { - final int count = findMatchesCount(s1, s2); - assertFalse("Validation does not work", true); - } catch (MalformedPatternException ex) {} - } - - //public void testRelationBetweenVars() { - // final String s1 = "public class Foo {\n" + - // " public static final Logger log = Logger.getInstance(Foo.class);\n" + - // " public static final Logger log2 = Logger.getInstance(Foo2.class);\n" + - // " public static final Logger log3 = Logger.getInstance(Foo2.class);\n" + - // "}"; - // final String s2 = "class '_a { static Logger 'log+ = Logger.getInstance('_b:[script( \"_a != _b\" )].class); }"; - // assertEquals( - // "relation between vars in script", - // 2, - // findMatchesCount(s1,s2) - // ); - //} - - public void testExprTypeWithObject() { - String s1 = "import java.util.*;\n" + - "class A {\n" + - " void b() {\n" + - " Map map = new HashMap();" + - " class AppPreferences {}\n" + - " String key = \"key\";\n" + - " AppPreferences value = new AppPreferences();\n" + - " map.put(key, value );\n" + - " map.put(value, value );\n" + - " map.put(\"key\", value );\n" + - " map.put(\"key\", new AppPreferences());\n" + - " }\n" + - "}"; - String s2 = "'_map:[exprtype( *java\\.util\\.Map )].put('_key:[ exprtype( *Object ) ], '_value:[ exprtype( *AppPreferences ) ]);"; - - assertEquals( - "expr type with object", - 4, - findMatchesCount(s1,s2,true) - ); - } - - public void testInterfaceImplementationsSearch() { - String in = "class A implements Cloneable {\n" + - " \n" + - " }\n" + - " \n" + - " class B implements Serializable {\n" + - " \n" + - " }\n" + - " \n" + - " class C implements Cloneable,Serializable {\n" + - " \n" + - " }\n" + - " class C2 implements Serializable,Cloneable {\n" + - " \n" + - " }\n" + - " \n" + - " class E extends B implements Cloneable {\n" + - " \n" + - " }\n" + - " \n" + - " class F extends A implements Serializable {\n" + - " \n" + - " }\n" + - " \n" + - " class D extends C {\n" + - " \n" + - " }"; - String what = "class 'A implements '_B:*Serializable , '_C:*Cloneable {}"; - assertEquals( - "search interface within hierarchy", - 5, - findMatchesCount(in, what) - ); - } - - public void testSearchBacktracking() { - assertEquals( - "backtracking greedy regexp", - findMatchesCount(s89,s90), - 1 - ); - - assertEquals( - "backtracking greedy regexp 2", - findMatchesCount(s89,s90_2), - 1 - ); - - assertEquals( - "backtracking greedy regexp 3", - findMatchesCount(s89,s90_3), - 0 - ); - - assertEquals( - "counted regexp (with back tracking)", - findMatchesCount(s89,s90_4), - 1 - ); - - assertEquals( - "nongreedy regexp (counted, with back tracking)", - findMatchesCount(s89,s90_5), - 1 - ); - - assertEquals( - "nongreedy regexp (counted, with back tracking) 2", - findMatchesCount(s89,s90_6), - 0 - ); - - String s1000 = "class A {\n" + - " void _() {}\n" + - " void a(String in, String pattern) {}\n" + - " }"; - String s1001 = "class '_Class { \n" + - " '_ReturnType+ 'MethodName+ ('_ParameterType* '_Parameter* );\n" + - "}"; - assertEquals( - "handling of no match", - findMatchesCount(s1000,s1001), - 2 - ); - } - - public void testSearchSymbol() { - final String s131 = "a.b(); c.d = 1; "; - final String s132 = "'T:b|d"; - - assertEquals( - "symbol match", - 2, - findMatchesCount(s131,s132) - ); - - final String s129 = "A a = new A();"; - final String s130 = "'Sym:A"; - - options.setCaseSensitiveMatch(true); - assertEquals( - "case sensitive match", - findMatchesCount(s129,s130), - 2 - ); - - options.setDistinct(true); - assertEquals( - "case sensitive disitinct match", - findMatchesCount(s129,s130), - 1 - ); - - options.setDistinct(false); - - final String s133 = "class C { int a; int A() { a = 1; }} void c(int a) { a = 2; }"; - final String s133_2 = "class C { int a() {} int A() { a(1); }}"; - final String s134 = "a"; - - List<MatchResult> results = findMatches(s133, s134, true, StdFileTypes.JAVA); - assertEquals( - "find sym finds declaration", - 4, results.size() - ); - - assertEquals( - "find sym finds declaration", - 2, findMatchesCount(s133_2, s134, true) - ); - } - - public void testSearchGenerics() { - assertEquals( - "parameterized class match", - findMatchesCount(s81,s82), - 2 - ); - - assertEquals( - "parameterized instanceof match", - findMatchesCount(s81,s82_2), - 1 - ); - - assertEquals( - "parameterized cast match", - findMatchesCount(s81,s82_3), - 1 - ); - - assertEquals( - "parameterized definition match", - findMatchesCount(s81,s82_4), - 3 - ); - - assertEquals( - "parameterized method match", - findMatchesCount(s81,s82_5), - 1 - ); - - assertEquals( - "parameterized constraint match", - findMatchesCount(s81_2,s82_6), - 2 - ); - - assertEquals( - "symbol matches parameterization", - findMatchesCount(s81,s82_7), - 29 - ); - - assertEquals( - "symbol matches parameterization 2", - findMatchesCount(s81_2,s82_7), - 7 - ); - - String s81_3 = " class A {\n" + - " public static <T> Collection<T> unmodifiableCollection(int c) {\n" + - " return new d<T>(c);\n" + - " }\n" + - " static class d<E> implements Collection<E>, Serializable {\n" + - " public <T> T[] toArray(T[] a) {return c.toArray(a);}\n" + - " }\n" + - "}"; - assertEquals( - "typed symbol symbol", - findMatchesCount(s81_3,s82_5), - 2 - ); - - String s81_4="class A<B> { \n" + - " static <C> void c(D<E> f) throws R<S> {\n" + - " if ( f instanceof G<H>) {\n" + - " ((I<G<K>>)l).a();\n" + - " throw new P<Q>();" + - " }\n" + - " }\n" + - "} " + - "class C {\n" + - " void d(E f) throws Q {\n" + - " if (g instanceof H) { a.c(); b.d(new A() {}); throw new Exception(((I)k)); }"+ - " }\n" + - "}"; - String s82_8 = "'T<'_Subst+>"; - assertEquals( - "typed symbol", - findMatchesCount(s81_4,s82_8), - 6 - ); - - String s81_5 = "class A { HashMap<String, Integer> variable = new HashMap<String, Integer>(\"aaa\");}"; - String s82_9 = "'_Type<'_GType, '_GType2> '_instance = new '_Type<'_GType, '_GType2>('_Param);"; - assertEquals( - "generic vars in new", - findMatchesCount(s81_5,s82_9), - 1 - ); - String source1 = "class Comparator<T> { private Comparator<String> c; private Comparator d; }"; - String target1 = "java.util.Comparator 'a;"; - assertEquals( - "qualified type should not match 1", - 0, - findMatchesCount(source1, target1) - ); - - String target2 = "java.util.Comparator<String> 'a;"; - assertEquals( - "qualified type should not match 2", - 0, - findMatchesCount(source1, target2) - ); - - // @todo typed vars constrains (super), - // @todo generic method invocation - - //String s83 = "class A {} List<A> a; List b;"; - //String s84 = "'a:List 'c;"; - //String s84_2 = "'a:List\\<'_\\> 'c;"; - //String s84_3 = "'a:List(?>\\<'_\\>) 'c;"; - // - //assertEquals( - // "finding list", - // findMatchesCount(s83,s84), - // 2 - //); - // - //assertEquals( - // "finding list 2", - // findMatchesCount(s83,s84_2), - // 1 - //); - // - //assertEquals( - // "finding list 3", - // findMatchesCount(s83,s84_3), - // 1 - //); - } - - public void testSearchSubstitutions() { - // searching for parameterized pattern - assertEquals("search for parameterized pattern",findMatchesCount(s14_1,s15),2); - - assertEquals("search for parameterized pattern 2",findMatchesCount(s14_2,s15),5); - - options.setRecursiveSearch(false); - - assertEquals("search for parameterized pattern-non-recursive",findMatchesCount(s14_1,s15),1); - - assertEquals("search for parameterized pattern 2-non-recursive",findMatchesCount(s14_2,s15),2); - - // typed vars with arrays - assertEquals("typed pattern with array 2-non-recursive",findMatchesCount(s23,s24_2),4); - - options.setRecursiveSearch(true); - - // searching for parameterized pattern - assertEquals("search for parameterized pattern 3",findMatchesCount(s14_2,s16),1); - - // searching for parameterized pattern in complex expr (with field selection) - assertEquals("search for parameterized pattern in field selection",findMatchesCount(s17,s18_1),1); - - // searching for parameterized pattern in complex expr (with method call) - assertEquals("search for parameterized pattern with method call",findMatchesCount(s17,s18_2),1); - - // searching for parameterized pattern in complex expr (with method call) - assertEquals("search for parameterized pattern with method call ep.2",findMatchesCount(s17,s18_3),4); - - // searching for parameterized pattern in definition with initializer - assertEquals("search for same var constraint",findMatchesCount(s19,s20),1); - - // searching for semi anonymous parameterized pattern in definition with initializer - assertEquals("search for same var constraint for semi anonymous typed vars",findMatchesCount(s19,s20_2),1); - - // support for type var constraint - assertEquals("search for typed var constraint",findMatchesCount(s22,s21_1),1); - - // noncompatible same typed var constraints - try { - findMatchesCount(s22,s21_2); - assertFalse("search for noncompatible typed var constraint",false); - } catch(MalformedPatternException e) { - } - - // compatible same typed var constraints - assertEquals("search for same typed var constraint",findMatchesCount(s22,s21_3),1); - - // typed var with instanceof - assertEquals("typed instanceof",findMatchesCount(s65,s66),1); - - // typed vars with arrays - assertEquals("typed pattern with array",findMatchesCount(s23,s24_1),2); - - // typed vars with arrays - assertEquals("typed pattern with array 2",findMatchesCount(s23,s24_2),6); - - // typed vars in class name, method name, its return type, parameter type and name - assertEquals("typed pattern in class name, method name, return type, parameter type and name",findMatchesCount(s25,s26),1); - - assertEquals( - "finding interface", - findMatchesCount(s27,s28), - 1 - ); - - // finding anonymous type vars - assertEquals( - "anonymous typed vars", - findMatchesCount(s29,s30), - 1 - ); - - // finding descedants - assertEquals( - "finding class descendants", - findMatchesCount(s31,s32), - 2 - ); - - // finding interface implementation - assertEquals( - "interface implementation", - findMatchesCount(s33,s34), - 2 - ); - - // different order of fields and methods - assertEquals( - "different order of fields and methods", - findMatchesCount(s35,s36), - 1 - ); - - // different order of exceptions in throws - assertEquals( - "differend order in throws", - findMatchesCount(s37,s38), - 1 - ); - - // class pattern without extends matches pattern with extends - assertEquals( - "match of class without extends to class with it", - findMatchesCount(s39,s40), - 2 - ); - - // class pattern without extends matches pattern with extends - assertEquals( - "match of class without extends to class with it, ep. 2", - findMatchesCount(s41,s42_1), - 2 - ); - - // class pattern without extends matches pattern with extends - assertEquals( - "match of class without extends to class with it, ep 3", - findMatchesCount(s41,s42_2), - 2 - ); - - // typed reference element - assertEquals( - "typed reference element", - findMatchesCount(s51,s52), - 2 - ); - - // empty name of type var - assertEquals( - "empty name for typed var", - findMatchesCount(s59,s60), - 1 - ); - - // comparing method with constructor - assertEquals( - "comparing method with constructor", - findMatchesCount(s63,s64), - 1 - ); - - // comparing method with constructor - assertEquals( - "finding nested class", - findMatchesCount(s63_2,s64), - 2 - ); - - // comparing method with constructor - assertEquals( - "finded nested class by special pattern", - findMatchesCount(s63_2,s64_2), - 1 - ); - - assertEquals( - "* regexp for typed var", - findMatchesCount(s61,s62_1), - 5 - ); - - assertEquals( - "+ regexp for typed var", - findMatchesCount(s61,s62_2), - 4 - ); - - assertEquals( - "? regexp for typed var", - findMatchesCount(s61,s62_3), - 2 - ); - - assertEquals( - "cast in method parameters", - findMatchesCount(s67,s68), - 1 - ); - - assertEquals( - "searching for static field in static call", - 2, - findMatchesCount(s69,s70) - ); - - assertEquals( - "searching for static field in static call, 2", - 2, - findMatchesCount(s69,s70_2) - ); - - assertEquals( - "* regexp for anonymous typed var", - findMatchesCount(s61,s62_4), - 3 - ); - - assertEquals( - "+ regexp for anonymous typed var", - findMatchesCount(s61,s62_5), - 2 - ); - - assertEquals( - "? regexp for anonymous typed var", - findMatchesCount(s61,s62_6), - 2 - ); - - assertEquals( - "statement inside anonymous class", - findMatchesCount(s71,s72), - 3 - ); - - assertEquals( - "clever regexp match", - findMatchesCount(s91,s92), - 2 - ); - - assertEquals( - "clever regexp match 2", - findMatchesCount(s91,s92_2), - 2 - ); - - assertEquals( - "clever regexp match 3", - findMatchesCount(s91,s92_3), - 2 - ); - } - - public void testSearchJavaDoc() { - // javadoc comment in class - assertEquals( - "java doc comment in class", - 1, - findMatchesCount(s57,s58) - ); - - assertEquals( - "java doc comment in class in file", - 1, - findMatchesCount(s57_2,s58,true) - ); - - // javadoc comment for field - assertEquals( - "javadoc comment for field", - 2, - findMatchesCount(s57, s58_2) - ); - - // javadoc comment for method - assertEquals( - "javadoc comment for method", - 3, - findMatchesCount(s57, s58_3) - ); - - // just javadoc comment search - assertEquals( - "just javadoc comment search", - 4, - findMatchesCount(s57,s58_4) - ); - - assertEquals( - "XDoclet metadata", - 2, - findMatchesCount(s83,s84) - ); - - assertEquals( - "XDoclet metadata 2", - 1, - findMatchesCount(s83,s84_2) - ); - - assertEquals( - "optional tag value match", - 6, - findMatchesCount(s57, s58_5) - ); - - assertEquals( - "multiple tags match +", - 2, - findMatchesCount(s75,s76) - ); - - assertEquals( - "multiple tags match *", - 3, - findMatchesCount(s75, s76_2) - ); - - assertEquals( - "multiple tags match ?", - 3, - findMatchesCount(s75, s76_3) - ); - - } - - public void testNamedPatterns() { - String s133 = "class String1 implements java.io.Serializable { " + - "private static final long serialVersionUID = -6849794470754667710L;" + - "private static final ObjectStreamField[] serialPersistentFields = new ObjectStreamField[0];" + - "}" + - "class StringBuilder1 implements java.io.Serializable {" + - " private void writeObject(java.io.ObjectOutputStream s)\n" + - " throws java.io.IOException {\n" + - " s.defaultWriteObject();\n" + - " }" + - "private void readObject(java.io.ObjectInputStream s)\n" + - " throws java.io.IOException, ClassNotFoundException {\n" + - " s.defaultReadObject();\n" + - " }" + - " static final long serialVersionUID = 4383685877147921099L;" + - "}"; - String s134 = "class '_ implements '_:*Serializable {\n" + - " static final long 'VersionField?:serialVersionUID = '_?;\n" + - " private static final ObjectStreamField[] '_?:serialPersistentFields = '_?; \n" + - " private void '_SerializationWriteHandler?:writeObject (ObjectOutputStream s) throws IOException;\n" + - " private void '_SerializationReadHandler?:readObject (ObjectInputStream s) throws IOException, ClassNotFoundException;\n" + - " Object '_SpecialSerializationReadHandler?:readResolve () throws ObjectStreamException;" + - " Object '_SpecialSerializationWriteHandler?:writeReplace () throws ObjectStreamException;" + - "}"; - - assertEquals( - "serialization match", - findMatchesCount(s133,s134), - 2 - ); - - String s135 = "class SimpleStudentEventActionImpl extends Action { " + - " public ActionForward execute(ActionMapping mapping,\n" + - " ActionForm _form,\n" + - " HttpServletRequest _request,\n" + - " HttpServletResponse _response)" + - " throws Exception {}" + - "} " + - "public class DoEnrollStudent extends SimpleStudentEventActionImpl { }" + - "public class DoCancelStudent extends SimpleStudentEventActionImpl { }"; - String s136 = "public class 'StrutsActionClass extends '_*:Action {" + - " public ActionForward '_AnActionMethod:*execute (ActionMapping '_,\n" + - " ActionForm '_,\n" + - " HttpServletRequest '_,\n" + - " HttpServletResponse '_);" + - "}"; - - assertEquals( - "Struts actions", - findMatchesCount(s135,s136), - 2 - ); - - final String s123 = "class NodeFilter {} public class MethodFilter extends NodeFilter {\n" + - " private MethodFilter() {}\n" + - "\n" + - " public static NodeFilter getInstance() {\n" + - " if (instance==null) instance = new MethodFilter();\n" + - " return instance;\n" + - " }\n" + - " private static NodeFilter instance;\n" + - "}"; - final String s124 = "class 'Class {\n" + - " private 'Class('_* '_*) {\n" + - " '_*;\n" + - " }\n" + - " private static '_Class2:* '_Instance;\n" + - " static '_Class2:* '_GetInstance() {\n" + - " '_*;\n" + - " return '_Instance;\n" + - " }\n" + - "}"; - - assertEquals( - "singleton search", - findMatchesCount(s123,s124), - 1 - ); - - String s1111 = "if (true) { a=1; b=1; } else { a=1; }\n" + - "if(true) { a=1; } else { a=1; b=1; }\n" + - "if(true) { a=1; b=2; } else { a = 1; b=2; }"; - String s1112 = "if (true) { '_a{1,2}; } else { '_a; }"; - - assertEquals( - "same multiple name pattern", - findMatchesCount(s1111,s1112), - 1 - ); - } - - public void testHierarchy() { - final String s105 = "class B {} class A extends B { }"; - final String s106 = "class '_ extends '_:[ref('T)] {}"; - assertEquals( - "extends match", - findMatchesCount(s105,s106), - 1 - ); - - final String s107 = "interface IA {} interface IB extends IA { } interface IC extends IB {} interface ID extends IC {}" + - "class A implements IA {} class B extends A { } class C extends B implements IC {} class D extends C {}"; - final String s108 = "class '_ extends 'Type:+A {}"; - final String s108_2 = "class '_ implements 'Type:+IA {}"; - - assertEquals( - "extends navigation match", - findMatchesCount(s107,s108), - 2 - ); - - assertEquals( - "implements navigation match", - 3, - findMatchesCount(s107,s108_2) - ); - - final String s109 = "interface I {} interface I2 extends I {} class A implements I2 {} class B extends A { } class C extends B {} class D { void e() { C c; B b; A a;} }"; - final String s110 = "'_:*A '_;"; - final String s110_2 = "'_:*I '_;"; - final String s110_3 = "'_:*[regex( I ) && ref('T)] '_;"; - final String s110_4 = "'_:*[regex( I ) && ref2('T)] '_;"; - assertEquals( - "extends navigation match in definition", - findMatchesCount(s109,s110), - 3 - ); - - assertEquals( - "implements navigation match in definition 2", - findMatchesCount(s109,s110_2), - 3 - ); - - assertEquals( - "implements navigation match in definition 2 with nested conditions", - findMatchesCount(s109,s110_3), - 1 - ); - - try { - findMatchesCount(s109,s110_4); - assertFalse("implements navigation match in definition 2 with nested conditions - incorrect cond",false); - } catch(UnsupportedPatternException ex) {} - - final String s111 = "interface E {} class A implements E {} class B extends A { int f = 0; } class C extends B {} class D { void e() { C c; B b; A a;} }"; - final String s112 = "'_"; - assertEquals( - "symbol match", - findMatchesCount(s111,s112), - 17 - ); - - final String s113 = "class B {int c; void d() {} } int a; B b; a = 1; b.d(); ++a; int c=a; System.out.println(a); " + - "b.c = 1; System.out.println(b.c); b.c++;"; - final String s114 = "'_:[read]"; - final String s114_2 = "'_:[write]"; - assertEquals( - "read symbol match", - findMatchesCount(s113,s114), - 11 - ); - - assertEquals( - "write symbol match", - findMatchesCount(s113,s114_2), - 5 - ); - - final String s115 = "class B {} public class C {}"; - final String s116 = "public class '_ {}"; - assertEquals( - "public modifier for class", - findMatchesCount(s115,s116), - 1 - ); - - final String s117 = "class A { int b; void c() { int e; b=1; this.b=1; e=5; " + - "System.out.println(e); " + - "System.out.println(b); System.out.println(this.b);} }"; - final String s118 = "this.'Field"; - final String s118_2 = "this.'Field:[read]"; - final String s118_3 = "this.'Field:[write]"; - - assertEquals( - "fields of class", - 4, - findMatchesCount(s117,s118) - ); - - assertEquals( - "fields of class read", - findMatchesCount(s117,s118_2), - 2 - ); - - assertEquals( - "fields of class written", - findMatchesCount(s117,s118_3), - 2 - ); - - final String s119 = "try { a.b(); } catch(IOException e) { c(); } catch(Exception ex) { d(); }"; - final String s120 = "try { '_; } catch('_ '_) { '_; }"; - final String s120_2 = "try { '_; } catch(Throwable '_) { '_; }"; - assertEquals( - "catches loose matching", - findMatchesCount(s119,s120), - 1 - ); - - assertEquals( - "catches loose matching 2", - findMatchesCount(s119,s120_2), - 0 - ); - - final String s121 = "class A { private int a; class Inner {} } " + - "class B extends A { private int a; class Inner2 {} }"; - final String s122 = "class '_ { int '_:* ; }"; - final String s122_2 = "class '_ { int '_:+hashCode (); }"; - final String s122_3 = "class '_ { class '_:* {} }"; - assertEquals( - "hierarchical matching", - findMatchesCount(s121,s122), - 2 - ); - - assertEquals( - "hierarchical matching 2", - findMatchesCount(s121,s122_2), - 4 - ); - - assertEquals( - "hierarchical matching 3", - findMatchesCount(s121,s122_3), - 2 - ); - } - - public void testSearchInCommentsAndLiterals() { - String s1 = "{" + - "// This is some comment\n" + - "/* This is another\n comment*/\n" + - "// Some garbage\n"+ - "/** And now third comment*/\n" + - "/** Some garbage*/ }"; - String s2 = "// 'Comment:[regex( .*(?:comment).* )]"; - String s3 = "/** 'Comment:[regex( .*(?:comment).* )] */"; - String s2_2 = "/* 'Comment:[regex( .*(?:comment).* )] */"; - - assertEquals( - "Comment matching", - findMatchesCount(s1,s2), - 3 - ); - - assertEquals( - "Comment matching, 2", - 3, - findMatchesCount(s1,s2_2) - ); - - assertEquals( - "Java doc matching", - findMatchesCount(s1,s3), - 1 - ); - - String s4 = "\"'test\", \"another test\", \"garbage\""; - String s5 = "\"'test:[regex( .*test.* )]\""; - String s6 = "\"''test\""; - - assertEquals( - "Literal content", - findMatchesCount(s4,s5), - 2 - ); - - assertEquals( - "Literal content with escaping", - findMatchesCount(s4,s6), - 1 - ); - - String s7 = "\"aaa\""; - String s8 = "\"'test:[regex( aaa )]\""; - - assertEquals( - "Simple literal content", - findMatchesCount(s7,s8), - 1 - ); - - String s9 = "\" aaa \" \" bbb \" \" ccc ccc aaa\""; - String s10 = "\"'test:[regexw( aaa|ccc )]\""; - String s11 = "\"'test:[regexw( bbb )]\""; - - assertEquals( - "Whole word literal content with alternations", - findMatchesCount(s9,s10), - 2 - ); - - assertEquals( - "Whole word literal content", - findMatchesCount(s9,s11), - 1 - ); - - String s12 = "assert agentInfo != null : \"agentInfo is null\";\n" + - "assert addresses != null : \"addresses is null\";"; - String s13 = "assert $exp$ != null : \"$exp$ is null\";"; - - assertEquals( - "reference to substitution in comment", - findMatchesCount(s12,s13), - 2 - ); - - String s14 = "\"(some text with special chars)\"," + - "\" some\"," + - "\"(some)\""; - String s15 = "\"('a:[regexw( some )])\""; - - assertEquals( - "meta char in literal", - 2, - findMatchesCount(s14,s15) - ); - - String s16 = "/**\n" + - "* Created by IntelliJ IDEA.\n" + - "* User: cdr\n" + - "* Date: Nov 15, 2005\n" + - "* Time: 4:23:29 PM\n" + - "* To change this template use File | Settings | File Templates.\n" + - "*/\n" + - "public class Y {\n" + - "}"; - String s17 = "/**\n" + - "* Created by IntelliJ IDEA.\n" + - "* User: '_USER\n" + - "* Date: '_DATE\n" + - "* Time: '_TIME\n" + - "* To change this template use File | Settings | File Templates.\n" + - "*/\n" + - "class 'c {\n" + - "}"; - assertEquals( - "complete comment match", - 1, - findMatchesCount(s16,s17,true) - ); - - String s18 = "public class A {\n" + - " private void f(int i) {\n" + - " int g=0; //sss\n" + - " }\n" + - "}"; - String s19 = "class $c$ {\n" + - " $type$ $f$($t$ $p$){\n" + - " $s$; // sss\n" + - " }\n" + - "}"; - assertEquals( - "statement match with comment", - 1, - findMatchesCount(s18,s19) - ); - } - - public void testOther() { - assertEquals( - "optional init match in definition", - findMatchesCount(s73,s74), - 4 - ); - - assertEquals( - "null match", - findMatchesCount(s77,s78), - 0 - ); - - assertEquals( - "body of method by block search", - findMatchesCount(s79,s80), - 2 - ); - - - assertEquals( - "first matches, next not", - findMatchesCount(s95,s96), - 2 - ); - - final String s97 = "class A { int c; void b() { C d; } } class C { C() { A a; a.b(); a.c=1; } }"; - final String s98 = "'_.'_:[ref('T)] ()"; - final String s98_2 = "'_.'_:[ref('T)]"; - final String s98_3 = "'_:[ref('T)].'_ ();"; - final String s98_4 = "'_:[ref('T)] '_;"; - - assertEquals( - "method predicate match", - findMatchesCount(s97,s98), - 1 - ); - - assertEquals( - "field predicate match", - findMatchesCount(s97,s98_2), - 1 - ); - - assertEquals( - "dcl predicate match", - findMatchesCount(s97,s98_3), - 1 - ); - - final String s99 = " char s = '\\u1111'; char s1 = '\\n'; "; - final String s100 = " char 'var = '\\u1111'; "; - final String s100_2 = " char 'var = '\\n'; "; - assertEquals( - "char constants in pattern", - findMatchesCount(s99,s100), - 1 - ); - - assertEquals( - "char constants in pattern 2", - findMatchesCount(s99,s100_2), - 1 - ); - - assertEquals( - "class predicate match (from definition)", - findMatchesCount(s97,s98_4), - 3 - ); - - final String s125 = "a=1;"; - final String s126 = "'t:[regex(a)]"; - - try { - findMatchesCount(s125,s126); - assertFalse("spaces around reg exp check",false); - } catch(MalformedPatternException ex) {} - - options.setDistinct(true); - - final String s101 = "class A { void b() { String d; String e; String[] f; f.length=1; f.length=1; } }"; - final String s102 = "'_:[ref('T)] '_;"; - - assertEquals( - "distinct match", - findMatchesCount(s101,s102), - 1 - ); - - options.setDistinct(false); - - final String s103 = " a=1; "; - final String s104 = "'T:{ ;"; - try { - findMatchesCount(s103,s104); - assertFalse("incorrect reg exp",false); - } catch(MalformedPatternException ex) { - } - - final String s106 = "$_ReturnType$ $MethodName$($_ParameterType$ $_Parameter$);"; - final String s105 = " aaa; "; - - try { - findMatchesCount(s105,s106); - assertFalse("incorrect reg exp 2",false); - } catch(UnsupportedPatternException ex) { - } - - String s107 = "class A {\n" + - " /* */\n" + - " void a() {\n" + - " }" + - " /* */\n" + - " int b = 1;\n" + - " /*" + - " *" + - " */\n" + - " class C {}" + - "}"; - String s108 = " /*" + - " *" + - " */"; - - assertEquals("finding comments without typed var", 1, findMatchesCount(s107,s108)); - - String s109 = "class A { void b(); int b(int c); char d(char e); }\n" + - "A a; a.b(1); a.b(2); a.b(); a.d('e'); a.d('f'); a.d('g');"; - String s110 = "'_a.'_b:[exprtype( int ) ]('_c*);"; - assertEquals("caring about method return type", 2, findMatchesCount(s109,s110)); - - String s111 = "class A { void getManager() { getManager(); } };\n" + - "class B { void getManager() { getManager(); getManager(); } };"; - String s112 = "'Instance?:[exprtype( B )].getManager()"; - assertEquals("caring about missing qualifier type", 2, findMatchesCount(s111,s112)); - - String s112a = "'Instance?:[regex( B )].getManager()"; - assertEquals("static query should not match instance method", 0, findMatchesCount(s111, s112a)); - - String s112b = "B.getManager()"; - assertEquals("static query should not match instance method 2", 0, findMatchesCount(s111, s112b)); - - String s113 = "class A { static void a() { a(); }}\n" + - "class B { static void a() { a(); a(); }}\n"; - String s114 = "'_Q?:[regex( B )].a()"; - assertEquals("should care about implicit class qualifier", 2, findMatchesCount(s113, s114)); - - String s114a = "B.a()"; - assertEquals("should match simple implicit class qualifier query", 2, findMatchesCount(s113, s114a)); - - String s114b = "'_Q?:[exprtype( B )].a()"; - assertEquals("instance query should not match static method", 0, findMatchesCount(s113, s114b)); - - String s115 = "class A { int a; int f() { return a; }}\n" + - "class B { int a; int g() { return a + a; }}\n"; - String s116 = "'_Instance?:[exprtype( B )].a"; - assertEquals("should care about implicit instance qualifier", 2, findMatchesCount(s115, s116)); - - String s116a = "A.a"; - assertEquals("should not match instance method", 0, findMatchesCount(s115, s116a)); - - String s117 = "class A { static int a; static int f() { return a; }}\n" + - "class B { static int a; static int g() { return a + a; }}\n"; - String s118 = "'_Q?:[regex( B )].a"; - assertEquals("should care about implicit class qualifier for field", 2, findMatchesCount(s117, s118)); - - // b) hierarchy navigation support - // c) or search support - - // e) xml search (down-up, nested query), navigation from xml representation <-> java code - // f) impl data conversion (jdk 1.5 style) <-> other from (replace support) - - // Directions: - // @todo different navigation on sub/supertyping relation (fixed depth), methods implementing interface, - // g. like predicates - // i. performance - // more context for top level classes, difference with interface, etc - - // global issues: - // @todo matches out of context - // @todo proper regexp support - - // @todo define strict equality of the matches - // @todo search for field selection retrieves packages also - } - - public void testFQNInPatternAndVariableConstraints() { - String s1 = "import java.awt.List;\n" + - "class A { List l; }"; - String s1_2 = "import java.util.List;\n" + - "class A { List l; }"; - String s2 = "class '_ { 'Type:java\\.util\\.List '_Field; }"; - - assertEquals("No matches for qualified class",findMatchesCount(s1,s2,true),0); - assertEquals("Matches for qualified class",findMatchesCount(s1_2,s2,true),1); - - String s3 = "import java.util.ArrayList;\n" + - "class A { ArrayList l; }"; - String s4 = "class '_ { 'Type:*java\\.util\\.Collection '_Field; }"; - assertEquals("Matches for qualified class in hierarchy",findMatchesCount(s3,s4,true),1); - - String s5 = "import java.util.List;\n" + - "class A { { List l = new List(); l.add(\"1\"); } }"; - String s5_2 = "import java.awt.List;\n" + - "class A { { List l = new List(); l.add(\"1\"); } }"; - String s6 = "'a:[exprtype( java\\.util\\.List )]"; - String s6_2 = "'a:[exprtype( *java\\.util\\.Collection )]"; - String s6_3 = "java.util.List '_a = '_b?;"; - - assertEquals("Matches for qualified expr type",findMatchesCount(s5,s6,true), 2); - assertEquals("No matches for qualified expr type",findMatchesCount(s5_2,s6,true),0); - assertEquals("Matches for qualified expr type in hierarchy",findMatchesCount(s5,s6_2,true), 2); - - assertEquals("Matches for qualified var type in pattern",findMatchesCount(s5,s6_3,true),1); - assertEquals("No matches for qualified var type in pattern",findMatchesCount(s5_2,s6_3,true),0); - - String s7 = "import java.util.List;\n" + - "class A extends List { }"; - String s7_2 = "import java.awt.List;\n" + - "class A extends List {}"; - - String s8 = "class 'a extends java.util.List {}"; - - assertEquals("Matches for qualified type in pattern",findMatchesCount(s7,s8,true),1); - assertEquals("No matches for qualified type in pattern",findMatchesCount(s7_2,s8,true),0); - - String s9 = "String.intern(\"1\");\n" + - "java.util.Collections.sort(null);" + - "java.util.Collections.sort(null);"; - String s10 = "java.lang.String.'_method ( '_params* )"; - assertEquals("FQN in class name",1,findMatchesCount(s9,s10,false)); - } - - public void testAnnotations() throws Exception { - String s1 = "@MyBean(\"\")\n" + - "@MyBean2(\"\")\n" + - "public class TestBean {}\n" + - "@MyBean2(\"\")\n" + - "@MyBean(\"\")\n" + - "public class TestBean2 {}\n" + - "public class TestBean3 {}\n"; - String s2 = "@MyBean(\"\")\n" + - "@MyBean2(\"\")\n" + - "public class $a$ {}\n"; - - assertEquals("Simple find annotated class",2,findMatchesCount(s1,s2,false)); - - String s3 = "@VisualBean(\"????????? ?????????? ? ??\")\n" + - "public class TestBean\n" + - "{\n" + - " @VisualBeanField(\n" + - " name = \"??? ????????????\",\n" + - " initialValue = \"?????????????\"\n" + - " )\n" + - " public String user;\n" + - "\n" + - " @VisualBeanField(\n" + - " name = \"??????\",\n" + - " initialValue = \"\",\n" + - " fieldType = FieldTypeEnum.PASSWORD_FIELD\n" + - " )\n" + - " public String password;\n" + - "\n" + - " @VisualBeanField(\n" + - " initialValue = \"User\",\n" + - " name = \"????? ???????\",\n" + - " name = \"Second name\",\n" + - " fieldType = FieldTypeEnum.COMBOBOX_FIELD,\n" + - " comboValues = {\n" + - " @ComboFieldValue(\"Administrator\"),\n" + - " @ComboFieldValue(\"User\"),\n" + - " @ComboFieldValue(\"Guest\")}\n" + - " ) \n" + - " public String accessRights;\n" + - " \n" + - " public String otherField;\n" + - "}"; - String s4 = "class '_a {\n" + - " @'_Annotation+ ( 'AnnotationMember*:name = '_AnnotationValue* )\n" + - " String '_field* ;\n" + - "}"; - String s4_2 = "class '_a {\n" + - " @'_Annotation+ ()\n" + - " String 'field* ;\n" + - "}"; - - assertEquals("Find annotation members of annotated field class",4,findMatchesCount(s3,s4,false)); - assertEquals("Find annotation fields",3,findMatchesCount(s3,s4_2,false)); - - String s5 = "class A {" + - " @NotNull private static Collection<PsiElement> resolveElements(final PsiReference reference, final Project project) {}\n" + - " @NotNull private static Collection resolveElements2(final PsiReference reference, final Project project) {}\n" + - "}"; - String s6 = "class '_c {@NotNull '_rt 'method* ('_pt* '_p*){ '_inst*; } }"; - String s6_2 = "class '_c {@'_:NotNull '_rt 'method* ('_pt* '_p*){ '_inst*; } }"; - - assertEquals("Find annotated methods",2,findMatchesCount(s5,s6)); - assertEquals("Find annotated methods, 2",2,findMatchesCount(s5,s6_2)); - - String s7 = "class A { void message(@NonNls String msg); }\n" + - "class B { void message2(String msg); }\n" + - "class C { void message2(String msg); }"; - String s8 = "class '_A { void 'b( @'_Ann{0,0}:NonNls String '_); }"; - assertEquals("Find not annotated methods",2,findMatchesCount(s7,s8)); - - String s9 = "class A {\n" + - " Object[] method1() {}\n" + - " Object method1_2() {}\n" + - " Object method1_3() {}\n" + - " Object method1_4() {}\n" + - " @MyAnnotation Object[] method2(int a) {}\n" + - " @NonNls Object[] method3() {}\n" + - "}"; - String s10 = "class '_A { @'_Ann{0,0}:NonNls '_Type:Object\\[\\] 'b+( '_pt* '_p* ); }"; - String s10_2 = "class '_A { @'_Ann{0,0}:NonNls '_Type [] 'b+( '_pt* '_p* ); }"; - String s10_3 = "class '_A { @'_Ann{0,0}:NonNls '_Type:Object [] 'b+( '_pt* '_p* ); }"; - assertEquals("Find not annotated methods, 2",2,findMatchesCount(s9,s10)); - assertEquals("Find not annotated methods, 2",2,findMatchesCount(s9,s10_2)); - assertEquals("Find not annotated methods, 2",2,findMatchesCount(s9,s10_3)); - - String s11 = "class A {\n" + - "@Foo(value=baz) int a;\n" + - "@Foo(value=baz2) int a2;\n" + - "@Foo(value=baz2) int a3;\n" + - "@Foo(value2=baz3) int a3;\n" + - "@Foo(value2=baz3) int a3;\n" + - "@Foo(value2=baz3) int a3;\n" + - "@Foo(value2=baz4) int a3;\n" + - "}"; - String s12 = "@Foo(value=baz) int 'a;)"; - String s12_2 = "@Foo(value='baz:baz2 ) int 'a;)"; - String s12_3 = "@Foo('value:value2 = baz3 ) int 'a;)"; - String s12_4 = "@Foo('value:value2 = 'baz3:baz3 ) int 'a;)"; - String s12_5 = "@Foo('value:value2 = 'baz3:baz ) int 'a;)"; - String s12_6 = "@Foo('value:value2 = 'baz3 ) int 'a;)"; - - assertEquals("Find anno parameter value",1,findMatchesCount(s11,s12)); - assertEquals("Find anno parameter value",2,findMatchesCount(s11,s12_2)); - assertEquals("Find anno parameter value",3,findMatchesCount(s11,s12_3)); - assertEquals("Find anno parameter value",3,findMatchesCount(s11,s12_4)); - assertEquals("Find anno parameter value",0,findMatchesCount(s11,s12_5)); - assertEquals("Find anno parameter value",4,findMatchesCount(s11,s12_6)); - } - - public void testBoxingAndUnboxing() { - String s1 = " class A { void b(Integer i); void b2(int i); void c(int d); void c2(Integer d); }\n" + - "A a;\n" + - "a.b2(1)\n;" + - "a.b2(1)\n;" + - "a.b(1)\n;" + - "a.b( new Integer(0) )\n;" + - "a.b( new Integer(0) )\n;" + - "a.c(new Integer(2));\n" + - "a.c(new Integer(3));\n" + - "a.c2(new Integer(3));\n" + - "a.c(3);"; - String s2 = "a.'b('_Params:[formal( Integer ) && exprtype( int ) ])"; - String s2_2 = "a.c('_Params:[formal( int ) && exprtype( Integer ) ])"; - - assertEquals("Find boxing in method call",1,findMatchesCount(s1,s2,false)); - assertEquals("Find unboxing in method call",2,findMatchesCount(s1,s2_2,false)); - } - - public void testCommentsInDclSearch() { - String s1 = "class A {\n" + - " int a; // comment\n" + - " char b;\n" + - " int c; // comment2\n" + - "}"; - String s1_2 = "class A {\n" + - " // comment\n" + - " int a;\n" + - " char b;\n" + - " // comment2\n" + - " int c;\n" + - "}"; - - String s2 = "'_Type '_Variable = '_Value?; //'Comment"; - String s2_2 = "//'Comment\n" + - "'_Type '_Variable = '_Value?;"; - - assertEquals("Find field by dcl with comment",2,findMatchesCount(s1,s2)); - assertEquals("Find field by dcl with comment 2",2,findMatchesCount(s1_2,s2_2)); - } - - public void testSearchingEmptyModifiers() { - - String s1 = "class A {\n" + - " int a;\n" + - " private char b;\n" + - " private char b2;\n" + - " public int c;\n" + - " public int c2;\n" + - "}"; - String s2 = "@Modifier(\"packageLocal\") '_Type '_Variable = '_Value?;"; - String s2_2 = "@Modifier({\"packageLocal\",\"private\"}) '_Type '_Variable = '_Value?;"; - String s2_3 = "@Modifier({\"PackageLocal\",\"private\"}) '_Type '_Variable = '_Value?;"; - - assertEquals("Finding package local dcls",1,findMatchesCount(s1,s2)); - assertEquals("Finding package local dcls",3,findMatchesCount(s1,s2_2)); - - try { - findMatchesCount(s1,s2_3); - assertTrue("Finding package local dcls",false); - } catch(MalformedPatternException ex) { - - } - - String s3 = "class A {\n" + - " int a;\n" + - " static char b;\n" + - " static char b2;\n" + - "}"; - String s4 = "@Modifier(\"Instance\") '_Type '_Variable = '_Value?;"; - String s4_2 = "@Modifier({\"static\",\"Instance\"}) '_Type '_Variable = '_Value?;"; - assertEquals("Finding instance fields",1,findMatchesCount(s3,s4)); - assertEquals("Finding all fields",3,findMatchesCount(s3,s4_2)); - - String s5 = "class A {}\n" + - "abstract class B {}\n" + - "final class C {}\n" + - "class D {}"; - String s6 = "@Modifier(\"Instance\") class 'Type {}"; - String s6_2 = "@Modifier({\"abstract\",\"final\",\"Instance\"}) class 'Type {}"; - assertEquals("Finding instance classes",3,findMatchesCount(s5,s6)); - assertEquals("Finding all classes",4,findMatchesCount(s5,s6_2)); - } - - public void testSearchTransientFieldsWithModifier() { - String source = - "public class TestClass {\n" + - " transient private String field1;\n" + - " transient String field2;\n" + - " String field3;\n" + - "}"; - - String template = "transient @Modifier(\"packageLocal\") '_Type '_Variable = '_Value?;"; - - assertEquals("Finding package-local transient fields", 1, findMatchesCount(source, template)); - } - - public void test() { - String s1 = "if (LOG.isDebugEnabled()) {\n" + - " int a = 1;\n" + - " int a = 1;\n" + - "}"; - String s2 = "if ('_Log.isDebugEnabled()) {\n" + - " '_ThenStatement;\n" + - " '_ThenStatement;\n" + - "}"; - assertEquals("Comparing declarations",1,findMatchesCount(s1,s2)); - } - - public void testFindStaticMethodsWithinHierarchy() { - String s1 = "class A {}\n" + - "class B extends A { static void foo(); }\n" + - "class B2 extends A { static void foo(int a); }\n" + - "class B3 extends A { static void foo(int a, int b); }\n" + - "class C { static void foo(); }\n" + - "B.foo();\n" + - "B2.foo(1);\n" + - "B3.foo(2,3);\n" + - "C.foo();"; - String s2 = "'_Instance:[regex( *A )].'_Method:[regex( foo )] ( '_Params* )"; - assertEquals("Find static methods within expr type hierarchy", 3, findMatchesCount(s1,s2)); - } - - public void testFindClassesWithinHierarchy() { - String s1 = "class A implements I {}\n" + - "interface I {}\n" + - "class B extends A implements I { }\n" + - "class B2 implements I { }\n" + - "class B3 extends A { }\n" + - "class C extends B2 { static void foo(); }\n"; - String s2 = "class '_ extends '_Extends:[!regex( *A )] implements '_Implements:[regex( I )] {}"; - String s2_2 = "class '_ extends '_Extends:[!regex( *A )]{}"; - assertEquals("Find class within type hierarchy with not", 1, findMatchesCount(s1,s2)); - assertEquals("Find class within type hierarchy with not, 2", 1, findMatchesCount(s1,s2_2)); - } - - public void testFindTryWithoutProperFinally() { - String s1 = "try {\n" + - " conn = 1;\n" + - "} finally {\n" + - " conn.close();\n" + - "}\n" + - "try {\n" + - " conn = 1;\n" + - "} finally {\n" + - " int a = 1;\n" + - "}\n" + - "try {\n" + - " conn = 1;\n" + - "} finally {\n" + - " int a = 1;\n" + - "}"; - String s2 = "try { '_StatementBefore*; '_Dcl:[regex( conn = 1 )]; '_StatementAfter*; } finally { '_Finally*:[!regex( .*conn.* ) ]; }"; - assertEquals("FindTryWithoutProperFinally", 2, findMatchesCount(s1,s2)); - } - - public void testBug() { - String s1 = "public class DiallingNumber extends DataGroup\n" + "{\n" + " protected static byte [] CLEAR = { };\n" + "\n" + - " private static DataItemTemplate template;\n" + "\n" + "\tprotected DataTemplate createDefaultTemplate()\n" + "\t{\n" + - " return null;\n" + " }\n" + "}"; - String s2 = "class '_Class {\n" + " static '_FieldType '_FieldName:.*template.* = '_FieldInitial?;\n" + - " '_RetType createDefaultTemplate() { '_Statements*; }\n" + "\t'_Content*\n" + "}"; - assertEquals("Bug in class matching", 1, findMatchesCount(s1,s2)); - } - - //public void testFindFieldUsageByQName() { - // String s1 = "{ class A { int b; { b = 1; } } class B extends A { { this.b = 2} } { B i; i.b = 3; } }"; - // String s2 = "A.b"; - // assertEquals( 3, findMatchesCount(s1,s2)); - //} - // - //public void testFindMethodUsageByQName() { - // String s1 = "{ class A { void b(int a) {} { b(1); } } class B extends A { { this.b(2); } } { B i; i.b(3); } }"; - // String s2 = "A.b"; - // assertEquals( 3, findMatchesCount(s1,s2)); - //} - - public void _testStaticInstanceInitializers() { - String s1 = "public class DiallingNumber {\n static { int a = 1; } static { int b = 1; } { int c = 2; }}"; - String s2 = "class '_Class {\n" + " static { 't*; } }"; - String s2_2 = "class '_Class {\n" + " { 't*; } }"; - String s2_3 = "class '_Class {\n" + " @Modifier(\"Instance\") { 't*; } }"; - assertEquals("Static / instance initializers", 2, findMatchesCount(s1,s2)); - assertEquals("Static / instance initializers", 1, findMatchesCount(s1,s2_3)); - assertEquals("Static / instance initializers", 3, findMatchesCount(s1,s2_2)); - } - - @NotNull - @Override - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("structuralsearch") + "/testData/java/"; - } - - public void testDoNotFindReturn() throws IOException { - String s1 = loadFile(getTestName(false) + ".java"); - String s2 = "ApplicationManager.getApplication().runReadAction(new Runnable() {\n" + - " public void run() {\n" + - " 't*:[ !regex( .*return.* ) ];\n" + - " }});"; - assertEquals(0, findMatchesCount(s1,s2)); - } - - public void testDownUpMatch() { - String s1 = "class A {\n" + - " int bbb(int c, int ddd, int eee) {\n" + - " int a = 1;\n" + - " try { int b = 1; } catch(Type t) { a = 2; } catch(Type2 t2) { a = 3; }\n" + - " }\n" + - "}"; - String s2 = "try { '_st*; } catch('_Type 't+) { '_st2*; }"; - - final List<PsiVariable> vars = new ArrayList<PsiVariable>(); - final PsiFile file = PsiFileFactory.getInstance(getProject()).createFileFromText("_.java", s1); - - file.acceptChildren(new JavaRecursiveElementWalkingVisitor() { - @Override public void visitVariable(final PsiVariable variable) { - super.visitVariable(variable); - vars.add(variable); - } - }); - - assertEquals(7, vars.size()); - List<MatchResult> results = new ArrayList<MatchResult>(); - - Matcher testMatcher = new Matcher(getProject()); - MatchOptions options = new MatchOptions(); - options.setSearchPattern(s2); - MatcherImplUtil.transform(options); - options.setFileType(StdFileTypes.JAVA); - - for(PsiVariable var:vars) { - final MatchResult matchResult = testMatcher.isMatchedByDownUp(var, options); - if (matchResult != null) results.add(matchResult); - assertTrue( - (var instanceof PsiParameter && var.getParent() instanceof PsiCatchSection && matchResult != null) || - matchResult == null - ); - } - - assertEquals(2, results.size()); - MatchResult result = results.get(0); - assertEquals("t", result.getMatchImage()); - - result = results.get(1); - assertEquals("t2", result.getMatchImage()); - - results.clear(); - String s2_2 = "try { '_st*; } catch('Type:Type2 '_t) { '_st2*; }"; - - options.clearVariableConstraints(); - options.setSearchPattern(s2_2); - MatcherImplUtil.transform(options); - - for(PsiVariable var:vars) { - final PsiTypeElement typeElement = var.getTypeElement(); - final MatchResult matchResult = testMatcher.isMatchedByDownUp(typeElement, options); - if (matchResult != null) results.add(matchResult); - assertTrue( - (var instanceof PsiParameter && var.getParent() instanceof PsiCatchSection && matchResult != null) || - matchResult == null - ); - } - - assertEquals(1, results.size()); - - result = results.get(0); - assertEquals("Type2", result.getMatchImage()); - } - - @Bombed(day = 28, description = "support it", month = Calendar.JULY, user = "maxim.mossienko") - public void _testContainsPredicate() { - String s1 = "{{\n" + - " int a;\n" + - " a = 1;\n" + - "}\n" + - "{\n" + - " int b = 1;\n" + - " b = 1;\n" + - "}\n" + - "{\n" + - " int c = 2;\n" + - " c = 2;\n" + - "}}"; - String s2 = "{\n" + - " '_a*:[contains( \"'type $a$ = $b$;\" )];\n" + - "}"; - - String s2_2 = "{\n" + - " '_a*:[!contains( \"$type$ $a$ = $b$;\" )];\n" + - "}"; - - assertEquals(2, findMatchesCount(s1, s2)); - assertEquals(1, findMatchesCount(s1, s2_2)); - } - - public void testWithinPredicate() { - String s1 = "if (true) {\n" + - " int a = 1;\n" + - "}\n" + - "if (true) {\n" + - " int b = 1;\n" + - "}\n" + - "while(true) {\n" + - " int c = 2;\n" + - "}"; - String s2 = "'_type 'a:[within( \"if ('_a) { '_st*; }\" )] = '_b;"; - String s2_2 = "'_type 'a:[!within( \"if ('_a) { '_st*; }\" )] = '_b;"; - - assertEquals(2,findMatchesCount(s1, s2)); - assertEquals(1,findMatchesCount(s1, s2_2)); - - // TODO: xxx - //String s3 = "if (true) {\n" + - // " if (true) return;\n" + - // " int a = 1;\n" + - // "}\n else if (true) {\n" + - // " return;\n" + - // "}"; - //assertEquals(2,findMatchesCount(s3, s2)); - //assertEquals(1,findMatchesCount(s3, s2_2)); - } - - public void testWithinPredicate2() { - String s3 = "class C {\n" + - " void aaa() {\n" + - " LOG.debug(true);\n" + - " LOG.debug(true);\n" + - " LOG.debug(true);\n" + - " LOG.debug(true);\n" + - " LOG.debug(true);\n" + - " if (true) {\n" + - " LOG.debug(true);\n" + - " }\n" + - " if (true) LOG.debug(true);\n" + - " if (true) { int 1 = 1; } else { LOG.debug(true); }\n" + - " }" + - "}"; - String s4 = "LOG.debug('_params*:[!within( \"if('_a) { 'st*; }\" )]);"; - - assertEquals(6,findMatchesCount(s3, s4)); - } - - public void testMultiStatementPatternWithTypedVariable() throws Exception { - String s = "Integer i;\ni.valueOf();"; - String s_2 = "Integer i;\nint a = 1;\ni.valueOf();"; - String s2 = "Integer '_i;\n'_i.valueOf();"; - String s2_2 = "Integer '_i;\n'_st; '_i.valueOf();"; - String s2_3 = "Integer '_i;\n'_st*; '_i.valueOf();"; - - assertEquals(1, findMatchesCount(s,s2)); - assertEquals(1, findMatchesCount(s_2,s2_2)); - assertEquals(1, findMatchesCount(s_2,s2_3)); - assertEquals(1, findMatchesCount(s,s2_3)); - } - - public void testFindAnnotationDeclarations() throws Exception { - String s = "interface Foo {} interface Bar {} @interface X {}"; - String s2 = "@interface 'x {}"; - - assertEquals(1, findMatchesCount(s,s2)); - } - - public void testFindEnums() throws Exception { - String s = "class Foo {} class Bar {} enum X {}"; - String s2 = "enum 'x {}"; - - assertEquals(1, findMatchesCount(s,s2)); - } - - public void testFindDeclaration() throws Exception { - String s = "public class F {\n" + - " static Category cat = Category.getInstance(F.class.getName());\n" + - " Category cat2 = Category.getInstance(F.class.getName());\n" + - " Category cat3 = Category.getInstance(F.class.getName());\n" + - "}"; - String s2 = "static $Category$ $cat$ = $Category$.getInstance($Arg$);"; - - assertEquals(1, findMatchesCount(s,s2)); - } - - public void testFindMethodCallWithTwoOrThreeParameters() { - String source = "{ String.format(\"\"); String.format(\"\", 1); String.format(\"\", 1, 2); String.format(\"\", 1, 2, 3); }"; - String pattern = "'_Instance.'_MethodCall('_Parameter{2,3})"; - - assertEquals(2, findMatchesCount(source, pattern)); - } - - public void testFindMethodWithCountedExceptionsInThrows() { - String source = "class A {" + - " void a() {}" + - " void b() throws E1 {}" + - " void c() throws E1, E2{}" + - " void d() throws E1, E2, E3 {}" + - "}"; - - String pattern1 = "class '_A {" + - " '_type+ 'method+ () throws '_E{0,0}" + - "}"; - assertEquals(1, findMatchesCount(source, pattern1)); - - String pattern2 = "class '_A {" + - " '_type+ 'method+ () throws '_E{1,2}" + - "}"; - assertEquals(2, findMatchesCount(source, pattern2)); - - String pattern3 = "class '_A {" + - " '_type+ 'method+ () throws '_E{2,2}" + - "}"; - assertEquals(1, findMatchesCount(source, pattern3)); - - String pattern4 = "class '_A {" + - " '_type+ 'method+ () throws '_E{0,0}:[ regex( E2 )]" + - "}"; - assertEquals(2, findMatchesCount(source, pattern4)); - } - - public void testFindMethodsCalledWithinClass() { - String source = "class A {" + - " void a() {}" + - " static void b() {}" + - " void c() {" + - " a();" + - " b();" + - " }" + - "}" + - "class B extends A {" + - " void d() {" + - " a();" + - " b();" + - " }" + - "}"; - String pattern1 = "this.a()"; - assertEquals(2, findMatchesCount(source, pattern1)); - } - - public void testFindReferenceWithParentheses() { - String source = "class A {" + - " String value;" + - " A(String v) {" + - " value = (value);" + - " System.out.println(((2)));" + - " System.out.println(2);" + - " }" + - "}"; - - String pattern1 = "'_value='_value"; - assertEquals(1, findMatchesCount(source, pattern1)); - - String pattern2 = "System.out.println('_v);" + - "System.out.println('_v);"; - assertEquals(1, findMatchesCount(source, pattern2)); - } - - public void testFindSelfAssignment() { - String source = "class A {" + - " protected String s;" + - " A(String t) {" + - " this.s = s;" + - " t = t;" + - " s = this.s;" + - " }" + - //"}" + - //"class B {" + - //" B(String t) {" + - //" super.s = s;" + // would be nice if found also - //" }" + - "}"; - - String pattern = "'_var='_var"; - assertEquals(3, findMatchesCount(source, pattern)); - } - - public void testFindLambdas() { - String source = "public interface IntFunction<R> {" + - " R apply(int value);" + - "}" + - "public interface Function<T, R> {" + - " R apply(T t);" + - "}" + - "class A {" + - " void m() {" + - " Runnable q = () -> { /*comment*/ };" + - " Runnable r = () -> { System.out.println(); };" + - " IntFunction<String> f = a -> \"hello\";" + - " Function<String, String> g = a -> \"world\";" + - " }" + - "}"; - - String pattern1 = "() ->"; - assertEquals("should find lamdas", 4, findMatchesCount(source, pattern1)); - - String pattern2 = "(int '_a) -> {}"; - assertEquals("should find lambdas with specific parameter type", 1, findMatchesCount(source, pattern2)); - - String pattern3 = "('_a{0,0})->{}"; - assertEquals("should find lambdas without any parameters", 2, findMatchesCount(source, pattern3)); - - String pattern4 = "()->System.out.println()"; - assertEquals("should find lambdas with matching body", 1, findMatchesCount(source, pattern4)); - - String pattern5 = "()->{/*comment*/}"; - assertEquals("should find lambdas with comment body", 1, findMatchesCount(source, pattern5)); - } - - public void testFindDefaultMethods() { - String source = "interface XYZ {" + - " default void m() {" + - " System.out.println();" + - " }" + - " void f();" + - " void g();" + - "}" + - "interface ABC {" + - " void m();" + - "}"; - - String pattern1 = "interface '_Class { default '_ReturnType+ 'MethodName+('_ParameterType* '_Parameter*);}"; - assertEquals("should find default method", 1, findMatchesCount(source, pattern1)); - - String pattern2 = "interface 'Class { default '_ReturnType+ '_MethodName{0,0}('_ParameterType* '_Parameter*);}"; - assertEquals("should find interface without default methods", 1, findMatchesCount(source, pattern2)); - } - - public void testFindMethodReferences() { - String source = "class A {" + - " Runnable r = System.out::println;" + - " Runnable s = this::hashCode;" + - " Runnable t = this::new;" + - " static {" + - " System.out.println();" + - " }" + - "}"; - - String pattern1 = "System . out :: println"; - assertEquals("should find method reference", 1, findMatchesCount(source, pattern1)); - - String pattern2 = "this::'_a"; - assertEquals("should find method reference 2", 2, findMatchesCount(source, pattern2)); - - String pattern3 = "'_a::'_b"; - assertEquals("should find all method references", 3, findMatchesCount(source, pattern3)); - } -} diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTestCase.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTestCase.java deleted file mode 100644 index 6b8aceaba590..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTestCase.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.intellij.structuralsearch; - -import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase; -import com.intellij.lang.Language; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.openapi.fileTypes.StdFileTypes; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.openapi.util.io.FileUtilRt; -import com.intellij.openapi.vfs.CharsetToolkit; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.structuralsearch.impl.matcher.MatcherImpl; -import com.intellij.structuralsearch.impl.matcher.MatcherImplUtil; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -abstract class StructuralSearchTestCase extends LightQuickFixTestCase { - protected MatchOptions options; - protected Matcher testMatcher; - - @Override - protected void setUp() throws Exception { - super.setUp(); - - StructuralSearchUtil.ourUseUniversalMatchingAlgorithm = false; - testMatcher = new Matcher(getProject()); - options = new MatchOptions(); - options.setLooseMatching(true); - options.setRecursiveSearch(true); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.JDK_1_5); - } - - @Override - protected void tearDown() throws Exception { - testMatcher = null; - options = null; - super.tearDown(); - } - - protected int findMatchesCount(String in, String pattern, boolean filePattern, FileType fileType) { - return findMatches(in,pattern,filePattern, fileType).size(); - } - - protected List<MatchResult> findMatches(String in, - String pattern, - boolean filePattern, - FileType patternFileType, - Language patternLanugage, - FileType sourceFileType, - String sourceExtension, - boolean physicalSourceFile) { - return findMatches(in, pattern, filePattern, patternFileType, patternLanugage, sourceFileType, sourceExtension, physicalSourceFile, - true); - } - - protected List<MatchResult> findMatches(String in, - String pattern, - boolean filePattern, - FileType patternFileType, - Language patternLanugage, - FileType sourceFileType, - String sourceExtension, - boolean physicalSourceFile, - boolean transform) { - options.clearVariableConstraints(); - options.setSearchPattern(pattern); - if (transform) { - MatcherImplUtil.transform(options); - } - pattern = options.getSearchPattern(); - options.setFileType(patternFileType); - options.setDialect(patternLanugage); - - MatcherImpl.validate(getProject(), options); - return testMatcher.testFindMatches(in, pattern, options, filePattern, sourceFileType, sourceExtension, physicalSourceFile); - } - - protected List<MatchResult> findMatches(String in, String pattern, boolean filePattern, FileType patternFileType) { - return findMatches(in, pattern, filePattern, patternFileType, null, patternFileType, null, false); - } - - protected int findMatchesCount(String in, String pattern, boolean filePattern) { - return findMatchesCount(in, pattern,filePattern, StdFileTypes.JAVA); - } - - protected int findMatchesCount(String in, String pattern) { - return findMatchesCount(in,pattern,false); - } - - protected List<MatchResult> findMatches(String in, String pattern) { - return findMatches(in,pattern,false, StdFileTypes.JAVA); - } - - protected String loadFile(String fileName) throws IOException { - return FileUtilRt.loadFile(new File(getTestDataPath() + fileName), CharsetToolkit.UTF8, true); - } -} diff --git a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/impl/matcher/compiler/StringToConstraintsTransformerTest.java b/plugins/structuralsearch/testSource/com/intellij/structuralsearch/impl/matcher/compiler/StringToConstraintsTransformerTest.java deleted file mode 100644 index dc1cbc5802f2..000000000000 --- a/plugins/structuralsearch/testSource/com/intellij/structuralsearch/impl/matcher/compiler/StringToConstraintsTransformerTest.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.intellij.structuralsearch.impl.matcher.compiler; - -import com.intellij.structuralsearch.MalformedPatternException; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.MatchVariableConstraint; -import com.intellij.structuralsearch.UnsupportedPatternException; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * @author Bas Leijdekkers - */ -public class StringToConstraintsTransformerTest { - - private MatchOptions myOptions; - - @Before - public void setUp() throws Exception { - myOptions = new MatchOptions(); - } - - @Test(expected = MalformedPatternException.class) - public void testCharacterExpectedAfterQuote() { - test("' asdf"); - } - - @Test(expected = MalformedPatternException.class) - public void testUnexpectedEndOfPattern() { - test("'_a{"); - } - - @Test(expected = MalformedPatternException.class) - public void testDigitExpected() { - test("'a{a"); - } - - @Test(expected = MalformedPatternException.class) - public void testDigitExpected2() { - test("'a{1,a}"); - } - - @Test - public void testZeroOccurs() { - test("'a{,}"); - final MatchVariableConstraint constraint = myOptions.getVariableConstraint("a"); - assertEquals(0, constraint.getMinCount()); - assertEquals(0, constraint.getMaxCount()); - } - - @Test(expected = MalformedPatternException.class) - public void testOverflow() { - test("'a{2147483648}"); - } - - @Test(expected = MalformedPatternException.class) - public void testMissingBrace() { - test("'a{1,3"); - } - - @Test(expected = MalformedPatternException.class) - public void testNoOptions() { - test("'a:"); - } - - @Test - public void testColon() { - test("for('_t 'a : '_b) {}"); - assertEquals("for($t$ $a$ : $b$) {}", myOptions.getSearchPattern()); - } - - @Test(expected = MalformedPatternException.class) - public void testNoOptions2() { - test("'a:+"); - } - - @Test(expected = MalformedPatternException.class) - public void testUnclosedCondition() { - test("'a:["); - } - - @Test(expected = MalformedPatternException.class) - public void testClosedCondition() { - test("'a:[]"); - } - - @Test(expected = MalformedPatternException.class) - public void testEmptyNegated() { - test("'a:[!]"); - } - - @Test(expected = UnsupportedPatternException.class) - public void testCondition() { - test("'a:[aap()]"); - } - - @Test(expected = UnsupportedPatternException.class) - public void testIncompleteCondition() { - test("'a:[regex(]"); - } - - @Test(expected = MalformedPatternException.class) - public void testIncompleteCondition2() { - test("'a:[regex()]"); - } - - @Test(expected = MalformedPatternException.class) - public void testIncompleteMultipleCondition() { - test("'a:[regex( a ) &&]"); - } - - @Test(expected = MalformedPatternException.class) - public void testInvalidRegularExpression() { - test("'a:x!("); - } - - @Test - public void testMethodReference() { - test("'_a::'_b"); - assertEquals("$a$::$b$", myOptions.getSearchPattern()); - } - - private void test(String pattern) { - myOptions.setSearchPattern(pattern); - StringToConstraintsTransformer.transformOldPattern(myOptions); - } -} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java index 27b1b36800fe..e8361b0eb874 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/ConflictedSvnChange.java @@ -19,16 +19,15 @@ import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.FileStatus; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ContentRevision; -import org.tmatesoft.svn.core.internal.wc.SVNTreeConflictUtil; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import javax.swing.*; public class ConflictedSvnChange extends Change { private final ConflictState myConflictState; // also used if not move/rename - private SVNTreeConflictDescription myBeforeDescription; - private SVNTreeConflictDescription myAfterDescription; + private TreeConflictDescription myBeforeDescription; + private TreeConflictDescription myAfterDescription; // +- private final FilePath myTreeConflictMarkHolder; private boolean myIsPhantom; @@ -66,19 +65,19 @@ public class ConflictedSvnChange extends Change { return myIsPhantom; } - public SVNTreeConflictDescription getBeforeDescription() { + public TreeConflictDescription getBeforeDescription() { return myBeforeDescription; } - public void setBeforeDescription(SVNTreeConflictDescription beforeDescription) { + public void setBeforeDescription(TreeConflictDescription beforeDescription) { myBeforeDescription = beforeDescription; } - public SVNTreeConflictDescription getAfterDescription() { + public TreeConflictDescription getAfterDescription() { return myAfterDescription; } - public void setAfterDescription(SVNTreeConflictDescription afterDescription) { + public void setAfterDescription(TreeConflictDescription afterDescription) { myAfterDescription = afterDescription; } @@ -97,14 +96,14 @@ public class ConflictedSvnChange extends Change { if (myAfterDescription != null) { sb.append("before: "); } - sb.append(SVNTreeConflictUtil.getHumanReadableConflictDescription(myBeforeDescription)); + sb.append(myBeforeDescription.toPresentableString()); } if (myAfterDescription != null) { sb.append('\n'); if (myBeforeDescription != null) { sb.append("after: "); } - sb.append(SVNTreeConflictUtil.getHumanReadableConflictDescription(myAfterDescription)); + sb.append(myAfterDescription.toPresentableString()); } return sb.toString(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java index b55b50bb323a..4eea25ac14ca 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/DepthCombo.java @@ -15,50 +15,32 @@ */ package org.jetbrains.idea.svn; -import org.tmatesoft.svn.core.SVNDepth; +import com.intellij.ui.ListCellRendererWrapper; +import org.jetbrains.idea.svn.api.Depth; import javax.swing.*; public class DepthCombo extends JComboBox { public DepthCombo(final boolean forUpdate) { super(forUpdate ? ourForUpdate : ourForCheckout); - setSelectedIndex(forUpdate ? 0 : 3); + setRenderer(new DepthRenderer()); + setSelectedItem(forUpdate ? Depth.UNKNOWN : Depth.INFINITY); setEditable(false); setToolTipText(SvnBundle.message("label.depth.description")); } - public SVNDepth getDepth() { - return ((SVNDepthWithName) super.getSelectedItem()).getDepth(); + public Depth getDepth() { + return (Depth)super.getSelectedItem(); } - private final static SVNDepthWithName [] ourForUpdate = {new SVNDepthWithName(SVNDepth.UNKNOWN, "working copy"), - new SVNDepthWithName(SVNDepth.EMPTY), new SVNDepthWithName(SVNDepth.FILES), new SVNDepthWithName(SVNDepth.IMMEDIATES), - new SVNDepthWithName(SVNDepth.INFINITY)}; - private final static SVNDepthWithName [] ourForCheckout = { - new SVNDepthWithName(SVNDepth.EMPTY), new SVNDepthWithName(SVNDepth.FILES), new SVNDepthWithName(SVNDepth.IMMEDIATES), - new SVNDepthWithName(SVNDepth.INFINITY)}; + private final static Depth[] ourForUpdate = {Depth.UNKNOWN, Depth.EMPTY, Depth.FILES, Depth.IMMEDIATES, Depth.INFINITY}; + private final static Depth[] ourForCheckout = {Depth.EMPTY, Depth.FILES, Depth.IMMEDIATES, Depth.INFINITY}; - private static class SVNDepthWithName { - private final SVNDepth myDepth; - private final String myName; - - private SVNDepthWithName(SVNDepth depth) { - myDepth = depth; - myName = myDepth.toString(); - } - - private SVNDepthWithName(SVNDepth depth, String name) { - myDepth = depth; - myName = name; - } + private static class DepthRenderer extends ListCellRendererWrapper<Depth> { @Override - public String toString() { - return myName; - } - - public SVNDepth getDepth() { - return myDepth; + public void customize(JList list, Depth value, int index, boolean selected, boolean hasFocus) { + setText(Depth.UNKNOWN.equals(value) ? "working copy" : value.getName()); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java index 333cf9e52c01..e87c55dc447d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/ForNestedRootChecker.java @@ -21,10 +21,10 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNErrorCode; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -108,8 +108,8 @@ public class ForNestedRootChecker { @NotNull private final SvnVcs myVcs; @NotNull private final VirtualFile myFile; @NotNull private final File myIoFile; - @Nullable private SVNInfo myInfo; - @Nullable private SVNException myError; + @Nullable private Info myInfo; + @Nullable private SvnBindException myError; private VcsFileResolver(@NotNull SvnVcs vcs, @NotNull VirtualFile file) { myVcs = vcs; @@ -128,7 +128,7 @@ public class ForNestedRootChecker { try { myInfo = myVcs.getFactory(myIoFile, false).createInfoClient().doInfo(myIoFile, SVNRevision.UNDEFINED); } - catch (SVNException e) { + catch (SvnBindException e) { myError = e; } } @@ -138,9 +138,7 @@ public class ForNestedRootChecker { Node result = null; if (myError != null) { - SVNErrorCode errorCode = myError.getErrorMessage().getErrorCode(); - - if (!SvnUtil.isUnversionedOrNotFound(errorCode)) { + if (!SvnUtil.isUnversionedOrNotFound(myError)) { // error code does not indicate that myFile is unversioned or path is invalid => create result, but indicate error result = new Node(myFile, getFakeUrl(), getFakeUrl(), myError); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java index 7934761fce12..d0eafb77bc4b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/NestedCopiesBuilder.java @@ -20,10 +20,10 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.HashSet; @@ -42,9 +42,9 @@ public class NestedCopiesBuilder implements StatusReceiver { mySet = new HashSet<NestedCopyInfo>(); } - public void process(final FilePath path, final SVNStatus status) throws SVNException { + public void process(final FilePath path, final Status status) throws SVNException { VirtualFile file = path.getVirtualFile(); - if (file != null && SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL)) { + if (file != null && status.is(StatusType.STATUS_EXTERNAL)) { // We do not determine here url, repository url - because url, repository url in status will determine location in the // repository where folder is located and not where svn:externals property points. We want the later parameters - they'll // determined while creating RootUrlInfos later. Format will be also determined later. @@ -55,7 +55,7 @@ public class NestedCopiesBuilder implements StatusReceiver { } if (file == null || status.getURL() == null) return; - if (!SvnVcs.svnStatusIsUnversioned(status) && status.isSwitched()) { + if (!status.is(StatusType.STATUS_UNVERSIONED) && status.isSwitched()) { // this one called when there is switched directory under nested working copy // TODO: some other cases? final NestedCopyInfo diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java index 83290a3e05c0..3d1d77e210d1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/Node.java @@ -19,7 +19,7 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; import java.io.File; @@ -31,13 +31,13 @@ public class Node { @NotNull private final VirtualFile myFile; @NotNull private final SVNURL myUrl; @NotNull private final SVNURL myRepositoryUrl; - @Nullable private final SVNException myError; + @Nullable private final SvnBindException myError; public Node(@NotNull VirtualFile file, @NotNull SVNURL url, @NotNull SVNURL repositoryUrl) { this(file, url, repositoryUrl, null); } - public Node(@NotNull VirtualFile file, @NotNull SVNURL url, @NotNull SVNURL repositoryUrl, @Nullable SVNException error) { + public Node(@NotNull VirtualFile file, @NotNull SVNURL url, @NotNull SVNURL repositoryUrl, @Nullable SvnBindException error) { myFile = file; myUrl = url; myRepositoryUrl = repositoryUrl; @@ -65,7 +65,7 @@ public class Node { } @Nullable - public SVNException getError() { + public SvnBindException getError() { return myError; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java index b669f2bfb38b..e078c572d65d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/RepeatSvnActionThroughBusy.java @@ -15,6 +15,7 @@ */ package org.jetbrains.idea.svn; +import com.intellij.openapi.vcs.VcsException; import com.intellij.util.Processor; import org.tmatesoft.sqljet.core.SqlJetErrorCode; import org.tmatesoft.sqljet.core.SqlJetException; @@ -52,20 +53,23 @@ public abstract class RepeatSvnActionThroughBusy { protected int myCnt = REPEAT; protected long myTimeout = 50; - protected abstract void executeImpl() throws SVNException; + + protected abstract void executeImpl() throws VcsException; + protected Object myT; - public <T> T compute() throws SVNException { + public <T> T compute() throws VcsException { execute(); return (T) myT; } - public void execute() throws SVNException { + public void execute() throws VcsException { while (true) { try { executeImpl(); break; - } catch (SVNException e) { + } + catch (VcsException e) { if (ourBusyExceptionProcessor.process(e)) { if (myCnt > 0) { try { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java index 5ca7f9eaa39b..06138b345b74 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/RootsToWorkingCopies.java @@ -29,14 +29,9 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Alarm; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.internal.wc.admin.SVNEntry; -import org.tmatesoft.svn.core.internal.wc.admin.SVNWCAccess; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNWCUtil; import java.io.File; import java.util.HashMap; @@ -127,7 +122,7 @@ public class RootsToWorkingCopies implements VcsListener { WorkingCopy workingCopy = null; if (workingCopyRoot != null) { - final SVNInfo svnInfo = myVcs.getInfo(workingCopyRoot); + final Info svnInfo = myVcs.getInfo(workingCopyRoot); if (svnInfo != null && svnInfo.getURL() != null) { workingCopy = new WorkingCopy(workingCopyRoot, svnInfo.getURL(), true); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java index 8524c83366e6..ac165c48f5c3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusReceiver.java @@ -17,14 +17,14 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.util.EventListener; public interface StatusReceiver extends EventListener { - void process(final FilePath path, final SVNStatus status) throws SVNException; + void process(final FilePath path, final Status status) throws SVNException; void processIgnored(final VirtualFile vFile); void processUnversioned(final VirtualFile vFile); void processCopyRoot(VirtualFile file, SVNURL url, WorkingCopyFormat format, SVNURL rootURL); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java index 09d7d87ec1dc..367ae1bc4619 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/StatusWalkerPartner.java @@ -25,11 +25,11 @@ import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; -import org.tmatesoft.svn.core.wc.SVNEvent; public class StatusWalkerPartner { private final SvnVcs myVcs; @@ -50,9 +50,9 @@ public class StatusWalkerPartner { } @NotNull - public ISVNEventHandler getEventHandler() { - return new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public ProgressTracker getEventHandler() { + return new ProgressTracker() { + public void consume(ProgressEvent event) throws SVNException { // } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties index 38418b16ef53..df545b0373a1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnBundle.properties @@ -322,9 +322,9 @@ progress.title.commit=Commit progress.text.committing.changes.below=Creating commit packets... status.text.committed.revision=Committed revision {0}. checkin.operation.name=Comm_it -checkin.different.formats.involved=Selected changes for {0,choice,0#repository|1#repositories} {1}\nbelong to both before- 1.7 format and 1.7 format \ -Subversion working copies.\nCommit will split into several commits.\n\n\ -You can convert all working copies into 1.7 format in Changes | Subversion Working Copies Information.\nDo you wish to continue with commit? +checkin.different.formats.involved=Selected changes for {0,choice,0#repository|1#repositories} {1}\nbelong to Subversion working copies of \ +different formats.\nCommit will split into several commits.\n\n\ +You can convert all working copies to the same format in Changes | Subversion Working Copies Information.\nDo you wish to continue with commit? progress.text.collecting.commitables=Collecting commitables at ''{0}'' progress.text2.fetching.external.location=Fetching external location to ''{0}'' progress.text2.checked.out=Checked out {1} files, checking out {0} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java index 3b0195e6079d..073826f6b035 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProvider.java @@ -34,14 +34,15 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.EventDispatcher; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.actions.CleanupWorker; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnExceptionWrapper; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.*; @@ -86,12 +87,12 @@ public class SvnChangeProvider implements ChangeProvider { final SvnRecursiveStatusWalker walker = new SvnRecursiveStatusWalker(myVcs, statusReceiver.getMulticaster(), partner); for (FilePath path : zipper.getRecursiveDirs()) { - walker.go(path, SVNDepth.INFINITY); + walker.go(path, Depth.INFINITY); } partner.setFileProvider(fileProvider); for (SvnScopeZipper.MyDirNonRecursive item : nonRecursiveMap.values()) { - walker.go(item.getDir(), SVNDepth.IMMEDIATES); + walker.go(item.getDir(), Depth.IMMEDIATES); } processCopiedAndDeleted(context, dirtyScope); @@ -111,6 +112,10 @@ public class SvnChangeProvider implements ChangeProvider { } } + /** + * TODO: Currently could not find exact case when "file status is not correctly refreshed after external commit" that is covered by this + * TODO: code. So for now, checks for formats greater than 1.7 are not added here. + */ private static void putAdministrative17UnderVfsListener(Set<NestedCopyInfo> pointInfos) { if (! SvnVcs.ourListenToWcDb) return; final LocalFileSystem lfs = LocalFileSystem.getInstance(); @@ -169,11 +174,12 @@ public class SvnChangeProvider implements ChangeProvider { } } - public void getChanges(final FilePath path, final boolean recursive, final ChangelistBuilder builder) throws SVNException { + public void getChanges(final FilePath path, final boolean recursive, final ChangelistBuilder builder) + throws SVNException, SvnBindException { final SvnChangeProviderContext context = new SvnChangeProviderContext(myVcs, builder, null); final StatusWalkerPartner partner = new StatusWalkerPartner(myVcs, ProgressManager.getInstance().getProgressIndicator()); final SvnRecursiveStatusWalker walker = new SvnRecursiveStatusWalker(myVcs, context, partner); - walker.go(path, recursive ? SVNDepth.INFINITY : SVNDepth.IMMEDIATES); + walker.go(path, recursive ? Depth.INFINITY : Depth.IMMEDIATES); processCopiedAndDeleted(context, null); } @@ -181,7 +187,7 @@ public class SvnChangeProvider implements ChangeProvider { ChangelistBuilder builder, SvnChangeProviderContext context, final VcsDirtyScope dirtyScope) throws SVNException { boolean foundRename = false; - final SVNStatus copiedStatus = copiedFile.getStatus(); + final Status copiedStatus = copiedFile.getStatus(); final String copyFromURL = copiedFile.getCopyFromURL(); final FilePath copiedToPath = copiedFile.getFilePath(); @@ -199,7 +205,7 @@ public class SvnChangeProvider implements ChangeProvider { for (Iterator<SvnChangedFile> iterator = context.getDeletedFiles().iterator(); iterator.hasNext();) { SvnChangedFile deletedFile = iterator.next(); - final SVNStatus deletedStatus = deletedFile.getStatus(); + final Status deletedStatus = deletedFile.getStatus(); if ((deletedStatus != null) && (deletedStatus.getURL() != null) && Comparing.equal(copyFromURL, deletedStatus.getURL().toString())) { final String clName = SvnUtil.getChangelistName(copiedFile.getStatus()); final Change newChange = context.createMovedChange(createBeforeRevision(deletedFile, true), @@ -208,7 +214,7 @@ public class SvnChangeProvider implements ChangeProvider { applyMovedChange(copiedFile.getFilePath(), builder, dirtyScope, deletedToDelete, deletedFile, clName, newChange); for(Iterator<SvnChangedFile> iterChild = context.getDeletedFiles().iterator(); iterChild.hasNext();) { SvnChangedFile deletedChild = iterChild.next(); - final SVNStatus childStatus = deletedChild.getStatus(); + final Status childStatus = deletedChild.getStatus(); if (childStatus == null) { continue; } @@ -243,15 +249,15 @@ public class SvnChangeProvider implements ChangeProvider { // by building a relative url if (!foundRename && copiedStatus.getURL() != null) { File wcPath = guessWorkingCopyPath(copiedStatus.getFile(), copiedStatus.getURL(), copyFromURL); - SVNStatus status; + Status status; try { status = myVcs.getFactory(wcPath).createStatusClient().doStatus(wcPath, false); } - catch(SVNException ex) { + catch(SvnBindException ex) { LOG.info(ex); status = null; } - if (status != null && SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + if (status != null && status.is(StatusType.STATUS_DELETED)) { final FilePath filePath = myFactory.createFilePathOnDeleted(wcPath, false); final SvnContentRevision beforeRevision = SvnContentRevision.createBaseRevision(myVcs, filePath, status.getRevision()); final ContentRevision afterRevision = CurrentContentRevision.create(copiedFile.getFilePath()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java index f7e5857569ff..716abbe1b20b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangeProviderContext.java @@ -26,13 +26,13 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.actions.AbstractShowPropertiesDiffAction; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.lock.Lock; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLock; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.*; @@ -44,7 +44,7 @@ class SvnChangeProviderContext implements StatusReceiver { private List<SvnChangedFile> myCopiedFiles = null; private final List<SvnChangedFile> myDeletedFiles = new ArrayList<SvnChangedFile>(); // for files moved in a subtree, which were the targets of merge (for instance). - private final Map<String, SVNStatus> myTreeConflicted; + private final Map<String, Status> myTreeConflicted; private Map<FilePath, String> myCopyFromURLs = null; private final SvnVcs myVcs; private final SvnBranchConfigurationManager myBranchConfigurationManager; @@ -55,11 +55,11 @@ class SvnChangeProviderContext implements StatusReceiver { myVcs = vcs; myChangelistBuilder = changelistBuilder; myProgress = progress; - myTreeConflicted = new HashMap<String, SVNStatus>(); + myTreeConflicted = new HashMap<String, Status>(); myBranchConfigurationManager = SvnBranchConfigurationManager.getInstance(myVcs.getProject()); } - public void process(FilePath path, SVNStatus status) throws SVNException { + public void process(FilePath path, Status status) throws SVNException { processStatusFirstPass(path, status); } @@ -83,12 +83,12 @@ class SvnChangeProviderContext implements StatusReceiver { return myChangelistBuilder; } - public void reportTreeConflict(final SVNStatus status) { + public void reportTreeConflict(final Status status) { myTreeConflicted.put(status.getFile().getAbsolutePath(), status); } @Nullable - public SVNStatus getTreeConflictStatus(final File file) { + public Status getTreeConflictStatus(final File file) { return myTreeConflicted.get(file.getAbsolutePath()); } @@ -140,7 +140,7 @@ class SvnChangeProviderContext implements StatusReceiver { return null; } - public void addCopiedFile(final FilePath filePath, final SVNStatus status, final String copyFromURL) { + public void addCopiedFile(final FilePath filePath, final Status status, final String copyFromURL) { if (myCopiedFiles == null) { myCopiedFiles = new ArrayList<SvnChangedFile>(); } @@ -160,19 +160,19 @@ class SvnChangeProviderContext implements StatusReceiver { // - void processStatusFirstPass(final FilePath filePath, final SVNStatus status) throws SVNException { + void processStatusFirstPass(final FilePath filePath, final Status status) throws SVNException { if (status == null) { // external to wc return; } if (status.getRemoteLock() != null) { - final SVNLock lock = status.getRemoteLock(); + final Lock lock = status.getRemoteLock(); myChangelistBuilder.processLogicallyLockedFolder(filePath.getVirtualFile(), new LogicalLock(false, lock.getOwner(), lock.getComment(), lock.getCreationDate(), lock.getExpirationDate())); } if (status.getLocalLock() != null) { - final SVNLock lock = status.getLocalLock(); + final Lock lock = status.getLocalLock(); myChangelistBuilder.processLogicallyLockedFolder(filePath.getVirtualFile(), new LogicalLock(true, lock.getOwner(), lock.getComment(), lock.getCreationDate(), lock.getExpirationDate())); @@ -180,11 +180,11 @@ class SvnChangeProviderContext implements StatusReceiver { if (filePath.isDirectory() && status.isLocked()) { myChangelistBuilder.processLockedFolder(filePath.getVirtualFile()); } - if ((SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED) || SVNStatusType.STATUS_MODIFIED.equals(status.getNodeStatus())) && + if ((status.is(StatusType.STATUS_ADDED) || StatusType.STATUS_MODIFIED.equals(status.getNodeStatus())) && status.getCopyFromURL() != null) { addCopiedFile(filePath, status, status.getCopyFromURL()); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + else if (status.is(StatusType.STATUS_DELETED)) { myDeletedFiles.add(new SvnChangedFile(filePath, status)); } else { @@ -198,7 +198,7 @@ class SvnChangeProviderContext implements StatusReceiver { } } - void processStatus(final FilePath filePath, final SVNStatus status) throws SVNException { + void processStatus(final FilePath filePath, final Status status) throws SVNException { WorkingCopyFormat format = myVcs.getWorkingCopyFormat(filePath.getIOFile()); if (!WorkingCopyFormat.UNKNOWN.equals(format) && format.less(WorkingCopyFormat.ONE_DOT_SEVEN)) { loadEntriesFile(filePath); @@ -207,38 +207,36 @@ class SvnChangeProviderContext implements StatusReceiver { if (status != null) { FileStatus fStatus = SvnStatusConvertor.convertStatus(status); - final SVNStatusType statusType = status.getContentsStatus(); - final SVNStatusType propStatus = status.getPropertiesStatus(); - if (SvnVcs.svnStatusIsUnversioned(status) || SvnVcs.svnStatusIs(status, SVNStatusType.UNKNOWN)) { + final StatusType statusType = status.getContentsStatus(); + final StatusType propStatus = status.getPropertiesStatus(); + if (status.is(StatusType.STATUS_UNVERSIONED, StatusType.UNKNOWN)) { final VirtualFile file = filePath.getVirtualFile(); if (file != null) { myChangelistBuilder.processUnversionedFile(file); } } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { + else if (status.is(StatusType.STATUS_ADDED)) { myChangelistBuilder.processChangeInList(createChange(null, CurrentContentRevision.create(filePath), fStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey()); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_CONFLICTED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MODIFIED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_REPLACED) || - propStatus == SVNStatusType.STATUS_MODIFIED || - propStatus == SVNStatusType.STATUS_CONFLICTED) { + else if (status.is(StatusType.STATUS_CONFLICTED, StatusType.STATUS_MODIFIED, StatusType.STATUS_REPLACED) || + propStatus == StatusType.STATUS_MODIFIED || + propStatus == StatusType.STATUS_CONFLICTED) { myChangelistBuilder.processChangeInList( createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), fStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey() ); checkSwitched(filePath, myChangelistBuilder, status, fStatus); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + else if (status.is(StatusType.STATUS_DELETED)) { myChangelistBuilder.processChangeInList( createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, status), null, fStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey()); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) { + else if (status.is(StatusType.STATUS_MISSING)) { myChangelistBuilder.processLocallyDeletedFile(createLocallyDeletedChange(filePath, status)); } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) { + else if (status.is(StatusType.STATUS_IGNORED)) { if (!myVcs.isWcRoot(filePath)) { myChangelistBuilder.processIgnoredFile(filePath.getVirtualFile()); } @@ -246,7 +244,7 @@ class SvnChangeProviderContext implements StatusReceiver { else if (status.isCopied()) { // } - else if ((fStatus == FileStatus.NOT_CHANGED || fStatus == FileStatus.SWITCHED) && statusType != SVNStatusType.STATUS_NONE) { + else if ((fStatus == FileStatus.NOT_CHANGED || fStatus == FileStatus.SWITCHED) && statusType != StatusType.STATUS_NONE) { VirtualFile file = filePath.getVirtualFile(); if (file != null && FileDocumentManager.getInstance().isFileModified(file)) { myChangelistBuilder.processChangeInList( @@ -266,10 +264,10 @@ class SvnChangeProviderContext implements StatusReceiver { public void addModifiedNotSavedChange(final VirtualFile file) throws SVNException { final FilePath filePath = new FilePathImpl(file); - final SVNInfo svnInfo = myVcs.getInfo(file); + final Info svnInfo = myVcs.getInfo(file); if (svnInfo != null) { - final SVNStatus svnStatus = new SVNStatus(); + final Status svnStatus = new Status(); svnStatus.setRevision(svnInfo.getRevision()); myChangelistBuilder.processChangeInList( createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, svnInfo.getRevision()), CurrentContentRevision.create(filePath), @@ -278,7 +276,7 @@ class SvnChangeProviderContext implements StatusReceiver { } } - private void checkSwitched(final FilePath filePath, final ChangelistBuilder builder, final SVNStatus status, + private void checkSwitched(final FilePath filePath, final ChangelistBuilder builder, final Status status, final FileStatus convertedStatus) { if (status.isSwitched() || (convertedStatus == FileStatus.SWITCHED)) { final VirtualFile virtualFile = filePath.getVirtualFile(); @@ -322,8 +320,8 @@ class SvnChangeProviderContext implements StatusReceiver { // seems here we can only have a tree conflict; which can be marked on either path (?) // .. ok try to merge states - Change createMovedChange(final ContentRevision before, final ContentRevision after, final SVNStatus copiedStatus, - final SVNStatus deletedStatus) throws SVNException { + Change createMovedChange(final ContentRevision before, final ContentRevision after, final Status copiedStatus, + final Status deletedStatus) throws SVNException { // todo no convertion needed for the contents status? final ConflictedSvnChange conflictedSvnChange = new ConflictedSvnChange(before, after, ConflictState.mergeState(getState(copiedStatus), getState(deletedStatus)), @@ -340,13 +338,13 @@ class SvnChangeProviderContext implements StatusReceiver { private Change createChange(final ContentRevision before, final ContentRevision after, final FileStatus fStatus, - final SVNStatus svnStatus) + final Status svnStatus) throws SVNException { final ConflictedSvnChange conflictedSvnChange = new ConflictedSvnChange(before, after, correctContentsStatus(fStatus, svnStatus), getState(svnStatus), after == null ? before.getFile() : after.getFile()); if (svnStatus != null) { - if (SVNStatusType.STATUS_DELETED.equals(svnStatus.getNodeStatus()) && !svnStatus.getRevision().isValid()) { + if (StatusType.STATUS_DELETED.equals(svnStatus.getNodeStatus()) && !svnStatus.getRevision().isValid()) { conflictedSvnChange.setIsPhantom(true); } conflictedSvnChange.setBeforeDescription(svnStatus.getTreeConflict()); @@ -354,31 +352,31 @@ class SvnChangeProviderContext implements StatusReceiver { return patchWithPropertyChange(conflictedSvnChange, svnStatus, null); } - private FileStatus correctContentsStatus(final FileStatus fs, final SVNStatus svnStatus) throws SVNException { + private FileStatus correctContentsStatus(final FileStatus fs, final Status svnStatus) throws SVNException { //if (svnStatus.isSwitched()) return FileStatus.SWITCHED; return fs; //return SvnStatusConvertor.convertContentsStatus(svnStatus); } - private LocallyDeletedChange createLocallyDeletedChange(@NotNull FilePath filePath, final SVNStatus status) { + private LocallyDeletedChange createLocallyDeletedChange(@NotNull FilePath filePath, final Status status) { return new SvnLocallyDeletedChange(filePath, getState(status)); } - private Change patchWithPropertyChange(final Change change, final SVNStatus svnStatus, final SVNStatus deletedStatus) + private Change patchWithPropertyChange(final Change change, final Status svnStatus, final Status deletedStatus) throws SVNException { if (svnStatus == null) return change; - final SVNStatusType propertiesStatus = svnStatus.getPropertiesStatus(); - if (SVNStatusType.STATUS_CONFLICTED.equals(propertiesStatus) || SVNStatusType.CHANGED.equals(propertiesStatus) || - SVNStatusType.STATUS_ADDED.equals(propertiesStatus) || SVNStatusType.STATUS_DELETED.equals(propertiesStatus) || - SVNStatusType.STATUS_MODIFIED.equals(propertiesStatus) || SVNStatusType.STATUS_REPLACED.equals(propertiesStatus) || - SVNStatusType.MERGED.equals(propertiesStatus)) { + final StatusType propertiesStatus = svnStatus.getPropertiesStatus(); + if (StatusType.STATUS_CONFLICTED.equals(propertiesStatus) || StatusType.CHANGED.equals(propertiesStatus) || + StatusType.STATUS_ADDED.equals(propertiesStatus) || StatusType.STATUS_DELETED.equals(propertiesStatus) || + StatusType.STATUS_MODIFIED.equals(propertiesStatus) || StatusType.STATUS_REPLACED.equals(propertiesStatus) || + StatusType.MERGED.equals(propertiesStatus)) { final FilePath path = ChangesUtil.getFilePath(change); final File ioFile = path.getIOFile(); final File beforeFile = deletedStatus != null ? deletedStatus.getFile() : ioFile; - final String beforeList = SVNStatusType.STATUS_ADDED.equals(propertiesStatus) && deletedStatus == null ? null : + final String beforeList = StatusType.STATUS_ADDED.equals(propertiesStatus) && deletedStatus == null ? null : AbstractShowPropertiesDiffAction.getPropertyList(myVcs, beforeFile, SVNRevision.BASE); - final String afterList = SVNStatusType.STATUS_DELETED.equals(propertiesStatus) ? null : + final String afterList = StatusType.STATUS_DELETED.equals(propertiesStatus) ? null : AbstractShowPropertiesDiffAction.getPropertyList(myVcs, ioFile, SVNRevision.WORKING); // TODO: There are cases when status output is like (on newly added file with some properties that is locally deleted) @@ -398,16 +396,16 @@ class SvnChangeProviderContext implements StatusReceiver { return change; } - private ConflictState getState(@Nullable final SVNStatus svnStatus) { + private ConflictState getState(@Nullable final Status svnStatus) { if (svnStatus == null) { return ConflictState.none; } - final SVNStatusType propertiesStatus = svnStatus.getPropertiesStatus(); + final StatusType propertiesStatus = svnStatus.getPropertiesStatus(); final boolean treeConflict = svnStatus.getTreeConflict() != null; - final boolean textConflict = SVNStatusType.STATUS_CONFLICTED == svnStatus.getContentsStatus(); - final boolean propertyConflict = SVNStatusType.STATUS_CONFLICTED == propertiesStatus; + final boolean textConflict = StatusType.STATUS_CONFLICTED == svnStatus.getContentsStatus(); + final boolean propertyConflict = StatusType.STATUS_CONFLICTED == propertiesStatus; if (treeConflict) { reportTreeConflict(svnStatus); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java index 2bd5ee497102..8d4fab4ec40a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangedFile.java @@ -16,19 +16,19 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.vcs.FilePath; -import org.tmatesoft.svn.core.wc.SVNStatus; +import org.jetbrains.idea.svn.status.Status; class SvnChangedFile { private final FilePath myFilePath; - private final SVNStatus myStatus; + private final Status myStatus; private String myCopyFromURL; - public SvnChangedFile(final FilePath filePath, final SVNStatus status) { + public SvnChangedFile(final FilePath filePath, final Status status) { myFilePath = filePath; myStatus = status; } - public SvnChangedFile(final FilePath filePath, final SVNStatus status, final String copyFromURL) { + public SvnChangedFile(final FilePath filePath, final Status status, final String copyFromURL) { myFilePath = filePath; myStatus = status; myCopyFromURL = copyFromURL; @@ -38,7 +38,7 @@ class SvnChangedFile { return myFilePath; } - public SVNStatus getStatus() { + public Status getStatus() { return myStatus; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java index 00fa3a1cf9aa..a66146e259a6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnChangelistListener.java @@ -28,9 +28,8 @@ import com.intellij.openapi.vcs.changes.ChangeListListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.SVNErrorCode; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.io.File; import java.util.ArrayList; @@ -136,12 +135,11 @@ public class SvnChangelistListener implements ChangeListListener { @Nullable public static String getCurrentMapping(final SvnVcs vcs, final File file) { try { - final SVNStatus status = vcs.getFactory(file).createStatusClient().doStatus(file, false); + final Status status = vcs.getFactory(file).createStatusClient().doStatus(file, false); return status == null ? null : status.getChangelistName(); } - catch (SVNException e) { - final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode(); - if (SVNErrorCode.WC_NOT_DIRECTORY.equals(errorCode) || SVNErrorCode.WC_NOT_FILE.equals(errorCode)) { + catch (SvnBindException e) { + if (e.contains(SVNErrorCode.WC_NOT_DIRECTORY) || e.contains(SVNErrorCode.WC_NOT_FILE)) { LOG.debug("Logging only, exception is valid (caught) here", e); } else { LOG.info("Logging only, exception is valid (caught) here", e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java index 790cdae37629..6f5013c4a929 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfiguration.java @@ -26,13 +26,14 @@ import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.changes.VcsAnnotationRefresher; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationManager; import org.jetbrains.idea.svn.auth.SvnAuthenticationProvider; import org.jetbrains.idea.svn.auth.SvnInteractiveAuthenticationProvider; import org.jetbrains.idea.svn.config.SvnServerFileKeys; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.jetbrains.idea.svn.update.MergeRootInfo; import org.jetbrains.idea.svn.update.UpdateRootInfo; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNErrorMessage; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider; @@ -41,7 +42,6 @@ import org.tmatesoft.svn.core.internal.wc.ISVNAuthenticationStorage; import org.tmatesoft.svn.core.internal.wc.SVNConfigFile; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; import org.tmatesoft.svn.core.wc.ISVNOptions; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNWCUtil; import java.io.File; @@ -76,9 +76,6 @@ public class SvnConfiguration implements PersistentStateComponent<SvnConfigurati private SvnAuthenticationManager myInteractiveManager; public static final AuthStorage RUNTIME_AUTH_CACHE = new AuthStorage(); - // TODO: update depth is not stored in configuration as SVNDepth has wrong type for DefaultJDOMExternalizer - // TODO: check if it should be stored - public SVNDepth UPDATE_DEPTH = SVNDepth.UNKNOWN; private final Map<File, MergeRootInfo> myMergeRootInfos = new HashMap<File, MergeRootInfo>(); private final Map<File, UpdateRootInfo> myUpdateRootInfos = new HashMap<File, UpdateRootInfo>(); @@ -109,8 +106,9 @@ public class SvnConfiguration implements PersistentStateComponent<SvnConfigurati } } - public SVNDiffOptions getMergeOptions() { - return new SVNDiffOptions(isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge()); + @NotNull + public DiffOptions getMergeOptions() { + return new DiffOptions(isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge(), isIgnoreSpacesInMerge()); } private void initServers() { @@ -180,12 +178,12 @@ public class SvnConfiguration implements PersistentStateComponent<SvnConfigurati myState.sslProtocols = sslProtocols; } - public SVNDepth getUpdateDepth() { - return UPDATE_DEPTH; + public Depth getUpdateDepth() { + return myState.UPDATE_DEPTH; } - public void setUpdateDepth(SVNDepth updateDepth) { - this.UPDATE_DEPTH = updateDepth; + public void setUpdateDepth(Depth updateDepth) { + myState.UPDATE_DEPTH = updateDepth; } public UseAcceleration getUseAcceleration() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java index 8d155399c101..5d5585accf1a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnConfigurationState.java @@ -17,6 +17,7 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.util.SystemInfo; import com.intellij.util.xmlb.annotations.*; +import org.jetbrains.idea.svn.api.Depth; /** * @author Konstantin Kolosovsky. @@ -70,6 +71,7 @@ public class SvnConfigurationState { public boolean SHOW_MERGE_SOURCES_IN_ANNOTATE = true; public boolean FORCE_UPDATE; public boolean IGNORE_EXTERNALS; + public Depth UPDATE_DEPTH = Depth.UNKNOWN; @Tag("configuration") public static class ConfigurationDirectory { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java index 6e9693bdd6eb..d2dbe84f5505 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java @@ -29,8 +29,8 @@ import com.intellij.openapi.vcs.impl.CurrentRevisionProvider; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -56,7 +56,7 @@ public class SvnContentRevision implements ContentRevision, MarkerVcsContentRevi myFile = file; } - public static SvnContentRevision createBaseRevision(@NotNull SvnVcs vcs, @NotNull final FilePath file, final SVNStatus status) { + public static SvnContentRevision createBaseRevision(@NotNull SvnVcs vcs, @NotNull final FilePath file, final Status status) { SVNRevision revision = status.getRevision().isValid() ? status.getRevision() : status.getCommittedRevision(); return createBaseRevision(vcs, file, revision); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java index 8aade42edc1c..49ea87d44f6e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java @@ -32,7 +32,12 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.history.LatestExistentSearcher; +import org.jetbrains.idea.svn.info.InfoConsumer; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; @@ -55,13 +60,13 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } public VcsRevisionNumber getCurrentRevision(VirtualFile file) { - final SVNInfo svnInfo = myVcs.getInfo(new File(file.getPresentableUrl())); + final Info svnInfo = myVcs.getInfo(new File(file.getPresentableUrl())); return getRevision(svnInfo); } @Nullable - private static VcsRevisionNumber getRevision(@Nullable SVNInfo info) { + private static VcsRevisionNumber getRevision(@Nullable Info info) { VcsRevisionNumber result = null; if (info != null) { @@ -106,11 +111,11 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } @NotNull - private static ISVNInfoHandler createInfoHandler(@NotNull final Map<VirtualFile, VcsRevisionNumber> revisionMap, + private static InfoConsumer createInfoHandler(@NotNull final Map<VirtualFile, VcsRevisionNumber> revisionMap, @NotNull final Map<String, VirtualFile> fileMap) { - return new ISVNInfoHandler() { + return new InfoConsumer() { @Override - public void handleInfo(SVNInfo info) throws SVNException { + public void consume(Info info) throws SVNException { if (info != null) { VirtualFile file = fileMap.get(info.getFile().getAbsolutePath()); @@ -132,7 +137,7 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } private VcsRevisionDescription getCurrentRevisionDescription(File path) { - final SVNInfo svnInfo = myVcs.getInfo(path); + final Info svnInfo = myVcs.getInfo(path); if (svnInfo == null) { return null; } @@ -187,20 +192,20 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } // not clear why we need it, with remote check.. - SVNStatus svnStatus = getFileStatus(new File(selectedFile.getPresentableUrl()), false); + Status svnStatus = getFileStatus(new File(selectedFile.getPresentableUrl()), false); if (svnStatus != null && svnRevision.equals(svnStatus.getRevision())) { return SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision); } return SvnContentRevision.createRemote(myVcs, filePath, svnRevision); } - private SVNStatus getFileStatus(File file, boolean remote) { - SVNStatus result = null; + private Status getFileStatus(File file, boolean remote) { + Status result = null; try { - result = myVcs.getFactory(file).createStatusClient().doStatus(file, remote, false); + result = myVcs.getFactory(file).createStatusClient().doStatus(file, remote); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.debug(e); } @@ -217,10 +222,10 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif } private ItemLatestState getLastRevision(final File file) { - final SVNStatus svnStatus = getFileStatus(file, true); + final Status svnStatus = getFileStatus(file, true); if (svnStatus == null || itemExists(svnStatus) && SVNRevision.UNDEFINED.equals(svnStatus.getRemoteRevision())) { // IDEADEV-21785 (no idea why this can happen) - final SVNInfo info = myVcs.getInfo(file, SVNRevision.HEAD); + final Info info = myVcs.getInfo(file, SVNRevision.HEAD); if (info == null || info.getURL() == null) { LOG.info("No SVN status returned for " + file.getPath()); return defaultResult(); @@ -232,8 +237,8 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif WorkingCopyFormat format = myVcs.getWorkingCopyFormat(file); long revision = -1; - // skipped for 1.8 - if (!WorkingCopyFormat.ONE_DOT_EIGHT.equals(format)) { + // skipped for >= 1.8 + if (format.less(WorkingCopyFormat.ONE_DOT_EIGHT)) { // get really latest revision // TODO: Algorithm seems not to be correct in all cases - for instance, when some subtree was deleted and replaced by other // TODO: with same names. pegRevision should be used somehow but this complicates the algorithm @@ -254,8 +259,8 @@ public class SvnDiffProvider extends DiffProviderEx implements DiffProvider, Dif return createResult(svnStatus.getRevision(), exists, false); } - private boolean itemExists(SVNStatus svnStatus) { - return ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteContentsStatus()) && - ! SVNStatusType.STATUS_DELETED.equals(svnStatus.getRemoteNodeStatus()); + private boolean itemExists(Status svnStatus) { + return ! StatusType.STATUS_DELETED.equals(svnStatus.getRemoteContentsStatus()) && + ! StatusType.STATUS_DELETED.equals(svnStatus.getRemoteNodeStatus()); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java index 5c5419d10ade..02185ec7f9a0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileSystemListener.java @@ -45,13 +45,16 @@ import com.intellij.util.containers.MultiMap; import com.intellij.vcsUtil.ActionWithTempFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.*; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNMoveClient; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.io.IOException; @@ -153,8 +156,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return null; } - final SVNStatus fileStatus = getFileStatus(vcs, srcFile); - if (fileStatus != null && SvnVcs.svnStatusIs(fileStatus, SVNStatusType.STATUS_ADDED)) { + final Status fileStatus = getFileStatus(vcs, srcFile); + if (fileStatus != null && fileStatus.is(StatusType.STATUS_ADDED)) { myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false)); return null; } @@ -189,9 +192,9 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp @Nullable public String getRepositoryUUID(final Project project, final VirtualFile dir) { try { - final SVNInfo info1 = new RepeatSvnActionThroughBusy() { + final Info info1 = new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { + protected void executeImpl() { myT = myVcs.getInfo(new File(dir.getPath())); } }.compute(); @@ -207,7 +210,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } else { return info1.getRepositoryUUID(); } - } catch (SVNException e) { + } + catch (VcsException e) { // go to return default } return null; @@ -264,18 +268,18 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp final String list = isUndo ? null : SvnChangelistListener.getCurrentMapping(vcs, src); WorkingCopyFormat format = vcs.getWorkingCopyFormat(src); - final boolean is17OrLater = WorkingCopyFormat.ONE_DOT_EIGHT.equals(format) || WorkingCopyFormat.ONE_DOT_SEVEN.equals(format); + final boolean is17OrLater = format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN); if (is17OrLater) { - SVNStatus srcStatus = getFileStatus(vcs, src); + Status srcStatus = getFileStatus(vcs, src); final File toDir = dst.getParentFile(); - SVNStatus dstStatus = getFileStatus(vcs, toDir); - final boolean srcUnversioned = srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus); - if (srcUnversioned && (dstStatus == null || SvnVcs.svnStatusIsUnversioned(dstStatus))) { + Status dstStatus = getFileStatus(vcs, toDir); + final boolean srcUnversioned = srcStatus == null || srcStatus.is(StatusType.STATUS_UNVERSIONED); + if (srcUnversioned && (dstStatus == null || dstStatus.is(StatusType.STATUS_UNVERSIONED))) { return false; } if (srcUnversioned) { - SVNStatus dstWasStatus = getFileStatus(vcs, dst); - if (dstWasStatus == null || SvnVcs.svnStatusIsUnversioned(dstWasStatus)) { + Status dstWasStatus = getFileStatus(vcs, dst); + if (dstWasStatus == null || dstWasStatus.is(StatusType.STATUS_UNVERSIONED)) { return false; } } @@ -289,10 +293,6 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } dst.setLastModified(srcTime); } - catch (SVNException e) { - addToMoveExceptions(vcs.getProject(), e); - return false; - } catch(VcsException e) { addToMoveExceptions(vcs.getProject(), e); return false; @@ -300,12 +300,12 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return true; } - private final static Set<SVNStatusType> ourStatusesForUndoMove = new HashSet<SVNStatusType>(); + private final static Set<StatusType> ourStatusesForUndoMove = new HashSet<StatusType>(); static { - ourStatusesForUndoMove.add(SVNStatusType.STATUS_ADDED); + ourStatusesForUndoMove.add(StatusType.STATUS_ADDED); } - private boolean for17move(final SvnVcs vcs, final File src, final File dst, boolean undo, SVNStatus srcStatus) throws SVNException { + private boolean for17move(final SvnVcs vcs, final File src, final File dst, boolean undo, Status srcStatus) throws VcsException { if (srcStatus != null && srcStatus.getCopyFromURL() == null) { undo = false; } @@ -313,7 +313,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp myUndoingMove = true; createRevertAction(vcs, dst, true).execute(); copyUnversionedMembersOfDirectory(src, dst); - if (srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus)) { + if (srcStatus == null || srcStatus.is(StatusType.STATUS_UNVERSIONED)) { FileUtil.delete(src); } else { createRevertAction(vcs, src, true).execute(); @@ -322,13 +322,13 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } else { if (doUsualMove(vcs, src)) return true; // check destination directory - final SVNStatus dstParentStatus = getFileStatus(vcs, dst.getParentFile()); - if (dstParentStatus == null || SvnVcs.svnStatusIsUnversioned(dstParentStatus)) { + final Status dstParentStatus = getFileStatus(vcs, dst.getParentFile()); + if (dstParentStatus == null || dstParentStatus.is(StatusType.STATUS_UNVERSIONED)) { try { copyFileOrDir(src, dst); } catch (IOException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } createDeleteAction(vcs, src, true).execute(); return false; @@ -338,23 +338,18 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return false; } - public static void moveFileWithSvn(final SvnVcs vcs, final File src, final File dst) throws SVNException { + public static void moveFileWithSvn(final SvnVcs vcs, final File src, final File dst) throws VcsException { new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(src).createCopyMoveClient().copy(src, dst, false, true); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(src).createCopyMoveClient().copy(src, dst, false, true); } }.execute(); } - private void copyUnversionedMembersOfDirectory(final File src, final File dst) throws SVNException { + private void copyUnversionedMembersOfDirectory(final File src, final File dst) throws SvnBindException { if (src.isDirectory()) { - final SVNException[] exc = new SVNException[1]; + final SvnBindException[] exc = new SvnBindException[1]; FileUtil.processFilesRecursively(src, new Processor<File>() { @Override public boolean process(File file) { @@ -365,7 +360,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp copyFileOrDir(src, dst); } catch (IOException e) { - exc[0] = new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + exc[0] = new SvnBindException(e); return false; } } @@ -388,25 +383,25 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp private boolean doUsualMove(SvnVcs vcs, File src) { // if src is not under version control, do usual move. - SVNStatus srcStatus = getFileStatus(vcs, src); - if (srcStatus == null || SvnVcs.svnStatusIsUnversioned(srcStatus) || - SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_OBSTRUCTED) || - SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_MISSING) || - SvnVcs.svnStatusIs(srcStatus, SVNStatusType.STATUS_EXTERNAL)) { - return true; - } - return false; + Status srcStatus = getFileStatus(vcs, src); + return srcStatus == null || + srcStatus.is(StatusType.STATUS_UNVERSIONED, StatusType.STATUS_OBSTRUCTED, StatusType.STATUS_MISSING, StatusType.STATUS_EXTERNAL); } - private boolean for16move(SvnVcs vcs, final File src, final File dst, boolean undo) throws SVNException { + private boolean for16move(SvnVcs vcs, final File src, final File dst, boolean undo) throws VcsException { final SVNMoveClient mover = vcs.getSvnKitManager().createMoveClient(); if (undo) { myUndoingMove = true; restoreFromUndoStorage(dst); new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - mover.undoMove(src, dst); + protected void executeImpl() throws VcsException { + try { + mover.undoMove(src, dst); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } }.execute(); } @@ -415,8 +410,13 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp if (doUsualMove(vcs, src)) return true; new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - mover.doMove(src, dst); + protected void executeImpl() throws VcsException { + try { + mover.doMove(src, dst); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } }.execute(); } @@ -488,16 +488,14 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return false; } - SVNStatus status = getFileStatus(vcs, ioFile); + Status status = getFileStatus(vcs, ioFile); if (status == null || - SvnVcs.svnStatusIsUnversioned(status) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) { + status.is(StatusType.STATUS_UNVERSIONED, StatusType.STATUS_OBSTRUCTED, StatusType.STATUS_MISSING, StatusType.STATUS_EXTERNAL, + StatusType.STATUS_IGNORED)) { return false; - } else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + } + else if (status.is(StatusType.STATUS_DELETED)) { if (isUndo(vcs)) { moveToUndoStorage(file); } @@ -509,11 +507,11 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp myDeletedFiles.putValue(vcs.getProject(), ioFile); return true; } - if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { + if (status.is(StatusType.STATUS_ADDED)) { try { createRevertAction(vcs, ioFile, false).execute(); } - catch (SVNException e) { + catch (VcsException e) { // ignore } } @@ -531,13 +529,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp private RepeatSvnActionThroughBusy createRevertAction(@NotNull final SvnVcs vcs, @NotNull final File file, final boolean recursive) { return new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(file).createRevertClient().revert(new File[]{file}, SVNDepth.fromRecurse(recursive), null); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(file).createRevertClient().revert(new File[]{file}, Depth.allOrFiles(recursive), null); } }; } @@ -546,22 +539,12 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp private RepeatSvnActionThroughBusy createDeleteAction(@NotNull final SvnVcs vcs, @NotNull final File file, final boolean force) { return new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(file).createDeleteClient().delete(file, force, false, null); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(file).createDeleteClient().delete(file, force, false, null); } }; } - private static void wrapAndThrow(VcsException e) throws SVNException { - // TODO: probably we should wrap into new exception only if e.getCause is not SVNException - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, e), e); - } - private boolean isAboveSourceOfCopyOrMove(final Project p, File ioFile) { for (MovedFileInfo file : myMovedFiles) { if (FileUtil.isAncestor(ioFile, file.mySrc, false)) return true; @@ -617,20 +600,20 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp return false; } final File targetFile = new File(ioDir, name); - SVNStatus status = getFileStatus(vcs, targetFile); + Status status = getFileStatus(vcs, targetFile); - if (status == null || status.getContentsStatus() == SVNStatusType.STATUS_NONE || - status.getContentsStatus() == SVNStatusType.STATUS_UNVERSIONED) { + if (status == null || status.getContentsStatus() == StatusType.STATUS_NONE || + status.getContentsStatus() == StatusType.STATUS_UNVERSIONED) { myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive)); return false; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) { + else if (status.is(StatusType.STATUS_MISSING)) { return false; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { - SVNNodeKind kind = status.getKind(); + else if (status.is(StatusType.STATUS_DELETED)) { + NodeKind kind = status.getKind(); // kind differs. - if (directory && kind != SVNNodeKind.DIR || !directory && kind != SVNNodeKind.FILE) { + if (directory && !kind.isDirectory() || !directory && !kind.isFile()) { return false; } try { @@ -641,7 +624,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(dir, name, null, recursive)); return false; } - catch (SVNException e) { + catch (VcsException e) { SVNFileUtil.deleteAll(targetFile, true); return false; } @@ -794,23 +777,13 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp try { new ActionWithTempFile(ioFile) { protected void executeInternal() throws VcsException { - try { - // not recursive - new RepeatSvnActionThroughBusy() { - @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(copyFrom).createCopyMoveClient().copy(copyFrom, ioFile, true, false); - } - catch (VcsException e) { - wrapAndThrow(e); - } - } - }.execute(); - } - catch (SVNException e) { - throw new VcsException(e); - } + // not recursive + new RepeatSvnActionThroughBusy() { + @Override + protected void executeImpl() throws VcsException { + vcs.getFactory(copyFrom).createCopyMoveClient().copy(copyFrom, ioFile, true, false); + } + }.execute(); } }.execute(); } @@ -821,20 +794,15 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp else { new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { - try { - vcs.getFactory(ioFile).createAddClient().add(ioFile, null, false, false, true, null); - } - catch (VcsException e) { - wrapAndThrow(e); - } + protected void executeImpl() throws VcsException { + vcs.getFactory(ioFile).createAddClient().add(ioFile, null, false, false, true, null); } }.execute(); } VcsDirtyScopeManager.getInstance(project).fileDirty(file); } - catch (SVNException e) { - exceptions.add(new VcsException(e)); + catch (VcsException e) { + exceptions.add(e); } } } @@ -880,8 +848,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp addedFile = myLfs.refreshAndFindFileByIoFile(ioFile); } if (addedFile != null) { - final SVNStatus fileStatus = getFileStatus(vcs, ioFile); - if (fileStatus == null || ! SvnVcs.svnStatusIs(fileStatus, SVNStatusType.STATUS_IGNORED)) { + final Status fileStatus = getFileStatus(vcs, ioFile); + if (fileStatus == null || !fileStatus.is(StatusType.STATUS_IGNORED)) { boolean isIgnored = changeListManager.isIgnoredFile(addedFile); if (!isIgnored) { addedVFiles.add(addedFile); @@ -935,8 +903,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp FileUtil.delete(file.getIOFile()); } } - } catch (SVNException e) { - exceptions.add(new VcsException(e)); + } catch (VcsException e) { + exceptions.add(e); } if (! exceptions.isEmpty()) { vcsHelper.showErrors(exceptions, SvnBundle.message("delete.files.errors.title")); @@ -962,8 +930,8 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp VcsDirtyScopeManager.getInstance(project).fileDirty(file); } } - catch (SVNException e) { - exceptions.add(new VcsException(e)); + catch (VcsException e) { + exceptions.add(e); } } } @@ -988,7 +956,7 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp final String singleFilePrompt; if (deletedFiles.size() == 1 && deletedFiles.get(0).getFirst().isDirectory()) { - singleFilePrompt = WorkingCopyFormat.ONE_DOT_SEVEN.equals(deletedFiles.get(0).getSecond()) ? + singleFilePrompt = deletedFiles.get(0).getSecond().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN) ? SvnBundle.getString("confirmation.text.delete.dir.17") : SvnBundle.getString("confirmation.text.delete.dir"); } @@ -1004,17 +972,17 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } private void fillDeletedFiles(Project project, List<Pair<FilePath, WorkingCopyFormat>> deletedFiles, Collection<FilePath> deleteAnyway) - throws SVNException { + throws VcsException { final SvnVcs vcs = SvnVcs.getInstance(project); final Collection<File> files = myDeletedFiles.remove(project); for (final File file : files) { - final SVNStatus status = new RepeatSvnActionThroughBusy() { + final Status status = new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { + protected void executeImpl() throws VcsException { myT = vcs.getFactory(file).createStatusClient().doStatus(file, false); } }.compute(); - boolean isAdded = SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus()); + boolean isAdded = StatusType.STATUS_ADDED.equals(status.getNodeStatus()); final FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(file); if (isAdded) { deleteAnyway.add(filePath); @@ -1059,16 +1027,16 @@ public class SvnFileSystemListener extends CommandAdapter implements LocalFileOp } @Nullable - private static SVNStatus getFileStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { + private static Status getFileStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { try { return new RepeatSvnActionThroughBusy() { @Override - protected void executeImpl() throws SVNException { + protected void executeImpl() throws VcsException { myT = vcs.getFactory(file).createStatusClient().doStatus(file, false); } }.compute(); } - catch (SVNException e) { + catch (VcsException e) { return null; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java index f55f877fc965..11838314acbd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnFileUrlMappingImpl.java @@ -33,10 +33,10 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import java.io.File; import java.util.List; @@ -388,7 +388,7 @@ public class SvnFileUrlMappingImpl implements SvnFileUrlMapping, PersistentState if (copyRoot == null || vcsRoot == null) continue; final SvnVcs vcs = SvnVcs.getInstance(myProject); - final SVNInfo svnInfo = vcs.getInfo(copyRoot); + final Info svnInfo = vcs.getInfo(copyRoot); if ((svnInfo == null) || (svnInfo.getRepositoryRootURL() == null)) continue; Node node = new Node(copyRoot, svnInfo.getURL(), svnInfo.getRepositoryRootURL()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java index 5163dfa0ffea..dbad319b413a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnProgressCanceller.java @@ -17,15 +17,15 @@ package org.jetbrains.idea.svn; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; /** * @author yole */ -public class SvnProgressCanceller implements ISVNEventHandler { +public class SvnProgressCanceller implements ProgressTracker { public void checkCancelled() throws SVNCancelException { final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null && indicator.isCanceled()) { @@ -33,6 +33,6 @@ public class SvnProgressCanceller implements ISVNEventHandler { } } - public void handleEvent(final SVNEvent event, final double progress) throws SVNException { + public void consume(final ProgressEvent event) throws SVNException { } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java index 45b28e34b3d0..1b1cd00589d0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRecursiveStatusWalker.java @@ -31,16 +31,16 @@ import com.intellij.util.Processor; import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.internal.wc.SVNFileUtil; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.LinkedList; @@ -63,7 +63,7 @@ public class SvnRecursiveStatusWalker { myHandler = new MyHandler(); } - public void go(final FilePath rootPath, final SVNDepth depth) throws SVNException { + public void go(final FilePath rootPath, final Depth depth) throws SvnBindException { final MyItem root = createItem(rootPath, depth, false); myQueue.add(root); @@ -81,23 +81,26 @@ public class SvnRecursiveStatusWalker { client.doStatus(ioFile, SVNRevision.WORKING, item.getDepth(), false, false, true, true, myHandler, null); myHandler.checkIfCopyRootWasReported(null, ioFile); } - catch (SVNException e) { + catch (SvnBindException e) { handleStatusException(item, path, e); } } else { try { - final SVNStatus status = item.getClient().doStatus(ioFile, false, false); + final Status status = item.getClient().doStatus(ioFile, false); myReceiver.process(path, status); - } catch (SVNException e) { + } + catch (SvnBindException e) { handleStatusException(item, path, e); } + catch (SVNException e) { + handleStatusException(item, path, new SvnBindException(e)); + } } } } - private void handleStatusException(MyItem item, FilePath path, SVNException e) throws SVNException { - final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode(); - if (SVNErrorCode.WC_NOT_DIRECTORY.equals(errorCode) || SVNErrorCode.WC_NOT_FILE.equals(errorCode)) { + private void handleStatusException(MyItem item, FilePath path, SvnBindException e) throws SvnBindException { + if (e.contains(SVNErrorCode.WC_NOT_DIRECTORY) || e.contains(SVNErrorCode.WC_NOT_FILE)) { final VirtualFile virtualFile = path.getVirtualFile(); if (virtualFile != null) { if (! myPartner.isExcluded(virtualFile)) { @@ -116,11 +119,11 @@ public class SvnRecursiveStatusWalker { private static class MyItem { @NotNull private final FilePath myPath; - @NotNull private final SVNDepth myDepth; + @NotNull private final Depth myDepth; @NotNull private final StatusClient myStatusClient; private final boolean myIsInnerCopyRoot; - private MyItem(@NotNull FilePath path, @NotNull SVNDepth depth, boolean isInnerCopyRoot, @NotNull StatusClient statusClient) { + private MyItem(@NotNull FilePath path, @NotNull Depth depth, boolean isInnerCopyRoot, @NotNull StatusClient statusClient) { myPath = path; myDepth = depth; myStatusClient = statusClient; @@ -133,7 +136,7 @@ public class SvnRecursiveStatusWalker { } @NotNull - public SVNDepth getDepth() { + public Depth getDepth() { return myDepth; } @@ -147,13 +150,13 @@ public class SvnRecursiveStatusWalker { } } - private void processRecursively(final VirtualFile vFile, final SVNDepth prevDepth) { - if (SVNDepth.EMPTY.equals(prevDepth)) return; + private void processRecursively(final VirtualFile vFile, final Depth prevDepth) { + if (Depth.EMPTY.equals(prevDepth)) return; if (myPartner.isIgnoredIdeaLevel(vFile)) { myReceiver.processIgnored(vFile); return; } - final SVNDepth newDepth = SVNDepth.INFINITY.equals(prevDepth) ? SVNDepth.INFINITY : SVNDepth.EMPTY; + final Depth newDepth = Depth.INFINITY.equals(prevDepth) ? Depth.INFINITY : Depth.EMPTY; final File ioFile = new File(vFile.getPath()); final Processor<File> processor; @@ -180,7 +183,7 @@ public class SvnRecursiveStatusWalker { return true; } }; - if (SVNDepth.EMPTY.equals(newDepth)) { + if (Depth.EMPTY.equals(newDepth)) { directoryFilter = Processor.TRUE; processor = new Processor<File>() { @Override @@ -205,14 +208,14 @@ public class SvnRecursiveStatusWalker { } @NotNull - private MyItem createItem(@NotNull FilePath path, @NotNull SVNDepth depth, boolean isInnerCopyRoot) { + private MyItem createItem(@NotNull FilePath path, @NotNull Depth depth, boolean isInnerCopyRoot) { StatusClient statusClient = myVcs.getFactory(path.getIOFile()).createStatusClient(myPartner.getFileProvider(), myPartner.getEventHandler()); return new MyItem(path, depth, isInnerCopyRoot, statusClient); } - private class MyHandler implements ISVNStatusHandler { + private class MyHandler implements StatusConsumer { private MyItem myCurrentItem; private boolean myMetCurrentItem; @@ -221,37 +224,36 @@ public class SvnRecursiveStatusWalker { myMetCurrentItem = false; } - public void checkIfCopyRootWasReported(@Nullable final SVNStatus ioFileStatus, final File ioFile) { + public void checkIfCopyRootWasReported(@Nullable final Status ioFileStatus, final File ioFile) { File itemFile = myCurrentItem.getPath().getIOFile(); if (! myMetCurrentItem && FileUtil.filesEqual(ioFile, itemFile)) { myMetCurrentItem = true; - SVNStatus statusInner; + Status statusInner; try { - statusInner = ioFileStatus != null ? ioFileStatus : - myCurrentItem.getClient().doStatus(itemFile, false); + statusInner = ioFileStatus != null ? ioFileStatus : myCurrentItem.getClient().doStatus(itemFile, false); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); statusInner = null; } if (statusInner == null) return; - final SVNStatusType status = statusInner.getNodeStatus(); + final StatusType status = statusInner.getNodeStatus(); final VirtualFile vf = myCurrentItem.getPath().getVirtualFile(); - if (SVNStatusType.STATUS_IGNORED.equals(status)) { + if (StatusType.STATUS_IGNORED.equals(status)) { if (vf != null) { myReceiver.processIgnored(vf); } return; } - if (SVNStatusType.STATUS_UNVERSIONED.equals(status) || SVNStatusType.UNKNOWN.equals(status)) { + if (StatusType.STATUS_UNVERSIONED.equals(status) || StatusType.UNKNOWN.equals(status)) { if (vf != null) { myReceiver.processUnversioned(vf); processRecursively(vf, myCurrentItem.getDepth()); } return; } - if (SVNStatusType.OBSTRUCTED.equals(status) || SVNStatusType.STATUS_NONE.equals(status)) { + if (StatusType.OBSTRUCTED.equals(status) || StatusType.STATUS_NONE.equals(status)) { return; } if (vf != null) { @@ -264,7 +266,8 @@ public class SvnRecursiveStatusWalker { } } - public void handleStatus(final SVNStatus status) throws SVNException { + @Override + public void consume(final Status status) throws SVNException { myPartner.checkCanceled(); final File ioFile = status.getFile(); checkIfCopyRootWasReported(status, ioFile); @@ -282,20 +285,20 @@ public class SvnRecursiveStatusWalker { } if (myProject.isDisposed()) throw new ProcessCanceledException(); - if ((vFile != null) && (SvnVcs.svnStatusIsUnversioned(status))) { + if ((vFile != null) && (status.is(StatusType.STATUS_UNVERSIONED))) { if (vFile.isDirectory()) { if (FileUtil.filesEqual(myCurrentItem.getPath().getIOFile(), ioFile)) { //myReceiver.processUnversioned(vFile); //processRecursively(vFile, myCurrentItem.getDepth()); } else { - final MyItem childItem = createItem(new FilePathImpl(vFile), SVNDepth.INFINITY, true); + final MyItem childItem = createItem(new FilePathImpl(vFile), Depth.INFINITY, true); myQueue.add(childItem); } } else { myReceiver.processUnversioned(vFile); } } else { - final FilePath path = VcsUtil.getFilePath(ioFile, status.getKind().equals(SVNNodeKind.DIR)); + final FilePath path = VcsUtil.getFilePath(ioFile, status.getKind().isDirectory()); myReceiver.process(path, status); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java index fd77d80fc565..78a02d28f2c0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnRootsDetector.java @@ -29,9 +29,9 @@ import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.io.File; import java.util.ArrayList; @@ -165,7 +165,7 @@ public class SvnRootsDetector { // TODO: No checked exceptions are thrown - remove catch/LOG.error/rethrow to fix real cause if any try { final File infoFile = VfsUtilCore.virtualToIoFile(info.getFile()); - final SVNStatus svnStatus = SvnUtil.getStatus(myVcs, infoFile); + final Status svnStatus = SvnUtil.getStatus(myVcs, infoFile); if (svnStatus != null && svnStatus.getURL() != null) { info.setUrl(svnStatus.getURL()); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java index 84c316691c1e..ced496e9fa2b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnStatusConvertor.java @@ -19,15 +19,15 @@ import com.intellij.openapi.vcs.FileStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.status.PortableStatus; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; public class SvnStatusConvertor { private SvnStatusConvertor() { } @NotNull - public static FileStatus convertStatus(@Nullable SVNStatusType itemStatus, @Nullable SVNStatusType propertiesStatus) { + public static FileStatus convertStatus(@Nullable StatusType itemStatus, @Nullable StatusType propertiesStatus) { PortableStatus status = new PortableStatus(); status.setContentsStatus(itemStatus); @@ -37,47 +37,47 @@ public class SvnStatusConvertor { } @NotNull - public static FileStatus convertStatus(@Nullable final SVNStatus status) { + public static FileStatus convertStatus(@Nullable final Status status) { if (status == null) { return FileStatus.UNKNOWN; } - if (SvnVcs.svnStatusIsUnversioned(status)) { + if (status.is(StatusType.STATUS_UNVERSIONED)) { return FileStatus.UNKNOWN; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_MISSING)) { + else if (status.is(StatusType.STATUS_MISSING)) { return FileStatus.DELETED_FROM_FS; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_EXTERNAL)) { + else if (status.is(StatusType.STATUS_EXTERNAL)) { return SvnFileStatus.EXTERNAL; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED)) { + else if (status.is(StatusType.STATUS_OBSTRUCTED)) { return SvnFileStatus.OBSTRUCTED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_IGNORED)) { + else if (status.is(StatusType.STATUS_IGNORED)) { return FileStatus.IGNORED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { + else if (status.is(StatusType.STATUS_ADDED)) { return FileStatus.ADDED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_DELETED)) { + else if (status.is(StatusType.STATUS_DELETED)) { return FileStatus.DELETED; } - else if (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_REPLACED)) { + else if (status.is(StatusType.STATUS_REPLACED)) { return SvnFileStatus.REPLACED; } - else if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED || - status.getPropertiesStatus() == SVNStatusType.STATUS_CONFLICTED) { - if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED && - status.getPropertiesStatus() == SVNStatusType.STATUS_CONFLICTED) { + else if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED || + status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) { + if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED && + status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) { return FileStatus.MERGED_WITH_BOTH_CONFLICTS; } - else if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED) { + else if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED) { return FileStatus.MERGED_WITH_CONFLICTS; } return FileStatus.MERGED_WITH_PROPERTY_CONFLICTS; } - else if (status.getContentsStatus() == SVNStatusType.STATUS_MODIFIED || - status.getPropertiesStatus() == SVNStatusType.STATUS_MODIFIED) { + else if (status.getContentsStatus() == StatusType.STATUS_MODIFIED || + status.getPropertiesStatus() == StatusType.STATUS_MODIFIED) { return FileStatus.MODIFIED; } else if (status.isSwitched()) { @@ -90,38 +90,38 @@ public class SvnStatusConvertor { } @NotNull - public static FileStatus convertPropertyStatus(final SVNStatusType status) { + public static FileStatus convertPropertyStatus(final StatusType status) { if (status == null) { return FileStatus.UNKNOWN; } - if (SVNStatusType.STATUS_UNVERSIONED.equals(status)) { + if (StatusType.STATUS_UNVERSIONED.equals(status)) { return FileStatus.UNKNOWN; } - else if (SVNStatusType.STATUS_MISSING.equals(status)) { + else if (StatusType.STATUS_MISSING.equals(status)) { return FileStatus.DELETED_FROM_FS; } - else if (SVNStatusType.STATUS_EXTERNAL.equals(status)) { + else if (StatusType.STATUS_EXTERNAL.equals(status)) { return SvnFileStatus.EXTERNAL; } - else if (SVNStatusType.STATUS_OBSTRUCTED.equals(status)) { + else if (StatusType.STATUS_OBSTRUCTED.equals(status)) { return SvnFileStatus.OBSTRUCTED; } - else if (SVNStatusType.STATUS_IGNORED.equals(status)) { + else if (StatusType.STATUS_IGNORED.equals(status)) { return FileStatus.IGNORED; } - else if (SVNStatusType.STATUS_ADDED.equals(status)) { + else if (StatusType.STATUS_ADDED.equals(status)) { return FileStatus.ADDED; } - else if (SVNStatusType.STATUS_DELETED.equals(status)) { + else if (StatusType.STATUS_DELETED.equals(status)) { return FileStatus.DELETED; } - else if (SVNStatusType.STATUS_REPLACED.equals(status)) { + else if (StatusType.STATUS_REPLACED.equals(status)) { return SvnFileStatus.REPLACED; } - else if (status == SVNStatusType.STATUS_CONFLICTED) { + else if (status == StatusType.STATUS_CONFLICTED) { return FileStatus.MERGED_WITH_PROPERTY_CONFLICTS; } - else if (status == SVNStatusType.STATUS_MODIFIED) { + else if (status == StatusType.STATUS_MODIFIED) { return FileStatus.MODIFIED; } return FileStatus.NOT_CHANGED; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java index bd2882562404..43407f4b2064 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnUtil.java @@ -45,9 +45,17 @@ import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.LockDialog; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; import org.tmatesoft.sqljet.core.SqlJetException; import org.tmatesoft.sqljet.core.table.SqlJetDb; import org.tmatesoft.svn.core.*; @@ -99,7 +107,7 @@ public class SvnUtil { } public static boolean isSvnVersioned(final @NotNull SvnVcs vcs, File parent) { - final SVNInfo info = vcs.getInfo(parent); + final Info info = vcs.getInfo(parent); return info != null; } @@ -157,7 +165,7 @@ public class SvnUtil { @Nullable public static String getExactLocation(final SvnVcs vcs, File path) { - SVNInfo info = vcs.getInfo(path); + Info info = vcs.getInfo(path); return info != null && info.getURL() != null ? info.getURL().toString() : null; } @@ -182,9 +190,9 @@ public class SvnUtil { final VcsException[] exception = new VcsException[1]; final Collection<String> failedLocks = new ArrayList<String>(); final int[] count = new int[]{ioFiles.length}; - final ISVNEventHandler eventHandler = new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) { - if (event.getAction() == SVNEventAction.LOCK_FAILED) { + final ProgressTracker eventHandler = new ProgressTracker() { + public void consume(ProgressEvent event) { + if (event.getAction() == EventAction.LOCK_FAILED) { failedLocks.add(event.getErrorMessage() != null ? event.getErrorMessage().getFullMessage() : event.getFile().getAbsolutePath()); @@ -247,9 +255,9 @@ public class SvnUtil { final VcsException[] exception = new VcsException[1]; final Collection<String> failedUnlocks = new ArrayList<String>(); final int[] count = new int[]{ioFiles.length}; - final ISVNEventHandler eventHandler = new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) { - if (event.getAction() == SVNEventAction.UNLOCK_FAILED) { + final ProgressTracker eventHandler = new ProgressTracker() { + public void consume(ProgressEvent event) { + if (event.getAction() == EventAction.UNLOCK_FAILED) { failedUnlocks.add(event.getErrorMessage() != null ? event.getErrorMessage().getFullMessage() : event.getFile().getAbsolutePath()); @@ -398,40 +406,41 @@ public class SvnUtil { @Nullable public static String getRepositoryUUID(final SvnVcs vcs, final File file) { - final SVNInfo info = vcs.getInfo(file); + final Info info = vcs.getInfo(file); return info != null ? info.getRepositoryUUID() : null; } @Nullable public static String getRepositoryUUID(final SvnVcs vcs, final SVNURL url) { try { - final SVNInfo info = vcs.getInfo(url, SVNRevision.UNDEFINED); + final Info info = vcs.getInfo(url, SVNRevision.UNDEFINED); return (info == null) ? null : info.getRepositoryUUID(); - } catch (SVNException e) { + } + catch (SvnBindException e) { return null; } } @Nullable public static SVNURL getRepositoryRoot(final SvnVcs vcs, final File file) { - final SVNInfo info = vcs.getInfo(file); + final Info info = vcs.getInfo(file); return info != null ? info.getRepositoryRootURL() : null; } @Nullable public static SVNURL getRepositoryRoot(final SvnVcs vcs, final String url) { try { - return getRepositoryRoot(vcs, SVNURL.parseURIEncoded(url)); + return getRepositoryRoot(vcs, createUrl(url)); } - catch (SVNException e) { + catch (SvnBindException e) { return null; } } @Nullable - public static SVNURL getRepositoryRoot(final SvnVcs vcs, final SVNURL url) throws SVNException { - SVNInfo info = vcs.getInfo(url, SVNRevision.HEAD); + public static SVNURL getRepositoryRoot(final SvnVcs vcs, final SVNURL url) throws SvnBindException { + Info info = vcs.getInfo(url, SVNRevision.HEAD); return (info == null) ? null : info.getRepositoryRootURL(); } @@ -496,17 +505,6 @@ public class SvnUtil { } @Nullable - public static String getPathForProgress(final SVNEvent event) { - if (event.getFile() != null) { - return event.getFile().getName(); - } - if (event.getURL() != null) { - return event.getURL().toString(); - } - return null; - } - - @Nullable public static VirtualFile correctRoot(final Project project, final VirtualFile file) { if (file.getPath().length() == 0) { // project root @@ -533,19 +531,19 @@ public class SvnUtil { } @Nullable - public static SVNStatus getStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { + public static Status getStatus(@NotNull final SvnVcs vcs, @NotNull final File file) { try { return vcs.getFactory(file).createStatusClient().doStatus(file, false); } - catch (SVNException e) { + catch (SvnBindException e) { return null; } } - public static SVNDepth getDepth(final SvnVcs vcs, final File file) { - SVNInfo info = vcs.getInfo(file); + public static Depth getDepth(final SvnVcs vcs, final File file) { + Info info = vcs.getInfo(file); - return info != null && info.getDepth() != null ? info.getDepth() : SVNDepth.UNKNOWN; + return info != null && info.getDepth() != null ? info.getDepth() : Depth.UNKNOWN; } public static boolean seemsLikeVersionedDir(final VirtualFile file) { @@ -579,7 +577,7 @@ public class SvnUtil { @Nullable public static SVNURL getUrl(final SvnVcs vcs, final File file) { // todo for moved items? - final SVNInfo info = vcs.getInfo(file); + final Info info = vcs.getInfo(file); return info == null ? null : info.getURL(); } @@ -587,15 +585,17 @@ public class SvnUtil { public static boolean remoteFolderIsEmpty(final SvnVcs vcs, final String url) throws VcsException { SvnTarget target = SvnTarget.fromURL(createUrl(url)); final Ref<Boolean> result = new Ref<Boolean>(true); - ISVNDirEntryHandler handler = new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - if (dirEntry != null) { + DirectoryEntryConsumer handler = new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + if (entry != null) { result.set(false); } } }; - vcs.getFactory(target).createBrowseClient().list(target, null, SVNDepth.IMMEDIATES, handler); + vcs.getFactory(target).createBrowseClient().list(target, null, Depth.IMMEDIATES, handler); return result.get(); } @@ -637,9 +637,7 @@ public class SvnUtil { WorkingCopyFormat format = getFormat(current); - return WorkingCopyFormat.ONE_DOT_EIGHT.equals(format) || WorkingCopyFormat.ONE_DOT_SEVEN.equals(format) - ? current - : getWorkingCopyRoot(file); + return format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN) ? current : getWorkingCopyRoot(file); } private static File getParentWithDb(File file) { @@ -695,14 +693,19 @@ public class SvnUtil { } @NotNull - public static SVNRevision getHeadRevision(@NotNull SvnVcs vcs, @NotNull SVNURL url) throws SVNException { - SVNInfo info = vcs.getInfo(url, SVNRevision.HEAD); + public static SVNURL removePathTail(@NotNull SVNURL url) throws SvnBindException { + return createUrl(SVNPathUtil.removeTail(url.toDecodedString())); + } + + @NotNull + public static SVNRevision getHeadRevision(@NotNull SvnVcs vcs, @NotNull SVNURL url) throws SvnBindException { + Info info = vcs.getInfo(url, SVNRevision.HEAD); if (info == null) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Could not get info for " + url)); + throw new SvnBindException("Could not get info for " + url); } if (info.getRevision() == null) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, "Could not get revision for " + url)); + throw new SvnBindException("Could not get revision for " + url); } return info.getRevision(); @@ -771,18 +774,18 @@ public class SvnUtil { } @Nullable - public static String getChangelistName(@NotNull final SVNStatus status) { + public static String getChangelistName(@NotNull final Status status) { // no explicit check on working copy format supports change lists as they are supported from svn 1.5 // and anyway status.getChangelistName() should just return null if change lists are not supported. - return SVNNodeKind.FILE.equals(status.getKind()) ? status.getChangelistName() : null; + return status.getKind().isFile() ? status.getChangelistName() : null; } - public static boolean isUnversionedOrNotFound(@NotNull SVNErrorCode code) { - return SVNErrorCode.WC_PATH_NOT_FOUND.equals(code) || - SVNErrorCode.UNVERSIONED_RESOURCE.equals(code) || - SVNErrorCode.WC_NOT_WORKING_COPY.equals(code) || + public static boolean isUnversionedOrNotFound(@NotNull SvnBindException e) { + return e.contains(SVNErrorCode.WC_PATH_NOT_FOUND) || + e.contains(SVNErrorCode.UNVERSIONED_RESOURCE) || + e.contains(SVNErrorCode.WC_NOT_WORKING_COPY) || // thrown when getting info from repository for non-existent item - like HEAD revision for deleted file - SVNErrorCode.ILLEGAL_TARGET.equals(code); + e.contains(SVNErrorCode.ILLEGAL_TARGET); } // TODO: Create custom Target class and implement append there diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java index ee4233fca1b2..5010ac580750 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java @@ -65,10 +65,12 @@ import org.jetbrains.idea.svn.actions.SvnMergeProvider; import org.jetbrains.idea.svn.annotate.SvnAnnotationProvider; import org.jetbrains.idea.svn.api.ClientFactory; import org.jetbrains.idea.svn.api.CmdClientFactory; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnKitClientFactory; import org.jetbrains.idea.svn.auth.SvnAuthenticationNotifier; import org.jetbrains.idea.svn.checkin.SvnCheckinEnvironment; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnExecutableChecker; import org.jetbrains.idea.svn.dialogs.SvnBranchPointsCalculator; import org.jetbrains.idea.svn.dialogs.WCInfo; @@ -76,14 +78,19 @@ import org.jetbrains.idea.svn.history.LoadedRevisionsCache; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnCommittedChangesProvider; import org.jetbrains.idea.svn.history.SvnHistoryProvider; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.info.InfoConsumer; import org.jetbrains.idea.svn.properties.PropertyClient; import org.jetbrains.idea.svn.rollback.SvnRollbackEnvironment; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.svnkit.SvnKitManager; import org.jetbrains.idea.svn.update.SvnIntegrateEnvironment; import org.jetbrains.idea.svn.update.SvnUpdateEnvironment; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.wc.SVNAdminUtil; -import org.tmatesoft.svn.core.wc.*; +import org.tmatesoft.svn.core.wc.SVNPropertyData; +import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -213,6 +220,10 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { myWorkingCopiesContent.activate(); } + /** + * TODO: This seems to be related to some issues when upgrading from 1.6 to 1.7. So it is not currently required for 1.8 and later + * TODO: formats. And should be removed when 1.6 working copies are no longer supported by IDEA. + */ private void cleanup17copies() { final Runnable callCleanupWorker = new Runnable() { public void run() { @@ -251,7 +262,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { public boolean checkCommandLineVersion() { boolean isValid = true; - if (!isProject16() && (myConfiguration.isCommandLine() || isProject18())) { + if (!isProject16() && (myConfiguration.isCommandLine() || isProject18OrGreater())) { isValid = myChecker.checkExecutableAndNotifyIfNeeded(); } @@ -588,30 +599,19 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { public boolean fileExistsInVcs(FilePath path) { File file = path.getIOFile(); try { - SVNStatus status = getFactory(file).createStatusClient().doStatus(file, false); + Status status = getFactory(file).createStatusClient().doStatus(file, false); if (status != null) { - if (svnStatusIs(status, SVNStatusType.STATUS_ADDED)) { - return status.isCopied(); - } - return !(svnStatusIsUnversioned(status) || - svnStatusIs(status, SVNStatusType.STATUS_IGNORED) || - svnStatusIs(status, SVNStatusType.STATUS_OBSTRUCTED)); + return status.is(StatusType.STATUS_ADDED) + ? status.isCopied() + : !status.is(StatusType.STATUS_UNVERSIONED, StatusType.STATUS_IGNORED, StatusType.STATUS_OBSTRUCTED); } } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } return false; } - public static boolean svnStatusIsUnversioned(final SVNStatus status) { - return svnStatusIs(status, SVNStatusType.STATUS_UNVERSIONED); - } - - public static boolean svnStatusIs(final SVNStatus status, @NotNull final SVNStatusType value) { - return value.equals(status.getNodeStatus()) || value.equals(status.getContentsStatus()); - } - @Override public boolean fileIsUnderVcs(FilePath path) { final ChangeListManager clManager = ChangeListManager.getInstance(myProject); @@ -623,33 +623,33 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { } @Nullable - public SVNInfo getInfo(@NotNull SVNURL url, + public Info getInfo(@NotNull SVNURL url, SVNRevision pegRevision, - SVNRevision revision) throws SVNException { + SVNRevision revision) throws SvnBindException { return getFactory().createInfoClient().doInfo(url, pegRevision, revision); } @Nullable - public SVNInfo getInfo(@NotNull SVNURL url, SVNRevision revision) throws SVNException { + public Info getInfo(@NotNull SVNURL url, SVNRevision revision) throws SvnBindException { return getInfo(url, SVNRevision.UNDEFINED, revision); } @Nullable - public SVNInfo getInfo(@NotNull final VirtualFile file) { + public Info getInfo(@NotNull final VirtualFile file) { return getInfo(new File(file.getPath())); } @Nullable - public SVNInfo getInfo(@NotNull String path) { + public Info getInfo(@NotNull String path) { return getInfo(new File(path)); } @Nullable - public SVNInfo getInfo(@NotNull File ioFile) { + public Info getInfo(@NotNull File ioFile) { return getInfo(ioFile, SVNRevision.UNDEFINED); } - public void collectInfo(@NotNull Collection<File> files, @Nullable ISVNInfoHandler handler) { + public void collectInfo(@NotNull Collection<File> files, @Nullable InfoConsumer handler) { File first = ContainerUtil.getFirstItem(files); if (first != null) { @@ -663,41 +663,42 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { // TODO: Generally this should be moved in SvnKit info client implementation. // TODO: Currently left here to have exception logic as in handleInfoException to be applied for each file separately. for (File file : files) { - SVNInfo info = getInfo(file); + Info info = getInfo(file); if (handler != null) { - handler.handleInfo(info); + handler.consume(info); } } } } catch (SVNException e) { + handleInfoException(new SvnBindException(e)); + } + catch (SvnBindException e) { handleInfoException(e); } } } @Nullable - public SVNInfo getInfo(@NotNull File ioFile, @NotNull SVNRevision revision) { - SVNInfo result = null; + public Info getInfo(@NotNull File ioFile, @NotNull SVNRevision revision) { + Info result = null; try { result = getFactory(ioFile).createInfoClient().doInfo(ioFile, revision); } - catch (SVNException e) { + catch (SvnBindException e) { handleInfoException(e); } return result; } - private void handleInfoException(SVNException e) { - final SVNErrorCode errorCode = e.getErrorMessage().getErrorCode(); - + private void handleInfoException(@NotNull SvnBindException e) { if (!myLogExceptions || - SvnUtil.isUnversionedOrNotFound(errorCode) || + SvnUtil.isUnversionedOrNotFound(e) || // do not log working copy format vs client version inconsistencies as errors - SVNErrorCode.WC_UNSUPPORTED_FORMAT.equals(errorCode) || - SVNErrorCode.WC_UPGRADE_REQUIRED.equals(errorCode)) { + e.contains(SVNErrorCode.WC_UNSUPPORTED_FORMAT) || + e.contains(SVNErrorCode.WC_UPGRADE_REQUIRED)) { LOG.debug(e); } else { @@ -797,7 +798,7 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { List<WCInfo> result = new ArrayList<WCInfo>(getAllWcInfos()); for (RootUrlInfo info : getSvnFileUrlMapping().getErrorRoots()) { - result.add(new WCInfo(info, SvnUtil.isWorkingCopyRoot(info.getIoFile()), SVNDepth.UNKNOWN)); + result.add(new WCInfo(info, SvnUtil.isWorkingCopyRoot(info.getIoFile()), Depth.UNKNOWN)); } return result; @@ -948,14 +949,15 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { return svnKitManager; } - public boolean isProject18() { - return WorkingCopyFormat.ONE_DOT_EIGHT.equals(getProjectRootFormat()); + public boolean isProject18OrGreater() { + return getProjectRootFormat().isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT); } public boolean isProject16() { return WorkingCopyFormat.ONE_DOT_SIX.equals(getProjectRootFormat()); } + @NotNull private WorkingCopyFormat getProjectRootFormat() { return !getProject().isDefault() ? getWorkingCopyFormat(new File(getProject().getBaseDir().getPath())) : WorkingCopyFormat.UNKNOWN; } @@ -993,11 +995,11 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> { @NotNull private ClientFactory getFactory(@NotNull WorkingCopyFormat format, boolean useProjectRootForUnknown) { - boolean is18 = WorkingCopyFormat.ONE_DOT_EIGHT.equals(format); + boolean is18OrGreater = format.isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT); boolean is16 = WorkingCopyFormat.ONE_DOT_SIX.equals(format); boolean isUnknown = WorkingCopyFormat.UNKNOWN.equals(format); - return is18 + return is18OrGreater ? cmdClientFactory : (is16 ? svnKitClientFactory : (useProjectRootForUnknown && isUnknown ? getFactory() : getFactoryFromSettings())); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java index 223c69ab1c6f..97e6a618ba7c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java @@ -40,8 +40,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.history.SvnRepositoryContentRevision; -import org.jetbrains.idea.svn.properties.PropertyClient; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; import org.tmatesoft.svn.core.wc.SVNPropertyData; @@ -276,7 +276,7 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen final List<SVNPropertyData> lines = new ArrayList<SVNPropertyData>(); final ISVNPropertyHandler propertyHandler = createHandler(revision, lines); - vcs.getFactory(target).createPropertyClient().list(target, revision, SVNDepth.EMPTY, propertyHandler); + vcs.getFactory(target).createPropertyClient().list(target, revision, Depth.EMPTY, propertyHandler); return toSortedStringPresentation(lines); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java index 7623f083eb86..dc6fb8c0d55b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CleanupWorker.java @@ -30,10 +30,10 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; import java.io.File; import java.util.LinkedList; @@ -69,9 +69,9 @@ public class CleanupWorker { final File path = new File(root.getPath()); indicator.setText(SvnBundle.message("action.Subversion.cleanup.progress.text", path)); - ISVNEventHandler handler = new ISVNEventHandler() { + ProgressTracker handler = new ProgressTracker() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java index 7655751ded40..c6f633416a15 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateBranchOrTagAction.java @@ -37,6 +37,7 @@ import org.jetbrains.idea.svn.SvnStatusUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.checkin.CommitEventHandler; import org.jetbrains.idea.svn.checkin.IdeaCommitHandler; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.CreateBranchOrTagDialog; import org.jetbrains.idea.svn.update.AutoSvnUpdater; import org.jetbrains.idea.svn.update.SingleRootSwitcher; @@ -86,17 +87,17 @@ public class CreateBranchOrTagAction extends BasicAction { srcUrl = SVNURL.parseURIEncoded(dialog.getCopyFromUrl()); dstSvnUrl = SVNURL.parseURIEncoded(dstURL); parentUrl = dstSvnUrl.removePathTail(); - - if (!dirExists(activeVcs, parentUrl)) { - int rc = Messages.showYesNoDialog(project, "The repository path '" + parentUrl + "' does not exist. Would you like to create it?", - "Branch or Tag", Messages.getQuestionIcon()); - if (rc == Messages.NO) { - return; - } - } } catch (SVNException e) { - throw new VcsException(e); + throw new SvnBindException(e); + } + + if (!dirExists(activeVcs, parentUrl)) { + int rc = Messages.showYesNoDialog(project, "The repository path '" + parentUrl + "' does not exist. Would you like to create it?", + "Branch or Tag", Messages.getQuestionIcon()); + if (rc == Messages.NO) { + return; + } } Runnable copyCommand = new Runnable() { @@ -145,8 +146,8 @@ public class CreateBranchOrTagAction extends BasicAction { } } - private static boolean dirExists(@NotNull final SvnVcs vcs, @NotNull final SVNURL url) throws SVNException { - final Ref<SVNException> excRef = new Ref<SVNException>(); + private static boolean dirExists(@NotNull final SvnVcs vcs, @NotNull final SVNURL url) throws SvnBindException { + final Ref<SvnBindException> excRef = new Ref<SvnBindException>(); final Ref<Boolean> resultRef = new Ref<Boolean>(Boolean.TRUE); final Runnable taskImpl = new Runnable() { @@ -154,8 +155,8 @@ public class CreateBranchOrTagAction extends BasicAction { try { vcs.getInfo(url, SVNRevision.HEAD); } - catch (SVNException e) { - if (e.getErrorMessage().getErrorCode().equals(SVNErrorCode.RA_ILLEGAL_URL)) { + catch (SvnBindException e) { + if (e.contains(SVNErrorCode.RA_ILLEGAL_URL)) { resultRef.set(Boolean.FALSE); } else { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java index b65332a44604..31206eec045c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/CreateExternalAction.java @@ -18,7 +18,6 @@ package org.jetbrains.idea.svn.actions; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; @@ -38,11 +37,13 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.dialogs.SelectCreateExternalTargetDialog; import org.jetbrains.idea.svn.update.UpdateClient; import org.tmatesoft.svn.core.SVNCancelException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.internal.wc.SVNExternal; @@ -100,9 +101,9 @@ public class CreateExternalAction extends DumbAwareAction { if (checkout) { // +- final UpdateClient client = vcs.getFactory(ioFile).createUpdateClient(); - client.setEventHandler(new ISVNEventHandler() { + client.setEventHandler(new ProgressTracker() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { } @Override @@ -111,7 +112,7 @@ public class CreateExternalAction extends DumbAwareAction { if (pi != null && pi.isCanceled()) throw new SVNCancelException(); } }); - client.doUpdate(ioFile, SVNRevision.HEAD, SVNDepth.UNKNOWN, false, false); + client.doUpdate(ioFile, SVNRevision.HEAD, Depth.UNKNOWN, false, false); vf.refresh(true, true, new Runnable() { @Override public void run() { @@ -148,7 +149,7 @@ public class CreateExternalAction extends DumbAwareAction { } else { newValue = createExternalDefinitionString(url, target); } - factory.createPropertyClient().setProperty(ioFile, SvnPropertyKeys.SVN_EXTERNALS, SVNPropertyValue.create(newValue), SVNDepth.EMPTY, + factory.createPropertyClient().setProperty(ioFile, SvnPropertyKeys.SVN_EXTERNALS, SVNPropertyValue.create(newValue), Depth.EMPTY, false); return false; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java index 10793269c041..2e400adfd8fa 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkLocallyDeletedTreeConflictResolvedAction.java @@ -36,7 +36,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnLocallyDeletedChange; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import java.util.Collections; import java.util.List; @@ -93,7 +93,7 @@ public class MarkLocallyDeletedTreeConflictResolvedAction extends AnAction { SvnVcs vcs = SvnVcs.getInstance(project); try { - vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), SVNDepth.EMPTY, false, false, true); + vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), Depth.EMPTY, false, false, true); } catch (VcsException e) { exception.set(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java index d20b5f14d6b5..6d51d9d90dd8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkResolvedAction.java @@ -33,12 +33,15 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnStatusUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.conflict.ConflictClient; import org.jetbrains.idea.svn.dialogs.SelectFilesDialog; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.*; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; +import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; import java.util.Collection; @@ -98,7 +101,7 @@ public class MarkResolvedAction extends BasicAction { ConflictClient client = vcs.getFactory(ioFile).createConflictClient(); // TODO: Probably false should be passed to "resolveTree", but previous logic used true implicitly - client.resolve(ioFile, SVNDepth.EMPTY, true, true, true); + client.resolve(ioFile, Depth.EMPTY, true, true, true); } } finally { @@ -124,16 +127,17 @@ public class MarkResolvedAction extends BasicAction { File path = new File(file.getPath()); StatusClient client = vcs.getFactory(path).createStatusClient(); - client.doStatus(path, true, false, false, false, new ISVNStatusHandler() { - public void handleStatus(SVNStatus status) { - if (status.getContentsStatus() == SVNStatusType.STATUS_CONFLICTED || - status.getPropertiesStatus() == SVNStatusType.STATUS_CONFLICTED) { + client.doStatus(path, SVNRevision.UNDEFINED, Depth.INFINITY, false, false, false, false, new StatusConsumer() { + @Override + public void consume(Status status) { + if (status.getContentsStatus() == StatusType.STATUS_CONFLICTED || + status.getPropertiesStatus() == StatusType.STATUS_CONFLICTED) { target.add(status.getFile().getAbsolutePath()); } } - }); + }, null); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.warn(e); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java index 73d9c28eb48d..10330ded734c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/MarkTreeConflictResolvedAction.java @@ -37,7 +37,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.ConflictedSvnChange; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import java.util.ArrayList; import java.util.Collection; @@ -114,7 +114,7 @@ public class MarkTreeConflictResolvedAction extends AnAction implements DumbAwar SvnVcs vcs = SvnVcs.getInstance(checker.getProject()); try { - vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), SVNDepth.EMPTY, false, false, true); + vcs.getFactory(path.getIOFile()).createConflictClient().resolve(path.getIOFile(), Depth.EMPTY, false, false, true); } catch (VcsException e) { exception.set(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java index 87615a08588c..af601f3cd126 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/RelocateAction.java @@ -28,7 +28,7 @@ import com.intellij.util.WaitForProgressToShow; import org.jetbrains.idea.svn.SvnStatusUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.dialogs.RelocateDialog; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.jetbrains.idea.svn.info.Info; import java.io.File; @@ -49,7 +49,7 @@ public class RelocateAction extends BasicAction { } protected void perform(final Project project, final SvnVcs activeVcs, final VirtualFile file, DataContext context) throws VcsException { - SVNInfo info = activeVcs.getInfo(file); + Info info = activeVcs.getInfo(file); assert info != null; RelocateDialog dlg = new RelocateDialog(project, info.getURL()); dlg.show(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java index 3f740bad1bef..cdc738cf2d40 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java @@ -27,9 +27,9 @@ import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.SetPropertyDialog; import org.jetbrains.idea.svn.properties.PropertyClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNPropertyValue; import java.io.File; @@ -79,7 +79,7 @@ public class SetPropertyAction extends BasicAction { // TODO: most likely SVNDepth.getInfinityOrEmptyDepth should be used instead of SVNDepth.fromRecursive - to have either "infinity" // TODO: or "empty" depth, and not "infinity" or "files" depth. But previous logic used SVNDepth.fromRecursive implicitly - client.setProperty(ioFile, name, SVNPropertyValue.create(value), SVNDepth.fromRecurse(recursive), false); + client.setProperty(ioFile, name, SVNPropertyValue.create(value), Depth.allOrFiles(recursive), false); } for(int i = 0; i < file.length; i++) { if (recursive && file[i].isDirectory()) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java index 7f648dce75b9..012a870676a0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/ShareProjectAction.java @@ -35,9 +35,9 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.jetbrains.idea.svn.dialogs.ShareDialog; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -167,7 +167,7 @@ public class ShareProjectAction extends BasicAction { final ClientFactory factory = SvnCheckoutProvider.getFactory(activeVcs, format); factory.createCheckoutClient() - .checkout(SvnTarget.fromURL(checkoutUrl), path, revision, SVNDepth.INFINITY, false, false, format, null); + .checkout(SvnTarget.fromURL(checkoutUrl), path, revision, Depth.INFINITY, false, false, format, null); addRecursively(activeVcs, factory, file); } catch (SVNException e) { error[0] = e; @@ -254,9 +254,9 @@ public class ShareProjectAction extends BasicAction { indicator.checkCanceled(); indicator.setText(SvnBundle.message("share.or.import.add.progress.text", virtualFile.getPath())); } - factory.createAddClient().add(ioFile, SVNDepth.EMPTY, false, false, true, null); + factory.createAddClient().add(ioFile, Depth.EMPTY, false, false, true, null); } - }, SVNDepth.INFINITY); + }, Depth.INFINITY); operation.execute(file); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java index 49fdc0279dd5..c206cd3451d8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnExcludingIgnoredOperation.java @@ -26,14 +26,14 @@ import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileVisitor; import org.jetbrains.annotations.NotNull; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; public class SvnExcludingIgnoredOperation { private final Operation myImportAction; - private final SVNDepth myDepth; + private final Depth myDepth; private final Filter myFilter; - public SvnExcludingIgnoredOperation(final Project project, final Operation importAction, final SVNDepth depth) { + public SvnExcludingIgnoredOperation(final Project project, final Operation importAction, final Depth depth) { myImportAction = importAction; myDepth = depth; @@ -48,17 +48,18 @@ public class SvnExcludingIgnoredOperation { public Filter(final Project project) { myProject = project; - if (! project.isDefault()) { + if (!project.isDefault()) { myIndex = PeriodicalTasksCloser.getInstance().safeGetService(project, FileIndexFacade.class); myClManager = ChangeListManager.getInstance(project); - } else { + } + else { myIndex = null; myClManager = null; } } public boolean accept(final VirtualFile file) { - if (! myProject.isDefault()) { + if (!myProject.isDefault()) { if (isExcluded(file)) { return false; } @@ -80,7 +81,7 @@ public class SvnExcludingIgnoredOperation { } private boolean operation(final VirtualFile file) throws VcsException { - if (! myFilter.accept(file)) return false; + if (!myFilter.accept(file)) return false; myImportAction.doOperation(file); return true; @@ -101,21 +102,21 @@ public class SvnExcludingIgnoredOperation { } public void execute(final VirtualFile file) throws VcsException { - if (SVNDepth.INFINITY.equals(myDepth)) { + if (Depth.INFINITY.equals(myDepth)) { executeDown(file); return; } - if (! operation(file)) { + if (!operation(file)) { return; } - if (SVNDepth.EMPTY.equals(myDepth)) { + if (Depth.EMPTY.equals(myDepth)) { return; } for (VirtualFile child : file.getChildren()) { - if (SVNDepth.FILES.equals(myDepth) && child.isDirectory()) { + if (Depth.FILES.equals(myDepth) && child.isDirectory()) { continue; } operation(child); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java index a4d71ceb9241..912bd970f7b0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SvnMergeProvider.java @@ -29,8 +29,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.properties.PropertyClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNProperty; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.wc.*; @@ -64,7 +65,7 @@ public class SvnMergeProvider implements MergeProvider { File workingFile = null; boolean mergeCase = false; SvnVcs vcs = SvnVcs.getInstance(myProject); - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); if (info != null) { oldFile = info.getConflictOldFile(); @@ -142,7 +143,7 @@ public class SvnMergeProvider implements MergeProvider { File path = new File(file.getPath()); try { // TODO: Probably false should be passed to "resolveTree", but previous logic used true implicitly - vcs.getFactory(path).createConflictClient().resolve(path, SVNDepth.EMPTY, false, true, true); + vcs.getFactory(path).createConflictClient().resolve(path, Depth.EMPTY, false, true, true); } catch (VcsException e) { LOG.warn(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java index 718a56dea9af..872e290db0c0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/AddClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.add; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -15,9 +15,9 @@ import java.io.File; public interface AddClient extends SvnClient { void add(@NotNull File file, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java index 4811e3286d70..6894800427c2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/CmdAddClient.java @@ -4,15 +4,12 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.api.FileStatusResultParser; +import org.jetbrains.idea.svn.api.*; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -33,11 +30,11 @@ public class CmdAddClient extends BaseSvnClient implements AddClient { @Override public void add(@NotNull File file, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = prepareParameters(file, depth, makeParents, includeIgnored, force); // TODO: handler should be called in parallel with command execution, but this will be in other thread @@ -48,7 +45,7 @@ public class CmdAddClient extends BaseSvnClient implements AddClient { parser.parse(command.getOutput()); } - private static List<String> prepareParameters(File file, SVNDepth depth, boolean makeParents, boolean includeIgnored, boolean force) { + private static List<String> prepareParameters(File file, Depth depth, boolean makeParents, boolean includeIgnored, boolean force) { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, file); @@ -60,14 +57,13 @@ public class CmdAddClient extends BaseSvnClient implements AddClient { return parameters; } - private static class AddStatusConvertor implements Convertor<Matcher, SVNEvent> { + private static class AddStatusConvertor implements Convertor<Matcher, ProgressEvent> { @Override - public SVNEvent convert(Matcher o) { - SVNStatusType contentStatus = CommandUtil.getStatusType(o.group(1)); + public ProgressEvent convert(Matcher o) { + StatusType contentStatus = CommandUtil.getStatusType(o.group(1)); String path = o.group(3); - return new SVNEvent(new File(path), null, null, 0, contentStatus, null, null, null, null, null, null, null, - null, null, null); + return new ProgressEvent(new File(path), 0, contentStatus, null, null, null, null); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java index 66e122d80232..7b05f0bd17d3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/add/SvnKitAddClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -22,19 +22,19 @@ public class SvnKitAddClient extends BaseSvnClient implements AddClient { */ @Override public void add(@NotNull File file, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean makeParents, boolean includeIgnored, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { try { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); client.doAdd(file, force, false, // directory should already be created makeParents, // not used but will be passed as makeParents value - SVNDepth.recurseFromDepth(depth)); + Depth.isRecursive(depth)); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java index df30cfd89ae2..90be057af431 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotateClient.java @@ -4,8 +4,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -19,6 +18,6 @@ public interface AnnotateClient extends SvnClient { @NotNull SVNRevision endRevision, @Nullable SVNRevision pegRevision, boolean includeMergedRevisions, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNAnnotateHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable AnnotationConsumer handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotationConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotationConsumer.java new file mode 100644 index 000000000000..8d33be224b99 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/AnnotationConsumer.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.annotate; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface AnnotationConsumer { + + void consume(int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) throws SVNException; +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java index f4fa9f950a32..00a529e11b4d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/BaseSvnFileAnnotation.java @@ -19,6 +19,7 @@ import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.annotate.*; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; +import com.intellij.util.containers.ContainerUtil; import com.intellij.util.text.DateFormatUtil; import com.intellij.xml.util.XmlStringUtil; import org.jetbrains.annotations.NotNull; @@ -27,6 +28,7 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.history.SvnFileRevision; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -46,27 +48,19 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { protected final SvnVcs myVcs; private final Map<Long, SvnFileRevision> myRevisionMap = new HashMap<Long, SvnFileRevision>(); - private final LineAnnotationAspect DATE_ASPECT = new SvnAnnotationAspect(SvnAnnotationAspect.DATE, true) { - public String getValue(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - else { - final LineInfo lineInfo = myInfos.get(lineNumber); - return (lineInfo == null) ? "" : DateFormatUtil.formatPrettyDate(lineInfo.getDate()); - } + private final LineAnnotationAspect DATE_ASPECT = new SvnAnnotationAspect(LineAnnotationAspect.DATE, true) { + + @Override + public String getValue(@NotNull CommitInfo info) { + return DateFormatUtil.formatPrettyDate(info.getDate()); } }; - private final LineAnnotationAspect REVISION_ASPECT = new SvnAnnotationAspect(SvnAnnotationAspect.REVISION, false) { - public String getValue(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - else { - final long revision = getRevision(lineNumber); - return (revision == -1) ? "" : String.valueOf(revision); - } + private final LineAnnotationAspect REVISION_ASPECT = new SvnAnnotationAspect(LineAnnotationAspect.REVISION, false) { + + @Override + public String getValue(@NotNull CommitInfo info) { + return String.valueOf(info.getRevision()); } }; @@ -84,31 +78,25 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { @Override public String getTooltipText(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - final LineInfo info = myInfos.get(lineNumber); + // TODO: Check what is the difference in returning "" or null + if (!myInfos.isValid(lineNumber)) return ""; + + CommitInfo info = myInfos.get(lineNumber); if (info == null) return null; - SvnFileRevision svnRevision = myRevisionMap.get(info.getRevision()); - if (svnRevision != null) { - final String tooltip = "Revision " + info.getRevision() + ": " + svnRevision.getCommitMessage(); - return XmlStringUtil.escapeString(tooltip); - } - return ""; + + SvnFileRevision revision = myRevisionMap.get(info.getRevision()); + return revision != null ? XmlStringUtil.escapeString("Revision " + info.getRevision() + ": " + revision.getCommitMessage()) : ""; } }; - private final LineAnnotationAspect AUTHOR_ASPECT = new SvnAnnotationAspect(SvnAnnotationAspect.AUTHOR, true) { - public String getValue(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - else { - final LineInfo lineInfo = myInfos.get(lineNumber); - return (lineInfo == null) ? "" : lineInfo.getAuthor(); - } + private final LineAnnotationAspect AUTHOR_ASPECT = new SvnAnnotationAspect(LineAnnotationAspect.AUTHOR, true) { + + @Override + public String getValue(@NotNull CommitInfo info) { + return info.getAuthor(); } }; + private final SvnConfiguration myConfiguration; private boolean myShowMergeSources; // null if full annotation @@ -118,10 +106,6 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { myRevisionMap.put(revision, svnRevision); } - public void clearRevisions() { - myRevisionMap.clear(); - } - public SvnFileRevision getRevision(final long revision) { return myRevisionMap.get(revision); } @@ -134,30 +118,6 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myFirstRevisionNumber; } - static class LineInfo { - private final Date myDate; - private final long myRevision; - private final String myAuthor; - - public LineInfo(final Date date, final long revision, final String author) { - myDate = date; - myRevision = revision; - myAuthor = author; - } - - public Date getDate() { - return myDate; - } - - public long getRevision() { - return myRevision; - } - - public String getAuthor() { - return myAuthor; - } - } - public BaseSvnFileAnnotation(final SvnVcs vcs, final String contents, final VcsRevisionNumber baseRevision) { super(vcs.getProject()); myVcs = vcs; @@ -174,18 +134,14 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { } public String getToolTip(final int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return ""; - } - final LineInfo info = myInfos.get(lineNumber); + final CommitInfo info = myInfos.getOrNull(lineNumber); if (info == null) return ""; - SvnFileRevision svnRevision = myRevisionMap.get(info.getRevision()); - if (svnRevision != null) { - if (myInfos.getAnnotationSource(lineNumber).showMerged()) { - return "Merge source revision " + info.getRevision() + ": " + svnRevision.getCommitMessage(); - } else { - return "Revision " + info.getRevision() + ": " + svnRevision.getCommitMessage(); - } + + SvnFileRevision revision = myRevisionMap.get(info.getRevision()); + if (revision != null) { + String prefix = myInfos.getAnnotationSource(lineNumber).showMerged() ? "Merge source revision" : "Revision"; + + return prefix + " " + info.getRevision() + ": " + revision.getCommitMessage(); } return ""; } @@ -194,53 +150,35 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myContents; } - public void setLineInfo(final int lineNumber, final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - myInfos.appendNumberedLineInfo(lineNumber, date, revision, author, mergeDate, mergeRevision, mergeAuthor); - } - - public void appendLineInfo(final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - myInfos.appendNumberedLineInfo(date, revision, author, mergeDate, mergeRevision, mergeAuthor); + public void setLineInfo(int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) { + myInfos.appendNumberedLineInfo(lineNumber, info, mergeInfo); } @Nullable public VcsRevisionNumber originalRevision(final int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return null; - } - final SvnFileRevision revision = myRevisionMap.get(myInfos.originalRevision(lineNumber)); - return revision == null ? null : revision.getRevisionNumber(); + SvnFileRevision revision = myInfos.isValid(lineNumber) ? myRevisionMap.get(myInfos.originalRevision(lineNumber)) : null; + + return revision != null ? revision.getRevisionNumber() : null; } public VcsRevisionNumber getLineRevisionNumber(final int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return null; - } - final LineInfo info = myInfos.get(lineNumber); - if (info == null) return null; - final long revision = info.getRevision(); - if (revision >= 0) { - return new SvnRevisionNumber(SVNRevision.create(revision)); - } - return null; + CommitInfo info = myInfos.getOrNull(lineNumber); + + return info != null && info.getRevision() >= 0 ? new SvnRevisionNumber(SVNRevision.create(info.getRevision())) : null; } @Override public Date getLineDate(int lineNumber) { - if (myInfos.size() <= lineNumber || lineNumber < 0) { - return null; - } - final LineInfo info = myInfos.get(lineNumber); - if (info == null) return null; - return info.getDate(); + CommitInfo info = myInfos.getOrNull(lineNumber); + + return info != null ? info.getDate() : null; } public List<VcsFileRevision> getRevisions() { final List<VcsFileRevision> result = new ArrayList<VcsFileRevision>(myRevisionMap.values()); Collections.sort(result, new Comparator<VcsFileRevision>() { public int compare(final VcsFileRevision o1, final VcsFileRevision o2) { - return -1 * o1.getRevisionNumber().compareTo(o2.getRevisionNumber()); + return o2.getRevisionNumber().compareTo(o1.getRevisionNumber()); } }); return result; @@ -250,10 +188,6 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return ! myRevisionMap.isEmpty(); } - public int getNumLines() { - return myInfos.size(); - } - @Nullable public AnnotationSourceSwitcher getAnnotationSourceSwitcher() { if (! myShowMergeSources) return null; @@ -285,7 +219,7 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { @Override public int getLineCount() { - return getNumLines(); + return myInfos.size(); } @Override @@ -294,44 +228,52 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { } private abstract class SvnAnnotationAspect extends LineAnnotationAspectAdapter { + public SvnAnnotationAspect(String id, boolean showByDefault) { super(id, showByDefault); } protected long getRevision(final int lineNum) { - final LineInfo lineInfo = myInfos.get(lineNum); + final CommitInfo lineInfo = myInfos.get(lineNum); return (lineInfo == null) ? -1 : lineInfo.getRevision(); } @Override protected void showAffectedPaths(int lineNum) { - if (lineNum >= 0 && lineNum < myInfos.size()) { + if (myInfos.isValid(lineNum)) { final long revision = getRevision(lineNum); if (revision >= 0) { showAllAffectedPaths(new SvnRevisionNumber(SVNRevision.create(revision))); } } } + + @Override + public String getValue(int lineNumber) { + CommitInfo info = myInfos.getOrNull(lineNumber); + + return info == null ? "" : getValue(info); + } + + public String getValue(@NotNull CommitInfo info) { + return ""; + } } protected abstract void showAllAffectedPaths(SvnRevisionNumber number); private static class MyPartiallyCreatedInfos { private boolean myShowMergeSource; - private final Map<Integer, LineInfo> myMappedLineInfo; - private final Map<Integer, LineInfo> myMergeSourceInfos; + private final Map<Integer, CommitInfo> myMappedLineInfo; + private final Map<Integer, CommitInfo> myMergeSourceInfos; private int myMaxIdx; private MyPartiallyCreatedInfos() { - myMergeSourceInfos = new HashMap<Integer, LineInfo>(); - myMappedLineInfo = new HashMap<Integer, LineInfo>(); + myMergeSourceInfos = ContainerUtil.newHashMap(); + myMappedLineInfo = ContainerUtil.newHashMap(); myMaxIdx = 0; } - boolean isShowMergeSource() { - return myShowMergeSource; - } - void setShowMergeSource(boolean showMergeSource) { myShowMergeSource = showMergeSource; } @@ -340,25 +282,18 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myMaxIdx + 1; } - void appendNumberedLineInfo(final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - appendNumberedLineInfo(myMaxIdx + 1, date, revision, author, mergeDate, mergeRevision, mergeAuthor); - } - - void appendNumberedLineInfo(final int lineNumber, final Date date, final long revision, final String author, - @Nullable final Date mergeDate, final long mergeRevision, @Nullable final String mergeAuthor) { - if (date == null) return; + void appendNumberedLineInfo(final int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) { if (myMappedLineInfo.get(lineNumber) != null) return; myMaxIdx = (myMaxIdx < lineNumber) ? lineNumber : myMaxIdx; - myMappedLineInfo.put(lineNumber, new LineInfo(date, revision, author)); - if (mergeDate != null) { - myMergeSourceInfos.put(lineNumber, new LineInfo(mergeDate, mergeRevision, mergeAuthor)); + myMappedLineInfo.put(lineNumber, info); + if (mergeInfo != null) { + myMergeSourceInfos.put(lineNumber, mergeInfo); } } - LineInfo get(final int idx) { + CommitInfo get(final int idx) { if (myShowMergeSource) { - final LineInfo lineInfo = myMergeSourceInfos.get(idx); + final CommitInfo lineInfo = myMergeSourceInfos.get(idx); if (lineInfo != null) { return lineInfo; } @@ -366,14 +301,23 @@ public abstract class BaseSvnFileAnnotation extends FileAnnotation { return myMappedLineInfo.get(idx); } + @Nullable + CommitInfo getOrNull(int lineNumber) { + return isValid(lineNumber) ? get(lineNumber) : null; + } + + private boolean isValid(int lineNumber) { + return lineNumber >= 0 && lineNumber < size(); + } + AnnotationSource getAnnotationSource(final int line) { return myShowMergeSource ? AnnotationSource.getInstance(myMergeSourceInfos.containsKey(line)) : AnnotationSource.LOCAL; } public long originalRevision(final int line) { - if (line >= size()) return -1; - final LineInfo lineInfo = myMappedLineInfo.get(line); - return lineInfo == null ? -1 : lineInfo.getRevision(); + CommitInfo info = line < size() ? myMappedLineInfo.get(line) : null; + + return info == null ? -1 : info.getRevision(); } public boolean mergeSourceAvailable(int lineNumber) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java index 5cb18a35fc5c..b48f14a41779 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/CmdAnnotateClient.java @@ -4,12 +4,12 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -18,7 +18,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -32,8 +31,8 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @NotNull SVNRevision endRevision, @Nullable SVNRevision pegRevision, boolean includeMergedRevisions, - @Nullable SVNDiffOptions diffOptions, - @Nullable final ISVNAnnotateHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable final AnnotationConsumer handler) throws VcsException { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, target.getPathOrUrlString(), pegRevision); parameters.add("--revision"); @@ -47,7 +46,7 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { parseOutput(command.getOutput(), handler); } - public void parseOutput(@NotNull String output, @Nullable ISVNAnnotateHandler handler) throws VcsException { + public void parseOutput(@NotNull String output, @Nullable AnnotationConsumer handler) throws VcsException { try { BlameInfo info = CommandUtil.parse(output, BlameInfo.class); @@ -65,12 +64,11 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { } } - private static void invokeHandler(ISVNAnnotateHandler handler, LineEntry entry) throws SVNException { - // line numbers in our api start from 0 - not from 1 like in svn output - // "line" value is not used in handlers - so null is passed - handler - .handleLine(entry.date(), entry.revision(), entry.author(), null, entry.mergedDate(), entry.mergedRevision(), entry.mergedAuthor(), - entry.mergedPath(), entry.lineNumber - 1); + private static void invokeHandler(@NotNull AnnotationConsumer handler, @NotNull LineEntry entry) throws SVNException { + if (entry.commit != null) { + // line numbers in our api start from 0 - not from 1 like in svn output + handler.consume(entry.lineNumber - 1, entry.commit.build(), entry.mergedCommit()); + } } @XmlRootElement(name = "blame") @@ -91,70 +89,15 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @XmlAttribute(name = "line-number") public int lineNumber; - @XmlElement(name = "commit") - public CommitEntry commit; + public CommitInfo.Builder commit; @XmlElement(name = "merged") public MergedEntry merged; - public long revision() { - return revision(commit); - } - - @Nullable - public String author() { - return author(commit); - } - - @Nullable - public Date date() { - return date(commit); - } - - @Nullable - public String mergedPath() { - return merged != null ? merged.path : null; - } - - public long mergedRevision() { - return merged != null ? revision(merged.commit) : 0; - } - - @Nullable - public String mergedAuthor() { - return merged != null ? author(merged.commit) : null; - } - - @Nullable - public Date mergedDate() { - return merged != null ? date(merged.commit) : null; - } - - private static long revision(@Nullable CommitEntry commit) { - return commit != null ? commit.revision : 0; - } - @Nullable - private static String author(@Nullable CommitEntry commit) { - return commit != null ? commit.author : null; + public CommitInfo mergedCommit() { + return merged != null && merged.commit != null ? merged.commit.build() : null; } - - @Nullable - private static Date date(@Nullable CommitEntry commit) { - return commit != null ? commit.date : null; - } - } - - public static class CommitEntry { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; } public static class MergedEntry { @@ -162,7 +105,6 @@ public class CmdAnnotateClient extends BaseSvnClient implements AnnotateClient { @XmlAttribute(name = "path") public String path; - @XmlElement(name = "commit") - public CommitEntry commit; + public CommitInfo.Builder commit; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java index c51f4dbcdaa3..a615fd4e3afa 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnAnnotationProvider.java @@ -35,11 +35,15 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; -import org.jetbrains.idea.svn.history.HistoryClient; -import org.jetbrains.idea.svn.history.SvnChangeList; -import org.jetbrains.idea.svn.history.SvnFileRevision; -import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.*; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.jetbrains.idea.svn.diff.DiffOptions; +import org.jetbrains.idea.svn.history.*; +import org.jetbrains.idea.svn.info.Info; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNErrorMessage; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -86,7 +90,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn public void run() { final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); final File ioFile = new File(file.getPath()).getAbsoluteFile(); - SVNInfo info = null; + Info info = null; try { final String contents; @@ -116,7 +120,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn } // ignore mime type=true : IDEA-19562 - final ISVNAnnotateHandler annotateHandler = createAnnotationHandler(progress, result); + final AnnotationConsumer annotateHandler = createAnnotationHandler(progress, result); final boolean calculateMergeinfo = SvnConfiguration.getInstance(myVcs.getProject()).isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, url); @@ -166,7 +170,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn } private void handleSvnException(File ioFile, - SVNInfo info, + Info info, SVNException e, VirtualFile file, VcsFileRevision revision, @@ -221,7 +225,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn private SvnRemoteFileAnnotation annotateNonExisting(Pair<SvnChangeList, FilePath> pair, VcsFileRevision revision, - SVNInfo info, + Info info, Charset charset, final VirtualFile current) throws VcsException, SVNException, IOException { final File wasFile = pair.getSecond().getIOFile(); final File root = getCommonAncestor(wasFile, info.getFile()); @@ -231,7 +235,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn final String relativePath = FileUtil.getRelativePath(root.getPath(), wasFile.getPath(), File.separatorChar); if (relativePath == null) throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString()); - SVNInfo wcRootInfo = myVcs.getInfo(root); + Info wcRootInfo = myVcs.getInfo(root); if (wcRootInfo == null || wcRootInfo.getURL() == null) { throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString()); } @@ -244,9 +248,8 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn final SVNRevision svnRevision = ((SvnRevisionNumber)revision.getRevisionNumber()).getRevision(); byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromURL(wasUrl), svnRevision, svnRevision); final String contents = LoadTextUtil.getTextByBinaryPresentation(data, charset == null ? CharsetToolkit.UTF8_CHARSET : charset).toString(); - final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), pair.getFirst(), - pair.getSecond().getPath(), current); - final ISVNAnnotateHandler annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result); + final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), current); + final AnnotationConsumer annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result); final boolean calculateMergeinfo = SvnConfiguration.getInstance(myVcs.getProject()).isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, wasUrl.toString()); @@ -256,45 +259,18 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn return result; } - private ISVNAnnotateHandler createAnnotationHandler(final ProgressIndicator progress, final BaseSvnFileAnnotation result) { - return new ISVNAnnotateHandler() { - public void handleLine(Date date, long revision, String author, String line) { - if (progress != null) { - progress.checkCanceled(); - } - result.appendLineInfo(date, revision, author, null, -1, null); - } - - public void handleLine(final Date date, - final long revision, - final String author, - final String line, - final Date mergedDate, - final long mergedRevision, - final String mergedAuthor, - final String mergedPath, - final int lineNumber) throws SVNException { - if (progress != null) { - progress.checkCanceled(); - } - if (revision == -1) return; - if ((mergedDate != null) && (revision > mergedRevision)) { - // !!! merged date = date of merge, i.e. date -> date of original change etc. - result.setLineInfo(lineNumber, date, revision, author, mergedDate, mergedRevision, mergedAuthor); - } else { - result.setLineInfo(lineNumber, date, revision, author, null, -1, null); - } - } + @NotNull + private static AnnotationConsumer createAnnotationHandler(@Nullable final ProgressIndicator progress, + @NotNull final BaseSvnFileAnnotation result) { + return new AnnotationConsumer() { - public boolean handleRevision(final Date date, final long revision, final String author, final File contents) - throws SVNException { + @Override + public void consume(int lineNumber, @NotNull CommitInfo info, @Nullable CommitInfo mergeInfo) throws SVNException { if (progress != null) { progress.checkCanceled(); } - return false; - } - public void handleEOF() { + result.setLineInfo(lineNumber, info, mergeInfo != null && info.getRevision() > mergeInfo.getRevision() ? mergeInfo : null); } }; } @@ -307,7 +283,7 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn if (annotationSourceSwitcher != null) { annotationSourceSwitcher.switchTo(AnnotationSource.LOCAL); } - final int size = svnFileAnnotation.getNumLines(); + final int size = svnFileAnnotation.getLineCount(); final VcsUsualLineAnnotationData lineAnnotationData = new VcsUsualLineAnnotationData(size); for (int i = 0; i < size; i++) { @@ -356,17 +332,15 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn for (int i = 0; i < basicAnnotation.getNumLines(); i++) { final VcsRevisionNumber revision = basicAnnotation.getRevision(i); final VcsRevisionNumber mergedData = data == null ? null : data.getRevision(i); - final VcsFileRevision fileRevision = historyAsMap.get(revision); + final SvnFileRevision fileRevision = (SvnFileRevision)historyAsMap.get(revision); if (fileRevision == null) return null; + if (mergedData == null) { - annotation.setLineInfo(i, fileRevision.getRevisionDate(), ((SvnRevisionNumber) revision).getRevision().getNumber(), - fileRevision.getAuthor(), null, -1, null); + annotation.setLineInfo(i, fileRevision.getCommitInfo(), null); } else { - final VcsFileRevision mergedRevision = cachedOtherRevisions.get(mergedData); + final SvnFileRevision mergedRevision = (SvnFileRevision)cachedOtherRevisions.get(mergedData); if (mergedRevision == null) return null; - annotation.setLineInfo(i, fileRevision.getRevisionDate(), ((SvnRevisionNumber) revision).getRevision().getNumber(), - fileRevision.getAuthor(), mergedRevision.getRevisionDate(), - ((SvnRevisionNumber) mergedRevision.getRevisionNumber()).getRevision().getNumber(), mergedRevision.getAuthor()); + annotation.setLineInfo(i, fileRevision.getCommitInfo(), mergedRevision.getCommitInfo()); } } if (vcsAnnotation.getFirstRevision() != null) { @@ -453,8 +427,9 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn private void doLog(final boolean includeMerged, final SVNRevision truncateTo, final int max) throws VcsException { myClient.doLog(SvnTarget.fromFile(myIoFile), myEndRevision, truncateTo == null ? SVNRevision.create(1L) : truncateTo, false, false, includeMerged, max, null, - new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { if (SVNRevision.UNDEFINED.getNumber() == logEntry.getRevision()) { return; } @@ -477,7 +452,8 @@ public class SvnAnnotationProvider implements AnnotationProvider, VcsCacheableAn return true; } - private static SVNDiffOptions getLogClientOptions(@NotNull SvnVcs vcs) { - return SvnConfiguration.getInstance(vcs.getProject()).isIgnoreSpacesInAnnotate() ? new SVNDiffOptions(true, true, true) : null; + @Nullable + private static DiffOptions getLogClientOptions(@NotNull SvnVcs vcs) { + return SvnConfiguration.getInstance(vcs.getProject()).isIgnoreSpacesInAnnotate() ? new DiffOptions(true, true, true) : null; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java index 191bd9079237..c2423de0b70d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnKitAnnotateClient.java @@ -4,13 +4,17 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.ISVNAnnotateHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNLogClient; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; +import java.io.File; +import java.util.Date; + /** * @author Konstantin Kolosovsky. */ @@ -22,21 +26,68 @@ public class SvnKitAnnotateClient extends BaseSvnClient implements AnnotateClien @NotNull SVNRevision endRevision, @Nullable SVNRevision pegRevision, boolean includeMergedRevisions, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNAnnotateHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable AnnotationConsumer handler) throws VcsException { try { SVNLogClient client = myVcs.getSvnKitManager().createLogClient(); - client.setDiffOptions(diffOptions); + client.setDiffOptions(toDiffOptions(diffOptions)); if (target.isFile()) { - client.doAnnotate(target.getFile(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, handler, null); + client + .doAnnotate(target.getFile(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), + null); } else { - client.doAnnotate(target.getURL(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, handler, null); + client + .doAnnotate(target.getURL(), pegRevision, startRevision, endRevision, true, includeMergedRevisions, toAnnotateHandler(handler), + null); } } catch (SVNException e) { throw new VcsException(e); } } + + @Nullable + private static ISVNAnnotateHandler toAnnotateHandler(@Nullable final AnnotationConsumer handler) { + ISVNAnnotateHandler result = null; + + if (handler != null) { + result = new ISVNAnnotateHandler() { + @Override + public void handleLine(Date date, long revision, String author, String line) throws SVNException { + // deprecated - not called + } + + @Override + public void handleLine(Date date, + long revision, + String author, + String line, + Date mergedDate, + long mergedRevision, + String mergedAuthor, + String mergedPath, + int lineNumber) throws SVNException { + if (revision > 0) { + CommitInfo info = new CommitInfo.Builder(revision, date, author).build(); + CommitInfo mergeInfo = mergedDate != null ? new CommitInfo.Builder(mergedRevision, mergedDate, mergedAuthor).build() : null; + + handler.consume(lineNumber, info, mergeInfo); + } + } + + @Override + public boolean handleRevision(Date date, long revision, String author, File contents) throws SVNException { + return false; + } + + @Override + public void handleEOF() throws SVNException { + } + }; + } + + return result; + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java index f00bc7b97aaa..3f0924650c5f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/annotate/SvnRemoteFileAnnotation.java @@ -29,15 +29,10 @@ import org.jetbrains.idea.svn.history.SvnChangeList; * Time: 12:10 PM */ public class SvnRemoteFileAnnotation extends BaseSvnFileAnnotation { - private final SvnChangeList mySvnChangeList; - private final String myPathToSelect; private final VirtualFile myCurrentFile; - public SvnRemoteFileAnnotation(SvnVcs vcs, String contents, VcsRevisionNumber baseRevision, SvnChangeList svnChangeList, - final String pathToSelect, final VirtualFile currentFile) { + public SvnRemoteFileAnnotation(SvnVcs vcs, String contents, VcsRevisionNumber baseRevision, final VirtualFile currentFile) { super(vcs, contents, baseRevision); - mySvnChangeList = svnChangeList; - myPathToSelect = pathToSelect; myCurrentFile = currentFile; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseNodeDescription.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseNodeDescription.java new file mode 100644 index 000000000000..03e2e07a339c --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseNodeDescription.java @@ -0,0 +1,42 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import org.jetbrains.annotations.NotNull; + +/** + * @author Konstantin Kolosovsky. + */ +public abstract class BaseNodeDescription { + + @NotNull protected final NodeKind myKind; + + protected BaseNodeDescription(@NotNull NodeKind kind) { + myKind = kind; + } + + public boolean isFile() { + return myKind.isFile(); + } + + public boolean isDirectory() { + return myKind.isDirectory(); + } + + public boolean isNone() { + return myKind.isNone(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java index bb8c613c8135..0d58355543ba 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/BaseSvnClient.java @@ -8,10 +8,11 @@ import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.auth.IdeaSvnkitBasedAuthenticationCallback; import org.jetbrains.idea.svn.commandLine.*; +import org.jetbrains.idea.svn.diff.DiffOptions; +import org.tmatesoft.svn.core.SVNCancelException; +import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; +import org.tmatesoft.svn.core.wc.*; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -109,10 +110,10 @@ public abstract class BaseSvnClient implements SvnClient { return runtime.runWithAuthenticationAttempt(command); } - protected static void callHandler(@Nullable ISVNEventHandler handler, @NotNull SVNEvent event) throws VcsException { + protected static void callHandler(@Nullable ProgressTracker handler, @NotNull ProgressEvent event) throws VcsException { if (handler != null) { try { - handler.handleEvent(event, 0); + handler.consume(event); } catch (SVNException e) { throw new SvnBindException(e); @@ -121,7 +122,44 @@ public abstract class BaseSvnClient implements SvnClient { } @NotNull - protected static SVNEvent createEvent(@NotNull File path, @Nullable SVNEventAction action) { - return new SVNEvent(path, null, null, 0, null, null, null, null, action, null, null, null, null, null, null); + protected static ProgressEvent createEvent(@NotNull File path, @Nullable EventAction action) { + return new ProgressEvent(path, 0, null, null, action, null, null); + } + + @Nullable + protected static ISVNEventHandler toEventHandler(@Nullable final ProgressTracker handler) { + ISVNEventHandler result = null; + + if (handler != null) { + result = new ISVNEventHandler() { + @Override + public void handleEvent(SVNEvent event, double progress) throws SVNException { + handler.consume(ProgressEvent.create(event)); + } + + @Override + public void checkCancelled() throws SVNCancelException { + handler.checkCancelled(); + } + }; + } + + return result; + } + + @Nullable + protected static SVNDiffOptions toDiffOptions(@Nullable DiffOptions options) { + return options != null ? new SVNDiffOptions(options.isIgnoreAllWhitespace(), options.isIgnoreAmountOfWhitespace(), + options.isIgnoreEOLStyle()) : null; + } + + @Nullable + protected static SVNDepth toDepth(@Nullable Depth depth) { + return depth != null ? SVNDepth.fromString(depth.getName()) : null; + } + + @NotNull + protected static SVNRevision notNullize(@Nullable SVNRevision revision) { + return revision != null ? revision : SVNRevision.UNDEFINED; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java index 99e00a373d7d..ba3e56de8e63 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ClientFactory.java @@ -27,7 +27,6 @@ import org.jetbrains.idea.svn.revert.RevertClient; import org.jetbrains.idea.svn.update.RelocateClient; import org.jetbrains.idea.svn.update.UpdateClient; import org.jetbrains.idea.svn.upgrade.UpgradeClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; /** @@ -102,7 +101,7 @@ public abstract class ClientFactory { } @NotNull - public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ISVNEventHandler handler) { + public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ProgressTracker handler) { return createStatusClient(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/Depth.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/Depth.java new file mode 100644 index 000000000000..9ccc96e81f67 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/Depth.java @@ -0,0 +1,93 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNDepth; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum Depth { + + UNKNOWN("unknown"), + INFINITY("infinity"), + IMMEDIATES("immediates"), + FILES("files"), + EMPTY("empty"); + + @NotNull private static final Map<String, Depth> ourAllDepths = ContainerUtil.newHashMap(); + + static { + for (Depth action : Depth.values()) { + register(action); + } + } + + @NotNull private final String myName; + + Depth(@NotNull String name) { + myName = name; + } + + @NotNull + public String getName() { + return myName; + } + + @Override + public String toString() { + return myName; + } + + private static void register(@NotNull Depth depth) { + ourAllDepths.put(depth.myName, depth); + } + + @NotNull + public static Depth from(@NotNull String depthName) { + Depth result = ourAllDepths.get(depthName); + + if (result == null) { + throw new IllegalArgumentException("Unknown depth " + depthName); + } + + return result; + } + + @NotNull + public static Depth from(@Nullable SVNDepth depth) { + return depth != null ? from(depth.getName()) : UNKNOWN; + } + + @NotNull + public static Depth allOrFiles(boolean recursive) { + return recursive ? INFINITY : FILES; + } + + @NotNull + public static Depth allOrEmpty(boolean recursive) { + return recursive ? INFINITY : EMPTY; + } + + public static boolean isRecursive(@Nullable Depth depth) { + return depth == null || depth == INFINITY || depth == UNKNOWN; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/EventAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/EventAction.java new file mode 100644 index 000000000000..3a1d3fc80ef1 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/EventAction.java @@ -0,0 +1,91 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.tmatesoft.svn.core.wc.SVNEventAction; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum EventAction { + + // currently used to represent some not used event action from SVNKit + UNKNOWN("unknown"), + + ADD("add"), + DELETE("delete"), + RESTORE("restore"), + REVERT("revert"), + FAILED_REVERT("failed_revert"), + SKIP("skip"), + + UPDATE_DELETE("update_delete"), + UPDATE_ADD("update_add"), + UPDATE_UPDATE("update_update"), + UPDATE_NONE("update_none"), + UPDATE_COMPLETED("update_completed"), + UPDATE_EXTERNAL("update_external"), + UPDATE_SKIP_OBSTRUCTION("update_skip_obstruction"), + UPDATE_STARTED("update_started"), + + COMMIT_MODIFIED("commit_modified"), + COMMIT_ADDED("commit_added"), + COMMIT_DELETED("commit_deleted"), + COMMIT_REPLACED("commit_replaced"), + COMMIT_DELTA_SENT("commit_delta_sent"), + FAILED_OUT_OF_DATE("failed_out_of_date"), + + LOCKED("locked"), + UNLOCKED("unlocked"), + LOCK_FAILED("lock_failed"), + UNLOCK_FAILED("unlock_failed"), + + UPGRADED_PATH("upgraded_path"), + + TREE_CONFLICT("tree_conflict"); + + @NotNull private static final Map<String, EventAction> ourAllActions = ContainerUtil.newHashMap(); + + static { + for (EventAction action : EventAction.values()) { + register(action); + } + } + + private String myKey; + + EventAction(String key) { + myKey = key; + } + + public String toString() { + return myKey; + } + + private static void register(@NotNull EventAction action) { + ourAllActions.put(action.myKey, action); + } + + @NotNull + public static EventAction from(@NotNull SVNEventAction action) { + return ObjectUtils.notNull(ourAllActions.get(action.toString()), UNKNOWN); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java index fc202c265a6a..7bc0b32a2e04 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/FileStatusResultParser.java @@ -6,8 +6,6 @@ import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -17,20 +15,18 @@ import java.util.regex.Pattern; */ public class FileStatusResultParser { - private static final double DEFAULT_PROGRESS = 0.0; - @NotNull private Pattern myLinePattern; @Nullable - private ISVNEventHandler handler; + private ProgressTracker handler; @NotNull - private Convertor<Matcher, SVNEvent> myConvertor; + private Convertor<Matcher, ProgressEvent> myConvertor; public FileStatusResultParser(@NotNull Pattern linePattern, - @Nullable ISVNEventHandler handler, - @NotNull Convertor<Matcher, SVNEvent> convertor) { + @Nullable ProgressTracker handler, + @NotNull Convertor<Matcher, ProgressEvent> convertor) { myLinePattern = linePattern; this.handler = handler; myConvertor = convertor; @@ -59,7 +55,7 @@ public class FileStatusResultParser { public void process(@NotNull Matcher matcher) throws VcsException { if (handler != null) { try { - handler.handleEvent(myConvertor.convert(matcher), DEFAULT_PROGRESS); + handler.consume(myConvertor.convert(matcher)); } catch (SVNException e) { throw new VcsException(e); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java index c2be897dc3a1..bfcf37de3a0d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/InfoCommandRepositoryProvider.java @@ -18,8 +18,7 @@ package org.jetbrains.idea.svn.api; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNRevision; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.wc2.SvnTarget; /** @@ -42,7 +41,7 @@ public class InfoCommandRepositoryProvider extends BaseRepositoryProvider { result = new Repository(myTarget.getURL()); } else { - SVNInfo info = myVcs.getInfo(myTarget.getFile()); + Info info = myVcs.getInfo(myTarget.getFile()); result = info != null ? new Repository(info.getRepositoryRootURL()) : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/NodeKind.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/NodeKind.java new file mode 100644 index 000000000000..e4820b844c23 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/NodeKind.java @@ -0,0 +1,94 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.tmatesoft.svn.core.SVNNodeKind; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlEnumValue; +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +@XmlEnum +public enum NodeKind { + + // see comments in LogEntryPath.Builder for cases when "" kind could appear + @XmlEnumValue("") UNKNOWN("unknown"), + @XmlEnumValue("file") FILE("file"), + @XmlEnumValue("dir") DIR("dir"), + // used in ConflictVersion when node is missing + @XmlEnumValue("none") NONE("none"); + + @NotNull private static final Map<String, NodeKind> ourAllNodeKinds = ContainerUtil.newHashMap(); + + static { + for (NodeKind kind : NodeKind.values()) { + register(kind); + } + } + + @NotNull private final String myKey; + + NodeKind(@NotNull String key) { + myKey = key; + } + + public boolean isFile() { + return FILE.equals(this); + } + + public boolean isDirectory() { + return DIR.equals(this); + } + + public boolean isNone() { + return NONE.equals(this); + } + + @Override + public String toString() { + return myKey; + } + + private static void register(@NotNull NodeKind kind) { + ourAllNodeKinds.put(kind.myKey, kind); + } + + @NotNull + public static NodeKind from(@NotNull String nodeKindName) { + NodeKind result = ourAllNodeKinds.get(nodeKindName); + + if (result == null) { + throw new IllegalArgumentException("Unknown node kind " + nodeKindName); + } + + return result; + } + + @NotNull + public static NodeKind from(@NotNull SVNNodeKind nodeKind) { + return from(nodeKind.toString()); + } + + @NotNull + public static NodeKind from(boolean isDirectory) { + return isDirectory ? DIR : FILE; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressEvent.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressEvent.java new file mode 100644 index 000000000000..12bd2e1a91f4 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressEvent.java @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.status.StatusType; +import org.tmatesoft.svn.core.SVNErrorMessage; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.wc.SVNEvent; + +import java.io.File; + +/** + * @author Konstantin Kolosovsky. + */ +public class ProgressEvent { + + private final File myFile; + + private final long myRevision; + private final SVNURL myURL; + + @NotNull private final StatusType myContentsStatus; + @NotNull private final StatusType myPropertiesStatus; + private final SVNErrorMessage myErrorMessage; + private final EventAction myAction; + + @Nullable + public static ProgressEvent create(@Nullable SVNEvent event) { + ProgressEvent result = null; + + if (event != null) { + if (event.getFile() == null && event.getURL() == null) { + result = new ProgressEvent(event.getErrorMessage()); + } + else { + result = + new ProgressEvent(event.getFile(), event.getRevision(), StatusType.from(event.getContentsStatus()), StatusType.from(event.getPropertiesStatus()), + EventAction.from(event.getAction()), event.getErrorMessage(), event.getURL()); + } + } + + return result; + } + + public ProgressEvent(SVNErrorMessage errorMessage) { + this(null, 0, null, null, EventAction.SKIP, errorMessage, null); + } + + public ProgressEvent(File file, + long revision, + @Nullable StatusType contentStatus, + @Nullable StatusType propertiesStatus, + EventAction action, + SVNErrorMessage error, + SVNURL url) { + myFile = file != null ? file.getAbsoluteFile() : null; + myRevision = revision; + myContentsStatus = contentStatus == null ? StatusType.INAPPLICABLE : contentStatus; + myPropertiesStatus = propertiesStatus == null ? StatusType.INAPPLICABLE : propertiesStatus; + myAction = action; + myErrorMessage = error; + myURL = url; + } + + public File getFile() { + return myFile; + } + + public EventAction getAction() { + return myAction; + } + + @NotNull + public StatusType getContentsStatus() { + return myContentsStatus; + } + + public SVNErrorMessage getErrorMessage() { + return myErrorMessage; + } + + @NotNull + public StatusType getPropertiesStatus() { + return myPropertiesStatus; + } + + public long getRevision() { + return myRevision; + } + + public SVNURL getURL() { + return myURL; + } + + @Nullable + public String getPath() { + return myFile != null ? myFile.getName() : myURL != null ? myURL.toString() : null; + } + + public String toString() { + return getAction() + " " + getFile() + " " + getURL(); + } +}
\ No newline at end of file diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressTracker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressTracker.java new file mode 100644 index 000000000000..303b66a00c62 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/ProgressTracker.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.api; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNCancelException; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface ProgressTracker extends ThrowableConsumer<ProgressEvent, SVNException> { + + void checkCancelled() throws SVNCancelException; +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java index 1b834c16585b..f46f5f06ebdb 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/api/SvnKitClientFactory.java @@ -29,7 +29,6 @@ import org.jetbrains.idea.svn.update.SvnKitRelocateClient; import org.jetbrains.idea.svn.update.SvnKitUpdateClient; import org.jetbrains.idea.svn.update.UpdateClient; import org.jetbrains.idea.svn.upgrade.SvnKitUpgradeClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.ISVNStatusFileProvider; /** @@ -72,7 +71,7 @@ public class SvnKitClientFactory extends ClientFactory { @NotNull @Override - public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ISVNEventHandler handler) { + public StatusClient createStatusClient(@Nullable ISVNStatusFileProvider provider, @NotNull ProgressTracker handler) { return prepare(new SvnKitStatusClient(provider, handler)); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java index 698ed90418c7..10f4574c7f39 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/BranchesLoader.java @@ -20,6 +20,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.integrate.SvnBranchItem; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.SVNLogClient; @@ -42,13 +45,14 @@ public class BranchesLoader { SVNURL branchesUrl = SVNURL.parseURIEncoded(url); List<SvnBranchItem> result = new LinkedList<SvnBranchItem>(); SvnTarget target = SvnTarget.fromURL(branchesUrl); - ISVNDirEntryHandler handler = createHandler(branchesUrl, result); if (!passive) { // TODO: Implement ability to specify interactive/non-interactive auth mode for clients - vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, SVNDepth.IMMEDIATES, handler); + DirectoryEntryConsumer handler = createConsumer(branchesUrl, result); + vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler); } else { + ISVNDirEntryHandler handler = createHandler(branchesUrl, result); SVNLogClient client = vcs.getSvnKitManager().createLogClient(configuration.getPassiveAuthenticationManager(project)); client .doList(target.getURL(), target.getPegRevision(), SVNRevision.HEAD, false, SVNDepth.IMMEDIATES, SVNDirEntry.DIRENT_ALL, handler); @@ -69,4 +73,18 @@ public class BranchesLoader { } }; } + + @NotNull + private static DirectoryEntryConsumer createConsumer(@NotNull final SVNURL branchesUrl, @NotNull final List<SvnBranchItem> result) { + return new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + // TODO: Remove equality check with branchesUrl when SVNLogClient will not be used directly, but rather through BrowseClient. + if (!branchesUrl.equals(entry.getUrl()) && entry.getDate() != null) { + result.add(new SvnBranchItem(entry.getUrl().toDecodedString(), entry.getDate(), entry.getRevision())); + } + } + }; + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java index 315954e7b520..d52798e6bfc3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/DefaultConfigLoader.java @@ -24,10 +24,13 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.integrate.SvnBranchItem; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -52,7 +55,7 @@ public class DefaultConfigLoader { final SvnVcs vcs = SvnVcs.getInstance(project); File rootFile = new File(vcsRoot.getPath()); - final SVNInfo info = vcs.getInfo(rootFile); + final Info info = vcs.getInfo(rootFile); if (info == null || info.getURL() == null) { LOG.info("Directory is not a working copy: " + vcsRoot.getPresentableUrl()); return null; @@ -67,7 +70,7 @@ public class DefaultConfigLoader { SVNURL rootPath = baseUrl.removePathTail(); SvnTarget target = SvnTarget.fromURL(rootPath); - vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, SVNDepth.IMMEDIATES, createHandler(result, rootPath)); + vcs.getFactory(target).createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, createHandler(result, rootPath)); break; } if (SVNPathUtil.removeTail(baseUrl.getPath()).length() == 0) { @@ -88,13 +91,15 @@ public class DefaultConfigLoader { } @NotNull - private static ISVNDirEntryHandler createHandler(final SvnBranchConfigurationNew result, final SVNURL rootPath) { - return new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - if (SVNNodeKind.DIR.equals(dirEntry.getKind())) { - SVNURL childUrl = rootPath.appendPath(dirEntry.getName(), false); + private static DirectoryEntryConsumer createHandler(final SvnBranchConfigurationNew result, final SVNURL rootPath) { + return new DirectoryEntryConsumer() { - if (StringUtil.endsWithIgnoreCase(dirEntry.getName(), DEFAULT_TRUNK_NAME)) { + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + if (entry.isDirectory()) { + SVNURL childUrl = rootPath.appendPath(entry.getName(), false); + + if (StringUtil.endsWithIgnoreCase(entry.getName(), DEFAULT_TRUNK_NAME)) { result.setTrunkUrl(childUrl.toString()); } else { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java index b3554ce89c74..4102210a657a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/branchConfig/SvnBranchConfigurationNew.java @@ -23,12 +23,12 @@ import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.integrate.SvnBranchItem; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import java.io.File; import java.util.*; @@ -221,7 +221,7 @@ public class SvnBranchConfigurationNew { private BranchRootSearcher(final SvnVcs vcs, final VirtualFile root) throws SVNException { myRoot = root; myBranchesUnder = new HashMap<String, String>(); - final SVNInfo info = vcs.getInfo(myRoot.getPath()); + final Info info = vcs.getInfo(myRoot.getPath()); myRootUrl = info != null ? info.getURL() : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java index 92e64bb5230e..f5c46cb32842 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/BrowseClient.java @@ -18,9 +18,8 @@ package org.jetbrains.idea.svn.browse; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.ISVNDirEntryHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -29,7 +28,7 @@ import org.tmatesoft.svn.core.wc2.SvnTarget; */ public interface BrowseClient extends SvnClient { - void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable SVNDepth depth, @Nullable ISVNDirEntryHandler handler) + void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable Depth depth, @Nullable DirectoryEntryConsumer handler) throws VcsException; long createDirectory(@NotNull SvnTarget target, @NotNull String message, boolean makeParents) throws VcsException; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java index 20d60a9e50bf..bceb516caef3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/CmdBrowseClient.java @@ -21,12 +21,17 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; import org.jetbrains.idea.svn.checkin.CmdCheckinClient; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.*; +import org.jetbrains.idea.svn.lock.Lock; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -35,7 +40,6 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; -import java.util.Date; import java.util.List; /** @@ -46,8 +50,8 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, - @Nullable ISVNDirEntryHandler handler) throws VcsException { + @Nullable Depth depth, + @Nullable DirectoryEntryConsumer handler) throws VcsException { assertUrl(target); List<String> parameters = new ArrayList<String>(); @@ -85,15 +89,15 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { return listener.getCommittedRevision(); } - private static void parseOutput(@NotNull SVNURL url, @NotNull CommandExecutor command, @Nullable ISVNDirEntryHandler handler) - throws VcsException, SVNException { + private static void parseOutput(@NotNull SVNURL url, @NotNull CommandExecutor command, @Nullable DirectoryEntryConsumer handler) + throws VcsException, SVNException { try { TargetLists lists = CommandUtil.parse(command.getOutput(), TargetLists.class); if (handler != null && lists != null) { for (TargetList list : lists.lists) { for (Entry entry : list.entries) { - handler.handleDirEntry(entry.toDirEntry(url)); + handler.consume(entry.toDirectoryEntry(url)); } } } @@ -122,8 +126,8 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { public static class Entry { - @XmlAttribute(name = "kind") - public String kind; + @XmlAttribute(name = "kind", required = true) + public NodeKind kind; @XmlElement(name = "name") public String name; @@ -131,68 +135,15 @@ public class CmdBrowseClient extends BaseSvnClient implements BrowseClient { @XmlElement(name = "size") public long size; - @XmlElement(name = "commit") - public Commit commit; + public CommitInfo.Builder commit; - @XmlElement(name = "lock") - public Lock lock; + public Lock.Builder lock; - public long revision() { - return commit != null ? commit.revision : 0; - } - - public String author() { - return commit != null ? commit.author : ""; - } - - public Date date() { - return commit != null ? commit.date : null; - } - - public SVNDirEntry toDirEntry(@NotNull SVNURL url) throws SVNException { + @NotNull + public DirectoryEntry toDirectoryEntry(@NotNull SVNURL url) throws SVNException { // TODO: repository is not used for now - SVNDirEntry entry = - new SVNDirEntry(url.appendPath(name, false), null, PathUtil.getFileName(name), SVNNodeKind.parseKind(kind), size, false, revision(), - date(), author()); - - entry.setRelativePath(name); - entry.setLock(lock != null ? lock.toLock(entry.getRelativePath()) : null); - - return entry; - } - } - - public static class Commit { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; - } - - public static class Lock { - - @XmlElement(name = "token") - public String token; - - @XmlElement(name = "owner") - public String owner; - - @XmlElement(name = "comment") - public String comment; - - @XmlElement(name = "created") - public Date created; - - @XmlElement(name = "expires") - public Date expires; - - public SVNLock toLock(@NotNull String path) { - return new SVNLock(path, token, owner, comment, created, expires); + return new DirectoryEntry(url.appendPath(name, false), null, PathUtil.getFileName(name), kind, + commit != null ? commit.build() : null, name); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java new file mode 100644 index 000000000000..e29e6e468bd1 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntry.java @@ -0,0 +1,100 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.browse; + +import com.intellij.util.ObjectUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.checkin.CommitInfo; +import org.tmatesoft.svn.core.SVNDirEntry; +import org.tmatesoft.svn.core.SVNURL; + +import java.util.Date; + +/** + * @author Konstantin Kolosovsky. + */ +public class DirectoryEntry extends BaseNodeDescription implements Comparable<DirectoryEntry> { + + private final String myName; + @NotNull private final CommitInfo myCommitInfo; + private final String myPath; + private final SVNURL myUrl; + private final SVNURL myRepositoryRoot; + + @NotNull + public static DirectoryEntry create(@NotNull SVNDirEntry entry) { + return new DirectoryEntry(entry.getURL(), entry.getRepositoryRoot(), entry.getName(), NodeKind.from(entry.getKind()), + new CommitInfo.Builder(entry.getRevision(), entry.getDate(), entry.getAuthor()).build(), + entry.getRelativePath()); + } + + public DirectoryEntry(SVNURL url, + SVNURL repositoryRoot, + String name, + @NotNull NodeKind kind, + @Nullable CommitInfo commitInfo, + String path) { + super(kind); + myUrl = url; + myRepositoryRoot = repositoryRoot; + myName = name; + myCommitInfo = ObjectUtils.notNull(commitInfo, CommitInfo.EMPTY); + myPath = path; + } + + public SVNURL getUrl() { + return myUrl; + } + + public SVNURL getRepositoryRoot() { + return myRepositoryRoot; + } + + public String getName() { + return myName; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + public Date getDate() { + return myCommitInfo.getDate(); + } + + public long getRevision() { + return myCommitInfo.getRevision(); + } + + public String getAuthor() { + return myCommitInfo.getAuthor(); + } + + public String getRelativePath() { + return myPath == null ? myName : myPath; + } + + @Override + public int compareTo(@NotNull DirectoryEntry o) { + int result = getKind().compareTo(o.getKind()); + + return result != 0 ? result : myUrl.toString().compareTo(o.getUrl().toString()); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java new file mode 100644 index 000000000000..f404413a6996 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/DirectoryEntryConsumer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.browse; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface DirectoryEntryConsumer extends ThrowableConsumer<DirectoryEntry, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java index 42ac680a6ab8..cdbb1ff1e67b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/browse/SvnKitBrowseClient.java @@ -20,6 +20,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.SVNLogClient; @@ -33,8 +34,8 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient { @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, - @Nullable ISVNDirEntryHandler handler) throws VcsException { + @Nullable Depth depth, + @Nullable DirectoryEntryConsumer handler) throws VcsException { assertUrl(target); SVNLogClient client = myVcs.getSvnKitManager().createLogClient(); @@ -42,10 +43,10 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient { try { if (target.isFile()) { - client.doList(target.getFile(), target.getPegRevision(), revision, true, depth, SVNDirEntry.DIRENT_ALL, wrappedHandler); + client.doList(target.getFile(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler); } else { - client.doList(target.getURL(), target.getPegRevision(), revision, true, depth, SVNDirEntry.DIRENT_ALL, wrappedHandler); + client.doList(target.getURL(), target.getPegRevision(), notNullize(revision), true, toDepth(depth), SVNDirEntry.DIRENT_ALL, wrappedHandler); } } catch (SVNException e) { @@ -69,26 +70,26 @@ public class SvnKitBrowseClient extends BaseSvnClient implements BrowseClient { } @Nullable - private static ISVNDirEntryHandler wrapHandler(@Nullable ISVNDirEntryHandler handler) { + private static ISVNDirEntryHandler wrapHandler(@Nullable DirectoryEntryConsumer handler) { return handler == null ? null : new SkipEmptyNameDirectoriesHandler(handler); } public static class SkipEmptyNameDirectoriesHandler implements ISVNDirEntryHandler { - @NotNull private final ISVNDirEntryHandler handler; + @NotNull private final DirectoryEntryConsumer handler; - public SkipEmptyNameDirectoriesHandler(@NotNull ISVNDirEntryHandler handler) { + public SkipEmptyNameDirectoriesHandler(@NotNull DirectoryEntryConsumer handler) { this.handler = handler; } @Override public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException { if (!isEmptyNameDirectory(dirEntry)) { - handler.handleDirEntry(dirEntry); + handler.consume(DirectoryEntry.create(dirEntry)); } } - private static boolean isEmptyNameDirectory(SVNDirEntry dirEntry) { + private static boolean isEmptyNameDirectory(@NotNull SVNDirEntry dirEntry) { return SVNNodeKind.DIR.equals(dirEntry.getKind()) && StringUtil.isEmpty(dirEntry.getName()); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java index 2791ce87af12..dc9feddf61d7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/change/CmdChangeListClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -25,7 +25,7 @@ public class CmdChangeListClient extends BaseSvnClient implements ChangeListClie parameters.add(changeList); CommandUtil.put(parameters, path); - CommandUtil.put(parameters, SVNDepth.EMPTY); + CommandUtil.put(parameters, Depth.EMPTY); if (changeListsToOperate != null) { CommandUtil.putChangeLists(parameters, Arrays.asList(changeListsToOperate)); } @@ -41,7 +41,7 @@ public class CmdChangeListClient extends BaseSvnClient implements ChangeListClie parameters.add("--remove"); CommandUtil.put(parameters, path); - CommandUtil.put(parameters, SVNDepth.EMPTY); + CommandUtil.put(parameters, Depth.EMPTY); // for now parsing of the output is not required as command is executed only for one file // and will be either successful or exception will be thrown diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java index 628c22219e11..cc8e2ef0e352 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CheckinClient.java @@ -18,7 +18,6 @@ package org.jetbrains.idea.svn.checkin; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNCommitInfo; import java.io.File; import java.util.Collection; @@ -29,5 +28,5 @@ import java.util.Collection; public interface CheckinClient extends SvnClient { @NotNull - SVNCommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException; + CommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java index ce95c6420204..ced5e62b0f33 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdCheckinClient.java @@ -29,13 +29,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.commandLine.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.CommandUtil; +import org.jetbrains.idea.svn.commandLine.LineCommandAdapter; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNCommitInfo; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -57,26 +58,21 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { @NotNull @Override - public SVNCommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String message) throws VcsException { + public CommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String message) throws VcsException { // if directory renames were used, IDEA reports all files under them as moved, but for svn we can not pass some of them // to commit command - since not all paths are registered as changes -> so we need to filter these cases, but only if // there at least some child-parent relationships in passed paths - try { - paths = filterCommittables(paths); - } - catch (SVNException e) { - throw new SvnBindException(e); - } + paths = filterCommittables(paths); return commit(ArrayUtil.toObjectArray(paths, File.class), message); } @NotNull - public SVNCommitInfo[] commit(@NotNull File[] paths, @NotNull String message) throws VcsException { - if (paths.length == 0) return new SVNCommitInfo[]{SVNCommitInfo.NULL}; + public CommitInfo[] commit(@NotNull File[] paths, @NotNull String message) throws VcsException { + if (paths.length == 0) return new CommitInfo[]{CommitInfo.EMPTY}; final List<String> parameters = new ArrayList<String>(); - CommandUtil.put(parameters, SVNDepth.EMPTY); + CommandUtil.put(parameters, Depth.EMPTY); CommandUtil.put(parameters, false, "--no-unlock"); CommandUtil.put(parameters, false, "--keep-changelists"); CommandUtil.putChangeLists(parameters, null); @@ -95,7 +91,7 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { long revision = validateRevisionNumber(listener.getCommittedRevision()); - return new SVNCommitInfo[]{new SVNCommitInfo(revision, null, null, null)}; + return new CommitInfo[]{new CommitInfo.Builder().setRevision(revision).build()}; } private static long validateRevisionNumber(long revision) throws VcsException { @@ -106,7 +102,7 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { return revision; } - private Collection<File> filterCommittables(@NotNull Collection<File> committables) throws SVNException { + private Collection<File> filterCommittables(@NotNull Collection<File> committables) throws SvnBindException { final Set<String> childrenOfSomebody = ContainerUtil.newHashSet(); new AbstractFilterChildren<File>() { @Override @@ -135,13 +131,13 @@ public class CmdCheckinClient extends BaseSvnClient implements CheckinClient { } else { try { - final SVNStatus status = statusClient.doStatus(file, false); - if (status != null && !SVNStatusType.STATUS_NONE.equals(status.getContentsStatus()) && - !SVNStatusType.STATUS_UNVERSIONED.equals(status.getContentsStatus())) { + final Status status = statusClient.doStatus(file, false); + if (status != null && !StatusType.STATUS_NONE.equals(status.getContentsStatus()) && + !StatusType.STATUS_UNVERSIONED.equals(status.getContentsStatus())) { result.add(file); } } - catch (SVNException e) { + catch (SvnBindException e) { // not versioned LOG.info(e); throw e; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java index 74eeadbb2fa1..a06c2800714a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CmdImportClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNCommitHandler; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,7 +23,7 @@ public class CmdImportClient extends BaseSvnClient implements ImportClient { @Override public long doImport(@NotNull File path, @NotNull SVNURL url, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull String message, boolean noIgnore, @Nullable CommitEventHandler handler, diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java index 87be3fae7dd5..54a92197d2c7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitEventHandler.java @@ -15,7 +15,7 @@ */ package org.jetbrains.idea.svn.checkin; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; +import org.jetbrains.idea.svn.api.ProgressTracker; import java.io.File; @@ -26,7 +26,7 @@ import java.io.File; * Date: 2/26/13 * Time: 10:12 AM */ -public interface CommitEventHandler extends ISVNEventHandler { +public interface CommitEventHandler extends ProgressTracker { void commitEvent(final CommitEventType type, final File target); void committedRevision(final long revNum); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitInfo.java new file mode 100644 index 000000000000..a09d3c0295db --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/CommitInfo.java @@ -0,0 +1,127 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.checkin; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNErrorMessage; + +import javax.xml.bind.annotation.*; +import java.util.Date; + +/** + * @author Konstantin Kolosovsky. + */ +public class CommitInfo { + + public static final CommitInfo EMPTY = new CommitInfo.Builder().setRevision(-1).build(); + + private final long myRevision; + private final Date myDate; + private final String myAuthor; + @Nullable private final SVNErrorMessage myErrorMessage; + + private CommitInfo(@NotNull CommitInfo.Builder builder) { + myRevision = builder.revision; + myAuthor = builder.author; + myDate = builder.date; + myErrorMessage = builder.error; + } + + public long getRevision() { + return myRevision; + } + + public String getAuthor() { + return myAuthor; + } + + public Date getDate() { + return myDate; + } + + @Nullable + public SVNErrorMessage getErrorMessage() { + return myErrorMessage; + } + + @XmlAccessorType(XmlAccessType.NONE) + @XmlType(name = "commit") + @XmlRootElement(name = "commit") + public static class Builder { + + @XmlAttribute(name = "revision") + private long revision; + + @XmlElement(name = "author") + private String author; + + @XmlElement(name = "date") + private Date date; + + @Nullable private SVNErrorMessage error; + + public Builder() { + } + + public Builder(long revision, Date date, String author) { + this.revision = revision; + this.date = date; + this.author = author; + } + + public long getRevision() { + return revision; + } + + public String getAuthor() { + return author; + } + + public Date getDate() { + return date; + } + + @NotNull + public Builder setRevision(long revision) { + this.revision = revision; + return this; + } + + @NotNull + public Builder setAuthor(String author) { + this.author = author; + return this; + } + + @NotNull + public Builder setDate(Date date) { + this.date = date; + return this; + } + + @NotNull + public Builder setError(@Nullable SVNErrorMessage error) { + this.error = error; + return this; + } + + @NotNull + public CommitInfo build() { + return new CommitInfo(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java index 3b78ac667efa..2dc46692cf59 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/IdeaCommitHandler.java @@ -27,11 +27,10 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; -import org.jetbrains.idea.svn.SvnUtil; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import java.io.File; import java.util.List; @@ -42,7 +41,7 @@ import java.util.List; * Date: 2/26/13 * Time: 11:13 AM */ -public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { +public class IdeaCommitHandler implements CommitEventHandler, ProgressTracker { private static final Logger LOG = Logger.getInstance(IdeaCommitHandler.class); @@ -81,8 +80,8 @@ public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { myProgress.setText2(SvnBundle.message("status.text.comitted.revision", revNum)); } - public void handleEvent(SVNEvent event, double p) { - final String path = SvnUtil.getPathForProgress(event); + public void consume(ProgressEvent event) { + final String path = event.getPath(); if (path != null) { CommitEventType eventType = convert(event.getAction()); @@ -120,7 +119,7 @@ public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { } } - private void trackDeletedFile(@NotNull SVNEvent event) { + private void trackDeletedFile(@NotNull ProgressEvent event) { @NonNls final String filePath = "file://" + event.getFile().getAbsolutePath().replace(File.separatorChar, '/'); VirtualFile virtualFile = ApplicationManager.getApplication().runReadAction(new Computable<VirtualFile>() { @Nullable @@ -135,22 +134,22 @@ public class IdeaCommitHandler implements CommitEventHandler, ISVNEventHandler { } @NotNull - private static CommitEventType convert(@NotNull SVNEventAction action) { + private static CommitEventType convert(@NotNull EventAction action) { CommitEventType result = CommitEventType.unknown; - if (SVNEventAction.COMMIT_ADDED.equals(action)) { + if (EventAction.COMMIT_ADDED.equals(action)) { result = CommitEventType.adding; - } else if (SVNEventAction.COMMIT_DELETED.equals(action)) { + } else if (EventAction.COMMIT_DELETED.equals(action)) { result = CommitEventType.deleting; - } else if (SVNEventAction.COMMIT_MODIFIED.equals(action)) { + } else if (EventAction.COMMIT_MODIFIED.equals(action)) { result = CommitEventType.sending; - } else if (SVNEventAction.COMMIT_REPLACED.equals(action)) { + } else if (EventAction.COMMIT_REPLACED.equals(action)) { result = CommitEventType.replacing; - } else if (SVNEventAction.COMMIT_DELTA_SENT.equals(action)) { + } else if (EventAction.COMMIT_DELTA_SENT.equals(action)) { result = CommitEventType.transmittingDeltas; - } else if (SVNEventAction.SKIP.equals(action)) { + } else if (EventAction.SKIP.equals(action)) { result = CommitEventType.skipped; - } else if (SVNEventAction.FAILED_OUT_OF_DATE.equals(action)) { + } else if (EventAction.FAILED_OUT_OF_DATE.equals(action)) { result = CommitEventType.failedOutOfDate; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java index d3c273ee1449..9338c5db47c6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/ImportClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.checkin; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNCommitHandler; @@ -17,7 +17,7 @@ public interface ImportClient extends SvnClient { long doImport(@NotNull File path, @NotNull SVNURL url, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull String message, boolean noIgnore, @Nullable CommitEventHandler handler, diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java index 6fb1b95b7afe..c9a843501253 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinEnvironment.java @@ -45,14 +45,14 @@ import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; -import org.tmatesoft.svn.core.SVNCommitInfo; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import javax.swing.*; import java.awt.*; @@ -130,18 +130,18 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { return; } - SVNCommitInfo[] results = mySvnVcs.getFactory(format).createCheckinClient().commit(committables, comment); + CommitInfo[] results = mySvnVcs.getFactory(format).createCheckinClient().commit(committables, comment); final StringBuilder committedRevisions = new StringBuilder(); - for (SVNCommitInfo result : results) { + for (CommitInfo result : results) { if (result.getErrorMessage() != null) { exception.add(new VcsException(result.getErrorMessage().getFullMessage())); } - else if (result != SVNCommitInfo.NULL && result.getNewRevision() > 0) { + else if (result != CommitInfo.EMPTY && result.getRevision() > 0) { if (committedRevisions.length() > 0) { committedRevisions.append(", "); } - committedRevisions.append(result.getNewRevision()); + committedRevisions.append(result.getRevision()); } } if (committedRevisions.length() > 0) { @@ -199,11 +199,9 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { } private void addParents(File file, final Adder adder) { - SVNStatus status = getStatus(file); + Status status = getStatus(file); - if (status != null && - (SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_ADDED) || - SvnVcs.svnStatusIs(status, SVNStatusType.STATUS_REPLACED))) { + if (status != null && status.is(StatusType.STATUS_ADDED, StatusType.STATUS_REPLACED)) { // file should be added adder.add(file); file = file.getParentFile(); @@ -214,13 +212,13 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { } @Nullable - private SVNStatus getStatus(@NotNull File file) { - SVNStatus result = null; + private Status getStatus(@NotNull File file) { + Status result = null; try { result = mySvnVcs.getFactory(file).createStatusClient().doStatus(file, false); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } @@ -287,9 +285,9 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { public static List<VcsException> scheduleUnversionedFilesForAddition(@NotNull SvnVcs vcs, List<VirtualFile> files, final boolean recursive) { Collections.sort(files, FilePathComparator.getInstance()); - ISVNEventHandler eventHandler = new SvnProgressCanceller() { + ProgressTracker eventHandler = new SvnProgressCanceller() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { // TODO: indicator is null here when invoking "Add" action ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); File file = event.getFile(); @@ -301,7 +299,7 @@ public class SvnCheckinEnvironment implements CheckinEnvironment { }; List<VcsException> exceptions = new ArrayList<VcsException>(); - SVNDepth depth = recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY; + Depth depth = Depth.allOrEmpty(recursive); for (VirtualFile file : files) { try { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java index 8af993b9aefc..29e5fe9d7f72 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnCheckinHandlerFactory.java @@ -32,15 +32,15 @@ import com.intellij.openapi.vcs.checkin.CheckinHandler; import com.intellij.openapi.vcs.checkin.VcsCheckinHandlerFactory; import com.intellij.openapi.vcs.ui.RefreshableOnComponent; import com.intellij.openapi.vcs.update.ActionInfo; -import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.PairConsumer; +import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.update.AutoSvnUpdater; -import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -74,22 +74,20 @@ public class SvnCheckinHandlerFactory extends VcsCheckinHandlerFactory { public ReturnResult beforeCheckin(@Nullable CommitExecutor executor, PairConsumer<Object, Object> additionalDataConsumer) { if (executor instanceof LocalCommitExecutor) return ReturnResult.COMMIT; final SvnVcs vcs = SvnVcs.getInstance(project); - final Map<String, Integer> copiesInfo = splitIntoCopies(vcs, myChanges); + final MultiMap<String, WorkingCopyFormat> copiesInfo = splitIntoCopies(vcs, myChanges); final List<String> repoUrls = new ArrayList<String>(); - for (Map.Entry<String, Integer> entry : copiesInfo.entrySet()) { - if (entry.getValue() == 3) { + for (Map.Entry<String, Collection<WorkingCopyFormat>> entry : copiesInfo.entrySet()) { + if (entry.getValue().size() > 1) { repoUrls.add(entry.getKey()); } } if (! repoUrls.isEmpty()) { - final String join = StringUtil.join(repoUrls.toArray(new String[repoUrls.size()]), ",\n"); + final String join = StringUtil.join(repoUrls, ",\n"); final int isOk = Messages.showOkCancelDialog(project, SvnBundle.message("checkin.different.formats.involved", repoUrls.size() > 1 ? 1 : 0, join), "Subversion: Commit Will Split", Messages.getWarningIcon()); - if (Messages.OK == isOk) { - return ReturnResult.COMMIT; - } - return ReturnResult.CANCEL; + + return Messages.OK == isOk ? ReturnResult.COMMIT : ReturnResult.CANCEL; } return ReturnResult.COMMIT; } @@ -104,17 +102,17 @@ public class SvnCheckinHandlerFactory extends VcsCheckinHandlerFactory { if (SvnConfiguration.getInstance(project).isAutoUpdateAfterCommit()) { final VirtualFile[] roots = ProjectLevelVcsManager.getInstance(project).getRootsUnderVcs(SvnVcs.getInstance(project)); final List<FilePath> paths = new ArrayList<FilePath>(); - for (int i = 0; i < roots.length; i++) { - VirtualFile root = roots[i]; + for (VirtualFile root : roots) { boolean take = false; for (VirtualFile commitRoot : commitRoots) { - if (VfsUtil.isAncestor(root, commitRoot, false)) { + if (VfsUtilCore.isAncestor(root, commitRoot, false)) { take = true; break; } } - if (! take) continue; - paths.add(new FilePathImpl(root)); + if (take) { + paths.add(new FilePathImpl(root)); + } } if (paths.isEmpty()) return; ApplicationManager.getApplication().invokeLater(new Runnable() { @@ -128,25 +126,19 @@ public class SvnCheckinHandlerFactory extends VcsCheckinHandlerFactory { }; } - private static Map<String, Integer> splitIntoCopies(SvnVcs vcs, final Collection<Change> changes) { - final SvnFileUrlMapping mapping = vcs.getSvnFileUrlMapping(); + @NotNull + private static MultiMap<String, WorkingCopyFormat> splitIntoCopies(@NotNull SvnVcs vcs, @NotNull Collection<Change> changes) { + MultiMap<String, WorkingCopyFormat> result = MultiMap.createSet(); + SvnFileUrlMapping mapping = vcs.getSvnFileUrlMapping(); - final Map<String, Integer> copiesInfo = new java.util.HashMap<String, Integer>(); for (Change change : changes) { - final File ioFile = ChangesUtil.getFilePath(change).getIOFile(); - final RootUrlInfo path = mapping.getWcRootForFilePath(ioFile); - if (path == null) continue; - final Integer integer = copiesInfo.get(path.getRepositoryUrl()); - int result = integer == null ? 0 : integer; - if (result != 3) { - if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(path.getFormat())) { - result |= 2; - } else { - result |= 1; - } - copiesInfo.put(path.getRepositoryUrl(), result); + RootUrlInfo path = mapping.getWcRootForFilePath(ChangesUtil.getFilePath(change).getIOFile()); + + if (path != null) { + result.putValue(path.getRepositoryUrl(), path.getFormat()); } } - return copiesInfo; + + return result; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java index a81aecd94ba2..c3f203a9e02f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitCheckinClient.java @@ -20,6 +20,8 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.api.BaseSvnClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; @@ -41,7 +43,7 @@ public class SvnKitCheckinClient extends BaseSvnClient implements CheckinClient @NotNull @Override - public SVNCommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException { + public CommitInfo[] commit(@NotNull Collection<File> paths, @NotNull String comment) throws VcsException { File[] pathsToCommit = ArrayUtil.toObjectArray(paths, File.class); boolean keepLocks = myVcs.getSvnConfiguration().isKeepLocks(); SVNCommitPacket[] commitPackets = null; @@ -49,7 +51,7 @@ public class SvnKitCheckinClient extends BaseSvnClient implements CheckinClient SVNCommitClient committer = myVcs.getSvnKitManager().createCommitClient(); IdeaCommitHandler handler = new IdeaCommitHandler(ProgressManager.getInstance().getProgressIndicator(), true, true); - committer.setEventHandler(handler); + committer.setEventHandler(toEventHandler(handler)); try { commitPackets = committer.doCollectCommitItems(pathsToCommit, keepLocks, true, SVNDepth.EMPTY, true, null); results = committer.doCommit(commitPackets, keepLocks, comment); @@ -76,6 +78,17 @@ public class SvnKitCheckinClient extends BaseSvnClient implements CheckinClient f.putUserData(VirtualFile.REQUESTOR_MARKER, this); } - return results; + return convert(results); + } + + @NotNull + private static CommitInfo[] convert(@NotNull SVNCommitInfo[] infos) { + return ContainerUtil.map(infos, new Function<SVNCommitInfo, CommitInfo>() { + @Override + public CommitInfo fun(SVNCommitInfo info) { + return new CommitInfo.Builder(info.getNewRevision(), info.getDate(), info.getAuthor()) + .setError(info.getErrorMessage()).build(); + } + }, new CommitInfo[0]); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java index 23edc8f22253..d64f8c3f95a9 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkin/SvnKitImportClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNCommitInfo; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNCommitHandler; @@ -22,18 +22,18 @@ public class SvnKitImportClient extends BaseSvnClient implements ImportClient { @Override public long doImport(@NotNull File path, @NotNull SVNURL url, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull String message, boolean noIgnore, @Nullable CommitEventHandler handler, @Nullable ISVNCommitHandler commitHandler) throws VcsException { SVNCommitClient client = myVcs.getSvnKitManager().createCommitClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); client.setCommitHandler(commitHandler); try { - SVNCommitInfo info = client.doImport(path, url, message, null, !noIgnore, false, depth); + SVNCommitInfo info = client.doImport(path, url, message, null, !noIgnore, false, toDepth(depth)); return info.getNewRevision(); } catch (SVNException e) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java index b31d0da1dc48..d338ca12e55d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -21,11 +21,11 @@ public interface CheckoutClient extends SvnClient { void checkout(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean ignoreExternals, boolean force, @NotNull WorkingCopyFormat format, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; List<WorkingCopyFormat> getSupportedFormats() throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java index 88f2a6940c10..868c38b8b364 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CheckoutEventHandler.java @@ -22,16 +22,15 @@ import com.intellij.openapi.wm.StatusBar; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; -import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -public class CheckoutEventHandler implements ISVNEventHandler { +public class CheckoutEventHandler implements ProgressTracker { @Nullable private final ProgressIndicator myIndicator; private int myExternalsCount; @NotNull private final SvnVcs myVCS; @@ -46,20 +45,19 @@ public class CheckoutEventHandler implements ISVNEventHandler { myCnt = 0; } - public void handleEvent(SVNEvent event, double progress) { - final String path = SvnUtil.getPathForProgress(event); - if (path == null) { + public void consume(ProgressEvent event) { + if (event.getPath() == null) { return; } - if (event.getAction() == SVNEventAction.UPDATE_EXTERNAL) { + if (event.getAction() == EventAction.UPDATE_EXTERNAL) { myExternalsCount++; progress(SvnBundle.message("progress.text2.fetching.external.location", event.getFile().getAbsolutePath())); } - else if (event.getAction() == SVNEventAction.UPDATE_ADD) { + else if (event.getAction() == EventAction.UPDATE_ADD) { progress2(SvnBundle.message(myIsExport ? "progress.text2.exported" : "progress.text2.checked.out", event.getFile().getName(), myCnt)); ++ myCnt; } - else if (event.getAction() == SVNEventAction.UPDATE_COMPLETED) { + else if (event.getAction() == EventAction.UPDATE_COMPLETED) { myExternalsCount--; progress2( (SvnBundle.message(myIsExport ? "progress.text2.exported.revision" : "progress.text2.checked.out.revision", event.getRevision()))); @@ -70,10 +68,10 @@ public class CheckoutEventHandler implements ISVNEventHandler { StatusBar.Info.set(SvnBundle.message(myIsExport ? "progress.text2.exported.revision" : "status.text.checked.out.revision", event.getRevision()), project); } } - } else if (event.getAction() == SVNEventAction.COMMIT_ADDED) { - progress2((SvnBundle.message("progress.text2.adding", path))); - } else if (event.getAction() == SVNEventAction.COMMIT_DELTA_SENT) { - progress2((SvnBundle.message("progress.text2.transmitting.delta", path))); + } else if (event.getAction() == EventAction.COMMIT_ADDED) { + progress2((SvnBundle.message("progress.text2.adding", event.getPath()))); + } else if (event.getAction() == EventAction.COMMIT_DELTA_SENT) { + progress2((SvnBundle.message("progress.text2.transmitting.delta", event.getPath()))); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java index b292e43b9c1b..7ea00c69d5d6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdCheckoutClient.java @@ -6,11 +6,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -26,11 +26,11 @@ public class CmdCheckoutClient extends BaseSvnClient implements CheckoutClient { public void checkout(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean ignoreExternals, boolean force, @NotNull WorkingCopyFormat format, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { validateFormat(format, getSupportedFormats()); List<String> parameters = new ArrayList<String>(); @@ -57,7 +57,7 @@ public class CmdCheckoutClient extends BaseSvnClient implements CheckoutClient { private void run(@NotNull SvnTarget source, @NotNull File destination, - @Nullable ISVNEventHandler handler, + @Nullable ProgressTracker handler, @NotNull List<String> parameters) throws VcsException { BaseUpdateCommandListener listener = new BaseUpdateCommandListener(destination, handler); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java index 1e4011378fb7..a35c7a475d02 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/CmdExportClient.java @@ -5,11 +5,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -26,11 +26,11 @@ public class CmdExportClient extends BaseSvnClient implements ExportClient { public void export(@NotNull SvnTarget from, @NotNull File to, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable String nativeLineEnd, boolean force, boolean ignoreExternals, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, from); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java index 6ddd6debe763..4033ead72bcc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/ExportClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.checkout; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -19,9 +19,9 @@ public interface ExportClient extends SvnClient { void export(@NotNull SvnTarget from, @NotNull File to, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable String nativeLineEnd, boolean force, boolean ignoreExternals, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java index 634d528c17f1..c7422ef2a220 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnCheckoutProvider.java @@ -44,12 +44,13 @@ import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.actions.ExclusiveBackgroundVcsAction; import org.jetbrains.idea.svn.actions.SvnExcludingIgnoredOperation; import org.jetbrains.idea.svn.api.ClientFactory; -import org.jetbrains.idea.svn.checkin.IdeaCommitHandler; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CommitEventHandler; +import org.jetbrains.idea.svn.checkin.IdeaCommitHandler; import org.jetbrains.idea.svn.dialogs.CheckoutDialog; import org.jetbrains.idea.svn.dialogs.UpgradeFormatDialog; import org.tmatesoft.svn.core.SVNCancelException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.*; @@ -68,8 +69,8 @@ public class SvnCheckoutProvider implements CheckoutProvider { dialog.show(); } - public static void doCheckout(final Project project, final File target, final String url, final SVNRevision revision, - final SVNDepth depth, final boolean ignoreExternals, @Nullable final Listener listener) { + public static void doCheckout(@NotNull Project project, @NotNull File target, final String url, final SVNRevision revision, + final Depth depth, final boolean ignoreExternals, @Nullable final Listener listener) { if (! target.exists()) { target.mkdirs(); } @@ -95,7 +96,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { final File target, final String url, final SVNRevision revision, - final SVNDepth depth, + final Depth depth, final boolean ignoreExternals, final Listener listener, final WorkingCopyFormat selectedFormat) { final Ref<Boolean> checkoutSuccessful = new Ref<Boolean>(); @@ -108,7 +109,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { SvnWorkingCopyFormatHolder.setPresetFormat(format); SvnVcs vcs = SvnVcs.getInstance(project); - ISVNEventHandler handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator()); + ProgressTracker handler = new CheckoutEventHandler(vcs, false, ProgressManager.getInstance().getProgressIndicator()); ProgressManager.progress(SvnBundle.message("progress.text.checking.out", target.getAbsolutePath())); try { getFactory(vcs, format).createCheckoutClient() @@ -186,11 +187,11 @@ public class SvnCheckoutProvider implements CheckoutProvider { @CalledInAwt @NotNull - public static WorkingCopyFormat promptForWCopyFormat(final File target, final Project project) { + public static WorkingCopyFormat promptForWCopyFormat(@NotNull File target, @NotNull Project project) { return new CheckoutFormatFromUserProvider(project, target).prompt(); } - public static void doExport(final Project project, final File target, final SVNURL url, final SVNDepth depth, + public static void doExport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean ignoreExternals, final boolean force, final String eolStyle) { try { final VcsException[] exception = new VcsException[1]; @@ -199,7 +200,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator(); - ISVNEventHandler handler = new CheckoutEventHandler(vcs, true, progressIndicator); + ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator); try { progressIndicator.setText(SvnBundle.message("progress.text.export", target.getAbsolutePath())); @@ -221,7 +222,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { } } - public static void doImport(final Project project, final File target, final SVNURL url, final SVNDepth depth, + public static void doImport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean includeIgnored, final String message) { final Ref<String> errorMessage = new Ref<String>(); final SvnVcs vcs = SvnVcs.getInstance(project); @@ -312,14 +313,15 @@ public class SvnCheckoutProvider implements CheckoutProvider { public WorkingCopyFormat prompt() { assert !ApplicationManager.getApplication().isUnitTestMode(); - final WorkingCopyFormat result = displayUpgradeDialog(WorkingCopyFormat.ONE_DOT_SEVEN); + final WorkingCopyFormat result = displayUpgradeDialog(); ApplicationManager.getApplication().getMessageBus().syncPublisher(SvnVcs.WC_CONVERTED).run(); return result; } - private WorkingCopyFormat displayUpgradeDialog(@NotNull WorkingCopyFormat defaultSelection) { + @NotNull + private WorkingCopyFormat displayUpgradeDialog() { final UpgradeFormatDialog dialog = new UpgradeFormatDialog(myProject, myPath, false); final ModalityState dialogState = ModalityState.any(); @@ -354,6 +356,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { return dialog.isOK() ? dialog.getUpgradeMode() : WorkingCopyFormat.UNKNOWN; } + @NotNull private List<WorkingCopyFormat> loadSupportedFormats() { List<WorkingCopyFormat> result = ContainerUtil.newArrayList(); @@ -368,6 +371,7 @@ public class SvnCheckoutProvider implements CheckoutProvider { return result; } + @NotNull private static List<WorkingCopyFormat> getOtherFactoryFormats(@NotNull ClientFactory otherFactory) { List<WorkingCopyFormat> result; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java index 9abd2da1b35c..d8f0ea5be3d2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitCheckoutClient.java @@ -5,11 +5,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.internal.wc2.SvnWcGeneration; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -39,11 +39,11 @@ public class SvnKitCheckoutClient extends BaseSvnClient implements CheckoutClien public void checkout(@NotNull SvnTarget source, @NotNull File destination, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean ignoreExternals, boolean force, @NotNull WorkingCopyFormat format, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); validateFormat(format, getSupportedFormats()); @@ -54,10 +54,10 @@ public class SvnKitCheckoutClient extends BaseSvnClient implements CheckoutClien } client.setIgnoreExternals(ignoreExternals); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { - client.doCheckout(source.getURL(), destination, source.getPegRevision(), revision, depth, force); + client.doCheckout(source.getURL(), destination, source.getPegRevision(), revision, toDepth(depth), force); } catch (SVNException e) { throw new SvnBindException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java index df7b496f9811..66eac246f3b7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/checkout/SvnKitExportClient.java @@ -4,10 +4,10 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,22 +23,22 @@ public class SvnKitExportClient extends BaseSvnClient implements ExportClient { public void export(@NotNull SvnTarget from, @NotNull File to, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable String nativeLineEnd, boolean force, boolean ignoreExternals, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { SVNUpdateClient client = myVcs.getSvnKitManager().createUpdateClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); client.setIgnoreExternals(ignoreExternals); try { if (from.isFile()) { - client.doExport(from.getFile(), to, from.getPegRevision(), revision, nativeLineEnd, force, depth); + client.doExport(from.getFile(), to, from.getPegRevision(), revision, nativeLineEnd, force, toDepth(depth)); } else { - client.doExport(from.getURL(), to, from.getPegRevision(), revision, nativeLineEnd, force, depth); + client.doExport(from.getURL(), to, from.getPegRevision(), revision, nativeLineEnd, force, toDepth(depth)); } } catch (SVNException e) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java index 3d1b9ee88b7c..6bf861062894 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CleanupClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.cleanup; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -13,5 +13,5 @@ import java.io.File; */ public interface CleanupClient extends SvnClient { - void cleanup(@NotNull File path, @Nullable ISVNEventHandler handler) throws VcsException; + void cleanup(@NotNull File path, @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java index 6ee1763d4120..478144579045 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/CmdCleanupClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -19,7 +19,7 @@ import java.util.List; public class CmdCleanupClient extends BaseSvnClient implements CleanupClient { @Override - public void cleanup(@NotNull File path, @Nullable ISVNEventHandler handler) throws VcsException { + public void cleanup(@NotNull File path, @Nullable ProgressTracker handler) throws VcsException { // TODO: Implement event handler support - currently in SVNKit implementation handler is used to support cancelling List<String> parameters = new ArrayList<String>(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java index b19a505ef63a..00ae19a5d8d6 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/cleanup/SvnKitCleanupClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -17,10 +17,10 @@ import java.io.File; public class SvnKitCleanupClient extends BaseSvnClient implements CleanupClient { @Override - public void cleanup(@NotNull File path, @Nullable ISVNEventHandler handler) throws VcsException { + public void cleanup(@NotNull File path, @Nullable ProgressTracker handler) throws VcsException { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { client.doCleanup(path); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java index eb80bad0c70f..a8ef20b21765 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/BaseUpdateCommandListener.java @@ -2,12 +2,11 @@ package org.jetbrains.idea.svn.commandLine; import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.util.Key; -import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; import java.io.File; import java.util.concurrent.atomic.AtomicReference; @@ -21,12 +20,12 @@ public class BaseUpdateCommandListener extends LineCommandAdapter { private final UpdateOutputLineConverter converter; @Nullable - private final ISVNEventHandler handler; + private final ProgressTracker handler; @NotNull private final AtomicReference<SVNException> exception; - public BaseUpdateCommandListener(@NotNull File base, @Nullable ISVNEventHandler handler) { + public BaseUpdateCommandListener(@NotNull File base, @Nullable ProgressTracker handler) { this.handler = handler; this.converter = new UpdateOutputLineConverter(base); exception = new AtomicReference<SVNException>(); @@ -35,7 +34,7 @@ public class BaseUpdateCommandListener extends LineCommandAdapter { @Override public void onLineAvailable(String line, Key outputType) { if (ProcessOutputTypes.STDOUT.equals(outputType)) { - final SVNEvent event = converter.convert(line); + final ProgressEvent event = converter.convert(line); if (event != null) { beforeHandler(event); try { @@ -49,28 +48,20 @@ public class BaseUpdateCommandListener extends LineCommandAdapter { } } - private void callHandler(SVNEvent event) throws SVNException { + private void callHandler(ProgressEvent event) throws SVNException { if (handler != null) { - handler.handleEvent(event, 0.5); + handler.consume(event); } } - public void throwIfException() throws SVNException { + public void throwWrappedIfException() throws SvnBindException { SVNException e = exception.get(); if (e != null) { - throw e; + throw new SvnBindException(e); } } - public void throwWrappedIfException() throws VcsException { - SVNException e = exception.get(); - - if (e != null) { - throw new VcsException(e); - } - } - - protected void beforeHandler(@NotNull SVNEvent event) { + protected void beforeHandler(@NotNull ProgressEvent event) { } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java index 66216d39a3c0..50215fba76c8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/Command.java @@ -5,7 +5,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.ISVNCanceller; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -31,7 +31,7 @@ public class Command { @Nullable private volatile SVNURL myRepositoryUrl; @NotNull private SvnTarget myTarget; - @Nullable private ISVNCanceller myCanceller; + @Nullable private ProgressTracker myCanceller; public Command(@NotNull SvnCommandName name) { myName = name; @@ -52,11 +52,11 @@ public class Command { } @Nullable - public ISVNCanceller getCanceller() { + public ProgressTracker getCanceller() { return myCanceller; } - public void setCanceller(@Nullable ISVNCanceller canceller) { + public void setCanceller(@Nullable ProgressTracker canceller) { myCanceller = canceller; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java index 84794b7249a8..eee798737846 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandUtil.java @@ -4,10 +4,10 @@ import com.intellij.openapi.application.PathManager; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.diff.DiffOptions; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.xml.bind.JAXBContext; @@ -90,12 +90,12 @@ public class CommandUtil { } } - public static void put(@NotNull List<String> parameters, @Nullable SVNDepth depth) { + public static void put(@NotNull List<String> parameters, @Nullable Depth depth) { put(parameters, depth, false); } - public static void put(@NotNull List<String> parameters, @Nullable SVNDepth depth, boolean sticky) { - if (depth != null && !SVNDepth.UNKNOWN.equals(depth)) { + public static void put(@NotNull List<String> parameters, @Nullable Depth depth, boolean sticky) { + if (depth != null && !Depth.UNKNOWN.equals(depth)) { parameters.add("--depth"); parameters.add(depth.getName()); @@ -113,7 +113,7 @@ public class CommandUtil { } } - public static void put(@NotNull List<String> parameters, @Nullable SVNDiffOptions diffOptions) { + public static void put(@NotNull List<String> parameters, @Nullable DiffOptions diffOptions) { if (diffOptions != null) { StringBuilder builder = new StringBuilder(); @@ -172,29 +172,29 @@ public class CommandUtil { } @NotNull - public static SVNStatusType getStatusType(@Nullable String type) { + public static StatusType getStatusType(@Nullable String type) { return getStatusType(getStatusChar(type)); } @NotNull - public static SVNStatusType getStatusType(char first) { - final SVNStatusType contentsStatus; + public static StatusType getStatusType(char first) { + final StatusType contentsStatus; if ('A' == first) { - contentsStatus = SVNStatusType.STATUS_ADDED; + contentsStatus = StatusType.STATUS_ADDED; } else if ('D' == first) { - contentsStatus = SVNStatusType.STATUS_DELETED; + contentsStatus = StatusType.STATUS_DELETED; } else if ('U' == first) { - contentsStatus = SVNStatusType.CHANGED; + contentsStatus = StatusType.CHANGED; } else if ('C' == first) { - contentsStatus = SVNStatusType.CONFLICTED; + contentsStatus = StatusType.CONFLICTED; } else if ('G' == first) { - contentsStatus = SVNStatusType.MERGED; + contentsStatus = StatusType.MERGED; } else if ('R' == first) { - contentsStatus = SVNStatusType.STATUS_REPLACED; + contentsStatus = StatusType.STATUS_REPLACED; } else if ('E' == first) { - contentsStatus = SVNStatusType.STATUS_OBSTRUCTED; + contentsStatus = StatusType.STATUS_OBSTRUCTED; } else { - contentsStatus = SVNStatusType.STATUS_NORMAL; + contentsStatus = StatusType.STATUS_NORMAL; } return contentsStatus; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java index 80c1f4078f85..6694083b4d81 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnBindException.java @@ -42,9 +42,16 @@ public class SvnBindException extends VcsException { public static final int ERROR_BASE = 120000; public static final int CATEGORY_SIZE = 5000; + public static final String ERROR_MESSAGE_FORMAT = "svn: E%d: %s"; + @NotNull private final MultiMap<Integer, String> errors = MultiMap.create(); @NotNull private final MultiMap<Integer, String> warnings = MultiMap.create(); + public SvnBindException(@NotNull SVNErrorCode code, @NotNull String message) { + super(String.format(ERROR_MESSAGE_FORMAT, code.getCode(), message)); + errors.putValue(code.getCode(), getMessage()); + } + public SvnBindException(String message) { super(message); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java index cd451e149d09..d7b849655ce7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnExceptionWrapper.java @@ -40,4 +40,8 @@ public class SvnExceptionWrapper extends RuntimeException { public SvnExceptionWrapper(SVNException cause) { super(cause); } + + public SvnExceptionWrapper(SvnBindException cause) { + super(cause); + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java index a5a1ab80b75b..602a6e8c460e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/UpdateOutputLineConverter.java @@ -18,12 +18,11 @@ package org.jetbrains.idea.svn.commandLine; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNErrorCode; import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.Arrays; @@ -80,7 +79,7 @@ public class UpdateOutputLineConverter { myCurrentFile = base; } - public SVNEvent convert(final String line) { + public ProgressEvent convert(final String line) { // TODO: Add direct processing of "Summary of conflicts" lines at the end of "svn update" output (if there are conflicts). // TODO: Now it works ok because parseNormalLine could not determine necessary statuses from that and further lines if (StringUtil.isEmptyOrSpaces(line)) return null; @@ -89,23 +88,19 @@ public class UpdateOutputLineConverter { return null; } else if (line.startsWith(UPDATING)) { myCurrentFile = parseForPath(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.UPDATE_NONE, SVNEventAction.UPDATE_NONE, null, null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.UPDATE_NONE, null, null); } else if (line.startsWith(RESTORED)) { myCurrentFile = parseForPath(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.RESTORE, SVNEventAction.RESTORE, null, null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.RESTORE, null, null); } else if (line.startsWith(SKIPPED)) { // called, for instance, when folder is not working copy myCurrentFile = parseForPath(line); final String comment = parseComment(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.SKIP, SVNEventAction.SKIP, - comment == null ? null : SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE, comment), null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.SKIP, + comment == null ? null : SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE, comment), null); } else if (line.startsWith(FETCHING_EXTERNAL)) { myCurrentFile = parseForPath(line); - return new SVNEvent(myCurrentFile, myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, -1, null, null, null, null, SVNEventAction.UPDATE_EXTERNAL, SVNEventAction.UPDATE_EXTERNAL, null, null, null, null, null); + return new ProgressEvent(myCurrentFile, -1, null, null, EventAction.UPDATE_EXTERNAL, null, null); } for (int i = 0; i < ourCompletePatterns.length; i++) { @@ -114,10 +109,7 @@ public class UpdateOutputLineConverter { if (revision != -1) { // TODO: seems that myCurrentFile will not always be correct - complete update message could be right after complete externals update // TODO: check this and use Stack instead - return new SVNEvent(myCurrentFile, - myCurrentFile == null ? null : (myCurrentFile.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE), - null, revision, null, null, null, null, SVNEventAction.UPDATE_COMPLETED, SVNEventAction.UPDATE_COMPLETED, null, - null, null, null, null); + return new ProgressEvent(myCurrentFile, revision, null, null, EventAction.UPDATE_COMPLETED, null, null); } } @@ -127,13 +119,13 @@ public class UpdateOutputLineConverter { private final static Set<Character> ourActions = new HashSet<Character>(Arrays.asList(new Character[] {'A', 'D', 'U', 'C', 'G', 'E', 'R'})); @Nullable - private SVNEvent parseNormalString(final String line) { + private ProgressEvent parseNormalString(final String line) { if (line.length() < 5) return null; final char first = line.charAt(0); if (' ' != first && ! ourActions.contains(first)) return null; - final SVNStatusType contentsStatus = CommandUtil.getStatusType(first); + final StatusType contentsStatus = CommandUtil.getStatusType(first); final char second = line.charAt(1); - final SVNStatusType propertiesStatus = CommandUtil.getStatusType(second); + final StatusType propertiesStatus = CommandUtil.getStatusType(second); final char lock = line.charAt(2); // dont know what to do with stolen lock info if (' ' != lock && 'B' != lock) return null; final char treeConflict = line.charAt(3); @@ -143,29 +135,26 @@ public class UpdateOutputLineConverter { final String path = line.substring(4).trim(); if (StringUtil.isEmptyOrSpaces(path)) return null; final File file = createFile(path); - if (SVNStatusType.STATUS_OBSTRUCTED.equals(contentsStatus)) { + if (StatusType.STATUS_OBSTRUCTED.equals(contentsStatus)) { // obstructed - return new SVNEvent(file, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE, - null, -1, contentsStatus, propertiesStatus, null, null, SVNEventAction.UPDATE_SKIP_OBSTRUCTION, SVNEventAction.UPDATE_ADD, - null, null, null, null, null); + return new ProgressEvent(file, -1, contentsStatus, propertiesStatus, EventAction.UPDATE_SKIP_OBSTRUCTION, null, null); } - SVNEventAction action; - SVNEventAction expectedAction; - if (SVNStatusType.STATUS_ADDED.equals(contentsStatus)) { - expectedAction = SVNEventAction.UPDATE_ADD; - } else if (SVNStatusType.STATUS_DELETED.equals(contentsStatus)) { - expectedAction = SVNEventAction.UPDATE_DELETE; + EventAction action; + EventAction expectedAction; + if (StatusType.STATUS_ADDED.equals(contentsStatus)) { + expectedAction = EventAction.UPDATE_ADD; + } else if (StatusType.STATUS_DELETED.equals(contentsStatus)) { + expectedAction = EventAction.UPDATE_DELETE; } else { - expectedAction = SVNEventAction.UPDATE_UPDATE; + expectedAction = EventAction.UPDATE_UPDATE; } action = expectedAction; if (haveTreeConflict) { - action = SVNEventAction.TREE_CONFLICT; + action = EventAction.TREE_CONFLICT; } - return new SVNEvent(file, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE, null, -1, contentsStatus, propertiesStatus, null, - null, action, expectedAction, null, null, null, null, null); + return new ProgressEvent(file, -1, contentsStatus, propertiesStatus, action, null, null); } private File createFile(String path) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java index c966737f9603..a70a4f28d0fd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/config/SvnConfigureProxiesDialog.java @@ -25,7 +25,6 @@ import com.intellij.openapi.util.Ref; import com.intellij.ui.components.JBTabbedPane; import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.commandLine.SvnBindException; -import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.SVNRevision; import javax.swing.*; @@ -43,7 +42,7 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati super(project, true); valid = true; myProject = project; - + setTitle(SvnBundle.message("dialog.title.edit.http.proxies.settings")); final Ref<SvnServerFileManager> systemManager = new Ref<SvnServerFileManager>(); @@ -56,7 +55,7 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati myUserTab = new SvnConfigureProxiesComponent(userManager.get(), myValidator, this); init(); - + mySystemTab.reset(); myUserTab.reset(); myValidator.run(); @@ -140,9 +139,6 @@ public class SvnConfigureProxiesDialog extends DialogWrapper implements Validati try { SvnVcs.getInstance(myProject).getInfo(SvnUtil.createUrl(url), SVNRevision.HEAD); } - catch (SVNException exc) { - excRef.set(exc); - } catch (SvnBindException e) { excRef.set(e); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java index 39a222dbeaf3..a07425dd1133 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/CmdConflictClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -22,7 +22,7 @@ public class CmdConflictClient extends BaseSvnClient implements ConflictClient { // TODO: Or rewrite logic to have one "Resolve conflicts" action instead of separate actions for each conflict type. @Override public void resolve(@NotNull File path, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) throws VcsException { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictAction.java new file mode 100644 index 000000000000..f4111ce2d981 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictAction.java @@ -0,0 +1,72 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum ConflictAction { + + EDIT("edit", "edited"), + ADD("add", "added"), + DELETE("delete", "deleted"), + REPLACE("replace", "replaced"); + + @NotNull private static final Map<String, ConflictAction> ourAllActions = ContainerUtil.newHashMap(); + + static { + for (ConflictAction action : ConflictAction.values()) { + register(action); + } + } + + @NotNull private final String myKey; + @NotNull private final String[] myOtherKeys; + + ConflictAction(@NotNull String key, @NotNull String... otherKeys) { + myKey = key; + myOtherKeys = otherKeys; + } + + @Override + public String toString() { + return myKey; + } + + private static void register(@NotNull ConflictAction action) { + ourAllActions.put(action.myKey, action); + + for (String otherKey : action.myOtherKeys) { + ourAllActions.put(otherKey, action); + } + } + + @NotNull + public static ConflictAction from(@NotNull String actionName) { + ConflictAction result = ourAllActions.get(actionName); + + if (result == null) { + throw new IllegalArgumentException("Unknown conflict action " + actionName); + } + + return result; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java index 64e50b874d93..7d862067cea2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.conflict; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; import java.io.File; @@ -13,6 +13,6 @@ import java.io.File; */ public interface ConflictClient extends SvnClient { - void resolve(@NotNull File path, @Nullable SVNDepth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) + void resolve(@NotNull File path, @Nullable Depth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictOperation.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictOperation.java new file mode 100644 index 000000000000..d0936a538945 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictOperation.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; + +/** + * @author Konstantin Kolosovsky. + */ +public enum ConflictOperation { + NONE, + UPDATE, + SWITCH, + MERGE; + + @NotNull + public static ConflictOperation from(@NotNull @NonNls String operationName) { + return valueOf(ConflictOperation.class, operationName.toUpperCase()); + } + + @Override + @NonNls + public String toString() { + return super.toString().toLowerCase(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictReason.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictReason.java new file mode 100644 index 000000000000..71eaf6d96b1a --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictReason.java @@ -0,0 +1,89 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum ConflictReason { + + EDITED("edit", "edited"), + OBSTRUCTED("obstruction", "obstruct", "obstructed"), + DELETED("delete", "deleted"), + MISSING("missing", "miss"), + UNVERSIONED("unversioned", "unversion"), + + /** + * @since 1.6 + */ + ADDED("add", "added"), + + /** + * @since 1.7 + */ + REPLACED("replace", "replaced"), + + /** + * @since 1.8 + */ + MOVED_AWAY("moved-away"), + MOVED_HERE("moved-here"); + + @NotNull private static final Map<String, ConflictReason> ourAllReasons = ContainerUtil.newHashMap(); + + static { + for (ConflictReason reason : ConflictReason.values()) { + register(reason); + } + } + + @NotNull private final String myKey; + @NotNull private final String[] myOtherKeys; + + ConflictReason(@NotNull String key, @NotNull String... otherKeys) { + myKey = key; + myOtherKeys = otherKeys; + } + + @Override + public String toString() { + return myKey; + } + + private static void register(@NotNull ConflictReason reason) { + ourAllReasons.put(reason.myKey, reason); + + for (String key : reason.myOtherKeys) { + ourAllReasons.put(key, reason); + } + } + + @NotNull + public static ConflictReason from(@NotNull String reasonName) { + ConflictReason result = ourAllReasons.get(reasonName); + + if (result == null) { + throw new IllegalArgumentException("Unknown conflict reason " + reasonName); + } + + return result; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictVersion.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictVersion.java new file mode 100644 index 000000000000..cee4cf56ac93 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/ConflictVersion.java @@ -0,0 +1,85 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; + +/** + * @author Konstantin Kolosovsky. + */ +public class ConflictVersion extends BaseNodeDescription { + + private final SVNURL myRepositoryRoot; + private final String myPath; + private final long myPegRevision; + + @Nullable + public static ConflictVersion create(@Nullable SVNConflictVersion conflictVersion) { + ConflictVersion result = null; + + if (conflictVersion != null) { + result = new ConflictVersion(conflictVersion.getRepositoryRoot(), conflictVersion.getPath(), conflictVersion.getPegRevision(), + NodeKind.from(conflictVersion.getKind())); + } + + return result; + } + + public ConflictVersion(SVNURL repositoryRoot, String path, long pegRevision, @NotNull NodeKind kind) { + super(kind); + myRepositoryRoot = repositoryRoot; + myPath = path; + myPegRevision = pegRevision; + } + + public SVNURL getRepositoryRoot() { + return myRepositoryRoot; + } + + public String getPath() { + return myPath; + } + + public long getPegRevision() { + return myPegRevision; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + @NotNull + public String toPresentableString() { + StringBuilder urlBuilder = new StringBuilder(); + + urlBuilder.append(myRepositoryRoot != null ? myRepositoryRoot : ""); + urlBuilder.append("/"); + urlBuilder.append(myPath != null ? myPath : "..."); + + return "(" + getKind() + ") " + urlBuilder + "@" + getPegRevision(); + } + + @NotNull + public static String toPresentableString(@Nullable ConflictVersion version) { + return version == null ? "" : version.toPresentableString(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java index b60ea38bd422..80fab5aede64 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/SvnKitConflictClient.java @@ -4,7 +4,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.SVNConflictChoice; @@ -16,13 +16,13 @@ import java.io.File; public class SvnKitConflictClient extends BaseSvnClient implements ConflictClient { @Override public void resolve(@NotNull File path, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean resolveProperty, boolean resolveContent, boolean resolveTree) throws VcsException { try { myVcs.getSvnKitManager().createWCClient() - .doResolve(path, depth, resolveContent, resolveProperty, resolveTree, SVNConflictChoice.MERGED); + .doResolve(path, toDepth(depth), resolveContent, resolveProperty, resolveTree, SVNConflictChoice.MERGED); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/TreeConflictDescription.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/TreeConflictDescription.java new file mode 100644 index 000000000000..541b6ae667bc --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/conflict/TreeConflictDescription.java @@ -0,0 +1,119 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.conflict; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; + +import java.io.File; + +/** + * @author Konstantin Kolosovsky. + */ +public class TreeConflictDescription extends BaseNodeDescription { + + private final File myPath; + private final ConflictAction myConflictAction; + private final ConflictReason myConflictReason; + + private final ConflictOperation myOperation; + private final ConflictVersion mySourceLeftVersion; + private final ConflictVersion mySourceRightVersion; + + @Nullable + public static TreeConflictDescription create(@Nullable SVNTreeConflictDescription conflict) { + TreeConflictDescription result = null; + + if (conflict != null) { + result = + new TreeConflictDescription(conflict.getPath(), NodeKind.from(conflict.getNodeKind()), + ConflictAction.from(conflict.getConflictAction().getName()), + ConflictReason.from(conflict.getConflictReason().getName()), + ConflictOperation.from(conflict.getOperation().getName()), + ConflictVersion.create(conflict.getSourceLeftVersion()), + ConflictVersion.create(conflict.getSourceRightVersion())); + } + + return result; + } + + public TreeConflictDescription(File path, + @NotNull NodeKind nodeKind, + ConflictAction conflictAction, + ConflictReason conflictReason, + ConflictOperation operation, + ConflictVersion sourceLeftVersion, + ConflictVersion sourceRightVersion) { + super(nodeKind); + myPath = path; + myConflictAction = conflictAction; + myConflictReason = conflictReason; + + myOperation = operation; + mySourceLeftVersion = sourceLeftVersion; + mySourceRightVersion = sourceRightVersion; + } + + // TODO: is*Conflict() methods are not really necessary in any logic - remove them + public boolean isTextConflict() { + return false; + } + + public boolean isPropertyConflict() { + return false; + } + + public boolean isTreeConflict() { + return true; + } + + public File getPath() { + return myPath; + } + + public ConflictAction getConflictAction() { + return myConflictAction; + } + + public ConflictReason getConflictReason() { + return myConflictReason; + } + + @NotNull + public NodeKind getNodeKind() { + return myKind; + } + + public ConflictOperation getOperation() { + return myOperation; + } + + public ConflictVersion getSourceLeftVersion() { + return mySourceLeftVersion; + } + + public ConflictVersion getSourceRightVersion() { + return mySourceRightVersion; + } + + @NotNull + public String toPresentableString() { + return "local " + getConflictReason() + ", incoming " + getConflictAction() + " upon " + getOperation(); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java index e73e9fb4013f..6a42a0fcf07e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CmdCopyMoveClient.java @@ -6,12 +6,12 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CmdCheckinClient; import org.jetbrains.idea.svn.checkin.CommitEventHandler; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -78,7 +78,7 @@ public class CmdCopyMoveClient extends BaseSvnClient implements CopyMoveClient { @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, source); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java index dd4395f612b6..b4b9ed961e5f 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/CopyMoveClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.copy; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; import org.jetbrains.idea.svn.checkin.CommitEventHandler; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -41,5 +41,5 @@ public interface CopyMoveClient extends SvnClient { @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java index 1a46e7ce26b4..7f6f64c9ff17 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/copy/SvnKitCopyMoveClient.java @@ -4,11 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CommitEventHandler; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNCopyClient; import org.tmatesoft.svn.core.wc.SVNCopySource; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -50,7 +50,7 @@ public class SvnKitCopyMoveClient extends BaseSvnClient implements CopyMoveClien final SVNCopySource copySource = createCopySource(source, revision); SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); SVNCommitInfo info; try { @@ -69,9 +69,9 @@ public class SvnKitCopyMoveClient extends BaseSvnClient implements CopyMoveClien @NotNull File destination, @Nullable SVNRevision revision, boolean makeParents, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable ProgressTracker handler) throws VcsException { SVNCopyClient client = myVcs.getSvnKitManager().createCopyClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { client.doCopy(new SVNCopySource[]{createCopySource(source, revision)}, destination, false, makeParents, true); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java index dfd6d72cc0f9..9d1d0c082c5b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/CmdDeleteClient.java @@ -5,12 +5,12 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkin.CmdCheckinClient; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -23,7 +23,7 @@ import java.util.List; public class CmdDeleteClient extends BaseSvnClient implements DeleteClient { @Override - public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ISVNEventHandler handler) throws VcsException { + public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ProgressTracker handler) throws VcsException { // TODO: no actual support for dryRun in 'svn delete', SvnKit performs certain validation on file status and svn:externals property // TODO: probably add some widespread checks for dryRun delete - but most likely this should be placed upper - in merge logic if (!dryRun) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java index ec6f01481d44..a60935436bf8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/DeleteClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.delete; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -14,7 +14,7 @@ import java.io.File; */ public interface DeleteClient extends SvnClient { - void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ISVNEventHandler handler) throws VcsException; + void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ProgressTracker handler) throws VcsException; long delete(@NotNull SVNURL url, @NotNull String message) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java index 7e67b1770009..c2cdb42e17dd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/delete/SvnKitDeleteClient.java @@ -4,11 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -19,9 +19,9 @@ import java.io.File; public class SvnKitDeleteClient extends BaseSvnClient implements DeleteClient { @Override - public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ISVNEventHandler handler) throws VcsException { + public void delete(@NotNull File path, boolean force, boolean dryRun, @Nullable ProgressTracker handler) throws VcsException { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { client.doDelete(path, force, dryRun); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java index 463ed6ec01ba..4dfcf57b8049 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/BranchMerger.java @@ -21,13 +21,14 @@ import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.jetbrains.idea.svn.integrate.IMerger; import org.jetbrains.idea.svn.integrate.MergeClient; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -81,12 +82,13 @@ public class BranchMerger implements IMerger { client.merge(SvnTarget.fromURL(mySourceUrl), destination, false, createDiffOptions(), myHandler); } else { client.merge(SvnTarget.fromURL(mySourceUrl, SVNRevision.create(mySourceCopyRevision)), - SvnTarget.fromURL(mySourceUrl, mySourceLatestRevision), destination, SVNDepth.INFINITY, true, false, false, true, + SvnTarget.fromURL(mySourceUrl, mySourceLatestRevision), destination, Depth.INFINITY, true, false, false, true, createDiffOptions(), myHandler); } } - private SVNDiffOptions createDiffOptions() { + @NotNull + private DiffOptions createDiffOptions() { return myVcs.getSvnConfiguration().getMergeOptions(); } @@ -110,7 +112,7 @@ public class BranchMerger implements IMerger { try { result = SvnUtil.getHeadRevision(myVcs, mySourceUrl); } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java index 37dd5a5230f4..9ca5b89d517a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CopiesPanel.java @@ -47,10 +47,10 @@ import org.jetbrains.idea.svn.*; import org.jetbrains.idea.svn.actions.CleanupWorker; import org.jetbrains.idea.svn.actions.SelectBranchPopup; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.jetbrains.idea.svn.integrate.QuickMergeInteractionImpl; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -228,7 +228,7 @@ public class CopiesPanel { if (result == Messages.OK) { // update of view will be triggered by roots changed event SvnCheckoutProvider.checkout(myVcs.getProject(), new File(wcInfo.getPath()), wcInfo.getRootUrl(), SVNRevision.HEAD, - SVNDepth.INFINITY, false, null, wcInfo.getFormat()); + Depth.INFINITY, false, null, wcInfo.getFormat()); } } else if (CHANGE_FORMAT.equals(e.getDescription())) { changeFormat(wcInfo, upgradeFormats); @@ -296,7 +296,7 @@ public class CopiesPanel { sb.append("<tr valign=\"top\"><td>Format:</td><td colspan=\"2\">").append(info.getFormat().getName()).append("</td></tr>"); } - if (!SVNDepth.INFINITY.equals(info.getStickyDepth()) && !info.hasError()) { + if (!Depth.INFINITY.equals(info.getStickyDepth()) && !info.hasError()) { // can fix sb.append("<tr valign=\"top\"><td>Depth:</td><td>").append(info.getStickyDepth().getName()).append("</td><td><a href=\""). append(FIX_DEPTH).append("\">Fix</a></td></tr>"); @@ -312,7 +312,7 @@ public class CopiesPanel { sb.append("<tr valign=\"top\"><td colspan=\"3\"><i>").append("Working copy root</i></td></tr>"); } if (!info.hasError()) { - if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(info.getFormat()) || WorkingCopyFormat.ONE_DOT_EIGHT.equals(info.getFormat())) { + if (info.getFormat().isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN)) { sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"").append(CLEANUP).append("\">Cleanup</a></td></tr>"); } sb.append("<tr valign=\"top\"><td colspan=\"3\"><a href=\"").append(CONFIGURE_BRANCHES).append("\">Configure Branches</a></td></tr>"); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java index 9c5d19420399..a09de54fdbc4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/CreateBranchOrTagDialog.java @@ -37,10 +37,10 @@ import org.jetbrains.idea.svn.SvnBranchConfigurationManager; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.branchConfig.SvnBranchConfigurationNew; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.update.SvnRevisionPanel; import org.tmatesoft.svn.core.internal.util.SVNEncodingUtil; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import javax.swing.*; @@ -264,7 +264,7 @@ public class CreateBranchOrTagDialog extends DialogWrapper { super.init(); SvnVcs vcs = SvnVcs.getInstance(myProject); String revStr = ""; - SVNInfo info = vcs.getInfo(mySrcFile); + Info info = vcs.getInfo(mySrcFile); if (info != null) { mySrcURL = info.getURL() == null ? null : info.getURL().toString(); revStr = String.valueOf(info.getRevision()); @@ -349,7 +349,7 @@ public class CreateBranchOrTagDialog extends DialogWrapper { return true; } else if (myWorkingCopyRadioButton.isSelected()) { - SVNInfo info = SvnVcs.getInstance(myProject).getInfo(mySrcFile); + Info info = SvnVcs.getInstance(myProject).getInfo(mySrcFile); String srcUrl = info != null && info.getURL() != null ? info.getURL().toString() : null; if (srcUrl == null) { myErrorLabel.setText(SvnBundle.message("create.branch.no.working.copy.error", myWorkingCopyField.getText())); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java index 5748aa59280e..b71082390a55 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/LoadRecentBranchRevisions.java @@ -27,12 +27,8 @@ import com.intellij.util.continuation.TaskDescriptor; import com.intellij.util.continuation.Where; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; -import org.jetbrains.idea.svn.history.SvnChangeList; -import org.jetbrains.idea.svn.history.SvnCommittedChangesProvider; -import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.jetbrains.idea.svn.history.TreeStructureNode; +import org.jetbrains.idea.svn.history.*; import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import java.util.ArrayList; @@ -94,12 +90,12 @@ public class LoadRecentBranchRevisions extends TaskDescriptor { ProgressManager.progress2( SvnBundle.message("progress.text2.collecting.history", myMergeContext.getSourceUrl() + (myFirst > 0 ? ("@" + myFirst) : ""))); - final List<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>> list = new ArrayList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>>(); + final List<Pair<SvnChangeList, LogHierarchyNode>> list = new ArrayList<Pair<SvnChangeList, LogHierarchyNode>>(); try { committedChangesProvider.getCommittedChangesWithMergedRevisons(settings, new SvnRepositoryLocation(myMergeContext.getSourceUrl()), myBunchSize + (myFirst > 0 ? 2 : 1), - new PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>>() { - public void consume(SvnChangeList svnList, TreeStructureNode<SVNLogEntry> tree) { + new PairConsumer<SvnChangeList, LogHierarchyNode>() { + public void consume(SvnChangeList svnList, LogHierarchyNode tree) { indicator.setText2(SvnBundle.message("progress.text2.processing.revision", svnList.getNumber())); list.add(Pair.create(svnList, tree)); } @@ -109,7 +105,7 @@ public class LoadRecentBranchRevisions extends TaskDescriptor { return; } myCommittedChangeLists = new ArrayList<CommittedChangeList>(); - for (Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair : list) { + for (Pair<SvnChangeList, LogHierarchyNode> pair : list) { // do not take first since it's equal if (myFirst > 0 && myFirst == pair.getFirst().getNumber()) continue; // TODO: Currently path filtering with QuickMerge.checkListForPaths is not applied as it removes some necessary revisions diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java index 81116e669870..860c524ed591 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java @@ -36,6 +36,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; import org.tmatesoft.svn.core.wc.SVNPropertyData; @@ -166,7 +167,7 @@ public class PropertiesComponent extends JPanel { public void handleProperty(long revision, SVNPropertyData property) throws SVNException { } }; - vcs.getFactory(file).createPropertyClient().list(SvnTarget.fromFile(file, SVNRevision.UNDEFINED), SVNRevision.WORKING, SVNDepth.EMPTY, + vcs.getFactory(file).createPropertyClient().list(SvnTarget.fromFile(file, SVNRevision.UNDEFINED), SVNRevision.WORKING, Depth.EMPTY, handler); } catch (VcsException e) { @@ -272,7 +273,7 @@ public class PropertiesComponent extends JPanel { try { myVcs.getFactory(myFile).createPropertyClient() .setProperty(myFile, property, value != null ? SVNPropertyValue.create(value) : null, - SVNDepth.getInfinityOrEmptyDepth(recursive), force); + Depth.allOrEmpty(recursive), force); } catch (VcsException error) { VcsBalloonProblemNotifier diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java index 78acfe32cf53..0fd1f06bf7cb 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserComponent.java @@ -18,7 +18,6 @@ package org.jetbrains.idea.svn.dialogs; import com.intellij.openapi.Disposable; import com.intellij.openapi.actionSystem.CommonDataKeys; import com.intellij.openapi.actionSystem.DataProvider; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.fileEditor.OpenFileDescriptor; import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.project.Project; @@ -37,11 +36,10 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.browserCache.Expander; import org.jetbrains.idea.svn.history.SvnFileRevision; -import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -152,7 +150,7 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da } @Nullable - public SVNDirEntry getSelectedEntry() { + public DirectoryEntry getSelectedEntry() { TreePath selection = myRepositoryTree.getSelectionPath(); if (selection == null) { return null; @@ -241,8 +239,8 @@ public class RepositoryBrowserComponent extends JPanel implements Disposable, Da final RepositoryTreeNode node = getSelectedNode(); if (node == null) return null; - SVNDirEntry entry = node.getSVNDirEntry(); - if (entry == null || entry.getKind() != SVNNodeKind.FILE) { + DirectoryEntry entry = node.getSVNDirEntry(); + if (entry == null || !entry.isFile()) { return null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java index 5fe19963cf93..191acf387b86 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryBrowserDialog.java @@ -53,6 +53,7 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.actions.BrowseRepositoryAction; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.browser.*; @@ -60,7 +61,9 @@ import org.jetbrains.idea.svn.dialogs.browserCache.Expander; import org.jetbrains.idea.svn.dialogs.browserCache.KeepingExpandedExpander; import org.jetbrains.idea.svn.dialogs.browserCache.SyntheticWorker; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.tmatesoft.svn.core.*; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -345,8 +348,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { if (node == null) { return; } - boolean isDirectory = node.getUserObject() instanceof SVNURL || - (node.getSVNDirEntry() != null && node.getSVNDirEntry().getKind() == SVNNodeKind.DIR); + boolean isDirectory = + node.getUserObject() instanceof SVNURL || (node.getSVNDirEntry() != null && node.getSVNDirEntry().isDirectory()); String url = node.getURL().toDecodedString(); AbstractVcsHelper.getInstance(myProject) @@ -500,14 +503,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { } public void update(AnActionEvent e) { - RepositoryTreeNode node = myBrowserComponent.getSelectedNode(); //e.getPresentation().setText(SvnBundle.message("repository.browser.new.folder.action"), true); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled(entry == null || entry.getKind() == SVNNodeKind.DIR); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, myBrowserComponent.getSelectedNode()); } public void actionPerformed(AnActionEvent e) { @@ -537,14 +534,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { protected class DiffAction extends AnAction { public void update(AnActionEvent e) { - RepositoryTreeNode node = getRepositoryBrowser().getSelectedNode(); e.getPresentation().setText("Compare With...", true); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled(entry == null || entry.getKind() == SVNNodeKind.DIR); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, getRepositoryBrowser().getSelectedNode()); } public void actionPerformed(AnActionEvent e) { @@ -854,14 +845,8 @@ public class RepositoryBrowserDialog extends DialogWrapper { public void update(AnActionEvent e) { e.getPresentation().setVisible(showImportAction()); e.getPresentation().setText(SvnBundle.message("repository.browser.import.action")); - RepositoryTreeNode node = getRepositoryBrowser().getSelectedNode(); - final boolean running = ProjectLevelVcsManager.getInstance(myProject).isBackgroundVcsOperationRunning(); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled((entry == null || entry.getKind() == SVNNodeKind.DIR) && (! running)); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, getRepositoryBrowser().getSelectedNode(), + ProjectLevelVcsManager.getInstance(myProject).isBackgroundVcsOperationRunning()); } public void actionPerformed(AnActionEvent e) { @@ -897,13 +882,7 @@ public class RepositoryBrowserDialog extends DialogWrapper { protected class CheckoutAction extends AnAction { public void update(AnActionEvent e) { e.getPresentation().setText("_Checkout...", true); - RepositoryTreeNode node = getRepositoryBrowser().getSelectedNode(); - if (node != null) { - SVNDirEntry entry = node.getSVNDirEntry(); - e.getPresentation().setEnabled(entry == null || entry.getKind() == SVNNodeKind.DIR); - } else { - e.getPresentation().setEnabled(false); - } + setEnabled(e, getRepositoryBrowser().getSelectedNode()); } public void actionPerformed(AnActionEvent e) { final RepositoryTreeNode selectedNode = getSelectedNode(); @@ -914,6 +893,14 @@ public class RepositoryBrowserDialog extends DialogWrapper { } } + private static void setEnabled(@NotNull AnActionEvent e, @Nullable RepositoryTreeNode node) { + setEnabled(e, node, false); + } + + private static void setEnabled(@NotNull AnActionEvent e, @Nullable RepositoryTreeNode node, boolean isRunning) { + e.getPresentation().setEnabled(node != null && (node.getSVNDirEntry() == null || node.getSVNDirEntry().isDirectory()) && !isRunning); + } + protected class BrowseChangesAction extends AnAction { public BrowseChangesAction() { super(SvnBundle.message("repository.browser.browse.changes.action"), @@ -1051,14 +1038,14 @@ public class RepositoryBrowserDialog extends DialogWrapper { SVNURL url = selectedNode.getURL(); String relativePath = ""; - final SVNDirEntry dirEntry = selectedNode.getSVNDirEntry(); - if (dirEntry != null) { - if (dirEntry.getRepositoryRoot() != null) { - if (! dirEntry.getRepositoryRoot().equals(url)) { - relativePath = SVNPathUtil.getRelativePath(dirEntry.getRepositoryRoot().toString(), url.toDecodedString()); + final DirectoryEntry entry = selectedNode.getSVNDirEntry(); + if (entry != null) { + if (entry.getRepositoryRoot() != null) { + if (! entry.getRepositoryRoot().equals(url)) { + relativePath = SVNPathUtil.getRelativePath(entry.getRepositoryRoot().toString(), url.toDecodedString()); } } else { - relativePath = dirEntry.getRelativePath(); + relativePath = entry.getRelativePath(); } } else { relativePath = url.getPath(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java index d3ef02da19c6..f21ca1735ff4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/RepositoryTreeNode.java @@ -21,11 +21,9 @@ import com.intellij.util.NotNullFunction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.browserCache.Expander; import org.jetbrains.idea.svn.dialogs.browserCache.NodeLoadState; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -89,7 +87,7 @@ public class RepositoryTreeNode implements TreeNode, Disposable { } public boolean isLeaf() { - return myUserObject instanceof SVNDirEntry ? ((SVNDirEntry) myUserObject).getKind() == SVNNodeKind.FILE : false; + return myUserObject instanceof DirectoryEntry && ((DirectoryEntry)myUserObject).isFile(); } public TreeNode getParent() { @@ -146,9 +144,9 @@ public class RepositoryTreeNode implements TreeNode, Disposable { } @Nullable - public SVNDirEntry getSVNDirEntry() { - if (myUserObject instanceof SVNDirEntry) { - return (SVNDirEntry) myUserObject; + public DirectoryEntry getSVNDirEntry() { + if (myUserObject instanceof DirectoryEntry) { + return (DirectoryEntry) myUserObject; } return null; } @@ -161,7 +159,7 @@ public class RepositoryTreeNode implements TreeNode, Disposable { } public boolean isRepositoryRoot() { - return ! (myUserObject instanceof SVNDirEntry); + return ! (myUserObject instanceof DirectoryEntry); } @NotNull @@ -194,13 +192,13 @@ public class RepositoryTreeNode implements TreeNode, Disposable { return myModel.isDisposed(); } - public void setChildren(final List<SVNDirEntry> children, final NodeLoadState state) { + public void setChildren(final List<DirectoryEntry> children, final NodeLoadState state) { final List<TreeNode> nodes = new ArrayList<TreeNode>(); - for (final SVNDirEntry entry : children) { - if (!myModel.isShowFiles() && entry.getKind() != SVNNodeKind.DIR) { + for (final DirectoryEntry entry : children) { + if (!myModel.isShowFiles() && !entry.isDirectory()) { continue; } - nodes.add(new RepositoryTreeNode(myModel, this, entry.getURL(), entry, state)); + nodes.add(new RepositoryTreeNode(myModel, this, entry.getUrl(), entry, state)); } myChildrenLoadState = state; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java index 10bfc0971cc9..a6ca6ad54f11 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SelectLocationDialog.java @@ -28,8 +28,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.dialogs.browser.UrlOpeningExpander; -import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNEncodingUtil; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -79,7 +79,7 @@ public class SelectLocationDialog extends DialogWrapper { boolean showFiles, String errorMessage) { try { - SVNURL svnUrl = SVNURL.parseURIEncoded(url); + SVNURL svnUrl = SvnUtil.createUrl(url); final SVNURL repositoryUrl = initRoot(project, svnUrl); if (repositoryUrl == null) { Messages.showErrorDialog(project, "Can not detect repository root for URL: " + url, @@ -91,7 +91,7 @@ public class SelectLocationDialog extends DialogWrapper { dialog.show(); return dialog; } - catch (SVNException e) { + catch (SvnBindException e) { Messages.showErrorDialog(project, errorMessage != null ? errorMessage : e.getMessage(), SvnBundle.message("dialog.title.select.repository.location")); return null; @@ -124,15 +124,15 @@ public class SelectLocationDialog extends DialogWrapper { } @Nullable - private static SVNURL initRoot(final Project project, final SVNURL url) throws SVNException { + private static SVNURL initRoot(final Project project, final SVNURL url) throws SvnBindException { final Ref<SVNURL> result = new Ref<SVNURL>(); - final Ref<SVNException> excRef = new Ref<SVNException>(); + final Ref<SvnBindException> excRef = new Ref<SvnBindException>(); ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { try { result.set(SvnUtil.getRepositoryRoot(SvnVcs.getInstance(project), url)); - } catch (SVNException e) { + } catch (SvnBindException e) { excRef.set(e); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java index 421f0a0ce138..28375d28b7ba 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java @@ -27,8 +27,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.properties.PropertyClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; @@ -221,7 +221,7 @@ public class SetPropertyDialog extends DialogWrapper { }; PropertyClient client = myVCS.getFactory(file).createPropertyClient(); - client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, SVNDepth.EMPTY, handler); + client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, Depth.EMPTY, handler); } catch (VcsException e) { LOG.info(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java index 8e99055ef94d..bfdadef54cc8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnFormatWorker.java @@ -33,11 +33,11 @@ import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.ClientFactory; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import java.io.File; import java.util.ArrayList; @@ -111,7 +111,7 @@ public class SvnFormatWorker extends Task.Backgroundable { String cleanupMessage = SvnBundle.message("action.Subversion.cleanup.progress.text", path.getAbsolutePath()); String upgradeMessage = SvnBundle.message("action.change.wcopy.format.task.progress.text", path.getAbsolutePath(), wcInfo.getFormat(), myNewFormat); - ISVNEventHandler handler = createUpgradeHandler(indicator, cleanupMessage, upgradeMessage); + ProgressTracker handler = createUpgradeHandler(indicator, cleanupMessage, upgradeMessage); getFactory(path, myNewFormat).createUpgradeClient().upgrade(path, myNewFormat, handler); } catch (Throwable e) { @@ -155,22 +155,22 @@ public class SvnFormatWorker extends Task.Backgroundable { return result; } - private static ISVNEventHandler createUpgradeHandler(@NotNull final ProgressIndicator indicator, + private static ProgressTracker createUpgradeHandler(@NotNull final ProgressIndicator indicator, @NotNull final String cleanupMessage, @NotNull final String upgradeMessage) { - return new ISVNEventHandler() { + return new ProgressTracker() { @Override - public void handleEvent(SVNEvent event, double progress) throws SVNException { + public void consume(ProgressEvent event) throws SVNException { if (event.getFile() != null) { - if (SVNEventAction.UPGRADED_PATH.equals(event.getAction())) { + if (EventAction.UPGRADED_PATH.equals(event.getAction())) { indicator.setText2("Upgraded path " + VcsUtil.getPathForProgressPresentation(event.getFile())); } // fake event indicating cleanup start - if (SVNEventAction.UPDATE_STARTED.equals(event.getAction())) { + if (EventAction.UPDATE_STARTED.equals(event.getAction())) { indicator.setText(cleanupMessage); } // fake event indicating upgrade start - if (SVNEventAction.UPDATE_COMPLETED.equals(event.getAction())) { + if (EventAction.UPDATE_COMPLETED.equals(event.getAction())) { indicator.setText(upgradeMessage); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java index 1215be72c18a..6ecd89f82fd7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SvnRepositoryTreeCellRenderer.java @@ -21,9 +21,8 @@ import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; import com.intellij.util.PlatformIcons; import com.intellij.util.text.DateFormatUtil; -import org.tmatesoft.svn.core.SVNDirEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNNodeKind; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; @@ -44,7 +43,7 @@ public class SvnRepositoryTreeCellRenderer extends ColoredTreeCellRenderer { String name = node.getSVNDirEntry().getName(); append(name, node.isCached() ? SimpleTextAttributes.GRAY_ITALIC_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES); if (myIsShowDetails) { - SVNDirEntry entry = node.getSVNDirEntry(); + DirectoryEntry entry = node.getSVNDirEntry(); append(" " + entry.getRevision(), SimpleTextAttributes.GRAY_ATTRIBUTES); if (entry.getAuthor() != null) { append(" " + entry.getAuthor(), SimpleTextAttributes.GRAYED_BOLD_ATTRIBUTES); @@ -53,11 +52,9 @@ public class SvnRepositoryTreeCellRenderer extends ColoredTreeCellRenderer { append(" " + DateFormatUtil.formatPrettyDateTime(entry.getDate()), SimpleTextAttributes.GRAY_ATTRIBUTES); } } - if (node.getSVNDirEntry().getKind() == SVNNodeKind.FILE) { - setIcon(FileTypeManager.getInstance().getFileTypeByFileName(name).getIcon()); - } else { - setIcon(PlatformIcons.DIRECTORY_CLOSED_ICON); - } + setIcon(node.getSVNDirEntry().isFile() + ? FileTypeManager.getInstance().getFileTypeByFileName(name).getIcon() + : PlatformIcons.DIRECTORY_CLOSED_ICON); } } else if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) value; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java index a75fa4a847db..8fc57db64cdc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/WCInfo.java @@ -20,22 +20,22 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.NestedCopyType; import org.jetbrains.idea.svn.RootUrlInfo; import org.jetbrains.idea.svn.WorkingCopyFormat; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; public class WCInfo implements WCPaths { private final boolean myIsWcRoot; - private final SVNDepth myStickyDepth; + private final Depth myStickyDepth; @NotNull private final RootUrlInfo myRootInfo; - public WCInfo(@NotNull RootUrlInfo rootInfo, boolean isWcRoot, SVNDepth stickyDepth) { + public WCInfo(@NotNull RootUrlInfo rootInfo, boolean isWcRoot, Depth stickyDepth) { myRootInfo = rootInfo; myIsWcRoot = isWcRoot; myStickyDepth = stickyDepth; } - public SVNDepth getStickyDepth() { + public Depth getStickyDepth() { return myStickyDepth; } @@ -70,7 +70,7 @@ public class WCInfo implements WCPaths { public String getErrorMessage() { @SuppressWarnings("ThrowableResultOfMethodCallIgnored") - SVNException error = getRootInfo().getNode().getError(); + SvnBindException error = getRootInfo().getNode().getError(); return error != null ? error.getMessage() : ""; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java index b5c3782d3cdc..e42fdd5d1585 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/CheckoutOptionsDialog.java @@ -30,9 +30,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnBundle; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.revision.SvnSelectRevisionPanel; import org.jetbrains.idea.svn.update.SvnRevisionPanel; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -147,7 +147,7 @@ public class CheckoutOptionsDialog extends DialogWrapper { return (objects == null) || (objects.length != 1) ? null : (File) objects[0]; } - public SVNDepth getDepth() { + public Depth getDepth() { return myDepthCombo.getDepth(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java index 38aff96752bb..7f6de72703f2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ExportOptionsDialog.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnBundle; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNURL; import javax.swing.*; @@ -64,7 +64,7 @@ public class ExportOptionsDialog extends DialogWrapper implements ActionListener return new File(myPathField.getText()); } - public SVNDepth getDepth() { + public Depth getDepth() { return myDepth.getDepth(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java index aba7cf7a09d3..0694247fd542 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/ImportOptionsDialog.java @@ -29,7 +29,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnBundle; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNURL; import javax.swing.*; @@ -68,7 +68,7 @@ public class ImportOptionsDialog extends DialogWrapper implements ActionListener return new File(myPathField.getText()); } - public SVNDepth getDepth() { + public Depth getDepth() { return myDepth.getDepth(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java index 07d2d607de91..d80efb97a123 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/CacheLoader.java @@ -16,9 +16,8 @@ package org.jetbrains.idea.svn.dialogs.browserCache; import com.intellij.openapi.components.ServiceManager; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; import javax.swing.*; import java.util.List; @@ -40,7 +39,7 @@ public class CacheLoader extends Loader { public void run() { final String nodeUrl = node.getURL().toString(); - final List<SVNDirEntry> cached = myCache.getChildren(nodeUrl); + final List<DirectoryEntry> cached = myCache.getChildren(nodeUrl); if (cached != null) { refreshNode(node, cached, expander); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java index 774b07187b98..ab2b6ddb67f3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/Loader.java @@ -15,9 +15,8 @@ */ package org.jetbrains.idea.svn.dialogs.browserCache; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; import java.util.List; @@ -47,7 +46,7 @@ public abstract class Loader { existingNode.setErrorNode(text, getNodeLoadState()); } - protected void refreshNode(final RepositoryTreeNode node, final List<SVNDirEntry> data, final Expander expander) { + protected void refreshNode(final RepositoryTreeNode node, final List<DirectoryEntry> data, final Expander expander) { if (node.isDisposed()) { return; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java index 4c9fc92751e5..319699cfc1b8 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/RepositoryLoader.java @@ -23,7 +23,10 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationProvider; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -56,7 +59,7 @@ class RepositoryLoader extends Loader { } } - private void setResults(final Pair<RepositoryTreeNode, Expander> data, final List<SVNDirEntry> children) { + private void setResults(final Pair<RepositoryTreeNode, Expander> data, final List<DirectoryEntry> children) { myCache.put(data.first.getURL().toString(), children); refreshNode(data.first, children, data.second); } @@ -114,19 +117,21 @@ class RepositoryLoader extends Loader { } public void run() { - final Collection<SVNDirEntry> entries = new TreeSet<SVNDirEntry>(); + final Collection<DirectoryEntry> entries = new TreeSet<DirectoryEntry>(); final RepositoryTreeNode node = myData.first; final SvnVcs vcs = node.getVcs(); SvnAuthenticationProvider.forceInteractive(); - ISVNDirEntryHandler handler = new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - entries.add(dirEntry); + DirectoryEntryConsumer handler = new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + entries.add(entry); } }; try { SvnTarget target = SvnTarget.fromURL(node.getURL()); - vcs.getFactoryFromSettings().createBrowseClient().list(target, SVNRevision.HEAD, SVNDepth.IMMEDIATES, handler); + vcs.getFactoryFromSettings().createBrowseClient().list(target, SVNRevision.HEAD, Depth.IMMEDIATES, handler); } catch (final VcsException e) { SwingUtilities.invokeLater(new Runnable() { @@ -142,7 +147,7 @@ class RepositoryLoader extends Loader { SwingUtilities.invokeLater(new Runnable() { public void run() { - setResults(myData, new ArrayList<SVNDirEntry>(entries)); + setResults(myData, new ArrayList<DirectoryEntry>(entries)); startNext(); } }); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java index b615abbce8ea..d038dc127b90 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SvnRepositoryCache.java @@ -18,15 +18,14 @@ package org.jetbrains.idea.svn.dialogs.browserCache; import com.intellij.openapi.components.ServiceManager; import com.intellij.util.containers.SoftHashMap; import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNDirEntry; -import org.tmatesoft.svn.core.SVNErrorMessage; +import org.jetbrains.idea.svn.browse.DirectoryEntry; import java.util.Iterator; import java.util.List; import java.util.Map; public class SvnRepositoryCache { - private final Map<String, List<SVNDirEntry>> myMap; + private final Map<String, List<DirectoryEntry>> myMap; private final Map<String, String> myErrorsMap; public static SvnRepositoryCache getInstance() { @@ -34,12 +33,12 @@ public class SvnRepositoryCache { } private SvnRepositoryCache() { - myMap = new SoftHashMap<String, List<SVNDirEntry>>(); + myMap = new SoftHashMap<String, List<DirectoryEntry>>(); myErrorsMap = new SoftHashMap<String, String>(); } @Nullable - public List<SVNDirEntry> getChildren(final String parent) { + public List<DirectoryEntry> getChildren(final String parent) { return myMap.get(parent); } @@ -53,7 +52,7 @@ public class SvnRepositoryCache { myErrorsMap.put(parent, error); } - public void put(final String parent, List<SVNDirEntry> children) { + public void put(final String parent, List<DirectoryEntry> children) { myErrorsMap.remove(parent); myMap.put(parent, children); } @@ -64,8 +63,8 @@ public class SvnRepositoryCache { } public void clear(final String repositoryRootUrl) { - for (Iterator<Map.Entry<String, List<SVNDirEntry>>> iterator = myMap.entrySet().iterator(); iterator.hasNext();) { - final Map.Entry<String, List<SVNDirEntry>> entry = iterator.next(); + for (Iterator<Map.Entry<String, List<DirectoryEntry>>> iterator = myMap.entrySet().iterator(); iterator.hasNext();) { + final Map.Entry<String, List<DirectoryEntry>> entry = iterator.next(); if (entry.getKey().startsWith(repositoryRootUrl)) { iterator.remove(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java index 5ee07d8db8fe..5d7c3c3c55c7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browserCache/SyntheticWorker.java @@ -17,12 +17,12 @@ package org.jetbrains.idea.svn.dialogs.browserCache; import com.intellij.util.NotNullFunction; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.jetbrains.idea.svn.dialogs.RepositoryTreeNode; -import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNRevision; import java.util.*; @@ -44,13 +44,13 @@ public class SyntheticWorker { return; } - final List<SVNDirEntry> children = myCache.getChildren(parentUrl); + final List<DirectoryEntry> children = myCache.getChildren(parentUrl); if (children == null) { return; } - for (Iterator<SVNDirEntry> iterator = children.iterator(); iterator.hasNext();) { - final SVNDirEntry entry = iterator.next(); - if (myUrl.equals(entry.getURL())) { + for (Iterator<DirectoryEntry> iterator = children.iterator(); iterator.hasNext(); ) { + final DirectoryEntry entry = iterator.next(); + if (myUrl.equals(entry.getUrl())) { iterator.remove(); } } @@ -60,21 +60,14 @@ public class SyntheticWorker { public void addSyntheticChildToSelf(final SVNURL newUrl, final SVNURL repositoryUrl, final String name, final boolean isDir) { final String currentUrlAsString = myUrl.toString(); - final List<SVNDirEntry> children = myCache.getChildren(currentUrlAsString); + final List<DirectoryEntry> children = myCache.getChildren(currentUrlAsString); if (children == null) { return; } children.add(createSyntheticEntry(newUrl, repositoryUrl, name, isDir)); - Collections.sort(children, new Comparator<SVNDirEntry>() { - public int compare(final SVNDirEntry o1, final SVNDirEntry o2) { - final boolean dirStatus = SVNNodeKind.DIR.equals(o1.getKind()) ^ SVNNodeKind.DIR.equals(o1.getKind()); - if (dirStatus) { - return SVNNodeKind.DIR.equals(o1.getKind()) ? -1 : 1; - } - return o1.toString().compareTo(o2.toString()); - } - }); + // TODO: Seems that just Set instead of List could be used in cache - so no sort() after add() will be required + Collections.sort(children); myCache.put(currentUrlAsString, children); } @@ -91,8 +84,8 @@ public class SyntheticWorker { node.doOnSubtree(new Remover()); } - public static SVNDirEntry createSyntheticEntry(final SVNURL newUrl, final SVNURL repositoryUrl, final String name, final boolean isDir) { - return new SVNDirEntry(newUrl, repositoryUrl, name, isDir ? SVNNodeKind.DIR : SVNNodeKind.FILE, 0, false, SVNRevision.UNDEFINED.getNumber(), null, null); + public static DirectoryEntry createSyntheticEntry(final SVNURL newUrl, final SVNURL repositoryUrl, final String name, final boolean isDir) { + return new DirectoryEntry(newUrl, repositoryUrl, name, NodeKind.from(isDir), CommitInfo.EMPTY, null); } private static class Remover implements NotNullFunction<RepositoryTreeNode, Object> { @@ -116,15 +109,15 @@ public class SyntheticWorker { @NotNull public Object fun(final RepositoryTreeNode repositoryTreeNode) { - final List<SVNDirEntry> children = myCache.getChildren(repositoryTreeNode.getURL().toString()); + final List<DirectoryEntry> children = myCache.getChildren(repositoryTreeNode.getURL().toString()); if (children == null) { return Boolean.FALSE; } - final List<SVNDirEntry> newChildren = new ArrayList<SVNDirEntry>(children.size()); + final List<DirectoryEntry> newChildren = new ArrayList<DirectoryEntry>(children.size()); try { - for (SVNDirEntry child : children) { - newChildren.add(createSyntheticEntry(convertUrl(child.getURL()), child.getRepositoryRoot(), child.getName(), SVNNodeKind.DIR.equals(child.getKind()))); + for (DirectoryEntry child : children) { + newChildren.add(createSyntheticEntry(convertUrl(child.getUrl()), child.getRepositoryRoot(), child.getName(), child.isDirectory())); } myCache.put(convertUrl(repositoryTreeNode.getURL()).toString(), newChildren); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java index 10890d18cd6d..497134727ee4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/CmdDiffClient.java @@ -30,21 +30,18 @@ import org.jetbrains.idea.svn.SvnStatusConvertor; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.NodeKind; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; import org.jetbrains.idea.svn.history.SvnRepositoryContentRevision; import org.jetbrains.idea.svn.status.SvnStatusHandler; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.*; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; @@ -64,7 +61,7 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { assertDirectory(target1); WorkingCopyFormat format = WorkingCopyFormat.from(myFactory.createVersionClient().getVersion()); - if (!format.isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT)) { + if (format.less(WorkingCopyFormat.ONE_DOT_EIGHT)) { throw new SvnBindException("Could not compare local file and remote url with executable for svn " + format); } } @@ -104,8 +101,8 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { DiffInfo diffInfo = CommandUtil.parse(executor.getOutput(), DiffInfo.class); List<Change> result = ContainerUtil.newArrayList(); - if (diffInfo != null && diffInfo.paths != null) { - for (DiffPath path : diffInfo.paths.diffPaths) { + if (diffInfo != null) { + for (DiffPath path : diffInfo.diffPaths) { result.add(createChange(target1, target2, path)); } } @@ -194,20 +191,15 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { @XmlRootElement(name = "diff") public static class DiffInfo { - @XmlElement(name = "paths") - public DiffPaths paths; - } - - public static class DiffPaths { - + @XmlElementWrapper(name = "paths") @XmlElement(name = "path") public List<DiffPath> diffPaths = new ArrayList<DiffPath>(); } public static class DiffPath { - @XmlAttribute(name = "kind") - public String kind; + @XmlAttribute(name = "kind", required = true) + public NodeKind kind; @XmlAttribute(name = "props") public String propertiesStatus; @@ -219,7 +211,7 @@ public class CmdDiffClient extends BaseSvnClient implements DiffClient { public String path; public boolean isDirectory() { - return SVNNodeKind.DIR.equals(SVNNodeKind.parseKind(kind)); + return kind.isDirectory(); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DiffOptions.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DiffOptions.java new file mode 100644 index 000000000000..1e44a8389505 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DiffOptions.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.diff; + +/** + * @author Konstantin Kolosovsky. + */ +public class DiffOptions { + + private final boolean myIgnoreAllWhitespace; + private final boolean myIgnoreAmountOfWhitespace; + private final boolean myIgnoreEOLStyle; + + public DiffOptions(boolean ignoreAllWhitespace, boolean ignoreAmountOfWhiteSpace, boolean ignoreEOLStyle) { + myIgnoreAllWhitespace = ignoreAllWhitespace; + myIgnoreAmountOfWhitespace = ignoreAmountOfWhiteSpace; + myIgnoreEOLStyle = ignoreEOLStyle; + } + + public boolean isIgnoreAllWhitespace() { + return myIgnoreAllWhitespace; + } + + public boolean isIgnoreAmountOfWhitespace() { + return myIgnoreAmountOfWhitespace; + } + + public boolean isIgnoreEOLStyle() { + return myIgnoreEOLStyle; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java index 4d3a09a39e26..0f0e6a714037 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/DirectoryWithBranchComparer.java @@ -65,7 +65,7 @@ public class DirectoryWithBranchComparer extends ElementWithBranchComparer { // svn 1.7 command line "--summarize" option for "diff" command does not support comparing working copy directories with repository // directories - that is why command line is only used explicitly for svn 1.8 - return WorkingCopyFormat.ONE_DOT_EIGHT.equals(format) ? myVcs.getCommandLineFactory() : myVcs.getSvnKitFactory(); + return format.isOrGreater(WorkingCopyFormat.ONE_DOT_EIGHT) ? myVcs.getCommandLineFactory() : myVcs.getSvnKitFactory(); } @Override diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java index 850fb1b2a295..0a1b14837b7e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/diff/SvnKitDiffClient.java @@ -19,10 +19,11 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.idea.svn.SvnProgressCanceller; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.svnkit.SvnKitProgressCanceller; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.wc.SVNCancellableEditor; import org.tmatesoft.svn.core.internal.wc.SVNErrorManager; @@ -38,7 +39,6 @@ import org.tmatesoft.svn.core.io.ISVNReporterBaton; import org.tmatesoft.svn.core.io.SVNRepository; import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import org.tmatesoft.svn.util.SVNDebugLog; @@ -114,7 +114,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { private Collection<Change> runUrlDiff() throws SVNException { SVNRepository sourceRepository = myVcs.getSvnKitManager().createRepository(myTarget1.getURL()); - sourceRepository.setCanceller(new SvnProgressCanceller()); + sourceRepository.setCanceller(new SvnKitProgressCanceller()); SvnDiffEditor diffEditor; final long rev; SVNRepository targetRepository = null; @@ -123,7 +123,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { // generate Map of path->Change targetRepository = myVcs.getSvnKitManager().createRepository(myTarget2.getURL()); diffEditor = new SvnDiffEditor(sourceRepository, targetRepository, -1, false); - final ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null); + final ISVNEditor cancellableEditor = SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null); sourceRepository.diff(myTarget2.getURL(), rev, rev, null, true, true, false, new ISVNReporterBaton() { public void report(ISVNReporter reporter) throws SVNException { reporter.setPath("", null, rev, false); @@ -142,7 +142,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { } private Collection<Change> run17Diff() throws SVNException { - final SVNInfo info1 = myVcs.getInfo(myTarget1.getFile(), SVNRevision.HEAD); + final Info info1 = myVcs.getInfo(myTarget1.getFile(), SVNRevision.HEAD); if (info1 == null) { SVNErrorMessage err = @@ -172,7 +172,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { repository2 = myVcs.getSvnKitManager().createRepository(myTarget2.getURL()); SvnDiffEditor diffEditor = new SvnDiffEditor(myTarget1.getFile(), repository2, rev, true); repository.diff(myTarget2.getURL(), rev, rev, null, true, SVNDepth.INFINITY, false, reporter17, - SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null)); + SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null)); return diffEditor.getChangesMap().values(); } @@ -219,7 +219,7 @@ public class SvnKitDiffClient extends BaseSvnClient implements DiffClient { SvnDiffEditor diffEditor = new SvnDiffEditor(target == null ? myTarget1.getFile() : myTarget1.getFile().getParentFile(), repository2, rev, true); repository.diff(myTarget2.getURL(), rev, rev, target, true, true, false, reporter, - SVNCancellableEditor.newInstance(diffEditor, new SvnProgressCanceller(), null)); + SVNCancellableEditor.newInstance(diffEditor, new SvnKitProgressCanceller(), null)); return diffEditor.getChangesMap().values(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java index 3494b9ac9d28..ca934d4a40e4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/CmdHistoryClient.java @@ -9,19 +9,15 @@ import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.*; +import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.xml.bind.JAXBException; -import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlValue; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.Map; /** * @author Konstantin Kolosovsky. @@ -37,7 +33,7 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, - @Nullable ISVNLogEntryHandler handler) throws VcsException { + @Nullable LogEntryConsumer handler) throws VcsException { // TODO: add revision properties parameter if necessary List<String> parameters = @@ -54,13 +50,13 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { } } - private static void parseOutput(@NotNull CommandExecutor command, @Nullable ISVNLogEntryHandler handler) + private static void parseOutput(@NotNull CommandExecutor command, @Nullable LogEntryConsumer handler) throws VcsException, SVNException { try { LogInfo log = CommandUtil.parse(command.getOutput(), LogInfo.class); if (handler != null && log != null) { - for (LogEntry entry : log.entries) { + for (LogEntry.Builder entry : log.entries) { iterateRecursively(entry, handler); } } @@ -70,16 +66,16 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { } } - private static void iterateRecursively(@NotNull LogEntry entry, @NotNull ISVNLogEntryHandler handler) throws SVNException { - handler.handleLogEntry(entry.toLogEntry()); + private static void iterateRecursively(@NotNull LogEntry.Builder entry, @NotNull LogEntryConsumer handler) throws SVNException { + handler.consume(entry.build()); - for (LogEntry childEntry : entry.childEntries) { + for (LogEntry.Builder childEntry : entry.getChildEntries()) { iterateRecursively(childEntry, handler); } if (entry.hasChildren()) { // empty log entry passed to handler to fully correspond to SVNKit behavior. - handler.handleLogEntry(SVNLogEntry.EMPTY_ENTRY); + handler.consume(LogEntry.EMPTY); } } @@ -109,81 +105,6 @@ public class CmdHistoryClient extends BaseSvnClient implements HistoryClient { public static class LogInfo { @XmlElement(name = "logentry") - public List<LogEntry> entries = new ArrayList<LogEntry>(); - } - - public static class LogEntry { - - @XmlAttribute(name = "revision") - public long revision; - - @XmlElement(name = "author") - public String author; - - @XmlElement(name = "date") - public Date date; - - @XmlElement(name = "msg") - public String message; - - @XmlElement(name = "paths") - public ChangedPaths changedPaths; - - @XmlElement(name = "logentry") - public List<LogEntry> childEntries = new ArrayList<LogEntry>(); - - public boolean hasChildren() { - return !childEntries.isEmpty(); - } - - public SVNLogEntry toLogEntry() { - SVNLogEntry entry = new SVNLogEntry(toChangedPathsMap(), revision, author, date, message); - - entry.setHasChildren(hasChildren()); - - return entry; - } - - public Map<String, SVNLogEntryPath> toChangedPathsMap() { - return changedPaths != null ? changedPaths.toMap() : ContainerUtil.<String, SVNLogEntryPath>newHashMap(); - } - } - - public static class ChangedPaths { - - @XmlElement(name = "path") - public List<ChangedPath> changedPaths = new ArrayList<ChangedPath>(); - - public Map<String, SVNLogEntryPath> toMap() { - Map<String, SVNLogEntryPath> changes = ContainerUtil.newHashMap(); - - for (ChangedPath path : changedPaths) { - changes.put(path.path, path.toLogEntryPath()); - } - - return changes; - } - } - - public static class ChangedPath { - - @XmlAttribute(name = "kind") - public String kind; - - @XmlAttribute(name = "action") - public String action; - - @XmlAttribute(name = "copyfrom-path") - public String copyFromPath; - - @XmlAttribute(name = "copyfrom-rev") - public long copyFromRevision; - - @XmlValue - public String path; - - public SVNLogEntryPath toLogEntryPath() { - return new SVNLogEntryPath(path, CommandUtil.getStatusChar(action), copyFromPath, copyFromRevision); - } + public List<LogEntry.Builder> entries = ContainerUtil.newArrayList(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java index f871ee09855a..a075251e7675 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/FirstInBranch.java @@ -125,7 +125,7 @@ public class FirstInBranch implements Runnable { } } - private static class MyLogEntryHandler implements ISVNLogEntryHandler { + private static class MyLogEntryHandler implements LogEntryConsumer { @NotNull private final SvnPathThroughHistoryCorrection myTrunkCorrector; @NotNull private final SvnPathThroughHistoryCorrection myBranchCorrector; @@ -137,17 +137,18 @@ public class FirstInBranch implements Runnable { myBranchCorrector = new SvnPathThroughHistoryCorrection(branchUrl); } - public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + @Override + public void consume(LogEntry logEntry) throws SVNException { final Map map = logEntry.getChangedPaths(); checkEntries(logEntry, map); - myTrunkCorrector.handleLogEntry(logEntry); - myBranchCorrector.handleLogEntry(logEntry); + myTrunkCorrector.consume(logEntry); + myBranchCorrector.consume(logEntry); checkEntries(logEntry, map); } - private void checkEntries(SVNLogEntry logEntry, Map map) throws SVNCancelException { + private void checkEntries(LogEntry logEntry, Map map) throws SVNCancelException { for (Object o : map.values()) { - final SVNLogEntryPath path = (SVNLogEntryPath) o; + final LogEntryPath path = (LogEntryPath) o; final String localPath = path.getPath(); final String copyPath = path.getCopyPath(); @@ -159,7 +160,7 @@ public class FirstInBranch implements Runnable { } } - private boolean checkForCopyCase(SVNLogEntry logEntry, SVNLogEntryPath path, String localPath, String copyPath, + private boolean checkForCopyCase(LogEntry logEntry, LogEntryPath path, String localPath, String copyPath, final String trunkUrl, final String branchUrl) { if (equalOrParent(localPath, branchUrl) && equalOrParent(copyPath, trunkUrl)) { myCopyDataConsumer.consume(new CopyData(path.getCopyRevision(), logEntry.getRevision(), true)); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java index d719e755e661..c85eb9e65968 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/HistoryClient.java @@ -4,7 +4,6 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -21,5 +20,5 @@ public interface HistoryClient extends SvnClient { boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, - @Nullable ISVNLogEntryHandler handler) throws VcsException; + @Nullable LogEntryConsumer handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java index dc1def418e99..030db0db6ef3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LatestExistentSearcher.java @@ -25,9 +25,10 @@ import org.jetbrains.idea.svn.RootUrlInfo; import org.jetbrains.idea.svn.SvnFileUrlMapping; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNURLUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -84,9 +85,6 @@ public class LatestExistentSearcher { myVcs.getFactory(target).createHistoryClient().doLog(target, startRevision, SVNRevision.HEAD, false, true, false, 0, null, createHandler(latest)); } - catch (SVNException e) { - LOG.info(e); - } catch (VcsException e) { LOG.info(e); } @@ -95,12 +93,13 @@ public class LatestExistentSearcher { } @NotNull - private ISVNLogEntryHandler createHandler(@NotNull final Ref<Long> latest) { - return new ISVNLogEntryHandler() { - public void handleLogEntry(final SVNLogEntry logEntry) throws SVNException { + private LogEntryConsumer createHandler(@NotNull final Ref<Long> latest) { + return new LogEntryConsumer() { + @Override + public void consume(final LogEntry logEntry) throws SVNException { final Map changedPaths = logEntry.getChangedPaths(); for (Object o : changedPaths.values()) { - final SVNLogEntryPath path = (SVNLogEntryPath)o; + final LogEntryPath path = (LogEntryPath)o; if ((path.getType() == 'D') && (myRelativeUrl.equals(path.getPath()))) { latest.set(logEntry.getRevision()); throw new SVNException(SVNErrorMessage.UNKNOWN_ERROR_MESSAGE); @@ -125,7 +124,7 @@ public class LatestExistentSearcher { } } } - catch (SVNException e) { + catch (SvnBindException e) { LOG.info(e); } @@ -138,7 +137,7 @@ public class LatestExistentSearcher { final RootUrlInfo rootUrlInfo = mapping.getWcRootForUrl(myUrl.toString()); if (rootUrlInfo == null) return true; final VirtualFile vf = rootUrlInfo.getVirtualFile(); - final SVNInfo info = myVcs.getInfo(vf); + final Info info = myVcs.getInfo(vf); if ((info == null) || (info.getRevision() == null)) { return false; } @@ -149,24 +148,24 @@ public class LatestExistentSearcher { } @Nullable - private SVNURL getExistingParent(SVNURL url) throws SVNException { + private SVNURL getExistingParent(SVNURL url) throws SvnBindException { while (url != null && !url.equals(myRepositoryUrl) && !existsInRevision(url, myEndNumber)) { - url = url.removePathTail(); + url = SvnUtil.removePathTail(url); } return url; } - private boolean existsInRevision(@NotNull SVNURL url, long revisionNumber) throws SVNException { + private boolean existsInRevision(@NotNull SVNURL url, long revisionNumber) throws SvnBindException { SVNRevision revision = SVNRevision.create(revisionNumber); - SVNInfo info = null; + Info info = null; try { info = myVcs.getInfo(url, revision, revision); } - catch (SVNException e) { + catch (SvnBindException e) { // throw error if not "does not exist" error code - if (!SVNErrorCode.RA_ILLEGAL_URL.equals(e.getErrorMessage().getErrorCode())) { + if (!e.contains(SVNErrorCode.RA_ILLEGAL_URL)) { throw e; } } @@ -174,7 +173,7 @@ public class LatestExistentSearcher { return info != null; } - private long getLatestRevision() throws SVNException { + private long getLatestRevision() throws SvnBindException { return SvnUtil.getHeadRevision(myVcs, myRepositoryUrl).getNumber(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java new file mode 100644 index 000000000000..1b3d12656d2b --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntry.java @@ -0,0 +1,187 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.history; + +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNLogEntry; +import org.tmatesoft.svn.core.SVNLogEntryPath; + +import javax.xml.bind.annotation.*; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public class LogEntry { + + public static final LogEntry EMPTY = new LogEntry.Builder().setRevision(-1).setHasChildren(false).build(); + + private final long myRevision; + private final Date myDate; + private final String myMessage; + private final String myAuthor; + @NotNull private final Map<String, LogEntryPath> myChangedPaths; + private boolean myHasChildren; + + @Nullable + public static LogEntry create(@Nullable SVNLogEntry entry) { + LogEntry result = null; + + if (entry != null) { + LogEntry.Builder builder = new LogEntry.Builder(); + + if (entry.getChangedPaths() != null) { + for (SVNLogEntryPath path : entry.getChangedPaths().values()) { + builder.addPath(LogEntryPath.create(path)); + } + } + + result = builder.setRevision(entry.getRevision()).setAuthor(entry.getAuthor()).setDate(entry.getDate()).setMessage(entry.getMessage()) + .setHasChildren(entry.hasChildren()).build(); + } + + return result; + } + + public LogEntry(@NotNull LogEntry.Builder builder) { + myRevision = builder.revision; + myChangedPaths = toImmutable(builder.changedPaths); + myAuthor = builder.author; + myDate = builder.date; + myMessage = builder.message; + myHasChildren = builder.hasChildren(); + } + + @NotNull + private static Map<String, LogEntryPath> toImmutable(@NotNull List<LogEntryPath.Builder> paths) { + ContainerUtil.ImmutableMapBuilder<String, LogEntryPath> builder = ContainerUtil.immutableMapBuilder(); + + for (LogEntryPath.Builder path : paths) { + builder.put(path.getPath(), path.build()); + } + + return builder.build(); + } + + @NotNull + public Map<String, LogEntryPath> getChangedPaths() { + return myChangedPaths; + } + + public String getAuthor() { + return myAuthor; + } + + public Date getDate() { + return myDate; + } + + public String getMessage() { + return myMessage; + } + + public long getRevision() { + return myRevision; + } + + public boolean hasChildren() { + return myHasChildren; + } + + @XmlAccessorType(XmlAccessType.NONE) + // type explicitly specified not to conflict with LogEntryPath.Builder + @XmlType(name = "logentry") + public static class Builder { + + @XmlAttribute(name = "revision") + private long revision; + + @XmlElement(name = "author") + private String author; + + @XmlElement(name = "date") + private Date date; + + @XmlElement(name = "msg") + private String message; + + @XmlElementWrapper(name = "paths") + @XmlElement(name = "path") + private List<LogEntryPath.Builder> changedPaths = ContainerUtil.newArrayList(); + + @XmlElement(name = "logentry") + private List<LogEntry.Builder> childEntries = ContainerUtil.newArrayList(); + + @NotNull + public List<LogEntry.Builder> getChildEntries() { + return childEntries; + } + + public boolean hasChildren() { + return !childEntries.isEmpty(); + } + + @NotNull + public Builder setRevision(long revision) { + this.revision = revision; + return this; + } + + @NotNull + public Builder setAuthor(String author) { + this.author = author; + return this; + } + + @NotNull + public Builder setDate(Date date) { + this.date = date; + return this; + } + + @NotNull + public Builder setMessage(String message) { + this.message = message; + return this; + } + + @NotNull + public Builder setHasChildren(boolean hasChildren) { + // probably LogEntry interface will be changed and child entries will be specified explicitly later, but for now just use such "fake" + // implementation for setting "hasChildren" value + childEntries.clear(); + if (hasChildren) { + childEntries.add(this); + } + return this; + } + + @NotNull + public Builder addPath(@NotNull LogEntryPath.Builder path) { + changedPaths.add(path); + return this; + } + + @NotNull + public LogEntry build() { + return new LogEntry(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryConsumer.java new file mode 100644 index 000000000000..b3269b1afb41 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryConsumer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.history; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface LogEntryConsumer extends ThrowableConsumer<LogEntry, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryPath.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryPath.java new file mode 100644 index 000000000000..41215f71f76e --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogEntryPath.java @@ -0,0 +1,132 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.history; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.commandLine.CommandUtil; +import org.tmatesoft.svn.core.SVNLogEntryPath; + +import javax.xml.bind.annotation.*; + +/** + * @author Konstantin Kolosovsky. + */ +public class LogEntryPath extends BaseNodeDescription { + + private final String myPath; + private final char myType; + private final String myCopyPath; + private final long myCopyRevision; + + @NotNull + public static LogEntryPath.Builder create(@NotNull SVNLogEntryPath path) { + return new LogEntryPath.Builder().setPath(path.getPath()).setType(path.getType()).setCopyFromPath( + path.getCopyPath()).setCopyFromRevision(path.getCopyRevision()).setKind(NodeKind.from(path.getKind())); + } + + public LogEntryPath(@NotNull LogEntryPath.Builder builder) { + super(builder.kind); + myPath = builder.path; + myType = CommandUtil.getStatusChar(builder.action); + myCopyPath = builder.copyFromPath; + myCopyRevision = builder.copyFromRevision; + } + + public String getCopyPath() { + return myCopyPath; + } + + public long getCopyRevision() { + return myCopyRevision; + } + + public String getPath() { + return myPath; + } + + public char getType() { + return myType; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + @XmlAccessorType(XmlAccessType.NONE) + // type explicitly specified not to conflict with LogEntry.Builder + @XmlType(name = "logentrypath") + public static class Builder { + + // empty string could be here if repository was < 1.6 when committing (see comments in schema for svn client xml output , in + // svn source code repository) - this will result in kind = NodeKind.UNKNOWN + @XmlAttribute(name = "kind", required = true) + private NodeKind kind; + + @XmlAttribute(name = "action") + private String action; + + @XmlAttribute(name = "copyfrom-path") + private String copyFromPath; + + @XmlAttribute(name = "copyfrom-rev") + private long copyFromRevision; + + @XmlValue + private String path; + + public String getPath() { + return path; + } + + @NotNull + public Builder setKind(@NotNull NodeKind kind) { + this.kind = kind; + return this; + } + + @NotNull + public Builder setType(char type) { + this.action = String.valueOf(type); + return this; + } + + @NotNull + public Builder setCopyFromPath(String copyFromPath) { + this.copyFromPath = copyFromPath; + return this; + } + + @NotNull + public Builder setCopyFromRevision(long copyFromRevision) { + this.copyFromRevision = copyFromRevision; + return this; + } + + @NotNull + public Builder setPath(String path) { + this.path = path; + return this; + } + + @NotNull + public LogEntryPath build() { + return new LogEntryPath(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/TreeStructureNode.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogHierarchyNode.java index 370f54f9ef22..d9ce35a100e4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/TreeStructureNode.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/LogHierarchyNode.java @@ -18,24 +18,24 @@ package org.jetbrains.idea.svn.history; import java.util.LinkedList; import java.util.List; -public class TreeStructureNode<T> { - private final T myMe; - private final List<TreeStructureNode<T>> myChildren; +public class LogHierarchyNode { + private final LogEntry myMe; + private final List<LogHierarchyNode> myChildren; - public TreeStructureNode(final T me) { - myChildren = new LinkedList<TreeStructureNode<T>>(); + public LogHierarchyNode(final LogEntry me) { + myChildren = new LinkedList<LogHierarchyNode>(); myMe = me; } - public void add(final T child) { - myChildren.add(new TreeStructureNode<T>(child)); + public void add(final LogEntry child) { + myChildren.add(new LogHierarchyNode(child)); } - public List<TreeStructureNode<T>> getChildren() { + public List<LogHierarchyNode> getChildren() { return myChildren; } - public T getMe() { + public LogEntry getMe() { return myMe; } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java index f0a77198925d..87896a739bca 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/MergeSourceHierarchyBuilder.java @@ -20,24 +20,23 @@ import com.intellij.util.Consumer; import com.intellij.util.ThrowableConsumer; import org.jetbrains.annotations.NotNull; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; import java.util.List; /** * @author Konstantin Kolosovsky. */ -public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException> { +public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<LogEntry, Integer>, SVNException> { - private TreeStructureNode<SVNLogEntry> myCurrentHierarchy; - @NotNull private final Consumer<TreeStructureNode<SVNLogEntry>> myConsumer; + private LogHierarchyNode myCurrentHierarchy; + @NotNull private final Consumer<LogHierarchyNode> myConsumer; - public MergeSourceHierarchyBuilder(@NotNull Consumer<TreeStructureNode<SVNLogEntry>> consumer) { + public MergeSourceHierarchyBuilder(@NotNull Consumer<LogHierarchyNode> consumer) { myConsumer = consumer; } - public void consume(Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { - final SVNLogEntry logEntry = svnLogEntryIntegerPair.getFirst(); + public void consume(Pair<LogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { + final LogEntry logEntry = svnLogEntryIntegerPair.getFirst(); final Integer mergeLevel = svnLogEntryIntegerPair.getSecond(); if (mergeLevel < 0) { @@ -45,11 +44,11 @@ public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<SVNLo myConsumer.consume(myCurrentHierarchy); } if (logEntry.hasChildren()) { - myCurrentHierarchy = new TreeStructureNode<SVNLogEntry>(logEntry); + myCurrentHierarchy = new LogHierarchyNode(logEntry); } else { // just pass myCurrentHierarchy = null; - myConsumer.consume(new TreeStructureNode<SVNLogEntry>(logEntry)); + myConsumer.consume(new LogHierarchyNode(logEntry)); } } else { addToLevel(myCurrentHierarchy, logEntry, mergeLevel); @@ -62,12 +61,12 @@ public class MergeSourceHierarchyBuilder implements ThrowableConsumer<Pair<SVNLo } } - private static void addToLevel(final TreeStructureNode<SVNLogEntry> tree, final SVNLogEntry entry, final int left) { + private static void addToLevel(final LogHierarchyNode tree, final LogEntry entry, final int left) { assert tree != null; if (left == 0) { tree.add(entry); } else { - final List<TreeStructureNode<SVNLogEntry>> children = tree.getChildren(); + final List<LogHierarchyNode> children = tree.getChildren(); assert ! children.isEmpty(); addToLevel(children.get(children.size() - 1), entry, left - 1); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java index 6ac6adc3b5cd..d9b37e003961 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SingleCommittedListProvider.java @@ -125,8 +125,9 @@ public class SingleCommittedListProvider { SvnTarget target = SvnTarget.fromURL(url); myVcs.getFactory(target).createHistoryClient().doLog(target, SVNRevision.HEAD, revisionBefore, false, true, false, 0, null, - new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { checkDisposed(); // date could be null for lists where there are paths that user has no rights to observe if (logEntry.getDate() != null) { @@ -144,7 +145,7 @@ public class SingleCommittedListProvider { } @NotNull - private SvnChangeList createChangeList(@NotNull SVNLogEntry logEntry) { + private SvnChangeList createChangeList(@NotNull LogEntry logEntry) { return new SvnChangeList(myVcs, svnRootLocation, logEntry, repositoryUrl.toDecodedString()); } @@ -155,8 +156,9 @@ public class SingleCommittedListProvider { } private boolean searchForUrl(@NotNull SVNURL url) throws VcsException { - ISVNLogEntryHandler handler = new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + LogEntryConsumer handler = new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { checkDisposed(); // date could be null for lists where there are paths that user has no rights to observe if (logEntry.getDate() != null) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java index f894bb3f423e..01f9a213907c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnChangeList.java @@ -40,10 +40,13 @@ import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.browse.DirectoryEntry; +import org.jetbrains.idea.svn.browse.DirectoryEntryConsumer; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -102,7 +105,7 @@ public class SvnChangeList implements CommittedChangeList { myKnownAsDirectories = new HashSet<String>(0); } - public SvnChangeList(SvnVcs vcs, @NotNull final SvnRepositoryLocation location, final SVNLogEntry logEntry, String repositoryRoot) { + public SvnChangeList(SvnVcs vcs, @NotNull final SvnRepositoryLocation location, final LogEntry logEntry, String repositoryRoot) { myVcs = vcs; myLocation = location; myRevision = logEntry.getRevision(); @@ -114,10 +117,10 @@ public class SvnChangeList implements CommittedChangeList { myCommonPathSearcher = new CommonPathSearcher(); myKnownAsDirectories = new HashSet<String>(0); - for(SVNLogEntryPath entry : logEntry.getChangedPaths().values()) { + for(LogEntryPath entry : logEntry.getChangedPaths().values()) { final String path = entry.getPath(); - if (SVNNodeKind.DIR.equals(entry.getKind())) { + if (entry.isDirectory()) { myKnownAsDirectories.add(path); } @@ -394,8 +397,8 @@ public class SvnChangeList implements CommittedChangeList { // TODO: Logic with detecting "isDirectory" status is not clear enough. Why we can't just collect this info from logEntry and // TODO: if loading from disk - use cached values? Not to invoke separate call here. SVNRevision beforeRevision = SVNRevision.create(getRevision(idxData.second.booleanValue())); - SVNInfo info = myVcs.getInfo(SvnUtil.createUrl(revision.getFullPath()), beforeRevision, beforeRevision); - boolean isDirectory = info != null && SVNNodeKind.DIR.equals(info.getKind()); + Info info = myVcs.getInfo(SvnUtil.createUrl(revision.getFullPath()), beforeRevision, beforeRevision); + boolean isDirectory = info != null && info.isDirectory(); Change replacingChange = new Change(createRevision((SvnRepositoryContentRevision)sourceChange.getBeforeRevision(), isDirectory), createRevision((SvnRepositoryContentRevision)sourceChange.getAfterRevision(), isDirectory)); replacingChange.setIsReplaced(sourceChange.isIsReplaced()); @@ -478,12 +481,14 @@ public class SvnChangeList implements CommittedChangeList { SVNRevision revisionNumber = SVNRevision.create(getRevision(isBefore)); SvnTarget target = SvnTarget.fromURL(fullPath, revisionNumber); - myVcs.getFactory(target).createBrowseClient().list(target, revisionNumber, SVNDepth.INFINITY, new ISVNDirEntryHandler() { - public void handleDirEntry(final SVNDirEntry dirEntry) throws SVNException { - final String childPath = path + '/' + dirEntry.getRelativePath(); + myVcs.getFactory(target).createBrowseClient().list(target, revisionNumber, Depth.INFINITY, new DirectoryEntryConsumer() { + + @Override + public void consume(final DirectoryEntry entry) throws SVNException { + final String childPath = path + '/' + entry.getRelativePath(); if (!duplicates.contains(Pair.create(isBefore, childPath))) { - final ContentRevision contentRevision = createRevision(childPath, isBefore, SVNNodeKind.DIR.equals(dirEntry.getKind())); + final ContentRevision contentRevision = createRevision(childPath, isBefore, entry.isDirectory()); result.add(new Change(isBefore ? contentRevision : null, isBefore ? null : contentRevision)); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java index 556ef1e9ebbe..83642894711e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCommittedChangesProvider.java @@ -49,12 +49,13 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.actions.ConfigureBranchesAction; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.DataInput; @@ -139,8 +140,8 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi final String repositoryRoot = getRepositoryRoot(svnLocation); final ChangeBrowserSettings.Filter filter = settings.createFilter(); - getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<SVNLogEntry>() { - public void consume(final SVNLogEntry svnLogEntry) { + getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<LogEntry>() { + public void consume(final LogEntry svnLogEntry) { final SvnChangeList cl = new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot); if (filter.accepts(cl)) { consumer.consume(cl); @@ -158,8 +159,8 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi final ArrayList<SvnChangeList> result = new ArrayList<SvnChangeList>(); final String repositoryRoot = getRepositoryRoot(svnLocation); - getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<SVNLogEntry>() { - public void consume(final SVNLogEntry svnLogEntry) { + getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<LogEntry>() { + public void consume(final LogEntry svnLogEntry) { result.add(new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot)); } }, false, true); @@ -169,24 +170,24 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi public void getCommittedChangesWithMergedRevisons(final ChangeBrowserSettings settings, final RepositoryLocation location, final int maxCount, - final PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>> finalConsumer) + final PairConsumer<SvnChangeList, LogHierarchyNode> finalConsumer) throws VcsException { final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location; final String repositoryRoot = getRepositoryRoot(svnLocation); - final MergeSourceHierarchyBuilder builder = new MergeSourceHierarchyBuilder(new Consumer<TreeStructureNode<SVNLogEntry>>() { - public void consume(TreeStructureNode<SVNLogEntry> node) { + final MergeSourceHierarchyBuilder builder = new MergeSourceHierarchyBuilder(new Consumer<LogHierarchyNode>() { + public void consume(LogHierarchyNode node) { finalConsumer.consume(new SvnChangeList(myVcs, svnLocation, node.getMe(), repositoryRoot), node); } }); - final SvnMergeSourceTracker mergeSourceTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException>() { - public void consume(Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { + final SvnMergeSourceTracker mergeSourceTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<LogEntry, Integer>, SVNException>() { + public void consume(Pair<LogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { builder.consume(svnLogEntryIntegerPair); } }); - getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<SVNLogEntry>() { - public void consume(final SVNLogEntry svnLogEntry) { + getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<LogEntry>() { + public void consume(final LogEntry svnLogEntry) { try { mergeSourceTracker.consume(svnLogEntry); } @@ -204,13 +205,7 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi // TODO: Additionally SvnRepositoryLocation could possibly be refactored to always contain FilePath (or similar local item) // TODO: So here we could get repository url without performing remote svn command - SVNURL rootUrl; - try { - rootUrl = SvnUtil.getRepositoryRoot(myVcs, svnLocation.toSvnUrl()); - } - catch (SVNException e) { - throw new SvnBindException(e); - } + SVNURL rootUrl = SvnUtil.getRepositoryRoot(myVcs, svnLocation.toSvnUrl()); if (rootUrl == null) { throw new SvnBindException("Could not resolve repository root url for " + svnLocation); @@ -220,7 +215,7 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi } private void getCommittedChangesImpl(ChangeBrowserSettings settings, final SvnRepositoryLocation location, - final int maxCount, final Consumer<SVNLogEntry> resultConsumer, final boolean includeMergedRevisions, + final int maxCount, final Consumer<LogEntry> resultConsumer, final boolean includeMergedRevisions, final boolean filterOutByDate) throws VcsException { setCollectingChangesProgress(location); @@ -258,11 +253,12 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi } @NotNull - private ISVNLogEntryHandler createLogHandler(final Consumer<SVNLogEntry> resultConsumer, + private LogEntryConsumer createLogHandler(final Consumer<LogEntry> resultConsumer, final boolean filterOutByDate, final String author) { - return new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + return new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { if (myProject.isDisposed()) throw new ProcessCanceledException(); ProgressManager.progress2(SvnBundle.message("progress.text2.processing.revision", logEntry.getRevision())); @@ -381,31 +377,26 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi final Set<FilePath> result = ContainerUtil.newHashSet(); File rootFile = root.getIOFile(); - try { - myVcs.getFactory(rootFile).createStatusClient() - .doStatus(rootFile, SVNRevision.UNDEFINED, SVNDepth.INFINITY, true, false, false, false, new ISVNStatusHandler() { - @Override - public void handleStatus(SVNStatus status) throws SVNException { - File file = status.getFile(); - boolean changedOnServer = isNotNone(status.getRemoteContentsStatus()) || - isNotNone(status.getRemoteNodeStatus()) || - isNotNone(status.getRemotePropertiesStatus()); - - if (file != null && changedOnServer) { - result.add(VcsUtil.getFilePath(file, file.isDirectory())); - } + myVcs.getFactory(rootFile).createStatusClient() + .doStatus(rootFile, SVNRevision.UNDEFINED, Depth.INFINITY, true, false, false, false, new StatusConsumer() { + @Override + public void consume(Status status) throws SVNException { + File file = status.getFile(); + boolean changedOnServer = isNotNone(status.getRemoteContentsStatus()) || + isNotNone(status.getRemoteNodeStatus()) || + isNotNone(status.getRemotePropertiesStatus()); + + if (file != null && changedOnServer) { + result.add(VcsUtil.getFilePath(file, file.isDirectory())); } - }, null); - } - catch (SVNException e) { - throw new SvnBindException(e); - } + } + }, null); return result; } - private static boolean isNotNone(@Nullable SVNStatusType status) { - return status != null && !SVNStatusType.STATUS_NONE.equals(status); + private static boolean isNotNone(@Nullable StatusType status) { + return status != null && !StatusType.STATUS_NONE.equals(status); } public boolean refreshCacheByNumber() { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java index 70e982aeff8e..413e05bdd781 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnCopyPathTracker.java @@ -22,8 +22,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnFileUrlMapping; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import java.io.File; @@ -45,12 +43,12 @@ public class SvnCopyPathTracker { myCurrentPath = relativeUrl; } - public void accept(@NotNull final SVNLogEntry entry) { + public void accept(@NotNull final LogEntry entry) { final Map changedPaths = entry.getChangedPaths(); if (changedPaths == null) return; for (Object o : changedPaths.values()) { - final SVNLogEntryPath entryPath = (SVNLogEntryPath) o; + final LogEntryPath entryPath = (LogEntryPath) o; if (entryPath != null && 'A' == entryPath.getType() && entryPath.getCopyPath() != null) { if (myCurrentPath.equals(entryPath.getPath())) { myHadChanged = true; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java index 046e16c148a4..007df92a403b 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnFileRevision.java @@ -26,12 +26,13 @@ import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.history.VcsFileRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import com.intellij.openapi.vcs.impl.ContentRevisionCache; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNLogEntry; +import org.jetbrains.idea.svn.checkin.CommitInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -47,7 +48,7 @@ public class SvnFileRevision implements VcsFileRevision { private final Date myDate; private String myCommitMessage; private final String myAuthor; - private final VcsRevisionNumber myRevisionNumber; + private final SvnRevisionNumber myRevisionNumber; private final SvnVcs myVCS; private final String myURL; private final SVNRevision myPegRevision; @@ -79,7 +80,7 @@ public class SvnFileRevision implements VcsFileRevision { public SvnFileRevision(SvnVcs vcs, SVNRevision pegRevision, - SVNLogEntry logEntry, + LogEntry logEntry, String url, String copyFromPath, Charset charset) { myCharset = charset; @@ -96,6 +97,11 @@ public class SvnFileRevision implements VcsFileRevision { myMergeSources = new ArrayList<SvnFileRevision>(); } + @NotNull + public CommitInfo getCommitInfo() { + return new CommitInfo.Builder(myRevisionNumber.getRevision().getNumber(), myDate, myAuthor).build(); + } + public String getURL() { return myURL; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java index 92b619a7465f..9e9dd7e1befc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistoryProvider.java @@ -40,10 +40,11 @@ import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.internal.wc.SVNErrorManager; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import org.tmatesoft.svn.util.SVNLogType; @@ -284,7 +285,7 @@ public class SvnHistoryProvider } private static class LocalLoader extends LogLoader { - private SVNInfo myInfo; + private Info myInfo; private LocalLoader(SvnVcs vcs, FilePath file, SVNRevision from, SVNRevision to, int limit, SVNRevision peg, boolean showMergeSources) { super(vcs, file, from, to, limit, peg, showMergeSources); @@ -419,7 +420,7 @@ public class SvnHistoryProvider private void loadBackwards(SVNURL svnurl) throws SVNException, VcsException { // this method is called when svnurl does not exist in latest repository revision - thus concrete old revision is used for "info" // command to get repository url - SVNInfo info = myVcs.getInfo(svnurl, myPeg, myPeg); + Info info = myVcs.getInfo(svnurl, myPeg, myPeg); final SVNURL rootURL = info != null ? info.getRepositoryRootURL() : null; final String root = rootURL != null ? rootURL.toString() : ""; String relativeUrl = myUrl; @@ -444,11 +445,11 @@ public class SvnHistoryProvider } private boolean existsNow(SVNURL svnurl) { - final SVNInfo info; + final Info info; try { info = myVcs.getInfo(svnurl, SVNRevision.HEAD, SVNRevision.HEAD); } - catch (SVNException e) { + catch (SvnBindException e) { return false; } return info != null && info.getURL() != null && info.getRevision().isValid(); @@ -470,7 +471,7 @@ public class SvnHistoryProvider return false; } - private static class MyLogEntryHandler implements ISVNLogEntryHandler { + private static class MyLogEntryHandler implements LogEntryConsumer { private final ProgressIndicator myIndicator; protected final SvnVcs myVcs; protected final SvnPathThroughHistoryCorrection myLastPathCorrector; @@ -503,10 +504,10 @@ public class SvnHistoryProvider myPegRevision = pegRevision; myUrl = url; myRepositoryRoot = repoRootURL; - myTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException>() { + myTracker = new SvnMergeSourceTracker(new ThrowableConsumer<Pair<LogEntry, Integer>, SVNException>() { @Override - public void consume(final Pair<SVNLogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { - final SVNLogEntry logEntry = svnLogEntryIntegerPair.getFirst(); + public void consume(final Pair<LogEntry, Integer> svnLogEntryIntegerPair) throws SVNException { + final LogEntry logEntry = svnLogEntryIntegerPair.getFirst(); if (myIndicator != null) { if (myIndicator.isCanceled()) { @@ -514,12 +515,12 @@ public class SvnHistoryProvider } myIndicator.setText2(SvnBundle.message("progress.text2.revision.processed", logEntry.getRevision())); } - SVNLogEntryPath entryPath = null; + LogEntryPath entryPath = null; String copyPath = null; final int mergeLevel = svnLogEntryIntegerPair.getSecond(); if (! myLastPathCorrector.isRoot()) { - myLastPathCorrector.handleLogEntry(logEntry); + myLastPathCorrector.consume(logEntry); entryPath = myLastPathCorrector.getDirectlyMentioned(); copyPath = null; if (entryPath != null) { @@ -528,7 +529,7 @@ public class SvnHistoryProvider // if there are no path with exact match, check whether parent or child paths had changed // "entry path" is allowed to be null now; if it is null, last path would be taken for revision construction - // Separate SVNLogEntry is issued for each "merge source" revision. These "merge source" revisions are treated as child + // Separate LogEntry is issued for each "merge source" revision. These "merge source" revisions are treated as child // revisions of some other revision - this way we construct merge hierarchy. // mergeLevel >= 0 indicates that we are currently processing some "merge source" revision. This "merge source" revision // contains changes from some other branch - so checkForChildChanges() and checkForParentChanges() return "false". @@ -556,11 +557,11 @@ public class SvnHistoryProvider }); } - private boolean checkForParentChanges(SVNLogEntry logEntry) { + private boolean checkForParentChanges(LogEntry logEntry) { final String lastPathBefore = myLastPathCorrector.getBefore(); String path = SVNPathUtil.removeTail(lastPathBefore); while (path.length() > 0) { - final SVNLogEntryPath entryPath = logEntry.getChangedPaths().get(path); + final LogEntryPath entryPath = logEntry.getChangedPaths().get(path); // A & D are checked since we are not interested in parent folders property changes, only in structure changes // TODO: seems that R (replaced) should also be checked here if (entryPath != null && (entryPath.getType() == 'A' || entryPath.getType() == 'D')) { @@ -576,7 +577,7 @@ public class SvnHistoryProvider // TODO: this makes sense only for directories, but should always return true if something under the directory was changed in revision // TODO: as svn will provide child changes in history for directory - private boolean checkForChildChanges(SVNLogEntry logEntry) { + private boolean checkForChildChanges(LogEntry logEntry) { final String lastPathBefore = myLastPathCorrector.getBefore(); for (String key : logEntry.getChangedPaths().keySet()) { if (SVNPathUtil.isAncestor(lastPathBefore, key)) { @@ -587,7 +588,7 @@ public class SvnHistoryProvider } @Override - public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + public void consume(LogEntry logEntry) throws SVNException { myTracker.consume(logEntry); } @@ -605,7 +606,7 @@ public class SvnHistoryProvider } } - protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath) throws SVNException { + protected SvnFileRevision createRevision(final LogEntry logEntry, final String copyPath, LogEntryPath entryPath) throws SVNException { Date date = logEntry.getDate(); String author = logEntry.getAuthor(); String message = logEntry.getMessage(); @@ -628,7 +629,7 @@ public class SvnHistoryProvider } @Override - protected SvnFileRevision createRevision(final SVNLogEntry logEntry, final String copyPath, SVNLogEntryPath entryPath) + protected SvnFileRevision createRevision(final LogEntry logEntry, final String copyPath, LogEntryPath entryPath) throws SVNException { final SVNURL url = entryPath == null ? myRepositoryRoot.appendPath(myLastPathCorrector.getBefore(), false) : myRepositoryRoot.appendPath(entryPath.getPath(), true); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java index 171b39cad623..f2f91bceec14 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnHistorySession.java @@ -20,7 +20,7 @@ import com.intellij.openapi.vcs.history.*; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -69,7 +69,7 @@ public class SvnHistorySession extends VcsAbstractHistorySession { } public static VcsRevisionNumber getCurrentCommittedRevision(final SvnVcs vcs, final File file) { - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); return info != null ? new SvnRevisionNumber(info.getCommittedRevision()) : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java index ca387bc9ca41..0aca8300e420 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnKitHistoryClient.java @@ -8,6 +8,7 @@ import org.jetbrains.idea.svn.api.BaseSvnClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.wc.SVNLogClient; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -28,22 +29,38 @@ public class SvnKitHistoryClient extends BaseSvnClient implements HistoryClient boolean includeMergedRevisions, long limit, @Nullable String[] revisionProperties, - @Nullable ISVNLogEntryHandler handler) throws VcsException { + @Nullable LogEntryConsumer handler) throws VcsException { try { // TODO: a bug noticed when testing: we should pass "limit + 1" to get "limit" rows SVNLogClient client = myVcs.getSvnKitManager().createLogClient(); if (target.isFile()) { client.doLog(new File[]{target.getFile()}, startRevision, endRevision, target.getPegRevision(), stopOnCopy, discoverChangedPaths, - includeMergedRevisions, limit, revisionProperties, handler); + includeMergedRevisions, limit, revisionProperties, toHandler(handler)); } else { client.doLog(target.getURL(), ArrayUtil.EMPTY_STRING_ARRAY, target.getPegRevision(), startRevision, endRevision, stopOnCopy, - discoverChangedPaths, includeMergedRevisions, limit, revisionProperties, handler); + discoverChangedPaths, includeMergedRevisions, limit, revisionProperties, toHandler(handler)); } } catch (SVNException e) { throw new SvnBindException(e); } } + + @Nullable + private static ISVNLogEntryHandler toHandler(@Nullable final LogEntryConsumer handler) { + ISVNLogEntryHandler result = null; + + if (handler != null) { + result = new ISVNLogEntryHandler() { + @Override + public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + handler.consume(LogEntry.create(logEntry)); + } + }; + } + + return result; + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java index 7f4f25f023a9..878f38e6a748 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLogUtil.java @@ -24,8 +24,6 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -50,7 +48,7 @@ public class SvnLogUtil implements SvnLogLoader { final int maxCount, final boolean includingYoungest, final boolean includeOldest) throws VcsException { final List<CommittedChangeList> result = new ArrayList<CommittedChangeList>(); - ISVNLogEntryHandler handler = createLogHandler(fromIncluding, toIncluding, includingYoungest, includeOldest, result); + LogEntryConsumer handler = createLogHandler(fromIncluding, toIncluding, includingYoungest, includeOldest, result); SvnTarget target = SvnTarget.fromURL(myLocation.toSvnUrl()); myVcs.getFactory(target).createHistoryClient().doLog(target, fromIncluding, toIncluding, true, true, false, maxCount, null, handler); @@ -59,12 +57,13 @@ public class SvnLogUtil implements SvnLogLoader { } @NotNull - private ISVNLogEntryHandler createLogHandler(final SVNRevision fromIncluding, + private LogEntryConsumer createLogHandler(final SVNRevision fromIncluding, final SVNRevision toIncluding, final boolean includingYoungest, final boolean includeOldest, final List<CommittedChangeList> result) { - return new ISVNLogEntryHandler() { - public void handleLogEntry(SVNLogEntry logEntry) { + return new LogEntryConsumer() { + @Override + public void consume(LogEntry logEntry) { if (myProject.isDisposed()) throw new ProcessCanceledException(); final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator(); if (progress != null) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java index f3ed60277dd5..be0722b6fc0c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceDetails.java @@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.MasterDetailsComponent; import com.intellij.openapi.ui.NamedConfigurable; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Pair; import com.intellij.openapi.vcs.changes.committed.CommittedChangeListRenderer; import com.intellij.openapi.vcs.changes.ui.ChangeListViewerDialog; @@ -73,6 +74,8 @@ public class SvnMergeSourceDetails extends MasterDetailsComponent { final ContentManager contentManager = toolWindow.getContentManager(); final MyDialog dialog = new MyDialog(project, revision, file); + // TODO: Temporary memory leak fix - rewrite this part not to create dialog if only createCenterPanel(), but not show() is invoked + Disposer.register(project, dialog.getDisposable()); Content content = ContentFactory.SERVICE.getInstance().createContent(dialog.createCenterPanel(), SvnBundle.message("merge.source.details.title", (file == null) ? revision.getURL() : file.getName(), revision.getRevisionNumber().asString()), true); @@ -213,7 +216,10 @@ public class SvnMergeSourceDetails extends MasterDetailsComponent { if (list == null) { myPanel = new JPanel(); } else { - myPanel = new ChangeListViewerDialog(myProject, list).createCenterPanel(); + ChangeListViewerDialog dialog = new ChangeListViewerDialog(myProject, list); + // TODO: Temporary memory leak fix - rewrite this part not to create dialog if only createCenterPanel(), but not show() is invoked + Disposer.register(myProject, dialog.getDisposable()); + myPanel = dialog.createCenterPanel(); } } return myPanel; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java index 53f151876ec9..023d8489d795 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnMergeSourceTracker.java @@ -18,24 +18,23 @@ package org.jetbrains.idea.svn.history; import com.intellij.openapi.util.Pair; import com.intellij.util.ThrowableConsumer; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; public class SvnMergeSourceTracker { private int myMergeLevel; // -1 - not merge source; 0 - direct merge source - private ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException> myConsumer; + private ThrowableConsumer<Pair<LogEntry, Integer>, SVNException> myConsumer; - public SvnMergeSourceTracker(final ThrowableConsumer<Pair<SVNLogEntry, Integer>, SVNException> consumer) { + public SvnMergeSourceTracker(final ThrowableConsumer<Pair<LogEntry, Integer>, SVNException> consumer) { myConsumer = consumer; myMergeLevel = -1; } - public void consume(final SVNLogEntry logEntry) throws SVNException { + public void consume(final LogEntry logEntry) throws SVNException { if (logEntry.getRevision() < 0) { -- myMergeLevel; return; } - myConsumer.consume(new Pair<SVNLogEntry, Integer>(logEntry, myMergeLevel)); + myConsumer.consume(new Pair<LogEntry, Integer>(logEntry, myMergeLevel)); if (logEntry.hasChildren()) { ++ myMergeLevel; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java index 8ecb8a3b1e90..bf6c08e74759 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnPathThroughHistoryCorrection.java @@ -17,10 +17,7 @@ package org.jetbrains.idea.svn.history; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.idea.svn.SvnUtil; -import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import java.util.Map; @@ -33,10 +30,10 @@ import java.util.Map; * * We consider here, that history is traversed "from now to past" */ -public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { +public class SvnPathThroughHistoryCorrection implements LogEntryConsumer { private String myBefore; private String myPath; - private SVNLogEntryPath myDirectlyMentioned; + private LogEntryPath myDirectlyMentioned; private boolean myRoot; public SvnPathThroughHistoryCorrection(String path) { @@ -46,14 +43,14 @@ public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { } @Override - public void handleLogEntry(SVNLogEntry logEntry) throws SVNException { + public void consume(LogEntry logEntry) throws SVNException { if (myRoot) { return; } myBefore = myPath; myDirectlyMentioned = null; - final Map<String,SVNLogEntryPath> paths = logEntry.getChangedPaths(); - final SVNLogEntryPath entryPath = paths.get(myPath); + final Map<String,LogEntryPath> paths = logEntry.getChangedPaths(); + final LogEntryPath entryPath = paths.get(myPath); if (entryPath != null) { myDirectlyMentioned = entryPath; // exact match @@ -62,7 +59,7 @@ public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { return; } } - for (SVNLogEntryPath path : paths.values()) { + for (LogEntryPath path : paths.values()) { // "the origin path *from where* the item, ..." // TODO: this could incorrectly handle case when parent folder was replaced - see IDEA-103042 // TODO: or several parent folder renames occur IDEA-96825 @@ -89,7 +86,7 @@ public class SvnPathThroughHistoryCorrection implements ISVNLogEntryHandler { return myBefore; } - public SVNLogEntryPath getDirectlyMentioned() { + public LogEntryPath getDirectlyMentioned() { return myDirectlyMentioned; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java index 7a11aee32c48..ca69ba7a58ec 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRevisionsNavigationMediator.java @@ -28,8 +28,8 @@ import com.intellij.openapi.vcs.changes.committed.CommittedChangesNavigation; import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.wc.SVNRevision; import java.util.*; @@ -56,7 +56,7 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio myChunks = new LinkedList<List<Fragment>>(); final VcsException[] exception = new VcsException[1]; - final Ref<SVNInfo> infoRef = new Ref<SVNInfo>(); + final Ref<Info> infoRef = new Ref<Info>(); Runnable process = new Runnable() { @Override @@ -64,17 +64,14 @@ public class SvnRevisionsNavigationMediator implements CommittedChangesNavigatio try { infoRef.set(vcs.getInfo(location.toSvnUrl(), SVNRevision.HEAD)); } - catch (VcsException e) { + catch (SvnBindException e) { exception[0] = e; } - catch (SVNException e) { - exception[0] = new VcsException(e); - } } }; underProgress(exception, process); - SVNInfo info = infoRef.get(); + Info info = infoRef.get(); if (info == null || info.getRevision() == null || info.getRepositoryRootURL() == null) { throw new VcsException("Could not get head info for " + location); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java index 2bd8627de196..8a9dbf760922 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/ignore/SvnPropertyService.java @@ -23,7 +23,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -187,7 +187,7 @@ public class SvnPropertyService { String newValue = getNewPropertyValue(data, propertyValue); newValue = (newValue.trim().isEmpty()) ? null : newValue; myVcs.getFactory(folderDir).createPropertyClient() - .setProperty(folderDir, SvnPropertyKeys.SVN_IGNORE, SVNPropertyValue.create(newValue), SVNDepth.EMPTY, false); + .setProperty(folderDir, SvnPropertyKeys.SVN_IGNORE, SVNPropertyValue.create(newValue), Depth.EMPTY, false); if (myUseCommonExtension) { dirtyScopeManager.dirDirtyRecursively(folder); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java index 475dd1a4f77d..91eb7ce42e3e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/CmdInfoClient.java @@ -20,17 +20,16 @@ import com.intellij.execution.process.ProcessOutputTypes; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.Consumer; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.*; -import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.ISVNInfoHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; import org.xml.sax.SAXException; @@ -41,7 +40,6 @@ import javax.xml.parsers.SAXParserFactory; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -55,48 +53,7 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { private static final Logger LOG = Logger.getInstance(CmdInfoClient.class); - @Override - public void doInfo(File path, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException { - doInfo(path, SVNRevision.UNDEFINED, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, null, handler); - } - - @Override - public void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - doInfo(path, pegRevision, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, null, handler); - } - - @Override - public void doInfo(File path, - SVNRevision pegRevision, - SVNRevision revision, - SVNDepth depth, - Collection changeLists, - final ISVNInfoHandler handler) throws SVNException { - File base = path.isDirectory() ? path : path.getParentFile(); - base = CommandUtil.correctUpToExistingParent(base); - if (base == null) { - // very unrealistic - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Can not find existing parent file")); - } - issueCommand(path, pegRevision, revision, depth, changeLists, handler, base); - } - - private void issueCommand(File path, SVNRevision pegRevision, - SVNRevision revision, - SVNDepth depth, - Collection changeLists, - final ISVNInfoHandler handler, File base) throws SVNException { - List<String> parameters = new ArrayList<String>(); - - fillParameters(path.getAbsolutePath(), pegRevision, revision, depth, parameters); - // TODO: Fix this check - update corresponding parameters in InfoClient - CommandUtil.putChangeLists(parameters, changeLists); - - parseResult(handler, base, execute(parameters, path)); - } - - private String execute(@NotNull List<String> parameters, @NotNull File path) throws SVNException { + private String execute(@NotNull List<String> parameters, @NotNull File path) throws SvnBindException { // workaround: separately capture command output - used in exception handling logic to overcome svn 1.8 issue (see below) final ProcessOutput output = new ProcessOutput(); LineCommandListener listener = new LineCommandAdapter() { @@ -113,51 +70,46 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { return command.getOutput(); } - catch (VcsException e) { - final String text = e.getMessage(); - final boolean notEmpty = !StringUtil.isEmptyOrSpaces(text); - if (notEmpty && text.contains("W155010")) { + catch (SvnBindException e) { + final String text = StringUtil.notNullize(e.getMessage()); + if (text.contains("W155010")) { // if "svn info" is executed for several files at once, then this warning could be printed only for some files, but info for other // files should be parsed from output return output.getStdout(); } // not a working copy exception // "E155007: '' is not a working copy" - if (notEmpty && text.contains("is not a working copy")) { - if (StringUtil.isNotEmpty(output.getStdout())) { - // TODO: Seems not reproducible in 1.8.4 - // workaround: as in subversion 1.8 "svn info" on a working copy root outputs such error for parent folder, - // if there are files with conflicts. - // but the requested info is still in the output except root closing tag - return output.getStdout() + "</info>"; - } else { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_NOT_WORKING_COPY, e), e); - } - // svn: E200009: Could not display info for all targets because some targets don't exist - } else if (notEmpty && text.contains("some targets don't exist")) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET, e), e); - } else if (notEmpty && text.contains(String.valueOf(SVNErrorCode.WC_UPGRADE_REQUIRED.getCode()))) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_UPGRADE_REQUIRED, e), e); - } else if (notEmpty && - (text.contains("upgrade your Subversion client") || - text.contains(String.valueOf(SVNErrorCode.WC_UNSUPPORTED_FORMAT.getCode())))) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_UNSUPPORTED_FORMAT, e), e); + if (text.contains("is not a working copy") && StringUtil.isNotEmpty(output.getStdout())) { + // TODO: Seems not reproducible in 1.8.4 + // workaround: as in subversion 1.8 "svn info" on a working copy root outputs such error for parent folder, + // if there are files with conflicts. + // but the requested info is still in the output except root closing tag + return output.getStdout() + "</info>"; } - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw e; } } - private static void parseResult(@NotNull final ISVNInfoHandler handler, @Nullable File base, @Nullable String result) throws SVNException { + @Nullable + private static Info parseResult(@Nullable File base, @Nullable String result) throws SvnBindException { + CollectInfoHandler handler = new CollectInfoHandler(); + + parseResult(handler, base, result); + + return handler.getInfo(); + } + + private static void parseResult(@NotNull final InfoConsumer handler, @Nullable File base, @Nullable String result) + throws SvnBindException { if (StringUtil.isEmptyOrSpaces(result)) { return; } - final SvnInfoHandler[] infoHandler = new SvnInfoHandler[1]; - infoHandler[0] = new SvnInfoHandler(base, new Consumer<SVNInfo>() { + final SvnInfoHandler infoHandler = new SvnInfoHandler(base, new Consumer<Info>() { @Override - public void consume(SVNInfo info) { + public void consume(Info info) { try { - handler.handleInfo(info); + handler.consume(info); } catch (SVNException e) { throw new SvnExceptionWrapper(e); @@ -165,87 +117,68 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { } }); + parseResult(result, infoHandler); + } + + private static void parseResult(@NotNull String result, @NotNull SvnInfoHandler handler) throws SvnBindException { try { SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); - parser.parse(new ByteArrayInputStream(result.trim().getBytes(CharsetToolkit.UTF8_CHARSET)), infoHandler[0]); + parser.parse(new ByteArrayInputStream(result.trim().getBytes(CharsetToolkit.UTF8_CHARSET)), handler); } catch (SvnExceptionWrapper e) { LOG.info("info output " + result); - throw (SVNException) e.getCause(); + throw new SvnBindException(e.getCause()); } catch (IOException e) { LOG.info("info output " + result); - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (ParserConfigurationException e) { LOG.info("info output " + result); - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (SAXException e) { LOG.info("info output " + result); - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } } - private static void fillParameters(String path, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, List<String> parameters) { + @NotNull + private static List<String> buildParameters(@NotNull String path, + @Nullable SVNRevision pegRevision, + @Nullable SVNRevision revision, + @Nullable Depth depth) { + List<String> parameters = ContainerUtil.newArrayList(); + CommandUtil.put(parameters, depth); CommandUtil.put(parameters, revision); CommandUtil.put(parameters, path, pegRevision); parameters.add("--xml"); - } - @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - doInfo(url, pegRevision, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, handler); + return parameters; } @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, ISVNInfoHandler handler) - throws SVNException { - String path = url.toDecodedString(); - List<String> parameters = new ArrayList<String>(); - - fillParameters(path, pegRevision, revision, depth, parameters); - CommandExecutor command; - try { - command = execute(myVcs, SvnTarget.fromURL(url), SvnCommandName.info, parameters, null); - } - catch (SvnBindException e) { - SVNErrorCode code = e.contains(SVNErrorCode.RA_ILLEGAL_URL) ? SVNErrorCode.RA_ILLEGAL_URL : SVNErrorCode.IO_ERROR; - - throw new SVNException(SVNErrorMessage.create(code, e), e); + public Info doInfo(File path, SVNRevision revision) throws SvnBindException { + File base = path.isDirectory() ? path : path.getParentFile(); + base = CommandUtil.correctUpToExistingParent(base); + if (base == null) { + // very unrealistic + throw new SvnBindException("Can not find existing parent file"); } - parseResult(handler, null, command.getOutput()); + return parseResult(base, execute(buildParameters(path.getAbsolutePath(), SVNRevision.UNDEFINED, revision, Depth.EMPTY), path)); } @Override - public SVNInfo doInfo(File path, SVNRevision revision) throws SVNException { - final SVNInfo[] infoArr = new SVNInfo[1]; - doInfo(path, SVNRevision.UNDEFINED, revision, SVNDepth.EMPTY, null, new ISVNInfoHandler() { - @Override - public void handleInfo(SVNInfo info) throws SVNException { - infoArr[0] = info; - } - }); - return infoArr[0]; - } + public Info doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SvnBindException { + CommandExecutor command = execute(myVcs, SvnTarget.fromURL(url), SvnCommandName.info, buildParameters(url.toDecodedString(), pegRevision, revision, Depth.EMPTY), null); - @Override - public SVNInfo doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SVNException { - final SVNInfo[] infoArr = new SVNInfo[1]; - doInfo(url, pegRevision, revision, SVNDepth.EMPTY, new ISVNInfoHandler() { - @Override - public void handleInfo(SVNInfo info) throws SVNException { - infoArr[0] = info; - } - }); - return infoArr[0]; + return parseResult(null, command.getOutput()); } @Override - public void doInfo(@NotNull Collection<File> paths, @Nullable ISVNInfoHandler handler) throws SVNException { + public void doInfo(@NotNull Collection<File> paths, @Nullable InfoConsumer handler) throws SvnBindException { File base = ContainerUtil.getFirstItem(paths); if (base != null) { @@ -265,4 +198,19 @@ public class CmdInfoClient extends BaseSvnClient implements InfoClient { } } } + + private static class CollectInfoHandler implements InfoConsumer { + + @Nullable private Info myInfo; + + @Override + public void consume(Info info) throws SVNException { + myInfo = info; + } + + @Nullable + public Info getInfo() { + return myInfo; + } + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/IdeaSVNInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/IdeaSVNInfo.java deleted file mode 100644 index 0e2905e73016..000000000000 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/IdeaSVNInfo.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.svn.info; - -import org.jetbrains.annotations.Nullable; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNLock; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; - -import java.io.File; -import java.util.Date; - -/** - * Created by IntelliJ IDEA. - * User: Irina.Chernushina - * Date: 1/23/12 - * Time: 1:02 PM - */ -public class IdeaSVNInfo extends SVNInfo { - private final Date myCorrectCommittedDate; - private final Date myCorrectTextDate; - - public IdeaSVNInfo(@Nullable File file, - SVNURL url, - SVNURL rootURL, - long revision, - SVNNodeKind kind, - String uuid, - long committedRevision, - Date committedDate, - String author, - String schedule, - SVNURL copyFromURL, - long copyFromRevision, - Date textTime, - String propTime, - String checksum, - String conflictOld, - String conflictNew, - String conflictWorking, - String propRejectFile, - SVNLock lock, - SVNDepth depth, - String changelistName, - long wcSize, - SVNTreeConflictDescription treeConflict) { - super(file, url, rootURL, revision, kind, uuid, committedRevision, null, author, schedule, copyFromURL, copyFromRevision, - null, propTime, checksum, conflictOld, conflictNew, conflictWorking, propRejectFile, lock, depth, changelistName, wcSize, - treeConflict); - myCorrectCommittedDate = committedDate; - myCorrectTextDate = textTime; - } - - /** - * Gets the item's last commit date. This is the value of the item's - * {@link org.tmatesoft.svn.core.SVNProperty#COMMITTED_DATE} - * property. - * - * @return the item's last commit date - */ - @Override - public Date getCommittedDate() { - return myCorrectCommittedDate; - } - - /** - * Gets the value of the item's {@link org.tmatesoft.svn.core.SVNProperty#TEXT_TIME} - * property. It corresponds to the last commit time. - * - * @return the value of the item's text-time property - */ - @Override - public Date getTextTime() { - return myCorrectTextDate; - } - - public IdeaSVNInfo(String path, - SVNURL url, - SVNRevision revision, - SVNNodeKind kind, - String uuid, - SVNURL reposRootURL, - long comittedRevision, Date date, String author, SVNLock lock, SVNDepth depth, long size) { - super(path, url, revision, kind, uuid, reposRootURL, comittedRevision, date, author, lock, depth, size); - myCorrectCommittedDate = date; - myCorrectTextDate = null; - } -} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/Info.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/Info.java new file mode 100644 index 000000000000..96dbdbbcbc99 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/Info.java @@ -0,0 +1,267 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.info; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.BaseNodeDescription; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.lock.Lock; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.internal.util.SVNDate; +import org.tmatesoft.svn.core.wc.SVNInfo; +import org.tmatesoft.svn.core.wc.SVNRevision; + +import java.io.File; +import java.util.Date; + +/** + * @author Konstantin Kolosovsky. + */ +public class Info extends BaseNodeDescription { + + private final File myFile; + private final String myPath; + private final SVNURL myURL; + private final SVNRevision myRevision; + private final SVNURL myRepositoryRootURL; + private final String myRepositoryUUID; + private final SVNRevision myCommittedRevision; + private final Date myCommittedDate; + private final String myAuthor; + @Nullable private final Lock myLock; + private final boolean myIsRemote; + private final String mySchedule; + private final SVNURL myCopyFromURL; + private final SVNRevision myCopyFromRevision; + private final File myConflictOldFile; + private final File myConflictNewFile; + private final File myConflictWrkFile; + private final File myPropConflictFile; + private final Depth myDepth; + @Nullable private final TreeConflictDescription myTreeConflict; + + @NotNull + public static Info create(@NotNull SVNInfo info) { + Info result; + + if (info.isRemote()) { + result = new Info(info.getPath(), info.getURL(), info.getRevision(), NodeKind.from(info.getKind()), info.getRepositoryUUID(), + info.getRepositoryRootURL(), info.getCommittedRevision().getNumber(), info.getCommittedDate(), info.getAuthor(), + Lock.create(info.getLock()), Depth.from(info.getDepth())); + } + else { + result = + new Info(info.getFile(), info.getURL(), info.getRepositoryRootURL(), info.getRevision().getNumber(), NodeKind.from(info.getKind()), + info.getRepositoryUUID(), info.getCommittedRevision().getNumber(), toString(info.getCommittedDate()), info.getAuthor(), + info.getSchedule(), info.getCopyFromURL(), info.getCopyFromRevision().getNumber(), getPath(info.getConflictOldFile()), + getPath(info.getConflictNewFile()), getPath(info.getConflictWrkFile()), getPath(info.getPropConflictFile()), + Lock.create(info.getLock()), Depth.from(info.getDepth()), TreeConflictDescription.create(info.getTreeConflict())); + } + + return result; + } + + public Info(File file, + SVNURL url, + SVNURL rootURL, + long revision, + @NotNull NodeKind kind, + String uuid, + long committedRevision, + String committedDate, + String author, + String schedule, + SVNURL copyFromURL, + long copyFromRevision, + String conflictOld, + String conflictNew, + String conflictWorking, + String propRejectFile, + @Nullable Lock lock, + Depth depth, + @Nullable TreeConflictDescription treeConflict) { + super(kind); + myFile = file; + myURL = url; + myRevision = SVNRevision.create(revision); + myRepositoryUUID = uuid; + myRepositoryRootURL = rootURL; + + myCommittedRevision = SVNRevision.create(committedRevision); + myCommittedDate = committedDate != null ? SVNDate.parseDate(committedDate) : null; + myAuthor = author; + + mySchedule = schedule; + + myCopyFromURL = copyFromURL; + myCopyFromRevision = SVNRevision.create(copyFromRevision); + + myLock = lock; + myTreeConflict = treeConflict; + + myConflictOldFile = resolveConflictFile(file, conflictOld); + myConflictNewFile = resolveConflictFile(file, conflictNew); + myConflictWrkFile = resolveConflictFile(file, conflictWorking); + myPropConflictFile = resolveConflictFile(file, propRejectFile); + + myIsRemote = false; + myDepth = depth; + + myPath = null; + } + + public Info(String path, + SVNURL url, + SVNRevision revision, + @NotNull NodeKind kind, + String uuid, + SVNURL reposRootURL, + long committedRevision, + Date date, + String author, + @Nullable Lock lock, + Depth depth) { + super(kind); + myIsRemote = true; + myURL = url; + myRevision = revision; + myRepositoryRootURL = reposRootURL; + myRepositoryUUID = uuid; + + myCommittedDate = date; + myCommittedRevision = SVNRevision.create(committedRevision); + myAuthor = author; + + myLock = lock; + myPath = path; + myDepth = depth; + + myFile = null; + mySchedule = null; + myCopyFromURL = null; + myCopyFromRevision = null; + myConflictOldFile = null; + myConflictNewFile = null; + myConflictWrkFile = null; + myPropConflictFile = null; + myTreeConflict = null; + } + + public String getAuthor() { + return myAuthor; + } + + public Date getCommittedDate() { + return myCommittedDate; + } + + public SVNRevision getCommittedRevision() { + return myCommittedRevision; + } + + public File getConflictNewFile() { + return myConflictNewFile; + } + + public File getConflictOldFile() { + return myConflictOldFile; + } + + public File getConflictWrkFile() { + return myConflictWrkFile; + } + + @Nullable + public TreeConflictDescription getTreeConflict() { + return myTreeConflict; + } + + public SVNRevision getCopyFromRevision() { + return myCopyFromRevision; + } + + public SVNURL getCopyFromURL() { + return myCopyFromURL; + } + + public File getFile() { + return myFile; + } + + public boolean isRemote() { + return myIsRemote; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + @Nullable + public Lock getLock() { + return myLock; + } + + public String getPath() { + return myPath; + } + + public File getPropConflictFile() { + return myPropConflictFile; + } + + public SVNURL getRepositoryRootURL() { + return myRepositoryRootURL; + } + + public String getRepositoryUUID() { + return myRepositoryUUID; + } + + public SVNRevision getRevision() { + return myRevision; + } + + public String getSchedule() { + return mySchedule; + } + + public SVNURL getURL() { + return myURL; + } + + public Depth getDepth() { + return myDepth; + } + + @Nullable + private static File resolveConflictFile(@Nullable File file, @Nullable String path) { + return file != null && path != null ? new File(file.getParentFile(), path) : null; + } + + @Nullable + private static String getPath(@Nullable File file) { + return file != null ? file.getPath() : null; + } + + @Nullable + private static String toString(@Nullable Date date) { + return date != null ? date.toString() : null; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java index f6582e603eda..56f87a040b17 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoClient.java @@ -18,11 +18,8 @@ package org.jetbrains.idea.svn.info; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNInfoHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -36,15 +33,9 @@ import java.util.Collection; */ public interface InfoClient extends SvnClient { - void doInfo(File path, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException; - void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException; - void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, - Collection changeLists, ISVNInfoHandler handler) throws SVNException; - void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException; - void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, - ISVNInfoHandler handler) throws SVNException; - SVNInfo doInfo(File path, SVNRevision revision) throws SVNException; - SVNInfo doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SVNException; + Info doInfo(File path, SVNRevision revision) throws SvnBindException; - void doInfo(@NotNull Collection<File> paths, @Nullable ISVNInfoHandler handler) throws SVNException; + Info doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SvnBindException; + + void doInfo(@NotNull Collection<File> paths, @Nullable InfoConsumer handler) throws SvnBindException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoConsumer.java new file mode 100644 index 000000000000..317b2b6a5156 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/InfoConsumer.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.info; + +import com.intellij.util.ThrowableConsumer; +import org.jetbrains.idea.svn.info.Info; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface InfoConsumer extends ThrowableConsumer<Info, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SVNLockWrapper.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SVNLockWrapper.java deleted file mode 100644 index f5752074da77..000000000000 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SVNLockWrapper.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2000-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jetbrains.idea.svn.info; - -import org.tmatesoft.svn.core.SVNLock; - -import java.util.Date; - -/** - * Created with IntelliJ IDEA. - * User: Irina.Chernushina - * Date: 2/21/12 - * Time: 2:33 PM - */ -public class SVNLockWrapper { - private String myPath; - private String myID; - private String myOwner; - private String myComment; - private Date myCreationDate; - private Date myExpirationDate; - - public SVNLockWrapper(String path, String ID, String owner, String comment, Date creationDate, Date expirationDate) { - myPath = path; - myID = ID; - myOwner = owner; - myComment = comment; - myCreationDate = creationDate; - myExpirationDate = expirationDate; - } - - public SVNLockWrapper() { - } - - public SVNLock create() { - return new SVNLock(myPath, myID, myOwner, myComment, myCreationDate, myExpirationDate); - } - - public String getPath() { - return myPath; - } - - public void setPath(String path) { - myPath = path; - } - - public String getID() { - return myID; - } - - public void setID(String ID) { - myID = ID; - } - - public String getOwner() { - return myOwner; - } - - public void setOwner(String owner) { - myOwner = owner; - } - - public String getComment() { - return myComment; - } - - public void setComment(String comment) { - myComment = comment; - } - - public Date getCreationDate() { - return myCreationDate; - } - - public void setCreationDate(Date creationDate) { - myCreationDate = creationDate; - } - - public Date getExpirationDate() { - return myExpirationDate; - } - - public void setExpirationDate(Date expirationDate) { - myExpirationDate = expirationDate; - } -} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java index e2e5fa910e38..969225eb69e3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoHandler.java @@ -21,12 +21,11 @@ import com.intellij.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNDate; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -42,14 +41,14 @@ import java.util.*; */ public class SvnInfoHandler extends DefaultHandler { @Nullable private final File myBase; - private final Consumer<SVNInfo> myInfoConsumer; - private Map<File, SVNInfo> myResultsMap; + private final Consumer<org.jetbrains.idea.svn.info.Info> myInfoConsumer; + private Map<File, org.jetbrains.idea.svn.info.Info> myResultsMap; private SvnInfoStructure myPending; private final Map<String, Getter<ElementHandlerBase>> myElementsMap; private final List<ElementHandlerBase> myParseStack; private final StringBuilder mySb; - public SvnInfoHandler(@Nullable File base, final Consumer<SVNInfo> infoConsumer) { + public SvnInfoHandler(@Nullable File base, final Consumer<org.jetbrains.idea.svn.info.Info> infoConsumer) { myBase = base; myInfoConsumer = infoConsumer; myPending = createPending(); @@ -57,12 +56,12 @@ public class SvnInfoHandler extends DefaultHandler { fillElements(); myParseStack = new ArrayList<ElementHandlerBase>(); myParseStack.add(new Fake()); - myResultsMap = new HashMap<File, SVNInfo>(); + myResultsMap = new HashMap<File, org.jetbrains.idea.svn.info.Info>(); mySb = new StringBuilder(); } private void switchPending() throws SAXException { - final SVNInfo info; + final org.jetbrains.idea.svn.info.Info info; try { info = myPending.convert(); } @@ -78,7 +77,7 @@ public class SvnInfoHandler extends DefaultHandler { private SvnInfoStructure createPending() { SvnInfoStructure pending = new SvnInfoStructure(); - pending.myDepth = SVNDepth.INFINITY; + pending.myDepth = org.jetbrains.idea.svn.api.Depth.INFINITY; return pending; } @@ -280,7 +279,7 @@ public class SvnInfoHandler extends DefaultHandler { myElementsMap.put("lock", new Getter<ElementHandlerBase>() { @Override public ElementHandlerBase get() { - return new Lock(); + return new LockElement(); } }); myElementsMap.put("token", new Getter<ElementHandlerBase>() { @@ -345,7 +344,7 @@ public class SvnInfoHandler extends DefaultHandler { }); } - public Map<File, SVNInfo> getResultsMap() { + public Map<File, org.jetbrains.idea.svn.info.Info> getResultsMap() { return myResultsMap; } @@ -514,8 +513,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - final SVNDate date = SVNDate.parseDate(s); - structure.myCommittedDate = date; + structure.myCommittedDate = s; } } @@ -600,8 +598,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - final SVNDate date = SVNDate.parseDate(s); - structure.myTextTime = date; + structure.myTextTime = s; } } @@ -616,7 +613,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myDepth = SVNDepth.fromString(s); + structure.myDepth = org.jetbrains.idea.svn.api.Depth.from(s); } } @@ -796,14 +793,14 @@ public class SvnInfoHandler extends DefaultHandler { } } - private static class Lock extends ElementHandlerBase { - private Lock() { + private static class LockElement extends ElementHandlerBase { + private LockElement() { super(new String[]{"token", "owner", "comment", "created"}, new String[]{}); } @Override protected void updateInfo(Attributes attributes, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper = new SVNLockWrapper(); + structure.myLockBuilder = new Lock.Builder(); } @Override @@ -822,7 +819,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setID(s); + structure.myLockBuilder.setToken(s); } } @@ -837,7 +834,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setOwner(s); + structure.myLockBuilder.setOwner(s); } } @@ -852,7 +849,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setComment(s); + structure.myLockBuilder.setComment(s); } } @@ -867,7 +864,7 @@ public class SvnInfoHandler extends DefaultHandler { @Override public void characters(String s, SvnInfoStructure structure) throws SAXException { - structure.myLockWrapper.setCreationDate(SVNDate.parseDate(s)); + structure.myLockBuilder.setCreationDate(SVNDate.parseDate(s)); } } @@ -883,7 +880,7 @@ public class SvnInfoHandler extends DefaultHandler { protected void updateInfo(Attributes attributes, SvnInfoStructure structure) throws SAXException { final String kind = attributes.getValue("kind"); assertSAX(! StringUtil.isEmptyOrSpaces(kind)); - structure.myKind = SVNNodeKind.parseKind(kind); + structure.myKind = NodeKind.from(kind); if (myBase != null) { final String path = attributes.getValue("path"); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java index 6e1b1db1efa2..42929885f364 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnInfoStructure.java @@ -15,17 +15,18 @@ */ package org.jetbrains.idea.svn.info; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.ConflictAction; +import org.jetbrains.idea.svn.conflict.ConflictOperation; +import org.jetbrains.idea.svn.conflict.ConflictReason; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; -import org.tmatesoft.svn.core.wc.*; import org.xml.sax.SAXException; import java.io.File; import java.util.Date; -import java.util.Map; /** * Created with IntelliJ IDEA. @@ -35,46 +36,28 @@ import java.util.Map; */ public class SvnInfoStructure { - private static final Map<String, SVNConflictAction> ourConflictActions = ContainerUtil.newHashMap(); - private static final Map<String, SVNConflictReason> ourConflictReasons = ContainerUtil.newHashMap(); - - static { - ourConflictActions.put("add", SVNConflictAction.ADD); - ourConflictActions.put("edit", SVNConflictAction.EDIT); - ourConflictActions.put("delete", SVNConflictAction.DELETE); - ourConflictActions.put("replace", SVNConflictAction.REPLACE); - - ourConflictReasons.put("edit", SVNConflictReason.EDITED); - ourConflictReasons.put("obstruct", SVNConflictReason.OBSTRUCTED); - ourConflictReasons.put("delete", SVNConflictReason.DELETED); - ourConflictReasons.put("miss", SVNConflictReason.MISSING); - ourConflictReasons.put("unversion", SVNConflictReason.UNVERSIONED); - ourConflictReasons.put("add", SVNConflictReason.ADDED); - ourConflictReasons.put("replace", SVNConflictReason.REPLACED); - } - @Nullable public File myFile; public String relativeUrl; public SVNURL myUrl; public SVNURL myRootURL; public long myRevision; - public SVNNodeKind myKind; + public NodeKind myKind; public String myUuid; public long myCommittedRevision; - public Date myCommittedDate; + public String myCommittedDate; public String myAuthor; public String mySchedule; public SVNURL myCopyFromURL; public long myCopyFromRevision; - public Date myTextTime; + public String myTextTime; public String myPropTime; public String myChecksum; public String myConflictOld; public String myConflictNew; public String myConflictWorking; public String myPropRejectFile; - public SVNLockWrapper myLockWrapper; - public SVNDepth myDepth; + public Lock.Builder myLockBuilder; + public Depth myDepth; public String myChangelistName; public long myWcSize; public Date myCorrectCommittedDate; @@ -82,65 +65,37 @@ public class SvnInfoStructure { public TreeConflictDescription myTreeConflict; - public SVNInfo convert() throws SAXException, SVNException { - return new IdeaSVNInfo(myFile, myUrl, myRootURL, myRevision, myKind, myUuid, myCommittedRevision, myCommittedDate, myAuthor, mySchedule, - myCopyFromURL, myCopyFromRevision, myTextTime, myPropTime, myChecksum, myConflictOld, myConflictNew, myConflictWorking, - myPropRejectFile, getLock(), myDepth, myChangelistName, myWcSize, createTreeConflict()); + public Info convert() throws SAXException, SVNException { + return new Info(myFile, myUrl, myRootURL, myRevision, myKind, myUuid, myCommittedRevision, myCommittedDate, myAuthor, mySchedule, + myCopyFromURL, myCopyFromRevision, myConflictOld, myConflictNew, myConflictWorking, + myPropRejectFile, getLock(), myDepth, createTreeConflict()); } - private SVNLock getLock() { - SVNLock lock = null; - - if (myLockWrapper != null) { - myLockWrapper.setPath(relativeUrl); - lock = myLockWrapper.create(); - } - - return lock; + @Nullable + private Lock getLock() { + return myLockBuilder != null ? myLockBuilder.build() : null; } - private SVNTreeConflictDescription createTreeConflict() throws SAXException, SVNException { + private org.jetbrains.idea.svn.conflict.TreeConflictDescription createTreeConflict() throws SAXException, SVNException { if (myTreeConflict == null) { return null; } else { assert myFile != null; - final SVNConflictAction action = parseConflictAction(myTreeConflict.myAction); - final SVNConflictReason reason = parseConflictReason(myTreeConflict.myReason); - SVNOperation operation = SVNOperation.fromString(myTreeConflict.myOperation); - operation = operation == null ? SVNOperation.NONE : operation; - return new SVNTreeConflictDescription(myFile, myKind, action, reason, operation, - createVersion(myTreeConflict.mySourceLeft), - createVersion(myTreeConflict.mySourceRight)); + return new org.jetbrains.idea.svn.conflict.TreeConflictDescription(myFile, myKind, ConflictAction.from(myTreeConflict.myAction), + ConflictReason.from(myTreeConflict.myReason), + ConflictOperation.from(myTreeConflict.myOperation), + createVersion(myTreeConflict.mySourceLeft), + createVersion(myTreeConflict.mySourceRight)); } } - private SVNConflictAction parseConflictAction(@NotNull String actionName) { - SVNConflictAction action = SVNConflictAction.fromString(actionName); - action = action != null ? action : ourConflictActions.get(actionName); - - if (action == null) { - throw new IllegalArgumentException("Unknown conflict action " + actionName); - } - - return action; - } - - private SVNConflictReason parseConflictReason(@NotNull String reasonName) throws SAXException { - SVNConflictReason reason = SVNConflictReason.fromString(reasonName); - reason = reason != null ? reason : ourConflictReasons.get(reasonName); - - if (reason == null) { - throw new SAXException("Can not parse conflict reason: " + reasonName); - } - - return reason; - } - - private SVNConflictVersion createVersion(final ConflictVersion version) throws SVNException, SAXException { - return version == null ? null : new SVNConflictVersion(SVNURL.parseURIEncoded(version.myRepoUrl), version.myPathInRepo, - parseRevision(version.myRevision), SVNNodeKind.parseKind(version.myKind)); + private org.jetbrains.idea.svn.conflict.ConflictVersion createVersion(final ConflictVersion version) throws SVNException, SAXException { + return version == null + ? null + : new org.jetbrains.idea.svn.conflict.ConflictVersion(SVNURL.parseURIEncoded(version.myRepoUrl), version.myPathInRepo, + parseRevision(version.myRevision), NodeKind.from(version.myKind)); } private long parseRevision(final String revision) throws SAXException { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java index 7f50e85cd2d7..3db2c647791a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/info/SvnKitInfoClient.java @@ -18,12 +18,9 @@ package org.jetbrains.idea.svn.info; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.info.InfoClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNInfoHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCClient; @@ -43,50 +40,27 @@ public class SvnKitInfoClient extends BaseSvnClient implements InfoClient { } @Override - public void doInfo(File path, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) throws SVNException { - getClient().doInfo(path, revision, recursive, handler); + public Info doInfo(File path, SVNRevision revision) throws SvnBindException { + try { + return Info.create(getClient().doInfo(path, revision)); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override - public void doInfo(File path, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - getClient().doInfo(path, pegRevision, revision, recursive, handler); + public Info doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SvnBindException { + try { + return Info.create(getClient().doInfo(url, pegRevision, revision)); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override - public void doInfo(File path, - SVNRevision pegRevision, - SVNRevision revision, - SVNDepth depth, - Collection changeLists, - ISVNInfoHandler handler) throws SVNException { - getClient().doInfo(path, pegRevision, revision, depth, changeLists, handler); - } - - @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNInfoHandler handler) - throws SVNException { - getClient().doInfo(url, pegRevision, revision, recursive, handler); - } - - @Override - public void doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, ISVNInfoHandler handler) - throws SVNException { - getClient().doInfo(url, pegRevision, revision, depth, handler); - } - - @Override - public SVNInfo doInfo(File path, SVNRevision revision) throws SVNException { - return getClient().doInfo(path, revision); - } - - @Override - public SVNInfo doInfo(SVNURL url, SVNRevision pegRevision, SVNRevision revision) throws SVNException { - return getClient().doInfo(url, pegRevision, revision); - } - - @Override - public void doInfo(@NotNull Collection<File> paths, @Nullable ISVNInfoHandler handler) throws SVNException { + public void doInfo(@NotNull Collection<File> paths, @Nullable InfoConsumer handler) throws SvnBindException { throw new UnsupportedOperationException(); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java index 63eb66d9b002..2f9d8ae5aac5 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/CmdMergeClient.java @@ -4,10 +4,10 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.*; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,8 +23,8 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull File destination, boolean dryRun, - @Nullable SVNDiffOptions diffOptions, - @Nullable final ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable final ProgressTracker handler) throws VcsException { assertUrl(source); List<String> parameters = new ArrayList<String>(); @@ -38,12 +38,12 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull SVNRevisionRange range, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); List<String> parameters = new ArrayList<String>(); @@ -60,13 +60,13 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source1, @NotNull SvnTarget source2, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean useAncestry, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source1); assertUrl(source2); @@ -82,12 +82,12 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { private static void fillParameters(@NotNull List<String> parameters, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, boolean reintegrate, - @Nullable SVNDiffOptions diffOptions) { + @Nullable DiffOptions diffOptions) { CommandUtil.put(parameters, destination); CommandUtil.put(parameters, diffOptions); CommandUtil.put(parameters, dryRun, "--dry-run"); @@ -102,7 +102,7 @@ public class CmdMergeClient extends BaseSvnClient implements MergeClient { CommandUtil.put(parameters, reintegrate, "--reintegrate"); } - private void run(File destination, ISVNEventHandler handler, List<String> parameters) throws VcsException { + private void run(File destination, ProgressTracker handler, List<String> parameters) throws VcsException { BaseUpdateCommandListener listener = new BaseUpdateCommandListener(CommandUtil.correctUpToExistingParent(destination), handler); execute(myVcs, SvnTarget.fromFile(destination), SvnCommandName.merge, parameters, listener); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java index cb62668cbb25..73346ad4af66 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/GroupMerger.java @@ -27,8 +27,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -131,7 +131,7 @@ public class GroupMerger implements IMerger { SvnTarget source = SvnTarget.fromURL(myCurrentBranchUrl); MergeClient client = myVcs.getFactory(myTarget).createMergeClient(); - client.merge(source, createRange(), myTarget, SVNDepth.INFINITY, mySvnConfig.isMergeDryRun(), myDryRun, true, + client.merge(source, createRange(), myTarget, Depth.INFINITY, mySvnConfig.isMergeDryRun(), myDryRun, true, mySvnConfig.getMergeOptions(), myHandler); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java index 75533d8801c3..d043c95f1f1d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegrateEventHandler.java @@ -19,22 +19,22 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.vcs.update.FileGroup; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -import org.tmatesoft.svn.core.wc.SVNStatusType; public class IntegrateEventHandler extends UpdateEventHandler { public IntegrateEventHandler(final SvnVcs vcs, final ProgressIndicator progressIndicator) { super(vcs, progressIndicator, null); } - protected boolean handleInDescendants(final SVNEvent event) { - if ((event.getAction() == SVNEventAction.UPDATE_UPDATE) && (event.getContentsStatus() == SVNStatusType.UNCHANGED) && - (event.getPropertiesStatus() == SVNStatusType.UNKNOWN)) { + protected boolean handleInDescendants(final ProgressEvent event) { + if ((event.getAction() == EventAction.UPDATE_UPDATE) && (event.getContentsStatus() == StatusType.UNCHANGED) && + (event.getPropertiesStatus() == StatusType.UNKNOWN)) { myText2 = SvnBundle.message("progres.text2.updated", event.getFile().getName()); return true; - } else if (event.getAction() == SVNEventAction.DELETE) { + } else if (event.getAction() == EventAction.DELETE) { addFileToGroup(FileGroup.REMOVED_FROM_REPOSITORY_ID, event); myText2 = SvnBundle.message("progress.text2.deleted", event.getFile().getName()); return true; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java index 3029f156a69c..3b2184c22484 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/IntegratedSelectedOptionsDialog.java @@ -32,8 +32,8 @@ import com.intellij.util.PlatformIcons; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import javax.swing.*; import javax.swing.event.ListSelectionEvent; @@ -248,7 +248,7 @@ public class IntegratedSelectedOptionsDialog extends DialogWrapper { @Nullable private static SVNURL realTargetUrl(final SvnVcs vcs, final WorkingCopyInfo info, final String targetBranchUrl) { - final SVNInfo svnInfo = vcs.getInfo(info.getLocalPath()); + final Info svnInfo = vcs.getInfo(info.getLocalPath()); final SVNURL svnurl = svnInfo != null ? svnInfo.getURL() : null; return (svnurl != null) && (svnurl.toString().startsWith(targetBranchUrl)) ? svnurl : null; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java index 782bd789e00e..6e9f165798a0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeCalculatorTask.java @@ -33,16 +33,11 @@ import org.jetbrains.idea.svn.actions.ChangeListsMergerFactory; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.jetbrains.idea.svn.dialogs.QuickMergeContentsVariants; import org.jetbrains.idea.svn.dialogs.SvnBranchPointsCalculator; -import org.jetbrains.idea.svn.history.SvnChangeList; -import org.jetbrains.idea.svn.history.SvnCommittedChangesProvider; -import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.jetbrains.idea.svn.history.TreeStructureNode; +import org.jetbrains.idea.svn.history.*; import org.jetbrains.idea.svn.mergeinfo.MergeChecker; import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; import org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNLogEntry; -import org.tmatesoft.svn.core.SVNLogEntryPath; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -121,13 +116,13 @@ public class MergeCalculatorTask extends BaseMergeTask implements String relativeBranch = SVNPathUtil.getRelativePath(myMergeContext.getWcInfo().getRepositoryRoot(), myMergeContext.getSourceUrl()); relativeBranch = (relativeBranch.startsWith("/") ? relativeBranch : "/" + relativeBranch); - final LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>> list = - new LinkedList<Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>>>(); + final LinkedList<Pair<SvnChangeList, LogHierarchyNode>> list = + new LinkedList<Pair<SvnChangeList, LogHierarchyNode>>(); try { committedChangesProvider.getCommittedChangesWithMergedRevisons(settings, new SvnRepositoryLocation(myMergeContext.getSourceUrl()), 0, - new PairConsumer<SvnChangeList, TreeStructureNode<SVNLogEntry>>() { + new PairConsumer<SvnChangeList, LogHierarchyNode>() { public void consume(SvnChangeList svnList, - TreeStructureNode<SVNLogEntry> tree) { + LogHierarchyNode tree) { indicator.checkCanceled(); if (sourceLatest >= svnList.getNumber()) return; list.add( @@ -144,7 +139,7 @@ public class MergeCalculatorTask extends BaseMergeTask implements indicator.setText("Checking merge information..."); // to do not go into file system while asking something on the net - for (Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair : list) { + for (Pair<SvnChangeList, LogHierarchyNode> pair : list) { final SvnChangeList svnList = pair.getFirst(); final SvnMergeInfoCache.MergeCheckResult checkResult = myMergeChecker.checkList(svnList); indicator.setText2("Processing revision " + svnList.getNumber()); @@ -204,7 +199,7 @@ public class MergeCalculatorTask extends BaseMergeTask implements // true if errors found static boolean checkListForPaths(String relativeLocal, - String relativeBranch, Pair<SvnChangeList, TreeStructureNode<SVNLogEntry>> pair) { + String relativeBranch, Pair<SvnChangeList, LogHierarchyNode> pair) { // TODO: Such filtering logic is not clear enough so far (and probably not correct for all cases - for instance when we perform merge // TODO: from branch1 to branch2 and have revision which contain merge changes from branch3 to branch1. // TODO: In this case paths of child log entries will not contain neither urls from branch1 nor from branch2 - and checkEntry() method @@ -212,9 +207,9 @@ public class MergeCalculatorTask extends BaseMergeTask implements // TODO: Why do we check entries recursively - we have a revision - set of changes in the "merge from" branch? Why do we need to check // TODO: where they came from - we want avoid some circular merges or what? Does subversion itself perform such checks or not? - final List<TreeStructureNode<SVNLogEntry>> children = pair.getSecond().getChildren(); + final List<LogHierarchyNode> children = pair.getSecond().getChildren(); boolean localChange = false; - for (TreeStructureNode<SVNLogEntry> child : children) { + for (LogHierarchyNode child : children) { if (checkForSubtree(child, relativeLocal, relativeBranch)) { localChange = true; break; @@ -228,13 +223,13 @@ public class MergeCalculatorTask extends BaseMergeTask implements } // true if errors found - private static boolean checkForSubtree(final TreeStructureNode<SVNLogEntry> tree, + private static boolean checkForSubtree(final LogHierarchyNode tree, String relativeBranch, final String localURL) { - final LinkedList<TreeStructureNode<SVNLogEntry>> queue = new LinkedList<TreeStructureNode<SVNLogEntry>>(); + final LinkedList<LogHierarchyNode> queue = new LinkedList<LogHierarchyNode>(); queue.addLast(tree); while (!queue.isEmpty()) { - final TreeStructureNode<SVNLogEntry> element = queue.removeFirst(); + final LogHierarchyNode element = queue.removeFirst(); ProgressManager.checkCanceled(); if (checkForEntry(element.getMe(), localURL, relativeBranch)) return true; @@ -248,11 +243,11 @@ public class MergeCalculatorTask extends BaseMergeTask implements // or if no changed paths in current branch, checks if at least one path in "merge from" branch // NOTE: this fails for "merge-source" log entries from other branches - when all changed paths are from some // third branch - this logic treats such log entry as local. - private static boolean checkForEntry(final SVNLogEntry entry, final String localURL, String relativeBranch) { + private static boolean checkForEntry(final LogEntry entry, final String localURL, String relativeBranch) { boolean atLeastOneUnderBranch = false; final Map map = entry.getChangedPaths(); for (Object o : map.values()) { - final SVNLogEntryPath path = (SVNLogEntryPath)o; + final LogEntryPath path = (LogEntryPath)o; if (SVNPathUtil.isAncestor(localURL, path.getPath())) { return true; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java index 94e4c9cece38..d32ea2951cd0 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/MergeClient.java @@ -3,10 +3,10 @@ package org.jetbrains.idea.svn.integrate; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -20,27 +20,27 @@ public interface MergeClient extends SvnClient { void merge(@NotNull SvnTarget source, @NotNull File destination, boolean dryRun, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException; void merge(@NotNull SvnTarget source, @NotNull SVNRevisionRange range, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException; void merge(@NotNull SvnTarget source1, @NotNull SvnTarget source2, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean useAncestry, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java index 8f534b90bb27..07e0c5bbb737 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/Merger.java @@ -28,8 +28,9 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.*; @@ -44,7 +45,7 @@ import java.util.List; public class Merger implements IMerger { protected final List<CommittedChangeList> myChangeLists; protected final File myTarget; - @Nullable private final ISVNEventHandler myHandler; + @Nullable private final ProgressTracker myHandler; protected int myCount; private final ProgressIndicator myProgressIndicator; protected CommittedChangeList myLatestProcessed; @@ -128,7 +129,7 @@ public class Merger implements IMerger { SvnTarget source = SvnTarget.fromURL(myCurrentBranchUrl); MergeClient client = myVcs.getFactory(myTarget).createMergeClient(); - client.merge(source, createRange(), myTarget, SVNDepth.INFINITY, mySvnConfig.isMergeDryRun(), isRecordOnly(), true, + client.merge(source, createRange(), myTarget, Depth.INFINITY, mySvnConfig.isMergeDryRun(), isRecordOnly(), true, mySvnConfig.getMergeOptions(), myHandler); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java index 1a58a3c80b68..aabf015f97ee 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/PointMerger.java @@ -22,11 +22,11 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.copy.CopyMoveClient; import org.jetbrains.idea.svn.delete.DeleteClient; import org.jetbrains.idea.svn.history.SvnRepositoryContentRevision; import org.jetbrains.idea.svn.update.UpdateEventHandler; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; @@ -87,7 +87,7 @@ public class PointMerger extends Merger { SvnTarget source1 = SvnTarget.fromURL(SVNURL.parseURIEncoded(beforeUrl), ((SvnRevisionNumber)before.getRevisionNumber()).getRevision()); SvnTarget source2 = SvnTarget.fromURL(SVNURL.parseURIEncoded(afterUrl), ((SvnRevisionNumber) after.getRevisionNumber()).getRevision()); - client.merge(source1, source2, afterPath, SVNDepth.FILES, true, mySvnConfig.isMergeDryRun(), false, false, mySvnConfig.getMergeOptions(), + client.merge(source1, source2, afterPath, Depth.FILES, true, mySvnConfig.isMergeDryRun(), false, false, mySvnConfig.getMergeOptions(), myHandler); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java index b4e544ba1e3d..5dd6f24b10ba 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnIntegrateChangesTask.java @@ -36,11 +36,11 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnChangeProvider; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.update.UpdateEventHandler; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.util.ArrayList; @@ -267,8 +267,8 @@ public class SvnIntegrateChangesTask extends Task.Backgroundable { private void initMergeTarget() { final File mergeInfoHolder = myMerger.getMergeInfoHolder(); if (mergeInfoHolder != null) { - final SVNStatus svnStatus = SvnUtil.getStatus(myVcs, mergeInfoHolder); - if ((svnStatus != null) && (SVNStatusType.STATUS_MODIFIED.equals(svnStatus.getPropertiesStatus()))) { + final Status svnStatus = SvnUtil.getStatus(myVcs, mergeInfoHolder); + if ((svnStatus != null) && (StatusType.STATUS_MODIFIED.equals(svnStatus.getPropertiesStatus()))) { myMergeTarget = FilePathImpl.create(mergeInfoHolder, mergeInfoHolder.isDirectory()); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java index e3635ff8827b..51cbc7c10409 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/integrate/SvnKitMergeClient.java @@ -4,11 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.diff.DiffOptions; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNDiffClient; -import org.tmatesoft.svn.core.wc.SVNDiffOptions; import org.tmatesoft.svn.core.wc.SVNRevisionRange; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -23,8 +23,8 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull File destination, boolean dryRun, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); try { @@ -39,17 +39,17 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source, @NotNull SVNRevisionRange range, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source); try { createClient(diffOptions, handler).doMerge(source.getURL(), source.getPegRevision(), Collections.singletonList(range), destination, - depth, true, force, dryRun, recordOnly); + toDepth(depth), true, force, dryRun, recordOnly); } catch (SVNException e) { throw new VcsException(e); @@ -60,19 +60,19 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { public void merge(@NotNull SvnTarget source1, @NotNull SvnTarget source2, @NotNull File destination, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean useAncestry, boolean dryRun, boolean recordOnly, boolean force, - @Nullable SVNDiffOptions diffOptions, - @Nullable ISVNEventHandler handler) throws VcsException { + @Nullable DiffOptions diffOptions, + @Nullable ProgressTracker handler) throws VcsException { assertUrl(source1); assertUrl(source2); try { createClient(diffOptions, handler).doMerge(source1.getURL(), source1.getPegRevision(), source2.getURL(), source2.getPegRevision(), - destination, depth, useAncestry, force, dryRun, recordOnly); + destination, toDepth(depth), useAncestry, force, dryRun, recordOnly); } catch (SVNException e) { throw new VcsException(e); @@ -80,11 +80,11 @@ public class SvnKitMergeClient extends BaseSvnClient implements MergeClient { } @NotNull - private SVNDiffClient createClient(@Nullable SVNDiffOptions diffOptions, @Nullable ISVNEventHandler handler) { + private SVNDiffClient createClient(@Nullable DiffOptions diffOptions, @Nullable ProgressTracker handler) { SVNDiffClient client = myVcs.getSvnKitManager().createDiffClient(); - client.setMergeOptions(diffOptions); - client.setEventHandler(handler); + client.setMergeOptions(toDiffOptions(diffOptions)); + client.setEventHandler(toEventHandler(handler)); return client; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java index abc4b5b794c2..551431dd7f16 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/CmdLockClient.java @@ -5,15 +5,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; import org.tmatesoft.svn.core.SVNErrorMessage; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -26,22 +25,22 @@ import java.util.List; public class CmdLockClient extends BaseSvnClient implements LockClient { @Override - public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ISVNEventHandler handler) throws VcsException { + public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = prepareParameters(file, force); parameters.add("--message"); parameters.add(message); CommandExecutor command = execute(myVcs, SvnTarget.fromFile(file), SvnCommandName.lock, parameters, null); - handleCommandCompletion(command, file, SVNEventAction.LOCKED, SVNEventAction.LOCK_FAILED, handler); + handleCommandCompletion(command, file, EventAction.LOCKED, EventAction.LOCK_FAILED, handler); } @Override - public void unlock(@NotNull File file, boolean force, @Nullable ISVNEventHandler handler) throws VcsException { + public void unlock(@NotNull File file, boolean force, @Nullable ProgressTracker handler) throws VcsException { List<String> parameters = prepareParameters(file, force); CommandExecutor command = execute(myVcs, SvnTarget.fromFile(file), SvnCommandName.unlock, parameters, null); - handleCommandCompletion(command, file, SVNEventAction.UNLOCKED, SVNEventAction.UNLOCK_FAILED, handler); + handleCommandCompletion(command, file, EventAction.UNLOCKED, EventAction.UNLOCK_FAILED, handler); } private static List<String> prepareParameters(@NotNull File file, boolean force) { @@ -55,9 +54,9 @@ public class CmdLockClient extends BaseSvnClient implements LockClient { private static void handleCommandCompletion(@NotNull CommandExecutor command, @NotNull File file, - @NotNull SVNEventAction success, - @NotNull SVNEventAction failure, - @Nullable ISVNEventHandler handler) throws VcsException { + @NotNull EventAction success, + @NotNull EventAction failure, + @Nullable ProgressTracker handler) throws VcsException { // just warning appears in output when can not lock/unlock file for some reason (like, that file is already locked) SVNErrorMessage error = SvnUtil.parseWarning(command.getErrorOutput()); @@ -70,17 +69,16 @@ public class CmdLockClient extends BaseSvnClient implements LockClient { } private static void invokeHandler(@NotNull File file, - @NotNull SVNEventAction action, - @Nullable ISVNEventHandler handler, + @NotNull EventAction action, + @Nullable ProgressTracker handler, @Nullable SVNErrorMessage error) throws SVNException { if (handler != null) { - handler.handleEvent(createEvent(file, action, error), 1); + handler.consume(createEvent(file, action, error)); } } - private static SVNEvent createEvent(@NotNull File file, @NotNull SVNEventAction action, @Nullable SVNErrorMessage error) { - return new SVNEvent(file, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE, null, -1, null, null, null, null, action, action, - error, null, null, null, null); + private static ProgressEvent createEvent(@NotNull File file, @NotNull EventAction action, @Nullable SVNErrorMessage error) { + return new ProgressEvent(file, -1, null, null, action, error, null); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/Lock.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/Lock.java new file mode 100644 index 000000000000..60598a91aeda --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/Lock.java @@ -0,0 +1,128 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.lock; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.SVNLock; + +import javax.xml.bind.annotation.*; +import java.util.Date; + +/** + * TODO: Probably unify with LogicalLock class + * + * @author Konstantin Kolosovsky. + */ +public class Lock { + + private final String myOwner; + private final String myComment; + private final Date myCreationDate; + @Nullable private final Date myExpirationDate; + + @Nullable + public static Lock create(@Nullable SVNLock lock) { + Lock result = null; + + if (lock != null) { + result = new Lock.Builder().setOwner(lock.getOwner()).setComment(lock.getComment()).setCreationDate(lock.getCreationDate()) + .setExpirationDate(lock.getExpirationDate()).build(); + } + + return result; + } + + public Lock(@NotNull Lock.Builder builder) { + myOwner = builder.owner; + myComment = builder.comment; + myCreationDate = builder.created; + myExpirationDate = builder.expires; + } + + public String getComment() { + return myComment; + } + + public Date getCreationDate() { + return myCreationDate; + } + + @Nullable + public Date getExpirationDate() { + return myExpirationDate; + } + + public String getOwner() { + return myOwner; + } + + @XmlAccessorType(XmlAccessType.NONE) + @XmlType(name = "lock") + @XmlRootElement(name = "lock") + public static class Builder { + + @XmlElement(name = "token") + private String token; + + @XmlElement(name = "owner") + private String owner; + + @XmlElement(name = "comment") + private String comment; + + @XmlElement(name = "created") + private Date created; + + @XmlElement(name = "expires") + @Nullable private Date expires; + + @NotNull + public Builder setToken(String token) { + this.token = token; + return this; + } + + @NotNull + public Builder setOwner(String owner) { + this.owner = owner; + return this; + } + + @NotNull + public Builder setComment(String comment) { + this.comment = comment; + return this; + } + + @NotNull + public Builder setCreationDate(Date creationDate) { + this.created = creationDate; + return this; + } + + @NotNull + public Builder setExpirationDate(@Nullable Date expirationDate) { + this.expires = expirationDate; + return this; + } + + @NotNull + public Lock build() { + return new Lock(this); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java index f36891f294b3..4a64a4e88de3 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/LockClient.java @@ -3,8 +3,8 @@ package org.jetbrains.idea.svn.lock; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -16,9 +16,9 @@ public interface LockClient extends SvnClient { void lock(@NotNull File file, boolean force, @NotNull String message, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; void unlock(@NotNull File file, boolean force, - @Nullable ISVNEventHandler handler) throws VcsException; + @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java index d11aec262b09..2db2650aab04 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/lock/SvnKitLockClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -17,7 +17,7 @@ import java.io.File; public class SvnKitLockClient extends BaseSvnClient implements LockClient { @Override - public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ISVNEventHandler handler) throws VcsException { + public void lock(@NotNull File file, boolean force, @NotNull String message, @Nullable ProgressTracker handler) throws VcsException { try { getClient(handler).doLock(new File[]{file}, force, message); } @@ -27,7 +27,7 @@ public class SvnKitLockClient extends BaseSvnClient implements LockClient { } @Override - public void unlock(@NotNull File file, boolean force, @Nullable ISVNEventHandler handler) throws VcsException { + public void unlock(@NotNull File file, boolean force, @Nullable ProgressTracker handler) throws VcsException { try { getClient(handler).doUnlock(new File[]{file}, force); } @@ -37,10 +37,10 @@ public class SvnKitLockClient extends BaseSvnClient implements LockClient { } @NotNull - private SVNWCClient getClient(@Nullable ISVNEventHandler handler) { + private SVNWCClient getClient(@Nullable ProgressTracker handler) { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); return client; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java index ead9b7ddc587..62638291b485 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/BranchInfo.java @@ -21,10 +21,10 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.util.containers.MultiMap; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.history.SvnChangeList; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNMergeInfoUtil; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -123,7 +123,7 @@ public class BranchInfo { } private SvnMergeInfoCache.MergeCheckResult checkAlive(final SvnChangeList list, final String branchPath) { - final SVNInfo info = getInfo(new File(branchPath)); + final Info info = getInfo(new File(branchPath)); if (info == null || info.getURL() == null || (! SVNPathUtil.isAncestor(myBranchUrl, info.getURL().toString()))) { return SvnMergeInfoCache.MergeCheckResult.NOT_MERGED; } @@ -179,7 +179,7 @@ public class BranchInfo { // no paths in local copy return SvnMergeInfoCache.MergeCheckResult.NOT_EXISTS; } - final SVNInfo svnInfo = getInfo(new File(branchRootPath)); + final Info svnInfo = getInfo(new File(branchRootPath)); if (svnInfo == null || svnInfo.getRevision() == null || svnInfo.getURL() == null) { return SvnMergeInfoCache.MergeCheckResult.NOT_MERGED; } @@ -238,7 +238,7 @@ public class BranchInfo { return processMergeinfoProperty(keyString, revisionAsked, mergeinfoProperty.getValue(), trunkUrl, false); } - private SVNInfo getInfo(final File pathFile) { + private Info getInfo(final File pathFile) { return myVcs.getInfo(pathFile); } @@ -255,7 +255,7 @@ public class BranchInfo { } } - final SVNInfo svnInfo = getInfo(pathFile); + final Info svnInfo = getInfo(pathFile); if (svnInfo == null || svnInfo.getRevision() == null || svnInfo.getURL() == null) { LOG.info("Svninfo for " + pathFile + " is null or not full."); return SvnMergeInfoCache.MergeCheckResult.NOT_MERGED; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java index bd2c41537091..0ea95c99c4d4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/mergeinfo/OneRecursiveShotMergeInfoWorker.java @@ -21,6 +21,7 @@ import com.intellij.openapi.vcs.AreaMap; import com.intellij.openapi.vcs.VcsException; import com.intellij.util.PairProcessor; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.internal.util.SVNMergeInfoUtil; @@ -61,7 +62,7 @@ public class OneRecursiveShotMergeInfoWorker implements MergeInfoWorker { } public void prepare() throws VcsException { - final SVNDepth depth = myMergeContext.getVcs().getSvnConfiguration().isCheckNestedForQuickMerge() ? SVNDepth.INFINITY : SVNDepth.EMPTY; + final Depth depth = Depth.allOrEmpty(myMergeContext.getVcs().getSvnConfiguration().isCheckNestedForQuickMerge()); ISVNPropertyHandler handler = new ISVNPropertyHandler() { public void handleProperty(File path, SVNPropertyData property) throws SVNException { final String key = keyFromFile(path); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java index 60ab43c3baba..e855abe1ec2e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java @@ -5,12 +5,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -63,7 +64,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { public void getProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { List<String> parameters = new ArrayList<String>(); @@ -77,7 +78,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { List<String> parameters = new ArrayList<String>(); fillListParameters(target, revision, depth, parameters, true); @@ -90,7 +91,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { public void setProperty(@NotNull File file, @NotNull String property, @Nullable SVNPropertyValue value, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean force) throws VcsException { runSetProperty(SvnTarget.fromFile(file), property, null, depth, value, force); } @@ -101,7 +102,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { currentProperties.putAll(properties); for (String propertyName : currentProperties.nameSet()) { - setProperty(file, propertyName, currentProperties.getSVNPropertyValue(propertyName), SVNDepth.EMPTY, true); + setProperty(file, propertyName, currentProperties.getSVNPropertyValue(propertyName), Depth.EMPTY, true); } } @@ -109,7 +110,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { private SVNProperties collectPropertiesToDelete(@NotNull File file) throws VcsException { final SVNProperties result = new SVNProperties(); - list(SvnTarget.fromFile(file), null, SVNDepth.EMPTY, new ISVNPropertyHandler() { + list(SvnTarget.fromFile(file), null, Depth.EMPTY, new ISVNPropertyHandler() { @Override public void handleProperty(File path, SVNPropertyData property) throws SVNException { // null indicates property will be deleted @@ -140,7 +141,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { private void runSetProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable SVNPropertyValue value, boolean force) throws VcsException { List<String> parameters = new ArrayList<String>(); @@ -169,7 +170,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { private void fillListParameters(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @NotNull List<String> parameters, boolean verbose) { CommandUtil.put(parameters, target); @@ -266,7 +267,7 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { // base should be resolved manually - could not set revision to BASE to get revision property if (SVNRevision.BASE.equals(revision)) { - SVNInfo info = myVcs.getInfo(path, SVNRevision.BASE); + Info info = myVcs.getInfo(path, SVNRevision.BASE); result = info != null ? info.getRevision().getNumber() : -1; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java index b44f7ea12e75..1b61d59c0e20 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java @@ -5,8 +5,8 @@ import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.LineSeparator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNProperties; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions; @@ -38,18 +38,18 @@ public interface PropertyClient extends SvnClient { void getProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException; void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException; void setProperty(@NotNull File file, @NotNull String property, @Nullable SVNPropertyValue value, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean force) throws VcsException; void setProperties(@NotNull File file, @NotNull SVNProperties properties) throws VcsException; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java index 64343927be11..4ad3f10afccc 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java @@ -4,6 +4,7 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.*; @@ -50,7 +51,7 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien public void getProperty(@NotNull SvnTarget target, @NotNull String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { runGetProperty(target, property, revision, depth, handler); } @@ -58,7 +59,7 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien @Override public void list(@NotNull SvnTarget target, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { runGetProperty(target, null, revision, depth, handler); } @@ -67,10 +68,10 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien public void setProperty(@NotNull File file, @NotNull String property, @Nullable SVNPropertyValue value, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean force) throws VcsException { try { - createClient().doSetProperty(file, property, value, force, depth, null, null); + createClient().doSetProperty(file, property, value, force, toDepth(depth), null, null); } catch (SVNException e) { throw new SvnBindException(e); @@ -114,15 +115,15 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien private void runGetProperty(@NotNull SvnTarget target, @Nullable String property, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, @Nullable ISVNPropertyHandler handler) throws VcsException { SVNWCClient client = createClient(); try { if (target.isURL()) { - client.doGetProperty(target.getURL(), property, target.getPegRevision(), revision, depth, handler); + client.doGetProperty(target.getURL(), property, target.getPegRevision(), revision, toDepth(depth), handler); } else { - client.doGetProperty(target.getFile(), property, target.getPegRevision(), revision, depth, handler, null); + client.doGetProperty(target.getFile(), property, target.getPegRevision(), revision, toDepth(depth), handler, null); } } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java index aef5ae942687..a57e24b525d7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/CmdRevertClient.java @@ -4,15 +4,11 @@ import com.intellij.openapi.vcs.VcsException; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.api.FileStatusResultParser; +import org.jetbrains.idea.svn.api.*; import org.jetbrains.idea.svn.commandLine.CommandExecutor; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -32,7 +28,7 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { private static final Pattern CHANGED_PATH = Pattern.compile(STATUS + PATH + OPTIONAL_COMMENT); @Override - public void revert(@NotNull File[] paths, @Nullable SVNDepth depth, @Nullable ISVNEventHandler handler) throws VcsException { + public void revert(@NotNull File[] paths, @Nullable Depth depth, @Nullable ProgressTracker handler) throws VcsException { if (paths.length > 0) { List<String> parameters = prepareParameters(paths, depth); @@ -46,7 +42,7 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { } } - private static List<String> prepareParameters(File[] paths, SVNDepth depth) { + private static List<String> prepareParameters(File[] paths, Depth depth) { ArrayList<String> parameters = new ArrayList<String>(); CommandUtil.put(parameters, paths); @@ -55,9 +51,9 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { return parameters; } - private static class RevertStatusConvertor implements Convertor<Matcher, SVNEvent> { + private static class RevertStatusConvertor implements Convertor<Matcher, ProgressEvent> { - public SVNEvent convert(@NotNull Matcher matcher) { + public ProgressEvent convert(@NotNull Matcher matcher) { String statusMessage = matcher.group(1); String path = matcher.group(2); @@ -65,17 +61,17 @@ public class CmdRevertClient extends BaseSvnClient implements RevertClient { } @Nullable - public static SVNEventAction createAction(@NotNull String code) { - SVNEventAction result = null; + public static EventAction createAction(@NotNull String code) { + EventAction result = null; if ("Reverted".equals(code)) { - result = SVNEventAction.REVERT; + result = EventAction.REVERT; } else if ("Failed to revert".equals(code)) { - result = SVNEventAction.FAILED_REVERT; + result = EventAction.FAILED_REVERT; } else if ("Skipped".equals(code)) { - result = SVNEventAction.SKIP; + result = EventAction.SKIP; } return result; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java index 053de373bc0a..5f0d26bb09aa 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/RevertClient.java @@ -3,9 +3,9 @@ package org.jetbrains.idea.svn.revert; import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; @@ -14,5 +14,5 @@ import java.io.File; */ public interface RevertClient extends SvnClient { - void revert(@NotNull File[] paths, @Nullable SVNDepth depth, @Nullable ISVNEventHandler handler) throws VcsException; + void revert(@NotNull File[] paths, @Nullable Depth depth, @Nullable ProgressTracker handler) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java index ea88ebcc7c32..06593f472106 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/revert/SvnKitRevertClient.java @@ -4,9 +4,9 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -17,12 +17,12 @@ import java.io.File; public class SvnKitRevertClient extends BaseSvnClient implements RevertClient { @Override - public void revert(@NotNull File[] paths, @Nullable SVNDepth depth, @Nullable ISVNEventHandler handler) throws VcsException { + public void revert(@NotNull File[] paths, @Nullable Depth depth, @Nullable ProgressTracker handler) throws VcsException { SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { - client.doRevert(paths, depth, null); + client.doRevert(paths, toDepth(depth), null); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java index 01c86eb1054b..237d05bd5f7a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/rollback/SvnRollbackEnvironment.java @@ -28,6 +28,12 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; import org.tmatesoft.svn.core.wc.*; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -75,15 +81,15 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { checker.gather(changes); exceptions.addAll(checker.getExceptions()); - ISVNEventHandler revertHandler = new ISVNEventHandler() { - public void handleEvent(SVNEvent event, double progress) { - if (event.getAction() == SVNEventAction.REVERT) { + ProgressTracker revertHandler = new ProgressTracker() { + public void consume(ProgressEvent event) { + if (event.getAction() == EventAction.REVERT) { final File file = event.getFile(); if (file != null) { listener.accept(file); } } - if (event.getAction() == SVNEventAction.FAILED_REVERT) { + if (event.getAction() == EventAction.FAILED_REVERT) { exceptions.add(new VcsException("Revert failed")); } } @@ -150,7 +156,7 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { final File source = entry.getKey(); final ThroughRenameInfo info = entry.getValue(); if (info.isVersioned()) { - mySvnVcs.getFactory(source).createPropertyClient().list(SvnTarget.fromFile(source), SVNRevision.WORKING, SVNDepth.EMPTY, handler); + mySvnVcs.getFactory(source).createPropertyClient().list(SvnTarget.fromFile(source), SVNRevision.WORKING, Depth.EMPTY, handler); } if (source.isDirectory()) { if (! FileUtil.filesEqual(info.getTo(), info.getFirstTo())) { @@ -225,8 +231,8 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { catch (IOException e) { exceptions.add(new VcsException(e)); } - catch (SVNException e) { - exceptions.add(new VcsException(e)); + catch (VcsException e) { + exceptions.add(e); } } } @@ -248,10 +254,10 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { private static class Reverter { @NotNull private final SvnVcs myVcs; - private ISVNEventHandler myHandler; + private ProgressTracker myHandler; private final List<VcsException> myExceptions; - private Reverter(@NotNull SvnVcs vcs, ISVNEventHandler handler, List<VcsException> exceptions) { + private Reverter(@NotNull SvnVcs vcs, ProgressTracker handler, List<VcsException> exceptions) { myVcs = vcs; myHandler = handler; myExceptions = exceptions; @@ -261,7 +267,7 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { if (files.length == 0) return; try { // Files passed here are split into groups by root and working copy format - thus we could determine factory based on first file - myVcs.getFactory(files[0]).createRevertClient().revert(files, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, myHandler); + myVcs.getFactory(files[0]).createRevertClient().revert(files, Depth.allOrEmpty(recursive), myHandler); } catch (VcsException e) { processRevertError(e); @@ -298,9 +304,9 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { } private void revertFileOrDir(File file) throws SVNException, VcsException { - SVNInfo info = mySvnVcs.getInfo(file); + Info info = mySvnVcs.getInfo(file); if (info != null) { - if (info.getKind() == SVNNodeKind.FILE) { + if (info.isFile()) { doRevert(file, false); } else { if (SVNProperty.SCHEDULE_ADD.equals(info.getSchedule())) { @@ -321,17 +327,17 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { } private void doRevert(@NotNull File path, boolean recursive) throws VcsException { - mySvnVcs.getFactory(path).createRevertClient().revert(new File[]{path}, SVNDepth.fromRecurse(recursive), null); + mySvnVcs.getFactory(path).createRevertClient().revert(new File[]{path}, Depth.allOrFiles(recursive), null); } - private boolean is17OrGreaterCopy(final File file, final SVNInfo info) throws VcsException { + private boolean is17OrGreaterCopy(final File file, final Info info) throws VcsException { final RootsToWorkingCopies copies = mySvnVcs.getRootsToWorkingCopies(); WorkingCopy copy = copies.getMatchingCopy(info.getURL()); if (copy == null) { WorkingCopyFormat format = mySvnVcs.getWorkingCopyFormat(file); - return !WorkingCopyFormat.UNKNOWN.equals(format) && format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN); + return format.isOrGreater(WorkingCopyFormat.ONE_DOT_SEVEN); } else { return copy.is17Copy(); } @@ -614,6 +620,9 @@ public class SvnRollbackEnvironment extends DefaultRollbackEnvironment { catch (SVNException e) { myExceptions.add(new VcsException(e)); } + catch (SvnBindException e) { + myExceptions.add(e); + } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java index 235f5d1ecddc..4030c83005ea 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/CmdStatusClient.java @@ -18,18 +18,18 @@ package org.jetbrains.idea.svn.status; import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.CharsetToolkit; import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.commandLine.CommandExecutor; -import org.jetbrains.idea.svn.commandLine.CommandUtil; -import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.jetbrains.idea.svn.commandLine.SvnExceptionWrapper; -import org.tmatesoft.svn.core.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.*; +import org.jetbrains.idea.svn.info.Info; +import org.tmatesoft.svn.core.SVNErrorCode; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; import org.tmatesoft.svn.core.wc.*; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -52,75 +52,38 @@ import java.util.*; public class CmdStatusClient extends BaseSvnClient implements StatusClient { @Override - public long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, ISVNStatusHandler handler) - throws SVNException { - return doStatus(path, recursive, remote, reportAll, includeIgnored, false, handler); - } - - @Override - public long doStatus(File path, - boolean recursive, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return doStatus(path, SVNRevision.UNDEFINED, recursive, remote, reportAll, includeIgnored, collectParentExternals, handler); - } - - @Override - public long doStatus(File path, - SVNRevision revision, - boolean recursive, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return doStatus(path, revision, recursive ? SVNDepth.INFINITY : SVNDepth.EMPTY, remote, reportAll, includeIgnored, - collectParentExternals, handler, null); - } - - @Override public long doStatus(final File path, final SVNRevision revision, - final SVNDepth depth, + final Depth depth, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, - final ISVNStatusHandler handler, - final Collection changeLists) throws SVNException { + final StatusConsumer handler, + final Collection changeLists) throws SvnBindException { File base = path.isDirectory() ? path : path.getParentFile(); base = CommandUtil.correctUpToExistingParent(base); - final SVNInfo infoBase = myFactory.createInfoClient().doInfo(base, revision); + final Info infoBase = myFactory.createInfoClient().doInfo(base, revision); List<String> parameters = new ArrayList<String>(); putParameters(parameters, path, depth, remote, reportAll, includeIgnored, changeLists); - CommandExecutor command; - try { - command = execute(myVcs, SvnTarget.fromFile(path), SvnCommandName.st, parameters, null); - } - catch (VcsException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); - } + CommandExecutor command = execute(myVcs, SvnTarget.fromFile(path), SvnCommandName.st, parameters, null); parseResult(path, revision, handler, base, infoBase, command); return 0; } private void parseResult(final File path, SVNRevision revision, - ISVNStatusHandler handler, + StatusConsumer handler, File base, - SVNInfo infoBase, - CommandExecutor command) throws SVNException { + Info infoBase, + CommandExecutor command) throws SvnBindException { String result = command.getOutput(); if (StringUtil.isEmptyOrSpaces(result)) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "Status request returned nothing for command: " + - command.getCommandText())); + throw new SvnBindException("Status request returned nothing for command: " + command.getCommandText()); } try { @@ -130,8 +93,7 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { parser.parse(new ByteArrayInputStream(result.trim().getBytes(CharsetToolkit.UTF8_CHARSET)), svnHandl[0]); if (!svnHandl[0].isAnythingReported()) { if (!SvnUtil.isSvnVersioned(myVcs, path)) { - throw new SVNException( - SVNErrorMessage.create(SVNErrorCode.WC_NOT_DIRECTORY, "Command - " + command.getCommandText() + ". Result - " + result)); + throw new SvnBindException(SVNErrorCode.WC_NOT_DIRECTORY, "Command - " + command.getCommandText() + ". Result - " + result); } else { // return status indicating "NORMAL" state // typical output would be like @@ -142,38 +104,42 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { PortableStatus status = new PortableStatus(); status.setPath(path.getAbsolutePath()); - status.setContentsStatus(SVNStatusType.STATUS_NORMAL); - status.setInfoGetter(new Getter<SVNInfo>() { + status.setContentsStatus(StatusType.STATUS_NORMAL); + status.setInfoGetter(new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return createInfoGetter(null).convert(path); } }); - handler.handleStatus(status); + try { + handler.consume(status); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } } } catch (SvnExceptionWrapper e) { - throw (SVNException) e.getCause(); + throw new SvnBindException(e.getCause()); } catch (IOException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (ParserConfigurationException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } catch (SAXException e) { // status parsing errors are logged separately as sometimes there are parsing errors connected to terminal output handling. // these errors primarily occur when status output is rather large. // and status output could be large, for instance, when working copy is locked (seems that each file is listed in status output). command.logCommand(); - - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e), e); + throw new SvnBindException(e); } } private static void putParameters(@NotNull List<String> parameters, @NotNull File path, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean remote, boolean reportAll, boolean includeIgnored, @@ -189,33 +155,33 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { } public SvnStatusHandler createStatusHandler(final SVNRevision revision, - final ISVNStatusHandler handler, + final StatusConsumer handler, final File base, - final SVNInfo infoBase, final SvnStatusHandler[] svnHandl) { + final Info infoBase, final SvnStatusHandler[] svnHandl) { final SvnStatusHandler.ExternalDataCallback callback = createStatusCallback(handler, base, infoBase, svnHandl); return new SvnStatusHandler(callback, base, createInfoGetter(revision)); } - private Convertor<File, SVNInfo> createInfoGetter(final SVNRevision revision) { - return new Convertor<File, SVNInfo>() { + private Convertor<File, Info> createInfoGetter(final SVNRevision revision) { + return new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { return myFactory.createInfoClient().doInfo(o, revision); } - catch (SVNException e) { + catch (SvnBindException e) { throw new SvnExceptionWrapper(e); } } }; } - public static SvnStatusHandler.ExternalDataCallback createStatusCallback(final ISVNStatusHandler handler, + public static SvnStatusHandler.ExternalDataCallback createStatusCallback(final StatusConsumer handler, final File base, - final SVNInfo infoBase, + final Info infoBase, final SvnStatusHandler[] svnHandl) { - final Map<File, SVNInfo> externalsMap = new HashMap<File, SVNInfo>(); + final Map<File, Info> externalsMap = new HashMap<File, Info>(); final String[] changelistName = new String[1]; return new SvnStatusHandler.ExternalDataCallback() { @@ -225,7 +191,7 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { pending.setChangelistName(changelistName[0]); try { //if (infoBase != null) { - SVNInfo baseInfo = infoBase; + Info baseInfo = infoBase; File baseFile = base; final File pendingFile = new File(pending.getPath()); if (! externalsMap.isEmpty()) { @@ -250,10 +216,10 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { } pending.setURL(SVNURL.parseURIEncoded(append)); } - if (SVNStatusType.STATUS_EXTERNAL.equals(pending.getNodeStatus())) { + if (StatusType.STATUS_EXTERNAL.equals(pending.getNodeStatus())) { externalsMap.put(pending.getFile(), pending.getInfo()); } - handler.handleStatus(pending); + handler.consume(pending); } catch (SVNException e) { throw new SvnExceptionWrapper(e); @@ -268,16 +234,11 @@ public class CmdStatusClient extends BaseSvnClient implements StatusClient { } @Override - public SVNStatus doStatus(File path, boolean remote) throws SVNException { - return doStatus(path, remote, false); - } - - @Override - public SVNStatus doStatus(File path, boolean remote, boolean collectParentExternals) throws SVNException { - final SVNStatus[] svnStatus = new SVNStatus[1]; - doStatus(path, SVNRevision.UNDEFINED, SVNDepth.EMPTY, remote, false, false, collectParentExternals, new ISVNStatusHandler() { + public Status doStatus(File path, boolean remote) throws SvnBindException { + final Status[] svnStatus = new Status[1]; + doStatus(path, SVNRevision.UNDEFINED, Depth.EMPTY, remote, false, false, false, new StatusConsumer() { @Override - public void handleStatus(SVNStatus status) throws SVNException { + public void consume(Status status) throws SVNException { svnStatus[0] = status; } }, null); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java index e78c0cd57316..4ed2d78f29ab 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/PortableStatus.java @@ -15,10 +15,13 @@ */ package org.jetbrains.idea.svn.status; -import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Getter; -import org.tmatesoft.svn.core.SVNLock; -import org.tmatesoft.svn.core.SVNNodeKind; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.*; @@ -27,18 +30,18 @@ import java.util.Date; import java.util.Map; /** + * TODO: Merge PortableStatus and Status to single class. + * * Created by IntelliJ IDEA. * User: Irina.Chernushina * Date: 1/24/12 * Time: 12:29 PM */ -public class PortableStatus extends SVNStatus { - - private static final Logger LOG = Logger.getInstance(PortableStatus.class); +public class PortableStatus extends Status { private boolean myConflicted; - private Getter<SVNInfo> myInfoGetter; - private SVNInfo myInfo; + private Getter<Info> myInfoGetter; + private Info myInfo; private String myPath; private boolean myFileExists; @@ -81,42 +84,42 @@ public class PortableStatus extends SVNStatus { */ public PortableStatus(SVNURL url, File file, - SVNNodeKind kind, + @NotNull NodeKind kind, SVNRevision revision, SVNRevision committedRevision, Date committedDate, String author, - SVNStatusType contentsStatus, - SVNStatusType propertiesStatus, - SVNStatusType remoteContentsStatus, - SVNStatusType remotePropertiesStatus, + StatusType contentsStatus, + StatusType propertiesStatus, + StatusType remoteContentsStatus, + StatusType remotePropertiesStatus, boolean isLocked, boolean isCopied, boolean isSwitched, boolean isFileExternal, - SVNLock remoteLock, - SVNLock localLock, + @Nullable Lock remoteLock, + @Nullable Lock localLock, Map entryProperties, String changelistName, int wcFormatVersion, boolean isConflicted, - Getter<SVNInfo> infoGetter) { - super(url, file, kind, revision, committedRevision, committedDate, author, contentsStatus, propertiesStatus, remoteContentsStatus, - remotePropertiesStatus, isLocked, isCopied, isSwitched, isFileExternal, null, null, null, null, null, null, remoteLock, - localLock, entryProperties, changelistName, wcFormatVersion, null); + Getter<Info> infoGetter) { + super(url, file, kind, revision, committedRevision, contentsStatus, propertiesStatus, remoteContentsStatus, + remotePropertiesStatus, isLocked, isCopied, isSwitched, null, remoteLock, + localLock, changelistName, null); myConflicted = isConflicted; - myInfoGetter = infoGetter == null ? new Getter<SVNInfo>() { + myInfoGetter = infoGetter == null ? new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return null; } } : infoGetter; } public PortableStatus() { - myInfoGetter = new Getter<SVNInfo>() { + myInfoGetter = new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return null; } }; @@ -124,22 +127,12 @@ public class PortableStatus extends SVNStatus { } @Override - public int getWorkingCopyFormat() { - LOG.error("Do not use working copy format detection through status"); - return 0; - } - - @Override public void setIsConflicted(boolean isConflicted) { myConflicted = isConflicted; super.setIsConflicted(isConflicted); } - public void setConflicted(boolean conflicted) { - myConflicted = conflicted; - } - - public void setInfoGetter(Getter<SVNInfo> infoGetter) { + public void setInfoGetter(Getter<Info> infoGetter) { myInfoGetter = infoGetter; } @@ -148,10 +141,10 @@ public class PortableStatus extends SVNStatus { return myConflicted; } - private SVNInfo initInfo() { + private Info initInfo() { if (myInfo == null) { - final SVNStatusType contentsStatus = getContentsStatus(); - if (contentsStatus == null || SVNStatusType.UNKNOWN.equals(contentsStatus)) { + final StatusType contentsStatus = getContentsStatus(); + if (contentsStatus == null || StatusType.UNKNOWN.equals(contentsStatus)) { return null; } myInfo = myInfoGetter.get(); @@ -159,14 +152,15 @@ public class PortableStatus extends SVNStatus { return myInfo; } - public SVNInfo getInfo() { + public Info getInfo() { return initInfo(); } @Override - public SVNNodeKind getKind() { + @NotNull + public NodeKind getKind() { if (myFileExists) return super.getKind(); - final SVNInfo info = initInfo(); + final Info info = initInfo(); if (info != null) { return info.getKind(); } @@ -174,68 +168,6 @@ public class PortableStatus extends SVNStatus { } /** - * Gets the temporary file that contains all latest changes from the - * repository which led to a conflict with local changes. This file is at - * the HEAD revision. - * - * @return an autogenerated temporary file just as it is in the latest - * revision in the repository - */ - @Override - public File getConflictNewFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getConflictNewFile(); - } - - /** - * Gets the temporary BASE revision file of that working file that is - * currently in conflict with changes received from the repository. This - * file does not contain the latest user's modifications, only 'pristine' - * contents. - * - * @return an autogenerated temporary file just as the conflicting file was - * before any modifications to it - */ - @Override - public File getConflictOldFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getConflictOldFile(); - } - - /** - * Gets the temporary <i>'.mine'</i> file with all current local changes to - * the original file. That is if the file item is in conflict with changes - * that came during an update this temporary file is created to get the - * snapshot of the user's file with only the user's local modifications and - * nothing more. - * - * @return an autogenerated temporary file with only the user's - * modifications - */ - @Override - public File getConflictWrkFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getConflictWrkFile(); - } - - /** - * Gets the <i>'.prej'</i> file containing details on properties conflicts. - * If the item's properties are in conflict with those that came during an - * update this file will contain a conflict description. - * - * @return the properties conflicts file - */ - @Override - public File getPropRejectFile() { - if (! isConflicted()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getPropConflictFile(); - } - - /** * Gets the URL (repository location) of the ancestor from which the item * was copied. That is when the item is added with history. * @@ -244,7 +176,7 @@ public class PortableStatus extends SVNStatus { @Override public String getCopyFromURL() { if (! isCopied()) return null; - final SVNInfo info = initInfo(); + final Info info = initInfo(); if (info == null) return null; SVNURL url = initInfo().getCopyFromURL(); return url == null ? null : url.toString(); @@ -255,7 +187,7 @@ public class PortableStatus extends SVNStatus { SVNURL url = super.getURL(); if (url == null) { - SVNInfo info = initInfo(); + Info info = initInfo(); url = info != null ? info.getURL() : url; } @@ -267,7 +199,7 @@ public class PortableStatus extends SVNStatus { SVNURL url = super.getRepositoryRootURL(); if (url == null) { - SVNInfo info = initInfo(); + Info info = initInfo(); url = info != null ? info.getRepositoryRootURL() : url; } @@ -279,7 +211,7 @@ public class PortableStatus extends SVNStatus { File file = super.getFile(); if (file == null) { - SVNInfo info = initInfo(); + Info info = initInfo(); file = info != null ? info.getFile() : file; } @@ -291,28 +223,15 @@ public class PortableStatus extends SVNStatus { final SVNRevision revision = super.getRevision(); if (revision != null && revision.isValid()) return revision; - final SVNStatusType status = getContentsStatus(); - if (SVNStatusType.STATUS_NONE.equals(status) || SVNStatusType.STATUS_UNVERSIONED.equals(status) || - SVNStatusType.STATUS_ADDED.equals(status)) return revision; + final StatusType status = getContentsStatus(); + if (StatusType.STATUS_NONE.equals(status) || StatusType.STATUS_UNVERSIONED.equals(status) || + StatusType.STATUS_ADDED.equals(status)) return revision; - final SVNInfo info = initInfo(); + final Info info = initInfo(); return info == null ? revision : info.getRevision(); } /** - * Gets the revision of the item's ancestor from which the item was copied - * (the item is added with history). - * - * @return the ancestor's revision - */ - @Override - public SVNRevision getCopyFromRevision() { - if (! isCopied()) return null; - final SVNInfo info = initInfo(); - return info == null ? null : info.getCopyFromRevision(); - } - - /** * Returns a tree conflict description. * * @return tree conflict description; <code>null</code> if no conflict @@ -320,9 +239,10 @@ public class PortableStatus extends SVNStatus { * @since 1.3 */ @Override - public SVNTreeConflictDescription getTreeConflict() { + @Nullable + public TreeConflictDescription getTreeConflict() { if (! isConflicted()) return null; - final SVNInfo info = initInfo(); + final Info info = initInfo(); return info == null ? null : info.getTreeConflict(); } @@ -334,7 +254,7 @@ public class PortableStatus extends SVNStatus { return myPath; } - public void setKind(boolean exists, SVNNodeKind kind) { + public void setKind(boolean exists, @NotNull NodeKind kind) { myFileExists = exists; setKind(kind); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/Status.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/Status.java new file mode 100644 index 000000000000..7fc81510076f --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/Status.java @@ -0,0 +1,313 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.status; + +import com.intellij.openapi.util.Condition; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.lock.Lock; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.wc.SVNRevision; +import org.tmatesoft.svn.core.wc.SVNStatus; + +import java.io.File; + +/** + * TODO: Could also inherit BaseNodeDescription when myKind becomes final. + * + * @author Konstantin Kolosovsky. + */ +public class Status { + private SVNURL myURL; + private File myFile; + private @NotNull NodeKind myKind; + private SVNRevision myRevision; + private SVNRevision myCommittedRevision; + private StatusType myContentsStatus; + private StatusType myPropertiesStatus; + private StatusType myRemoteContentsStatus; + private StatusType myRemoteNodeStatus; + private StatusType myRemotePropertiesStatus; + private boolean myIsLocked; + private boolean myIsCopied; + private boolean myIsSwitched; + private String myCopyFromURL; + @Nullable private Lock myRemoteLock; + @Nullable private Lock myLocalLock; + private SVNRevision myRemoteRevision; + private String myChangelistName; + @Nullable private TreeConflictDescription myTreeConflict; + private boolean myIsConflicted; + + private StatusType myNodeStatus; + private SVNURL myRepositoryRootURL; + + @Nullable + public static Status create(@Nullable SVNStatus status) { + Status result = null; + + if (status != null) { + result = + new Status(status.getURL(), status.getFile(), NodeKind.from(status.getKind()), status.getRevision(), status.getCommittedRevision(), + StatusType.from(status.getContentsStatus()), StatusType.from(status.getPropertiesStatus()), + StatusType.from(status.getRemoteContentsStatus()), StatusType.from(status.getRemotePropertiesStatus()), + status.isLocked(), status.isCopied(), status.isSwitched(), status.getCopyFromURL(), Lock.create(status.getRemoteLock()), + Lock.create(status.getLocalLock()), status.getChangelistName(), + TreeConflictDescription.create(status.getTreeConflict())); + result.setIsConflicted(status.isConflicted()); + result.setNodeStatus(StatusType.from(status.getNodeStatus())); + result.setRemoteNodeStatus(StatusType.from(status.getRemoteNodeStatus())); + result.setRemoteRevision(status.getRemoteRevision()); + result.setRepositoryRootURL(status.getRepositoryRootURL()); + } + + return result; + } + + public Status(SVNURL url, + File file, + @NotNull NodeKind kind, + SVNRevision revision, + SVNRevision committedRevision, + StatusType contentsStatus, + StatusType propertiesStatus, + StatusType remoteContentsStatus, + StatusType remotePropertiesStatus, + boolean isLocked, + boolean isCopied, + boolean isSwitched, + String copyFromURL, + @Nullable Lock remoteLock, + @Nullable Lock localLock, + String changelistName, + @Nullable TreeConflictDescription treeConflict) { + myURL = url; + myFile = file; + myKind = kind; + myRevision = revision == null ? SVNRevision.UNDEFINED : revision; + myCommittedRevision = committedRevision == null ? SVNRevision.UNDEFINED : committedRevision; + myContentsStatus = contentsStatus == null ? StatusType.STATUS_NONE : contentsStatus; + myPropertiesStatus = propertiesStatus == null ? StatusType.STATUS_NONE : propertiesStatus; + myRemoteContentsStatus = remoteContentsStatus == null ? StatusType.STATUS_NONE : remoteContentsStatus; + myRemotePropertiesStatus = remotePropertiesStatus == null ? StatusType.STATUS_NONE : remotePropertiesStatus; + myRemoteNodeStatus = StatusType.STATUS_NONE; + myIsLocked = isLocked; + myIsCopied = isCopied; + myIsSwitched = isSwitched; + myCopyFromURL = copyFromURL; + myRemoteLock = remoteLock; + myLocalLock = localLock; + myChangelistName = changelistName; + myTreeConflict = treeConflict; + myRemoteRevision = SVNRevision.UNDEFINED; + } + + public Status() { + setRevision(SVNRevision.UNDEFINED); + myRemoteRevision = SVNRevision.UNDEFINED; + } + + public SVNURL getURL() { + return myURL; + } + + public File getFile() { + return myFile; + } + + @NotNull + public NodeKind getKind() { + return myKind; + } + + public SVNRevision getRevision() { + return myRevision; + } + + public SVNRevision getCommittedRevision() { + return myCommittedRevision; + } + + public StatusType getContentsStatus() { + return myContentsStatus; + } + + public StatusType getPropertiesStatus() { + return myPropertiesStatus; + } + + public StatusType getRemoteContentsStatus() { + return myRemoteContentsStatus; + } + + public StatusType getRemotePropertiesStatus() { + return myRemotePropertiesStatus; + } + + public boolean is(@NotNull StatusType type) { + return type.equals(getNodeStatus()) || type.equals(getContentsStatus()); + } + + public boolean is(@NotNull StatusType... types) { + return ContainerUtil.or(types, new Condition<StatusType>() { + @Override + public boolean value(StatusType type) { + return is(type); + } + }); + } + + public boolean isLocked() { + return myIsLocked; + } + + public boolean isCopied() { + return myIsCopied; + } + + public boolean isSwitched() { + return myIsSwitched; + } + + public String getCopyFromURL() { + return myCopyFromURL; + } + + @Nullable + public Lock getRemoteLock() { + return myRemoteLock; + } + + @Nullable + public Lock getLocalLock() { + return myLocalLock; + } + + public SVNRevision getRemoteRevision() { + return myRemoteRevision; + } + + public String getChangelistName() { + return myChangelistName; + } + + @Nullable + public TreeConflictDescription getTreeConflict() { + return myTreeConflict; + } + + public boolean isConflicted() { + return myIsConflicted; + } + + public StatusType getRemoteNodeStatus() { + return myRemoteNodeStatus; + } + + public StatusType getNodeStatus() { + if (myNodeStatus == null) { + return myContentsStatus; + } + return myNodeStatus; + } + + public SVNURL getRepositoryRootURL() { + return myRepositoryRootURL; + } + + public void setURL(SVNURL uRL) { + myURL = uRL; + } + + public void setFile(File file) { + myFile = file; + } + + public void setKind(@NotNull NodeKind kind) { + myKind = kind; + } + + public void setRevision(SVNRevision revision) { + myRevision = revision; + } + + public void setCommittedRevision(SVNRevision committedRevision) { + myCommittedRevision = committedRevision; + } + + public void setContentsStatus(StatusType statusType) { + myContentsStatus = statusType; + } + + public void setPropertiesStatus(StatusType propertiesStatus) { + myPropertiesStatus = propertiesStatus; + } + + public void setRemoteContentsStatus(StatusType remoteContentsStatus) { + myRemoteContentsStatus = remoteContentsStatus; + } + + public void setRemotePropertiesStatus(StatusType remotePropertiesStatus) { + myRemotePropertiesStatus = remotePropertiesStatus; + } + + public void setIsLocked(boolean isLocked) { + myIsLocked = isLocked; + } + + public void setIsCopied(boolean isCopied) { + myIsCopied = isCopied; + } + + public void setIsSwitched(boolean isSwitched) { + myIsSwitched = isSwitched; + } + + public void setRemoteLock(@Nullable Lock remoteLock) { + myRemoteLock = remoteLock; + } + + public void setLocalLock(@Nullable Lock localLock) { + myLocalLock = localLock; + } + + public void setChangelistName(String changelistName) { + myChangelistName = changelistName; + } + + public void setIsConflicted(boolean isConflicted) { + myIsConflicted = isConflicted; + } + + public void setRemoteNodeStatus(StatusType remoteNodeStatus) { + myRemoteNodeStatus = remoteNodeStatus; + } + + public void setNodeStatus(StatusType nodeStatus) { + myNodeStatus = nodeStatus; + } + + public void setRepositoryRootURL(SVNURL repositoryRootURL) { + myRepositoryRootURL = repositoryRootURL; + } + + public void setRemoteRevision(SVNRevision remoteRevision) { + myRemoteRevision = remoteRevision; + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java index 4b43e6c51211..9bbf74b62084 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusClient.java @@ -15,12 +15,11 @@ */ package org.jetbrains.idea.svn.status; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; import java.io.File; import java.util.Collection; @@ -32,13 +31,20 @@ import java.util.Collection; * Time: 9:46 AM */ public interface StatusClient extends SvnClient { - long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, - boolean includeIgnored, ISVNStatusHandler handler) throws SVNException; - long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, ISVNStatusHandler handler) throws SVNException; - long doStatus(File path, SVNRevision revision, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, ISVNStatusHandler handler) throws SVNException; - long doStatus(File path, SVNRevision revision, SVNDepth depth, boolean remote, boolean reportAll, - boolean includeIgnored, boolean collectParentExternals, ISVNStatusHandler handler, - Collection changeLists) throws SVNException; - SVNStatus doStatus( File path, boolean remote) throws SVNException; - SVNStatus doStatus(File path, boolean remote, boolean collectParentExternals) throws SVNException; + + /** + * TODO: Return value is never used by other code + */ + long doStatus(File path, + SVNRevision revision, + Depth depth, + boolean remote, + boolean reportAll, + boolean includeIgnored, + boolean collectParentExternals, + StatusConsumer handler, + Collection changeLists) throws SvnBindException; + + @Nullable + Status doStatus(File path, boolean remote) throws SvnBindException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusConsumer.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusConsumer.java new file mode 100644 index 000000000000..ca82bdc85f13 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusConsumer.java @@ -0,0 +1,25 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.status; + +import com.intellij.util.ThrowableConsumer; +import org.tmatesoft.svn.core.SVNException; + +/** + * @author Konstantin Kolosovsky. + */ +public interface StatusConsumer extends ThrowableConsumer<Status, SVNException> { +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusType.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusType.java new file mode 100644 index 000000000000..ff1c3a8a342c --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/StatusType.java @@ -0,0 +1,110 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.status; + +import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.tmatesoft.svn.core.wc.SVNStatusType; + +import java.util.Map; + +/** + * @author Konstantin Kolosovsky. + */ +public enum StatusType { + + // currently used to represent some not used status types from SVNKit + UNUSED("unused"), + + INAPPLICABLE("inapplicable"), + UNKNOWN("unknown"), + UNCHANGED("unchanged"), + MISSING("missing"), + OBSTRUCTED("obstructed"), + CHANGED("changed"), + MERGED("merged"), + CONFLICTED("conflicted"), + + STATUS_NONE("none"), + STATUS_NORMAL("normal", ' '), + STATUS_MODIFIED("modified", 'M'), + STATUS_ADDED("added", 'A'), + STATUS_DELETED("deleted", 'D'), + STATUS_UNVERSIONED("unversioned", '?'), + STATUS_MISSING("missing", '!'), + STATUS_REPLACED("replaced", 'R'), + STATUS_CONFLICTED("conflicted", 'C'), + STATUS_OBSTRUCTED("obstructed", '~'), + STATUS_IGNORED("ignored", 'I'), + // directory is incomplete - checkout or update was interrupted + STATUS_INCOMPLETE("incomplete", '!'), + STATUS_EXTERNAL("external", 'X'); + + private static final String STATUS_PREFIX = "STATUS_"; + + @NotNull private static final Map<String, StatusType> ourOtherStatusTypes = ContainerUtil.newHashMap(); + @NotNull private static final Map<String, StatusType> ourStatusTypesForStatusOperation = ContainerUtil.newHashMap(); + + static { + for (StatusType action : StatusType.values()) { + register(action); + } + } + + private String myName; + private char myCode; + + StatusType(String name) { + this(name, ' '); + } + + StatusType(String name, char code) { + myName = name; + myCode = code; + } + + public char getCode() { + return myCode; + } + + public String toString() { + return myName; + } + + private static void register(@NotNull StatusType action) { + (action.name().startsWith(STATUS_PREFIX) ? ourStatusTypesForStatusOperation : ourOtherStatusTypes).put(action.myName, action); + } + + @NotNull + public static StatusType from(@NotNull SVNStatusType type) { + StatusType result = ourOtherStatusTypes.get(type.toString()); + + // CONFLICTED, OBSTRUCTED, MISSING status types have corresponding STATUS_* analogs with same names - so additional check added when + // converting from SVNKit values + if (type != SVNStatusType.CONFLICTED && type != SVNStatusType.OBSTRUCTED && type != SVNStatusType.MISSING) { + result = ObjectUtils.chooseNotNull(ourStatusTypesForStatusOperation.get(type.toString()), result); + } + + return ObjectUtils.notNull(result, UNUSED); + } + + @Nullable + public static StatusType forStatusOperation(@NotNull String statusName) { + return ourStatusTypesForStatusOperation.get(statusName); + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java index 4fc337ba1c0a..3f33435c678d 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnKitStatusClient.java @@ -18,8 +18,9 @@ package org.jetbrains.idea.svn.status; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.*; @@ -36,68 +37,50 @@ public class SvnKitStatusClient extends BaseSvnClient implements StatusClient { private SVNStatusClient myStatusClient; @Nullable private final ISVNStatusFileProvider myProvider; - @Nullable private final ISVNEventHandler myHandler; + @Nullable private final ProgressTracker myHandler; public SvnKitStatusClient() { this(null, null); } - public SvnKitStatusClient(@Nullable ISVNStatusFileProvider provider, @Nullable ISVNEventHandler handler) { + public SvnKitStatusClient(@Nullable ISVNStatusFileProvider provider, @Nullable ProgressTracker handler) { myProvider = provider; myHandler = handler; } @Override - public long doStatus(File path, boolean recursive, boolean remote, boolean reportAll, boolean includeIgnored, ISVNStatusHandler handler) - throws SVNException { - return getStatusClient().doStatus(path, recursive, remote, reportAll, includeIgnored, handler); - } - - @Override - public long doStatus(File path, - boolean recursive, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return getStatusClient().doStatus(path, recursive, remote, reportAll, includeIgnored, collectParentExternals, handler); - } - - @Override public long doStatus(File path, SVNRevision revision, - boolean recursive, + Depth depth, boolean remote, boolean reportAll, boolean includeIgnored, boolean collectParentExternals, - ISVNStatusHandler handler) throws SVNException { - return getStatusClient().doStatus(path, revision, recursive, remote, reportAll, includeIgnored, collectParentExternals, handler); - } - - @Override - public long doStatus(File path, - SVNRevision revision, - SVNDepth depth, - boolean remote, - boolean reportAll, - boolean includeIgnored, - boolean collectParentExternals, - ISVNStatusHandler handler, - Collection changeLists) throws SVNException { - return getStatusClient() - .doStatus(path, revision, depth, remote, reportAll, includeIgnored, collectParentExternals, handler, changeLists); - } - - @Override - public SVNStatus doStatus(File path, boolean remote) throws SVNException { - return getStatusClient().doStatus(path, remote); + final StatusConsumer handler, + Collection changeLists) throws SvnBindException { + try { + return getStatusClient() + .doStatus(path, revision, toDepth(depth), remote, reportAll, includeIgnored, collectParentExternals, new ISVNStatusHandler() { + @Override + public void handleStatus(SVNStatus status) throws SVNException { + handler.consume(Status.create(status)); + } + }, changeLists); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override - public SVNStatus doStatus(File path, boolean remote, boolean collectParentExternals) throws SVNException { - return getStatusClient().doStatus(path, remote, collectParentExternals); + @Nullable + public Status doStatus(File path, boolean remote) throws SvnBindException { + try { + return Status.create(getStatusClient().doStatus(path, remote)); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @NotNull @@ -111,7 +94,7 @@ public class SvnKitStatusClient extends BaseSvnClient implements StatusClient { if (myStatusClient == null) { myStatusClient = myVcs.getSvnKitManager().createStatusClient(); myStatusClient.setFilesProvider(myProvider); - myStatusClient.setEventHandler(myHandler); + myStatusClient.setEventHandler(toEventHandler(myHandler)); } return myStatusClient; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java index 642914a558ce..e0f97585f527 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/status/SvnStatusHandler.java @@ -18,18 +18,16 @@ package org.jetbrains.idea.svn.status; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.Getter; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.Convertor; import com.intellij.util.containers.MultiMap; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnUtil; -import org.jetbrains.idea.svn.info.SVNLockWrapper; -import org.tmatesoft.svn.core.SVNNodeKind; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.lock.Lock; import org.tmatesoft.svn.core.internal.util.SVNDate; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatusType; import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; @@ -47,29 +45,9 @@ public class SvnStatusHandler extends DefaultHandler { private static final Logger LOG = Logger.getInstance(SvnStatusHandler.class); - public static final Map<String, SVNStatusType> ourStatusTypes = ContainerUtil.newHashMap(); - - static { - // TODO: Check STATUS_MERGED as it is marked deprecated - put(SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_CONFLICTED, SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_EXTERNAL, - SVNStatusType.STATUS_IGNORED, SVNStatusType.STATUS_INCOMPLETE, SVNStatusType.STATUS_MERGED, SVNStatusType.STATUS_MISSING, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NONE, SVNStatusType.STATUS_NORMAL, SVNStatusType.STATUS_OBSTRUCTED, - SVNStatusType.STATUS_REPLACED, SVNStatusType.STATUS_UNVERSIONED); - } - - private static void put(@NotNull SVNStatusType... statusTypes) { - for (SVNStatusType statusType : statusTypes) { - put(statusType); - } - } - - private static void put(@NotNull SVNStatusType statusType) { - ourStatusTypes.put(statusType.toString(), statusType); - } - @Nullable - public static SVNStatusType getStatus(@NotNull String code) { - SVNStatusType result = ourStatusTypes.get(code); + public static StatusType getStatus(@NotNull String code) { + StatusType result = StatusType.forStatusOperation(code); if (result == null) { LOG.info("Unknown status type " + code); @@ -83,7 +61,7 @@ public class SvnStatusHandler extends DefaultHandler { private MultiMap<String, PortableStatus> myCurrentListChanges; private PortableStatus myPending; private boolean myInRemoteStatus; - private SVNLockWrapper myLockWrapper; + private Lock.Builder myLockBuilder; private final List<ElementHandlerBase> myParseStack; private final Map<String, Getter<ElementHandlerBase>> myElementsMap; @@ -92,7 +70,7 @@ public class SvnStatusHandler extends DefaultHandler { private final StringBuilder mySb; private boolean myAnythingReported; - public SvnStatusHandler(final ExternalDataCallback dataCallback, File base, final Convertor<File, SVNInfo> infoGetter) { + public SvnStatusHandler(final ExternalDataCallback dataCallback, File base, final Convertor<File, Info> infoGetter) { myBase = base; myParseStack = new ArrayList<ElementHandlerBase>(); myParseStack.add(new Fake()); @@ -104,17 +82,17 @@ public class SvnStatusHandler extends DefaultHandler { myDataCallback = new DataCallback() { @Override public void startLock() { - myLockWrapper = new SVNLockWrapper(); + myLockBuilder = new Lock.Builder(); } @Override public void endLock() { if (myInRemoteStatus) { - myPending.setRemoteLock(myLockWrapper.create()); + myPending.setRemoteLock(myLockBuilder.build()); } else { - myPending.setLocalLock(myLockWrapper.create()); + myPending.setLocalLock(myLockBuilder.build()); } - myLockWrapper = null; + myLockBuilder = null; } @Override @@ -143,17 +121,17 @@ public class SvnStatusHandler extends DefaultHandler { myDataCallback = new DataCallback() { @Override public void startLock() { - myLockWrapper = new SVNLockWrapper(); + myLockBuilder = new Lock.Builder(); } @Override public void endLock() { if (myInRemoteStatus) { - myPending.setRemoteLock(myLockWrapper.create()); + myPending.setRemoteLock(myLockBuilder.build()); } else { - myPending.setLocalLock(myLockWrapper.create()); + myPending.setLocalLock(myLockBuilder.build()); } - myLockWrapper = null; + myLockBuilder = null; } @Override @@ -191,12 +169,12 @@ public class SvnStatusHandler extends DefaultHandler { return myAnythingReported; } - private void newPending(final Convertor<File, SVNInfo> infoGetter) { + private void newPending(final Convertor<File, Info> infoGetter) { final PortableStatus status = new PortableStatus(); myPending = status; - status.setInfoGetter(new Getter<SVNInfo>() { + status.setInfoGetter(new Getter<Info>() { @Override - public SVNInfo get() { + public Info get() { return infoGetter.convert(status.getFile()); } }); @@ -224,7 +202,7 @@ public class SvnStatusHandler extends DefaultHandler { myElementsMap.put("lock", new Getter<ElementHandlerBase>() { @Override public ElementHandlerBase get() { - return new Lock(); + return new LockElement(); } }); @@ -319,7 +297,7 @@ public class SvnStatusHandler extends DefaultHandler { assertSAX(! myParseStack.isEmpty()); ElementHandlerBase current = myParseStack.get(myParseStack.size() - 1); if (mySb.length() > 0) { - current.characters(mySb.toString().trim(), myPending, myLockWrapper); + current.characters(mySb.toString().trim(), myPending, myLockBuilder); mySb.setLength(0); } @@ -329,7 +307,7 @@ public class SvnStatusHandler extends DefaultHandler { assertSAX(myElementsMap.containsKey(qName)); final ElementHandlerBase newChild = myElementsMap.get(qName).get(); newChild.preAttributesEffect(myDataCallback); - newChild.updateStatus(attributes, myPending, myLockWrapper); + newChild.updateStatus(attributes, myPending, myLockBuilder); newChild.preEffect(myDataCallback); myParseStack.add(newChild); return; @@ -365,13 +343,13 @@ public class SvnStatusHandler extends DefaultHandler { } } - private static SVNStatusType parseContentsStatus(Attributes attributes) throws SAXException { + private static StatusType parseContentsStatus(Attributes attributes) throws SAXException { final String item = attributes.getValue("item"); assertSAX(item != null); return getStatus(item); } - private static SVNStatusType parsePropertiesStatus(Attributes attributes) throws SAXException { + private static StatusType parsePropertiesStatus(Attributes attributes) throws SAXException { final String props = attributes.getValue("props"); assertSAX(props != null); return getStatus(props); @@ -383,7 +361,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -395,7 +373,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -405,7 +383,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -417,8 +395,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { - pending.setCommittedDate(SVNDate.parseDate(s)); + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -428,7 +405,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -440,8 +417,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { - pending.setAuthor(s); + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -456,7 +432,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { final String revision = attributes.getValue("revision"); if (!StringUtil.isEmpty(revision)) { status.setCommittedRevision(SVNRevision.create(Long.valueOf(revision))); @@ -472,7 +448,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -508,7 +484,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -520,7 +496,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { final SVNDate date = SVNDate.parseDate(s); lock.setCreationDate(date); } @@ -532,7 +508,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -544,7 +520,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { lock.setComment(s); } } @@ -555,7 +531,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -567,7 +543,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { lock.setOwner(s); } } @@ -578,7 +554,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -590,19 +566,18 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { - lock.setID(s); + public void characters(String s, PortableStatus pending, Lock.Builder lock) { + lock.setToken(s); } } - private static class Lock extends ElementHandlerBase { - private Lock() { + private static class LockElement extends ElementHandlerBase { + private LockElement() { super(new String[]{"token", "owner", "comment", "created"}, new String[]{}); } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { - lock.setPath(status.getPath()); + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -620,7 +595,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -630,11 +605,11 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { - final SVNStatusType propertiesStatus = parsePropertiesStatus(attributes); + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { + final StatusType propertiesStatus = parsePropertiesStatus(attributes); status.setRemotePropertiesStatus(propertiesStatus); - final SVNStatusType contentsStatus = parseContentsStatus(attributes); + final StatusType contentsStatus = parseContentsStatus(attributes); status.setRemoteContentsStatus(contentsStatus); } @@ -653,7 +628,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -675,13 +650,13 @@ public class SvnStatusHandler extends DefaultHandler { revision="120">*/ @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { - final SVNStatusType propertiesStatus = parsePropertiesStatus(attributes); + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { + final StatusType propertiesStatus = parsePropertiesStatus(attributes); status.setPropertiesStatus(propertiesStatus); - final SVNStatusType contentsStatus = parseContentsStatus(attributes); + final StatusType contentsStatus = parseContentsStatus(attributes); status.setContentsStatus(contentsStatus); - if (SVNStatusType.STATUS_CONFLICTED.equals(propertiesStatus) || SVNStatusType.STATUS_CONFLICTED.equals(contentsStatus)) { + if (StatusType.STATUS_CONFLICTED.equals(propertiesStatus) || StatusType.STATUS_CONFLICTED.equals(contentsStatus)) { status.setIsConflicted(true); } @@ -724,7 +699,7 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -737,14 +712,14 @@ public class SvnStatusHandler extends DefaultHandler { } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { final String path = attributes.getValue("path"); assertSAX(path != null); final File file = SvnUtil.resolvePath(myBase, path); status.setFile(file); final boolean exists = file.exists(); if (exists) { - status.setKind(exists, file.isDirectory() ? SVNNodeKind.DIR : SVNNodeKind.FILE); + status.setKind(exists, NodeKind.from(file.isDirectory())); } else { // this is a hack. This is done so because of strange svn native client output: /* @@ -779,15 +754,15 @@ c:\TestProjects\sortedProjects\Subversion\local\withExt82420\mod4>dir and no "mod4" under */ - final SVNStatusType ns = status.getNodeStatus(); - if (myBase.getName().equals(path) && ! SVNStatusType.MISSING.equals(ns) && - ! SVNStatusType.STATUS_DELETED.equals(ns) ) { - status.setKind(true, SVNNodeKind.DIR); + final StatusType ns = status.getNodeStatus(); + if (myBase.getName().equals(path) && ! StatusType.MISSING.equals(ns) && + ! StatusType.STATUS_DELETED.equals(ns) ) { + status.setKind(true, NodeKind.DIR); status.setFile(myBase); status.setPath(""); return; } - status.setKind(exists, SVNNodeKind.UNKNOWN); + status.setKind(exists, NodeKind.UNKNOWN); } status.setPath(path); } @@ -802,7 +777,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -814,7 +789,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { final String name = attributes.getValue("name"); assertSAX(! StringUtil.isEmptyOrSpaces(name)); myName = name; @@ -830,7 +805,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -840,7 +815,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) { } @Override @@ -852,7 +827,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -862,7 +837,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException { } @Override @@ -874,7 +849,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -884,7 +859,7 @@ and no "mod4" under } @Override - protected void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) { + protected void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) { } @Override @@ -896,7 +871,7 @@ and no "mod4" under } @Override - public void characters(String s, PortableStatus pending, SVNLockWrapper lock) { + public void characters(String s, PortableStatus pending, Lock.Builder lock) { } } @@ -909,7 +884,7 @@ and no "mod4" under myAwaitedChildrenMultiple = new HashSet<String>(Arrays.asList(awaitedChildrenMultiple)); } - protected abstract void updateStatus(Attributes attributes, PortableStatus status, SVNLockWrapper lock) throws SAXException; + protected abstract void updateStatus(Attributes attributes, PortableStatus status, Lock.Builder lock) throws SAXException; public abstract void postEffect(final DataCallback callback); public abstract void preEffect(final DataCallback callback); @@ -920,7 +895,7 @@ and no "mod4" under return myAwaitedChildren.remove(qName); } - public abstract void characters(String s, PortableStatus pending, SVNLockWrapper lock); + public abstract void characters(String s, PortableStatus pending, Lock.Builder lock); public void preAttributesEffect(DataCallback callback) {} } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitProgressCanceller.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitProgressCanceller.java new file mode 100644 index 000000000000..6bb370674ba2 --- /dev/null +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/svnkit/SvnKitProgressCanceller.java @@ -0,0 +1,34 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jetbrains.idea.svn.svnkit; + +import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.progress.ProgressManager; +import org.tmatesoft.svn.core.ISVNCanceller; +import org.tmatesoft.svn.core.SVNCancelException; + +/** + * @author Konstantin Kolosovsky. + */ +public class SvnKitProgressCanceller implements ISVNCanceller { + + public void checkCancelled() throws SVNCancelException { + final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); + if (indicator != null && indicator.isCanceled()) { + throw new SVNCancelException(); + } + } +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java index 762f4449b897..b655cdca170c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/MergeFromTheirsResolver.java @@ -52,12 +52,11 @@ import com.intellij.util.continuation.TaskDescriptor; import com.intellij.util.continuation.Where; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; import java.io.File; import java.io.IOException; @@ -71,7 +70,7 @@ import java.util.*; */ public class MergeFromTheirsResolver { private final SvnVcs myVcs; - private final SVNTreeConflictDescription myDescription; + private final TreeConflictDescription myDescription; private final Change myChange; private final FilePath myOldFilePath; private final FilePath myNewFilePath; @@ -86,7 +85,7 @@ public class MergeFromTheirsResolver { private List<TextFilePatch> myTextPatches; private VirtualFile myBaseForPatch; - public MergeFromTheirsResolver(SvnVcs vcs, SVNTreeConflictDescription description, Change change, SvnRevisionNumber revision) { + public MergeFromTheirsResolver(SvnVcs vcs, TreeConflictDescription description, Change change, SvnRevisionNumber revision) { myVcs = vcs; myDescription = description; myChange = change; @@ -126,11 +125,7 @@ public class MergeFromTheirsResolver { }); final List<TaskDescriptor> tasks = new SmartList<TaskDescriptor>(); - if (SVNNodeKind.DIR.equals(myDescription.getNodeKind())) { - tasks.add(new PreloadChangesContentsForDir()); - } else { - tasks.add(new PreloadChangesContentsForFile()); - } + tasks.add(myDescription.isDirectory() ? new PreloadChangesContentsForDir() : new PreloadChangesContentsForFile()); tasks.add(new ConvertTextPaths()); tasks.add(new PatchCreator()); tasks.add(new SelectPatchesInApplyPatchDialog()); @@ -290,7 +285,7 @@ public class MergeFromTheirsResolver { // TODO: is used. Command line also does not support automatic directory creation. // TODO: Need to check additionally if there are cases when directory does not exist and add corresponding code. myVcs.getFactory(myOldFilePath.getIOFile()).createAddClient() - .add(myOldFilePath.getIOFile(), SVNDepth.EMPTY, true, false, true, null); + .add(myOldFilePath.getIOFile(), Depth.EMPTY, true, false, true, null); } catch (VcsException e) { context.handleException(e, true); @@ -564,7 +559,7 @@ public class MergeFromTheirsResolver { } } - private List<CommittedChangeList> loadSvnChangeListsForPatch(SVNTreeConflictDescription description) throws VcsException { + private List<CommittedChangeList> loadSvnChangeListsForPatch(TreeConflictDescription description) throws VcsException { long max = description.getSourceRightVersion().getPegRevision(); long min = description.getSourceLeftVersion().getPegRevision(); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java index c637ce243981..584666c7e86a 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/SvnTreeConflictResolver.java @@ -27,8 +27,13 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; +import org.jetbrains.idea.svn.status.Status; import org.jetbrains.idea.svn.status.StatusClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.status.StatusConsumer; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.wc.*; @@ -57,7 +62,7 @@ public class SvnTreeConflictResolver { myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myVcs.getProject()); } - public void resolveSelectTheirsFull(SVNTreeConflictDescription d) throws VcsException { + public void resolveSelectTheirsFull(TreeConflictDescription d) throws VcsException { final LocalHistory localHistory = LocalHistory.getInstance(); localHistory.putSystemLabel(myVcs.getProject(), "Before accepting theirs for " + TreeConflictRefreshablePanel.filePath(myPath)); try { @@ -84,74 +89,64 @@ public class SvnTreeConflictResolver { private void revertAdditional() throws VcsException { if (myRevertPath == null) return; final File ioFile = myRevertPath.getIOFile(); - try { - final SVNStatus status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - if (SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { - FileUtil.delete(ioFile); - } - } - catch (SVNException e) { - throw new VcsException(e); + final Status status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + if (StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + FileUtil.delete(ioFile); } pathDirty(myRevertPath); } - public void resolveSelectMineFull(SVNTreeConflictDescription d) throws VcsException { + public void resolveSelectMineFull(TreeConflictDescription d) throws VcsException { final File ioFile = myPath.getIOFile(); - myVcs.getFactory(ioFile).createConflictClient().resolve(ioFile, SVNDepth.INFINITY, true, true, true); + myVcs.getFactory(ioFile).createConflictClient().resolve(ioFile, Depth.INFINITY, true, true, true); pathDirty(myPath); } private void updatetoTheirsFull() throws VcsException { - try { - final File ioFile = myPath.getIOFile(); - SVNStatus status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); - if (myCommittedRevision == null) { - myCommittedRevision = new SvnRevisionNumber(status.getCommittedRevision()); - } - if (status == null || SVNStatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())) { - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - updateIoFile(ioFile, SVNRevision.HEAD); - return; - } else if (SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - updateIoFile(ioFile, SVNRevision.HEAD); - FileUtil.delete(ioFile); - return; - } else { - final Set<File> usedToBeAdded = new HashSet<File>(); - if (myPath.isDirectory()) { - StatusClient statusClient = myVcs.getFactory(ioFile).createStatusClient(); - statusClient.doStatus(ioFile, SVNRevision.UNDEFINED, SVNDepth.INFINITY, false, false, false, false, - new ISVNStatusHandler() { - @Override - public void handleStatus(SVNStatus status) throws SVNException { - if (status != null && SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { - usedToBeAdded.add(status.getFile()); - } + final File ioFile = myPath.getIOFile(); + Status status = myVcs.getFactory(ioFile).createStatusClient().doStatus(ioFile, false); + if (myCommittedRevision == null) { + myCommittedRevision = new SvnRevisionNumber(status.getCommittedRevision()); + } + if (status == null || StatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())) { + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + updateIoFile(ioFile, SVNRevision.HEAD); + return; + } else if (StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + updateIoFile(ioFile, SVNRevision.HEAD); + FileUtil.delete(ioFile); + return; + } else { + final Set<File> usedToBeAdded = new HashSet<File>(); + if (myPath.isDirectory()) { + StatusClient statusClient = myVcs.getFactory(ioFile).createStatusClient(); + statusClient.doStatus(ioFile, SVNRevision.UNDEFINED, Depth.INFINITY, false, false, false, false, + new StatusConsumer() { + @Override + public void consume(Status status) throws SVNException { + if (status != null && StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + usedToBeAdded.add(status.getFile()); } - }, null); - } - myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, SVNDepth.INFINITY, null); - for (File wasAdded : usedToBeAdded) { - FileUtil.delete(wasAdded); - } - updateIoFile(ioFile, SVNRevision.HEAD); + } + }, null); } - } - catch (SVNException e1) { - throw new VcsException(e1); + myVcs.getFactory(ioFile).createRevertClient().revert(new File[]{ioFile}, Depth.INFINITY, null); + for (File wasAdded : usedToBeAdded) { + FileUtil.delete(wasAdded); + } + updateIoFile(ioFile, SVNRevision.HEAD); } } - private void updateIoFile(@NotNull File ioFile, @NotNull final SVNRevision revision) throws SVNException { + private void updateIoFile(@NotNull File ioFile, @NotNull final SVNRevision revision) throws SvnBindException { if (! ioFile.exists()) { File parent = ioFile.getParentFile(); - myVcs.getFactory(parent).createUpdateClient().doUpdate(parent, revision, SVNDepth.INFINITY, true, false); + myVcs.getFactory(parent).createUpdateClient().doUpdate(parent, revision, Depth.INFINITY, true, false); } else { - myVcs.getFactory(ioFile).createUpdateClient().doUpdate(ioFile, revision, SVNDepth.INFINITY, false, false); + myVcs.getFactory(ioFile).createUpdateClient().doUpdate(ioFile, revision, Depth.INFINITY, false, false); } } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java index da0b1e7f590b..9a68d63527ae 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/treeConflict/TreeConflictRefreshablePanel.java @@ -43,16 +43,14 @@ import gnu.trove.TLongArrayList; import org.jetbrains.idea.svn.ConflictedSvnChange; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.conflict.ConflictAction; +import org.jetbrains.idea.svn.conflict.ConflictReason; +import org.jetbrains.idea.svn.conflict.ConflictVersion; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import org.jetbrains.idea.svn.history.SvnHistoryProvider; import org.jetbrains.idea.svn.history.SvnHistorySession; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; -import org.tmatesoft.svn.core.internal.wc.SVNTreeConflictUtil; -import org.tmatesoft.svn.core.wc.SVNConflictAction; -import org.tmatesoft.svn.core.wc.SVNConflictReason; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; import javax.swing.*; import java.awt.*; @@ -96,7 +94,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return true; } - private static boolean descriptionsEqual(SVNTreeConflictDescription d1, SVNTreeConflictDescription d2) { + private static boolean descriptionsEqual(TreeConflictDescription d1, TreeConflictDescription d2) { if (d1.isPropertyConflict() != d2.isPropertyConflict()) return false; if (d1.isTextConflict() != d2.isTextConflict()) return false; if (d1.isTreeConflict() != d2.isTreeConflict()) return false; @@ -111,7 +109,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return true; } - private static boolean compareConflictVersion(SVNConflictVersion v1, SVNConflictVersion v2) { + private static boolean compareConflictVersion(ConflictVersion v1, ConflictVersion v2) { if (v1 == null && v2 == null) return true; if (v1 == null || v2 == null) return false; if (! v1.getKind().equals(v2.getKind())) return false; @@ -131,7 +129,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { processDescription(myChange.getAfterDescription())); } - private BeforeAfter<ConflictSidePresentation> processDescription(SVNTreeConflictDescription description) throws VcsException { + private BeforeAfter<ConflictSidePresentation> processDescription(TreeConflictDescription description) throws VcsException { if (description == null) return null; if (myChange.getBeforeRevision() != null) { myCommittedRevision = (SvnRevisionNumber)SvnHistorySession.getCurrentCommittedRevision(myVcs, @@ -180,12 +178,12 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return new BeforeAfter<ConflictSidePresentation>(leftSide, rightSide); } - private static boolean isDifferentURLs(SVNTreeConflictDescription description) { + private static boolean isDifferentURLs(TreeConflictDescription description) { return description.getSourceLeftVersion() != null && description.getSourceRightVersion() != null && ! Comparing.equal(description.getSourceLeftVersion().getPath(), description.getSourceRightVersion().getPath()); } - private ConflictSidePresentation createSide(SVNConflictVersion version, final SVNRevision untilThisOther, final boolean isLeft) throws VcsException { + private ConflictSidePresentation createSide(ConflictVersion version, final SVNRevision untilThisOther, final boolean isLeft) throws VcsException { if (version == null) return EmptyConflictSide.getInstance(); if (myChange.getBeforeRevision() != null && myCommittedRevision != null) { SvnRevisionNumber number = myCommittedRevision; @@ -226,12 +224,12 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return wrapper; } - private void appendDescription(SVNTreeConflictDescription description, + private void appendDescription(TreeConflictDescription description, JPanel main, GridBagConstraints gb, BeforeAfter<ConflictSidePresentation> ba, boolean directory) { if (description == null) return; - JLabel descriptionLbl = new JLabel(SVNTreeConflictUtil.getHumanReadableConflictDescription(description)); + JLabel descriptionLbl = new JLabel(description.toPresentableString()); descriptionLbl.setForeground(Color.red); main.add(descriptionLbl, gb); ++ gb.gridy; @@ -243,7 +241,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { addSide(main, gb, ba.getAfter(), description.getSourceRightVersion(), "Right", directory); } - private void addResolveButtons(SVNTreeConflictDescription description, JPanel main, GridBagConstraints gb) { + private void addResolveButtons(TreeConflictDescription description, JPanel main, GridBagConstraints gb) { final FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 5, 5); JPanel wrapper = new JPanel(flowLayout); final JButton both = new JButton("Both"); @@ -266,7 +264,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { ++ gb.gridy; } - private ActionListener createRight(final SVNTreeConflictDescription description) { + private ActionListener createRight(final TreeConflictDescription description) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -276,11 +274,11 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { FileDocumentManager.getInstance().saveAllDocuments(); final Paths paths = getPaths(description); ProgressManager.getInstance().run( - new VcsBackgroundTask<SVNTreeConflictDescription>(myVcs.getProject(), "Accepting theirs for: " + filePath(paths.myMainPath), + new VcsBackgroundTask<TreeConflictDescription>(myVcs.getProject(), "Accepting theirs for: " + filePath(paths.myMainPath), BackgroundFromStartOption.getInstance(), Collections.singletonList(description), true) { @Override - protected void process(SVNTreeConflictDescription d) throws VcsException { + protected void process(TreeConflictDescription d) throws VcsException { new SvnTreeConflictResolver(myVcs, paths.myMainPath, myCommittedRevision, paths.myAdditionalPath).resolveSelectTheirsFull(d); } @@ -296,11 +294,11 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { }; } - private Paths getPaths(final SVNTreeConflictDescription description) { - FilePath mainPath = new FilePathImpl(description.getPath(), SVNNodeKind.DIR.equals(description.getNodeKind())); + private Paths getPaths(final TreeConflictDescription description) { + FilePath mainPath; FilePath additionalPath = null; if (myChange.isMoved() || myChange.isRenamed()) { - if (SVNConflictAction.ADD.equals(description.getConflictAction())) { + if (ConflictAction.ADD.equals(description.getConflictAction())) { mainPath = myChange.getAfterRevision().getFile(); additionalPath = myChange.getBeforeRevision().getFile(); } else { @@ -323,7 +321,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { } } - private ActionListener createLeft(final SVNTreeConflictDescription description) { + private ActionListener createLeft(final TreeConflictDescription description) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -333,11 +331,11 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { FileDocumentManager.getInstance().saveAllDocuments(); final Paths paths = getPaths(description); ProgressManager.getInstance().run( - new VcsBackgroundTask<SVNTreeConflictDescription>(myVcs.getProject(), "Accepting yours for: " + filePath(paths.myMainPath), + new VcsBackgroundTask<TreeConflictDescription>(myVcs.getProject(), "Accepting yours for: " + filePath(paths.myMainPath), BackgroundFromStartOption.getInstance(), Collections.singletonList(description), true) { @Override - protected void process(SVNTreeConflictDescription d) throws VcsException { + protected void process(TreeConflictDescription d) throws VcsException { new SvnTreeConflictResolver(myVcs, paths.myMainPath, myCommittedRevision, paths.myAdditionalPath).resolveSelectMineFull(d); } @@ -353,22 +351,22 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { }; } - private ActionListener createMerge(final SVNTreeConflictDescription description) { + private ActionListener createMerge(final TreeConflictDescription description) { if (isDifferentURLs(description)) { return null; } // my edit, theirs move or delete - if (SVNConflictAction.EDIT.equals(description.getConflictAction()) && description.getSourceLeftVersion() != null && - SVNConflictReason.DELETED.equals(description.getConflictReason()) && (myChange.isMoved() || myChange.isRenamed()) && + if (ConflictAction.EDIT.equals(description.getConflictAction()) && description.getSourceLeftVersion() != null && + ConflictReason.DELETED.equals(description.getConflictReason()) && (myChange.isMoved() || myChange.isRenamed()) && myCommittedRevision != null) { - if (myPath.isDirectory() == SVNNodeKind.DIR.equals(description.getSourceRightVersion().getKind())) { + if (myPath.isDirectory() == description.getSourceRightVersion().isDirectory()) { return createMergeTheirsForFile(description); } } return null; } - private ActionListener createMergeTheirsForFile(final SVNTreeConflictDescription description) { + private ActionListener createMergeTheirsForFile(final TreeConflictDescription description) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -381,7 +379,7 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { return newFilePath.getName() + " (" + newFilePath.getParentPath().getPath() + ")"; } - private static ActionListener createBoth(SVNTreeConflictDescription description) { + private static ActionListener createBoth(TreeConflictDescription description) { return null; } @@ -397,10 +395,10 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { private void addSide(JPanel main, GridBagConstraints gb, ConflictSidePresentation before, - SVNConflictVersion leftVersion, final String name, boolean directory) { + ConflictVersion leftVersion, final String name, boolean directory) { final String leftPresentation = leftVersion == null ? name + ": (" + (directory ? "directory" : "file") + (myChange.getBeforeRevision() == null ? ") added" : ") unversioned") : - name + ": " + FileUtil.toSystemIndependentName(SVNTreeConflictUtil.getHumanReadableConflictVersion(leftVersion)); + name + ": " + FileUtil.toSystemIndependentName(ConflictVersion.toPresentableString(leftVersion)); gb.insets.top = 10; main.add(new JLabel(leftPresentation), gb); ++ gb.gridy; @@ -454,9 +452,9 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { private abstract static class AbstractConflictSide<T> implements ConflictSidePresentation, Convertor<T, VcsRevisionNumber> { protected final Project myProject; - protected final SVNConflictVersion myVersion; + protected final ConflictVersion myVersion; - private AbstractConflictSide(Project project, SVNConflictVersion version) { + private AbstractConflictSide(Project project, ConflictVersion version) { myProject = project; myVersion = version; } @@ -472,13 +470,13 @@ public class TreeConflictRefreshablePanel extends AbstractRefreshablePanel { private FileHistoryPanelImpl myFileHistoryPanel; private TLongArrayList myListToReportLoaded; - private HistoryConflictSide(SvnVcs vcs, SVNConflictVersion version, final SVNRevision peg) throws VcsException { + private HistoryConflictSide(SvnVcs vcs, ConflictVersion version, final SVNRevision peg) throws VcsException { super(vcs.getProject(), version); myVcs = vcs; myPeg = peg; try { myPath = FilePathImpl.createNonLocal( - version.getRepositoryRoot().appendPath(FileUtil.toSystemIndependentName(version.getPath()), true).toString(), SVNNodeKind.DIR.equals(version.getKind())); + version.getRepositoryRoot().appendPath(FileUtil.toSystemIndependentName(version.getPath()), true).toString(), version.isDirectory()); } catch (SVNException e) { throw new VcsException(e); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java index 0cea23ea3988..c57d043b33d2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractSvnUpdatePanel.java @@ -23,8 +23,8 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.DepthCombo; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import javax.swing.*; import java.awt.*; @@ -106,7 +106,7 @@ public abstract class AbstractSvnUpdatePanel { @Nullable private SVNURL getUrlFor(@NotNull final FilePath root) { - final SVNInfo info = myVCS.getInfo(root.getIOFile()); + final Info info = myVCS.getInfo(root.getIOFile()); return info != null ? info.getURL() : null; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java index 47b15802287b..991c2fe1e7b2 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AbstractUpdateIntegrateCrawler.java @@ -22,9 +22,7 @@ import com.intellij.openapi.vcs.update.UpdatedFiles; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.SvnWCRootCrawler; -import org.tmatesoft.svn.core.SVNErrorCode; -import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import java.io.File; import java.util.Collection; @@ -58,13 +56,9 @@ public abstract class AbstractUpdateIntegrateCrawler implements SvnWCRootCrawler long rev = doUpdate(root); if (rev < 0 && !isMerge()) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.UNKNOWN, SvnBundle.message("exception.text.root.was.not.properly.updated", root))); + throw new SvnBindException(SvnBundle.message("exception.text.root.was.not.properly.updated", root)); } } - catch (SVNException e) { - LOG.info(e); - myExceptions.add(new VcsException(e)); - } catch (VcsException e) { LOG.info(e); myExceptions.add(e); @@ -73,7 +67,7 @@ public abstract class AbstractUpdateIntegrateCrawler implements SvnWCRootCrawler protected abstract void showProgressMessage(ProgressIndicator progress, File root); - protected abstract long doUpdate(File root) throws SVNException, VcsException; + protected abstract long doUpdate(File root) throws VcsException; protected abstract boolean isMerge(); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java index 925d13c7242f..4bb3dbea9a18 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/AutoSvnUpdater.java @@ -29,7 +29,7 @@ import com.intellij.openapi.wm.WindowManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnConfiguration; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; import org.tmatesoft.svn.core.wc.SVNRevision; import javax.swing.*; @@ -66,7 +66,7 @@ public class AutoSvnUpdater extends AbstractCommonUpdateAction { final SvnConfiguration configuration17 = SvnConfiguration.getInstance(myProject); configuration17.setForceUpdate(false); configuration17.setUpdateLockOnDemand(false); - configuration17.setUpdateDepth(SVNDepth.INFINITY); + configuration17.setUpdateDepth(Depth.INFINITY); final SvnVcs vcs = SvnVcs.getInstance(myProject); for (FilePath root : myRoots) { configureUpdateRootInfo(root, configuration17.getUpdateRootInfo(root.getIOFile(), vcs)); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java index 051be8945b3e..61b0592af085 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/CmdUpdateClient.java @@ -16,16 +16,17 @@ package org.jetbrains.idea.svn.update; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; import org.jetbrains.idea.svn.commandLine.BaseUpdateCommandListener; import org.jetbrains.idea.svn.commandLine.CommandUtil; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.jetbrains.idea.svn.commandLine.SvnCommandName; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.*; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; @@ -47,46 +48,24 @@ public class CmdUpdateClient extends SvnKitUpdateClient { private static final Pattern ourExceptionPattern = Pattern.compile("svn: E(\\d{6}): .+"); private static final String ourAuthenticationRealm = "Authentication realm:"; - @Override - public long[] doUpdate(final File[] paths, final SVNRevision revision, final SVNDepth depth, final boolean allowUnversionedObstructions, - final boolean depthIsSticky, final boolean makeParents) throws SVNException { - // since one revision is passed -> I assume same repository here - checkWorkingCopy(paths[0]); - - final List<String> parameters = new ArrayList<String>(); - - fillParameters(parameters, revision, depth, depthIsSticky, allowUnversionedObstructions); - CommandUtil.put(parameters, makeParents, "--parents"); - CommandUtil.put(parameters, myIgnoreExternals, "--ignore-externals"); - CommandUtil.put(parameters, paths); - - return run(paths, parameters, SvnCommandName.up); - } - - private void checkWorkingCopy(@NotNull File path) throws SVNException { - final SVNInfo info = myFactory.createInfoClient().doInfo(path, SVNRevision.UNDEFINED); + private void checkWorkingCopy(@NotNull File path) throws SvnBindException { + final Info info = myFactory.createInfoClient().doInfo(path, SVNRevision.UNDEFINED); if (info == null || info.getURL() == null) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.WC_NOT_WORKING_COPY, path.getPath())); + throw new SvnBindException(SVNErrorCode.WC_NOT_WORKING_COPY, path.getPath()); } } - private long[] run(@NotNull File[] paths, @NotNull List<String> parameters, @NotNull SvnCommandName command) throws SVNException { - File base = paths[0]; - base = base.isDirectory() ? base : base.getParentFile(); + private long[] run(@NotNull File path, @NotNull List<String> parameters, @NotNull SvnCommandName command) throws SvnBindException { + File base = path.isDirectory() ? path : path.getParentFile(); final AtomicReference<long[]> updatedToRevision = new AtomicReference<long[]>(); updatedToRevision.set(new long[0]); - final BaseUpdateCommandListener listener = createCommandListener(paths, updatedToRevision, base); - try { - execute(myVcs, SvnTarget.fromFile(base), command, parameters, listener); - } - catch (VcsException e) { - throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e)); - } + final BaseUpdateCommandListener listener = createCommandListener(new File[]{path}, updatedToRevision, base); + execute(myVcs, SvnTarget.fromFile(base), command, parameters, listener); - listener.throwIfException(); + listener.throwWrappedIfException(); return updatedToRevision.get(); } @@ -98,8 +77,8 @@ public class CmdUpdateClient extends SvnKitUpdateClient { final long[] myRevisions = new long[paths.length]; @Override - protected void beforeHandler(@NotNull SVNEvent event) { - if (SVNEventAction.UPDATE_COMPLETED.equals(event.getAction())) { + protected void beforeHandler(@NotNull ProgressEvent event) { + if (EventAction.UPDATE_COMPLETED.equals(event.getAction())) { final long eventRevision = event.getRevision(); for (int i = 0; i < paths.length; i++) { final File path = paths[i]; @@ -121,7 +100,7 @@ public class CmdUpdateClient extends SvnKitUpdateClient { private static void fillParameters(@NotNull List<String> parameters, @Nullable SVNRevision revision, - @Nullable SVNDepth depth, + @Nullable Depth depth, boolean depthIsSticky, boolean allowUnversionedObstructions) { @@ -155,9 +134,17 @@ public class CmdUpdateClient extends SvnKitUpdateClient { } @Override - public long doUpdate(File path, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) - throws SVNException { - final long[] longs = doUpdate(new File[]{path}, revision, depth, allowUnversionedObstructions, depthIsSticky, false); + public long doUpdate(File path, SVNRevision revision, Depth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) + throws SvnBindException { + checkWorkingCopy(path); + + final List<String> parameters = new ArrayList<String>(); + + fillParameters(parameters, revision, depth, depthIsSticky, allowUnversionedObstructions); + CommandUtil.put(parameters, myIgnoreExternals, "--ignore-externals"); + CommandUtil.put(parameters, path); + + final long[] longs = run(path, parameters, SvnCommandName.up); return longs[0]; } @@ -166,9 +153,9 @@ public class CmdUpdateClient extends SvnKitUpdateClient { SVNURL url, SVNRevision pegRevision, SVNRevision revision, - SVNDepth depth, + Depth depth, boolean allowUnversionedObstructions, - boolean depthIsSticky) throws SVNException { + boolean depthIsSticky) throws SvnBindException { checkWorkingCopy(path); List<String> parameters = new ArrayList<String>(); @@ -178,7 +165,7 @@ public class CmdUpdateClient extends SvnKitUpdateClient { fillParameters(parameters, revision, depth, depthIsSticky, allowUnversionedObstructions); parameters.add("--ignore-ancestry"); - long[] revisions = run(new File[]{path}, parameters, SvnCommandName.switchCopy); + long[] revisions = run(path, parameters, SvnCommandName.switchCopy); return revisions != null && revisions.length > 0 ? revisions[0] : -1; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java index 872ee8f81573..6bc2af02415c 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/MergeRootInfo.java @@ -16,9 +16,9 @@ package org.jetbrains.idea.svn.update; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -33,7 +33,7 @@ public class MergeRootInfo { myRevision1 = SVNRevision.HEAD; myRevision2 = SVNRevision.HEAD; - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); myUrl1 = info != null && info.getURL() != null ? info.getURL().toString() : ""; myUrl2 = myUrl1; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java index be9923d1b07b..eaf6578b1587 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnKitUpdateClient.java @@ -18,10 +18,11 @@ package org.jetbrains.idea.svn.update; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.tmatesoft.svn.core.SVNDepth; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNUpdateClient; @@ -35,24 +36,19 @@ import java.io.File; */ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { - @Nullable protected ISVNEventHandler myDispatcher; + @Nullable protected ProgressTracker myDispatcher; protected boolean myIgnoreExternals; protected boolean myLocksOnDemand; @Override - public long[] doUpdate(File[] paths, - SVNRevision revision, - SVNDepth depth, - boolean allowUnversionedObstructions, - boolean depthIsSticky, - boolean makeParents) throws SVNException { - return getClient().doUpdate(paths, revision, depth, allowUnversionedObstructions, depthIsSticky, makeParents); - } - - @Override - public long doUpdate(File path, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) - throws SVNException { - return getClient().doUpdate(path, revision, depth, allowUnversionedObstructions, depthIsSticky); + public long doUpdate(File path, SVNRevision revision, Depth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) + throws SvnBindException { + try { + return getClient().doUpdate(path, revision, toDepth(depth), allowUnversionedObstructions, depthIsSticky); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override @@ -60,9 +56,14 @@ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { SVNURL url, SVNRevision pegRevision, SVNRevision revision, - SVNDepth depth, - boolean allowUnversionedObstructions, boolean depthIsSticky) throws SVNException { - return getClient().doSwitch(path, url, pegRevision, revision, depth, allowUnversionedObstructions, depthIsSticky); + Depth depth, + boolean allowUnversionedObstructions, boolean depthIsSticky) throws SvnBindException { + try { + return getClient().doSwitch(path, url, pegRevision, revision, toDepth(depth), allowUnversionedObstructions, depthIsSticky); + } + catch (SVNException e) { + throw new SvnBindException(e); + } } @Override @@ -71,7 +72,7 @@ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { } @Override - public void setEventHandler(ISVNEventHandler dispatcher) { + public void setEventHandler(ProgressTracker dispatcher) { myDispatcher = dispatcher; } @@ -84,7 +85,7 @@ public class SvnKitUpdateClient extends BaseSvnClient implements UpdateClient { private SVNUpdateClient getClient() { SVNUpdateClient client = myVcs.getSvnKitManager().createUpdateClient(); - client.setEventHandler(myDispatcher); + client.setEventHandler(toEventHandler(myDispatcher)); client.setIgnoreExternals(myIgnoreExternals); client.setUpdateLocksOnDemand(myLocksOnDemand); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java index e4d25c385375..554b2c29bc48 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/SvnUpdateEnvironment.java @@ -24,9 +24,9 @@ import com.intellij.openapi.vcs.update.UpdatedFiles; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.*; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -70,7 +70,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment progress.setText(SvnBundle.message("progress.text.updating", root.getAbsolutePath())); } - protected long doUpdate(final File root) throws SVNException { + protected long doUpdate(final File root) throws SvnBindException { final long rev; final SvnConfiguration configuration = SvnConfiguration.getInstance(myVcs.getProject()); @@ -113,7 +113,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment @Nullable private static SVNURL getSourceUrl(final SvnVcs vcs, final File root) { - final SVNInfo svnInfo = vcs.getInfo(root); + final Info svnInfo = vcs.getInfo(root); return svnInfo != null ? svnInfo.getURL() : null; } @@ -140,7 +140,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment } } } - catch (SVNException e) { + catch (SvnBindException e) { Messages.showErrorDialog(myVcs.getProject(), e.getMessage(), SvnBundle.message("switch.target.problem.title")); return false; }*/ @@ -148,7 +148,7 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment return true; } - private SVNRevision correctRevision(@NotNull UpdateRootInfo value) throws SVNException { + private SVNRevision correctRevision(@NotNull UpdateRootInfo value) throws SvnBindException { if (SVNRevision.HEAD.equals(value.getRevision())) { // find acual revision to update to (a bug if just say head in switch) value.setRevision(SvnUtil.getHeadRevision(myVcs, value.getUrl())); @@ -157,9 +157,9 @@ public class SvnUpdateEnvironment extends AbstractSvnUpdateIntegrateEnvironment } // false - do not do update - private boolean checkAncestry(final File sourceFile, final SVNURL targetUrl, final SVNRevision targetRevision) throws SVNException { - final SVNInfo sourceSvnInfo = myVcs.getInfo(sourceFile); - final SVNInfo targetSvnInfo = myVcs.getInfo(targetUrl, targetRevision); + private boolean checkAncestry(final File sourceFile, final SVNURL targetUrl, final SVNRevision targetRevision) throws SvnBindException { + final Info sourceSvnInfo = myVcs.getInfo(sourceFile); + final Info targetSvnInfo = myVcs.getInfo(targetUrl, targetRevision); if (sourceSvnInfo == null || targetSvnInfo == null) { // cannot check diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java index b68829e28940..7155400df04e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateClient.java @@ -15,11 +15,11 @@ */ package org.jetbrains.idea.svn.update; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.SVNDepth; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -32,14 +32,19 @@ import java.io.File; */ public interface UpdateClient extends SvnClient { - long[] doUpdate(File[] paths, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky, boolean makeParents) throws SVNException; - - long doUpdate(File path, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) throws SVNException; + long doUpdate(File path, SVNRevision revision, Depth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) + throws SvnBindException; void setUpdateLocksOnDemand(boolean locksOnDemand); - long doSwitch(File path, SVNURL url, SVNRevision pegRevision, SVNRevision revision, SVNDepth depth, boolean allowUnversionedObstructions, boolean depthIsSticky) throws SVNException; + long doSwitch(File path, + SVNURL url, + SVNRevision pegRevision, + SVNRevision revision, + Depth depth, + boolean allowUnversionedObstructions, + boolean depthIsSticky) throws SvnBindException; - void setEventHandler(ISVNEventHandler dispatcher); + void setEventHandler(ProgressTracker dispatcher); void setIgnoreExternals(boolean ignoreExternals); } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java index cea4edbcc7cd..fc552dbd1655 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateEventHandler.java @@ -25,6 +25,10 @@ import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnFileUrlMapping; import org.jetbrains.idea.svn.SvnRevisionNumber; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressEvent; +import org.jetbrains.idea.svn.api.ProgressTracker; +import org.jetbrains.idea.svn.status.StatusType; import org.tmatesoft.svn.core.SVNCancelException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.wc.SVNErrorManager; @@ -38,7 +42,7 @@ import java.util.Map; /** * @author lesya */ -public class UpdateEventHandler implements ISVNEventHandler { +public class UpdateEventHandler implements ProgressTracker { private ProgressIndicator myProgressIndicator; private UpdatedFiles myUpdatedFiles; private int myExternalsCount; @@ -66,7 +70,7 @@ public class UpdateEventHandler implements ISVNEventHandler { myUpdatedFiles = updatedFiles; } - public void handleEvent(final SVNEvent event, double progress) { + public void consume(final ProgressEvent event) { if (event == null || event.getFile() == null) { return; } @@ -81,7 +85,7 @@ public class UpdateEventHandler implements ISVNEventHandler { return; } - if (event.getAction() == SVNEventAction.TREE_CONFLICT) { + if (event.getAction() == EventAction.TREE_CONFLICT) { myText2 = SvnBundle.message("progress.text2.treeconflicted", displayPath); updateProgressIndicator(); myUpdatedFiles.registerGroup(createFileGroup(VcsBundle.message("update.group.name.merged.with.tree.conflicts"), @@ -89,10 +93,10 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(FileGroup.MERGED_WITH_TREE_CONFLICT, event); } - if (event.getAction() == SVNEventAction.UPDATE_ADD || - event.getAction() == SVNEventAction.ADD) { + if (event.getAction() == EventAction.UPDATE_ADD || + event.getAction() == EventAction.ADD) { myText2 = SvnBundle.message("progress.text2.added", displayPath); - if (event.getContentsStatus() == SVNStatusType.CONFLICTED || event.getPropertiesStatus() == SVNStatusType.CONFLICTED) { + if (event.getContentsStatus() == StatusType.CONFLICTED || event.getPropertiesStatus() == StatusType.CONFLICTED) { addFileToGroup(FileGroup.MERGED_WITH_CONFLICT_ID, event); myText2 = SvnBundle.message("progress.text2.conflicted", displayPath); } else if (myUpdatedFiles.getGroupById(FileGroup.REMOVED_FROM_REPOSITORY_ID).getFiles().contains(path)) { @@ -106,38 +110,38 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(FileGroup.CREATED_ID, event); } } - else if (event.getAction() == SVNEventAction.UPDATE_NONE) { + else if (event.getAction() == EventAction.UPDATE_NONE) { // skip it return; } - else if (event.getAction() == SVNEventAction.UPDATE_DELETE) { + else if (event.getAction() == EventAction.UPDATE_DELETE) { myText2 = SvnBundle.message("progress.text2.deleted", displayPath); addFileToGroup(FileGroup.REMOVED_FROM_REPOSITORY_ID, event); } - else if (event.getAction() == SVNEventAction.UPDATE_UPDATE) { + else if (event.getAction() == EventAction.UPDATE_UPDATE) { possiblySwitched(event); - if (event.getContentsStatus() == SVNStatusType.CONFLICTED || event.getPropertiesStatus() == SVNStatusType.CONFLICTED) { - if (event.getContentsStatus() == SVNStatusType.CONFLICTED) { + if (event.getContentsStatus() == StatusType.CONFLICTED || event.getPropertiesStatus() == StatusType.CONFLICTED) { + if (event.getContentsStatus() == StatusType.CONFLICTED) { addFileToGroup(FileGroup.MERGED_WITH_CONFLICT_ID, event); } - if (event.getPropertiesStatus() == SVNStatusType.CONFLICTED) { + if (event.getPropertiesStatus() == StatusType.CONFLICTED) { addFileToGroup(FileGroup.MERGED_WITH_PROPERTY_CONFLICT_ID, event); } myText2 = SvnBundle.message("progress.text2.conflicted", displayPath); } - else if (event.getContentsStatus() == SVNStatusType.MERGED || event.getPropertiesStatus() == SVNStatusType.MERGED) { + else if (event.getContentsStatus() == StatusType.MERGED || event.getPropertiesStatus() == StatusType.MERGED) { myText2 = SvnBundle.message("progres.text2.merged", displayPath); addFileToGroup(FileGroup.MERGED_ID, event); } - else if (event.getContentsStatus() == SVNStatusType.CHANGED || event.getPropertiesStatus() == SVNStatusType.CHANGED) { + else if (event.getContentsStatus() == StatusType.CHANGED || event.getPropertiesStatus() == StatusType.CHANGED) { myText2 = SvnBundle.message("progres.text2.updated", displayPath); addFileToGroup(FileGroup.UPDATED_ID, event); } - else if (event.getContentsStatus() == SVNStatusType.UNCHANGED && - (event.getPropertiesStatus() == SVNStatusType.UNCHANGED || event.getPropertiesStatus() == SVNStatusType.UNKNOWN)) { + else if (event.getContentsStatus() == StatusType.UNCHANGED && + (event.getPropertiesStatus() == StatusType.UNCHANGED || event.getPropertiesStatus() == StatusType.UNKNOWN)) { myText2 = SvnBundle.message("progres.text2.updated", displayPath); - } else if (SVNStatusType.INAPPLICABLE.equals(event.getContentsStatus()) && - (event.getPropertiesStatus() == SVNStatusType.UNCHANGED || event.getPropertiesStatus() == SVNStatusType.UNKNOWN)) { + } else if (StatusType.INAPPLICABLE.equals(event.getContentsStatus()) && + (event.getPropertiesStatus() == StatusType.UNCHANGED || event.getPropertiesStatus() == StatusType.UNKNOWN)) { myText2 = SvnBundle.message("progres.text2.updated", displayPath); } else { @@ -145,7 +149,7 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(FileGroup.UNKNOWN_ID, event); } } - else if (event.getAction() == SVNEventAction.UPDATE_EXTERNAL) { + else if (event.getAction() == EventAction.UPDATE_EXTERNAL) { if (mySequentialUpdatesContext != null) { mySequentialUpdatesContext.registerExternalRootBeingUpdated(event.getFile()); } @@ -158,11 +162,11 @@ public class UpdateEventHandler implements ISVNEventHandler { addFileToGroup(AbstractSvnUpdateIntegrateEnvironment.EXTERNAL_ID, event); myText = SvnBundle.message("progress.text.updating.external.location", event.getFile().getAbsolutePath()); } - else if (event.getAction() == SVNEventAction.RESTORE) { + else if (event.getAction() == EventAction.RESTORE) { myText2 = SvnBundle.message("progress.text2.restored.file", displayPath); addFileToGroup(FileGroup.RESTORED_ID, event); } - else if (event.getAction() == SVNEventAction.UPDATE_COMPLETED && event.getRevision() >= 0) { + else if (event.getAction() == EventAction.UPDATE_COMPLETED && event.getRevision() >= 0) { possiblySwitched(event); myExternalsCount--; myText2 = SvnBundle.message("progres.text2.updated.to.revision", event.getRevision()); @@ -171,7 +175,7 @@ public class UpdateEventHandler implements ISVNEventHandler { StatusBar.Info.set(SvnBundle.message("status.text.updated.to.revision", event.getRevision()), myVCS.getProject()); } } - else if (event.getAction() == SVNEventAction.SKIP) { + else if (event.getAction() == EventAction.SKIP) { myText2 = SvnBundle.message("progress.text2.skipped.file", displayPath); addFileToGroup(FileGroup.SKIPPED_ID, event); } @@ -179,7 +183,7 @@ public class UpdateEventHandler implements ISVNEventHandler { updateProgressIndicator(); } - private void possiblySwitched(SVNEvent event) { + private void possiblySwitched(ProgressEvent event) { final File file = event.getFile(); if (file == null) return; final SVNURL wasUrl = myUrlToCheckForSwitch.get(file); @@ -189,7 +193,7 @@ public class UpdateEventHandler implements ISVNEventHandler { } } - private boolean itemSwitched(final SVNEvent event) { + private boolean itemSwitched(final ProgressEvent event) { final File file = event.getFile(); final SvnFileUrlMapping urlMapping = myVCS.getSvnFileUrlMapping(); final SVNURL currentUrl = urlMapping.getUrlForFile(file); @@ -207,11 +211,11 @@ public class UpdateEventHandler implements ISVNEventHandler { } } - protected boolean handleInDescendants(final SVNEvent event) { + protected boolean handleInDescendants(final ProgressEvent event) { return false; } - protected void addFileToGroup(final String id, final SVNEvent event) { + protected void addFileToGroup(final String id, final ProgressEvent event) { final FileGroup fileGroup = myUpdatedFiles.getGroupById(id); final String path = event.getFile().getAbsolutePath(); fileGroup.add(path, SvnVcs.getKey(), new SvnRevisionNumber(SVNRevision.create(event.getRevision()))); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java index b2a318b39da8..c858f78890f4 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/update/UpdateRootInfo.java @@ -16,9 +16,9 @@ package org.jetbrains.idea.svn.update; import org.jetbrains.idea.svn.SvnVcs; +import org.jetbrains.idea.svn.info.Info; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; import java.io.File; @@ -31,7 +31,7 @@ public class UpdateRootInfo { public UpdateRootInfo(File file, SvnVcs vcs) { myRevision = SVNRevision.HEAD; - SVNInfo info = vcs.getInfo(file); + Info info = vcs.getInfo(file); myUrl = info != null && info.getURL() != null ? info.getURL().toString() : ""; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java index 3a4e6eb6ce92..f27615423904 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/CmdUpgradeClient.java @@ -7,14 +7,10 @@ import com.intellij.util.containers.Convertor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; -import org.jetbrains.idea.svn.api.BaseSvnClient; -import org.jetbrains.idea.svn.api.FileStatusResultParser; +import org.jetbrains.idea.svn.api.*; import org.jetbrains.idea.svn.commandLine.CommandUtil; import org.jetbrains.idea.svn.commandLine.LineCommandAdapter; import org.jetbrains.idea.svn.commandLine.SvnCommandName; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEvent; -import org.tmatesoft.svn.core.wc.SVNEventAction; import org.tmatesoft.svn.core.wc2.SvnTarget; import java.io.File; @@ -34,11 +30,11 @@ public class CmdUpgradeClient extends BaseSvnClient implements UpgradeClient { private static final Pattern CHANGED_PATH = Pattern.compile(STATUS + PATH); @Override - public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ISVNEventHandler handler) throws VcsException { + public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException { validateFormat(format, getSupportedFormats()); // fake event indicating upgrade start - callHandler(handler, createEvent(path, SVNEventAction.UPDATE_COMPLETED)); + callHandler(handler, createEvent(path, EventAction.UPDATE_COMPLETED)); List<String> parameters = new ArrayList<String>(); @@ -64,9 +60,9 @@ public class CmdUpgradeClient extends BaseSvnClient implements UpgradeClient { return result; } - private static class UpgradeStatusConvertor implements Convertor<Matcher, SVNEvent> { + private static class UpgradeStatusConvertor implements Convertor<Matcher, ProgressEvent> { - public SVNEvent convert(@NotNull Matcher matcher) { + public ProgressEvent convert(@NotNull Matcher matcher) { String statusMessage = matcher.group(1); String path = matcher.group(2); @@ -74,11 +70,11 @@ public class CmdUpgradeClient extends BaseSvnClient implements UpgradeClient { } @Nullable - public static SVNEventAction createAction(@NotNull String code) { - SVNEventAction result = null; + public static EventAction createAction(@NotNull String code) { + EventAction result = null; if ("Upgraded".equals(code)) { - result = SVNEventAction.UPGRADED_PATH; + result = EventAction.UPGRADED_PATH; } return result; diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java index 66b5f71b4911..f583ad2c8eda 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/SvnKitUpgradeClient.java @@ -5,11 +5,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.api.EventAction; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.checkout.SvnKitCheckoutClient; import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; -import org.tmatesoft.svn.core.wc.SVNEventAction; import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -21,12 +21,12 @@ import java.util.List; public class SvnKitUpgradeClient extends BaseSvnClient implements UpgradeClient { @Override - public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ISVNEventHandler handler) throws VcsException { + public void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException { validateFormat(format, getSupportedFormats()); SVNWCClient client = myVcs.getSvnKitManager().createWCClient(); - client.setEventHandler(handler); + client.setEventHandler(toEventHandler(handler)); try { cleanupIfNecessary(path, format, client, handler); upgrade(path, format, client, handler); @@ -44,11 +44,11 @@ public class SvnKitUpgradeClient extends BaseSvnClient implements UpgradeClient private static void cleanupIfNecessary(@NotNull File path, @NotNull WorkingCopyFormat format, @NotNull SVNWCClient client, - @Nullable ISVNEventHandler handler) throws SVNException, VcsException { + @Nullable ProgressTracker handler) throws SVNException, VcsException { // cleanup is executed only for SVNKit as it could handle both 1.6 and 1.7 formats if (WorkingCopyFormat.ONE_DOT_SEVEN.equals(format)) { // fake event indicating cleanup start - callHandler(handler, createEvent(path, SVNEventAction.UPDATE_STARTED)); + callHandler(handler, createEvent(path, EventAction.UPDATE_STARTED)); client.doCleanup(path); } } @@ -56,9 +56,9 @@ public class SvnKitUpgradeClient extends BaseSvnClient implements UpgradeClient private static void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @NotNull SVNWCClient client, - @Nullable ISVNEventHandler handler) throws SVNException, VcsException { + @Nullable ProgressTracker handler) throws SVNException, VcsException { // fake event indicating upgrade start - callHandler(handler, createEvent(path, SVNEventAction.UPDATE_COMPLETED)); + callHandler(handler, createEvent(path, EventAction.UPDATE_COMPLETED)); client.doSetWCFormat(path, format.getFormat()); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java index 2d22acf08c45..22d916f158fd 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/upgrade/UpgradeClient.java @@ -4,8 +4,8 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.WorkingCopyFormat; +import org.jetbrains.idea.svn.api.ProgressTracker; import org.jetbrains.idea.svn.api.SvnClient; -import org.tmatesoft.svn.core.wc.ISVNEventHandler; import java.io.File; import java.util.List; @@ -15,7 +15,7 @@ import java.util.List; */ public interface UpgradeClient extends SvnClient { - void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ISVNEventHandler handler) throws VcsException; + void upgrade(@NotNull File path, @NotNull WorkingCopyFormat format, @Nullable ProgressTracker handler) throws VcsException; List<WorkingCopyFormat> getSupportedFormats() throws VcsException; } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java index 635484fd2112..cca76e17f234 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/ConflictCreator.java @@ -26,8 +26,8 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; import com.intellij.util.containers.Convertor; import junit.framework.Assert; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.StatusType; import java.io.File; import java.io.IOException; @@ -100,7 +100,7 @@ public class ConflictCreator { String subPath = ""; for (String part : parts) { final String path = subPath + part; - SVNInfo info = vcs.getInfo(new File(myTheirsDir.getPath(), path)); + Info info = vcs.getInfo(new File(myTheirsDir.getPath(), path)); if (info == null || info.getURL() == null) { myClientRunner.add(myTheirsDir, path); } @@ -161,15 +161,15 @@ public class ConflictCreator { final File target = new File(root.getPath(), fileData.myRelativePath); // we dont apply properties changes fow now - if (SVNStatusType.STATUS_MISSING.equals(fileData.myNodeStatus)) { + if (StatusType.STATUS_MISSING.equals(fileData.myNodeStatus)) { // delete existing only from fs FileUtil.delete(target); return; - } else if (SVNStatusType.STATUS_UNVERSIONED.equals(fileData.myNodeStatus)) { + } else if (StatusType.STATUS_UNVERSIONED.equals(fileData.myNodeStatus)) { // create new unversioned createFile(root, fileData, target); return; - } else if (SVNStatusType.STATUS_ADDED.equals(fileData.myNodeStatus)) { + } else if (StatusType.STATUS_ADDED.equals(fileData.myNodeStatus)) { if (fileData.myCopyFrom != null) { myClientRunner.copy(root, fileData.myCopyFrom, fileData.myRelativePath); return; @@ -177,11 +177,11 @@ public class ConflictCreator { createFile(root, fileData, target); myClientRunner.add(root, fileData.myRelativePath); return; - } else if (SVNStatusType.STATUS_DELETED.equals(fileData.myNodeStatus)) { + } else if (StatusType.STATUS_DELETED.equals(fileData.myNodeStatus)) { myClientRunner.delete(root, fileData.myRelativePath); return; - } else if (SVNStatusType.STATUS_NORMAL.equals(fileData.myNodeStatus)) { - if (SVNStatusType.STATUS_MODIFIED.equals(fileData.myContentsStatus)) { + } else if (StatusType.STATUS_NORMAL.equals(fileData.myNodeStatus)) { + if (StatusType.STATUS_MODIFIED.equals(fileData.myContentsStatus)) { createFile(root, fileData, target); return; } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java index ee9e2cd46496..d3a9bc552224 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnCachingRevisionsTest.java @@ -8,7 +8,6 @@ import com.intellij.openapi.vcs.changes.committed.ChangesBunch; import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList; import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; import org.jetbrains.idea.svn.history.*; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -36,8 +35,10 @@ public class SvnCachingRevisionsTest extends CodeInsightFixtureTestCase { } private SvnChangeList createList(final long revision) { - return new SvnChangeList(null, myLocation, - new SVNLogEntry(Collections.emptyMap(), revision, AUTHOR, new Date(System.currentTimeMillis()), ""), ROOT.toDecodedString()); + LogEntry entry = + new LogEntry.Builder().setRevision(revision).setAuthor(AUTHOR).setDate(new Date(System.currentTimeMillis())).setMessage("").build(); + + return new SvnChangeList(null, myLocation, entry, ROOT.toDecodedString()); } private class MockSvnLogLoader implements SvnLogLoader { diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java index 1ed14dce6704..b6d83ad9ed2d 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnMergeInfoTest.java @@ -24,20 +24,20 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.jetbrains.idea.svn.dialogs.WCInfo; import org.jetbrains.idea.svn.history.SvnChangeList; import org.jetbrains.idea.svn.history.SvnRepositoryLocation; +import org.jetbrains.idea.svn.info.Info; import org.jetbrains.idea.svn.mergeinfo.BranchInfo; import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; import org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache; import org.junit.Assert; import org.junit.Test; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.internal.util.SVNPathUtil; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc.SVNWCClient; @@ -86,7 +86,7 @@ public class SvnMergeInfoTest extends Svn17TestCase { VirtualFile vcsRoot = LocalFileSystem.getInstance().findFileByIoFile(myBranchVcsRoot); Node node = new Node(vcsRoot, SVNURL.parseURIEncoded(myBranchUrl), SVNURL.parseURIEncoded(myRepoUrl)); RootUrlInfo root = new RootUrlInfo(node, WorkingCopyFormat.ONE_DOT_SIX, vcsRoot, null); - myWCInfo = new WCInfo(root, true, SVNDepth.INFINITY); + myWCInfo = new WCInfo(root, true, Depth.INFINITY); myMergeContext = new MergeContext(SvnVcs.getInstance(myProject), myTrunkUrl, myWCInfo, SVNPathUtil.tail(myTrunkUrl), vcsRoot); myOneShotMergeInfoHelper = new OneShotMergeInfoHelper(myMergeContext); @@ -255,7 +255,7 @@ public class SvnMergeInfoTest extends Svn17TestCase { assertMergeInfo(myBranchVcsRoot, "/trunk:3"); - final SVNInfo f1info = myVcs.getInfo(new File(myBranchVcsRoot, "folder/f1.txt")); + final Info f1info = myVcs.getInfo(new File(myBranchVcsRoot, "folder/f1.txt")); assert f1info.getRevision().getNumber() == 2; final List<SvnChangeList> changeListList = getTrunkChangeLists(); diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java index 99f7b0cda790..a0dfa979ea74 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnNativeClientAuthTest.java @@ -30,6 +30,7 @@ import com.intellij.util.Processor; import com.intellij.util.containers.Convertor; import junit.framework.Assert; import org.jetbrains.annotations.NotNull; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationManager; import org.jetbrains.idea.svn.auth.SvnAuthenticationNotifier; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; @@ -544,7 +545,7 @@ public class SvnNativeClientAuthTest extends Svn17TestCase { root.deleteOnExit(); Assert.assertTrue(root.exists()); SvnCheckoutProvider - .checkout(myProject, root, url, SVNRevision.HEAD, SVNDepth.INFINITY, false, new CheckoutProvider.Listener() { + .checkout(myProject, root, url, SVNRevision.HEAD, Depth.INFINITY, false, new CheckoutProvider.Listener() { @Override public void directoryCheckedOut(File directory, VcsKey vcs) { } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java index ec78b9fd5f55..6e0ee960b64a 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnParseCommandLineParseTest.java @@ -24,19 +24,15 @@ import com.intellij.util.containers.Convertor; import com.intellij.util.containers.MultiMap; import junit.framework.Assert; import junit.framework.TestCase; -import org.jetbrains.idea.svn.status.CmdStatusClient; +import org.jetbrains.idea.svn.api.Depth; +import org.jetbrains.idea.svn.api.NodeKind; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.*; import org.jetbrains.idea.svn.info.SvnInfoHandler; -import org.jetbrains.idea.svn.status.SvnStatusHandler; -import org.jetbrains.idea.svn.info.IdeaSVNInfo; -import org.jetbrains.idea.svn.status.PortableStatus; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNNodeKind; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.wc.ISVNStatusHandler; -import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNStatus; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; @@ -84,10 +80,10 @@ public class SvnParseCommandLineParseTest extends TestCase { "</entry>\n" + "</info>"; - final SVNInfo[] info = new SVNInfo[1]; - final SvnInfoHandler handler = new SvnInfoHandler(new File("C:/base/"), new Consumer<SVNInfo>() { + final Info[] info = new Info[1]; + final SvnInfoHandler handler = new SvnInfoHandler(new File("C:/base/"), new Consumer<Info>() { @Override - public void consume(SVNInfo info1) { + public void consume(Info info1) { info[0] = info1; } }); @@ -574,9 +570,9 @@ public class SvnParseCommandLineParseTest extends TestCase { @Override public void switchChangeList(String newList) { } - }, new File(basePath), new Convertor<File, SVNInfo>() { + }, new File(basePath), new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { o.getCanonicalFile(); } @@ -616,9 +612,9 @@ public class SvnParseCommandLineParseTest extends TestCase { return StringUtil.replace(s, "C:/", LINUX_ROOT); } - private IdeaSVNInfo createStubInfo(final String basePath, final String baseUrl) throws SVNException { - return new IdeaSVNInfo(basePath, SVNURL.parseURIEncoded(baseUrl), SVNRevision.HEAD, SVNNodeKind.FILE, "", - SVNURL.parseURIEncoded("http://a.b.c"), 1, new Date(), "me", null, SVNDepth.EMPTY, 1); + private Info createStubInfo(final String basePath, final String baseUrl) throws SVNException { + return new Info(basePath, SVNURL.parseURIEncoded(baseUrl), SVNRevision.HEAD, NodeKind.FILE, "", + SVNURL.parseURIEncoded("http://a.b.c"), 1, new Date(), "me", null, Depth.EMPTY); } public void testStatusInExternalMove() throws Exception { @@ -671,9 +667,9 @@ public class SvnParseCommandLineParseTest extends TestCase { final String basePath = "C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main"; final SvnStatusHandler[] handler = new SvnStatusHandler[1]; final File baseFile = new File(basePath); - final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(new ISVNStatusHandler() { + final SvnStatusHandler.ExternalDataCallback callback = CmdStatusClient.createStatusCallback(new StatusConsumer() { @Override - public void handleStatus(SVNStatus status) throws SVNException { + public void consume(Status status) throws SVNException { System.out.println(status.getURL()); if (new File( "C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave\\src\\com\\slave\\MacMessagesParser.java") @@ -686,9 +682,9 @@ public class SvnParseCommandLineParseTest extends TestCase { } } }, baseFile, createStubInfo(basePath, "http://mainurl/"), handler); - handler[0] = new SvnStatusHandler(callback, baseFile, new Convertor<File, SVNInfo>() { + handler[0] = new SvnStatusHandler(callback, baseFile, new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { if (new File("C:\\TestProjects\\sortedProjects\\Subversion\\local2\\sep12main\\main\\slave").equals(o)) { return createStubInfo(o.getPath(), "http://external"); @@ -756,9 +752,9 @@ public class SvnParseCommandLineParseTest extends TestCase { @Override public void switchChangeList(String newList) { } - }, new File(basePath), new Convertor<File, SVNInfo>() { + }, new File(basePath), new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { o.getCanonicalFile(); } @@ -846,9 +842,9 @@ public class SvnParseCommandLineParseTest extends TestCase { public void switchChangeList(String newList) { clName[0] = newList; } - }, new File(basePath), new Convertor<File, SVNInfo>() { + }, new File(basePath), new Convertor<File, Info>() { @Override - public SVNInfo convert(File o) { + public Info convert(File o) { try { o.getCanonicalFile(); } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java index 358f3722d7b5..af17c9aa2190 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnProtocolsTest.java @@ -35,6 +35,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; import com.intellij.util.containers.Convertor; import junit.framework.Assert; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.auth.SvnAuthenticationManager; import org.jetbrains.idea.svn.checkout.SvnCheckoutProvider; import org.junit.Before; @@ -222,7 +223,7 @@ public class SvnProtocolsTest extends Svn17TestCase { root.deleteOnExit(); Assert.assertTrue(root.exists()); SvnCheckoutProvider - .checkout(myProject, root, url, SVNRevision.HEAD, SVNDepth.INFINITY, false, new CheckoutProvider.Listener() { + .checkout(myProject, root, url, SVNRevision.HEAD, Depth.INFINITY, false, new CheckoutProvider.Listener() { @Override public void directoryCheckedOut(File directory, VcsKey vcs) { } diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java index 071da76aee78..03d3875b37b2 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnResolveTreeAcceptVariantsTest.java @@ -26,12 +26,12 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; import junit.framework.Assert; +import org.jetbrains.idea.svn.info.Info; +import org.jetbrains.idea.svn.status.Status; +import org.jetbrains.idea.svn.status.StatusType; import org.jetbrains.idea.svn.treeConflict.SvnTreeConflictResolver; import org.junit.Before; import org.junit.Test; -import org.tmatesoft.svn.core.wc.SVNInfo; -import org.tmatesoft.svn.core.wc.SVNStatus; -import org.tmatesoft.svn.core.wc.SVNStatusType; import java.io.File; import java.io.IOException; @@ -162,43 +162,43 @@ public class SvnResolveTreeAcceptVariantsTest extends Svn17TestCase { } private void checkStatusesAfterMineFullResolve(TreeConflictData.Data data, File conflictIoFile) { - SVNStatus conflStatus = SvnUtil.getStatus(myVcs, conflictIoFile); + Status conflStatus = SvnUtil.getStatus(myVcs, conflictIoFile); Assert.assertTrue(createTestFailedComment(data, conflictIoFile.getPath()) + " tree conflict resolved", conflStatus.getTreeConflict() == null); Collection<TreeConflictData.FileData> leftFiles = data.getLeftFiles(); for (TreeConflictData.FileData file : leftFiles) { File exFile = new File(myWorkingCopyDir.getPath(), file.myRelativePath); - final SVNStatus status = SvnUtil.getStatus(myVcs, exFile); + final Status status = SvnUtil.getStatus(myVcs, exFile); boolean theirsExists = new File(myTheirs.getPath(), file.myRelativePath).exists(); - if (SVNStatusType.STATUS_UNVERSIONED.equals(file.myNodeStatus)) { + if (StatusType.STATUS_UNVERSIONED.equals(file.myNodeStatus)) { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (file exists)", exFile.exists()); if (theirsExists) { // should be deleted - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || SVNStatusType.STATUS_DELETED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || StatusType.STATUS_DELETED.equals(status.getNodeStatus())); } else { // unversioned - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || SVNStatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (unversioned)", status == null || StatusType.STATUS_UNVERSIONED.equals(status.getNodeStatus())); } - } else if (SVNStatusType.STATUS_DELETED.equals(file.myNodeStatus)) { + } else if (StatusType.STATUS_DELETED.equals(file.myNodeStatus)) { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (deleted status)", status != null && file.myNodeStatus.equals(status.getNodeStatus())); - } else if (SVNStatusType.STATUS_ADDED.equals(file.myNodeStatus)) { + } else if (StatusType.STATUS_ADDED.equals(file.myNodeStatus)) { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (file exists)", exFile.exists()); if (theirsExists) { - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && SVNStatusType.STATUS_REPLACED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && StatusType.STATUS_REPLACED.equals(status.getNodeStatus())); } else { - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (added status)", status != null && StatusType.STATUS_ADDED.equals(status.getNodeStatus())); } } else { - if (SVNStatusType.STATUS_ADDED.equals(status.getNodeStatus())) { + if (StatusType.STATUS_ADDED.equals(status.getNodeStatus())) { // in theirs -> deleted Assert.assertFalse(createTestFailedComment(data, file.myRelativePath) + " check deleted in theirs", theirsExists); } else { if (theirsExists) { - Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (normal node status)", status != null && SVNStatusType.STATUS_REPLACED.equals(status.getNodeStatus())); + Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (normal node status)", status != null && StatusType.STATUS_REPLACED.equals(status.getNodeStatus())); } else { Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (normal node status)", status != null && - (SVNStatusType.STATUS_NORMAL.equals(status.getNodeStatus()) || SVNStatusType.STATUS_MODIFIED.equals(status.getNodeStatus()))); + (StatusType.STATUS_NORMAL.equals(status.getNodeStatus()) || StatusType.STATUS_MODIFIED.equals(status.getNodeStatus()))); } } Assert.assertTrue(createTestFailedComment(data, exFile.getPath()) + " (modified text status)", status != null && file.myContentsStatus.equals(status.getContentsStatus())); @@ -271,8 +271,8 @@ public class SvnResolveTreeAcceptVariantsTest extends Svn17TestCase { exists); } final File theirsFile = new File(file.getPath()); - SVNInfo theirsInfo = myVcs.getInfo(theirsFile); - SVNInfo thisInfo = myVcs.getInfo(workingFile); + Info theirsInfo = myVcs.getInfo(theirsFile); + Info thisInfo = myVcs.getInfo(workingFile); if (theirsInfo != null) { Assert.assertEquals("Check failed for test: " + getTestName(data) + " and file: " + relative + " in: " + myWorkingCopyDir.getPath() + ", theirs: " + theirsInfo.getRevision().getNumber() + ", mine: " + thisInfo.getRevision().getNumber(), diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java index a38d851fbe8e..00172495348c 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/SvnTreeConflictDataTest.java @@ -23,18 +23,15 @@ import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import junit.framework.Assert; +import org.jetbrains.idea.svn.conflict.ConflictAction; +import org.jetbrains.idea.svn.conflict.ConflictOperation; +import org.jetbrains.idea.svn.conflict.ConflictVersion; +import org.jetbrains.idea.svn.conflict.TreeConflictDescription; import org.junit.Before; import org.junit.Test; -import org.tmatesoft.svn.core.SVNNodeKind; -import org.tmatesoft.svn.core.internal.wc.SVNConflictVersion; -import org.tmatesoft.svn.core.wc.SVNConflictAction; -import org.tmatesoft.svn.core.wc.SVNOperation; -import org.tmatesoft.svn.core.wc.SVNTreeConflictDescription; import java.io.File; -import static com.intellij.util.TimeoutUtil.sleep; - /** * @author Irina.Chernushina * @since 2.05.2012 @@ -71,20 +68,20 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); Assert.assertNull(beforeDescription.getSourceLeftVersion()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -99,22 +96,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertTrue(version.isNone()); } private String createConflict(final TreeConflictData.Data data) throws Exception { @@ -138,22 +135,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -168,22 +165,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertTrue(version.isNone()); } @Test @@ -198,21 +195,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); + } @Test @@ -229,22 +227,23 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isFile()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); + } @Test @@ -261,22 +260,23 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - //Assert.assertEquals(SVNNodeKind.FILE, leftVersion.getKind()); + //Assert.assertEquals(NodeKind.FILE, leftVersion.getKind()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); + } //---------------------------------- dirs -------------------------------------------------------- @@ -292,21 +292,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } // not a conflict in Subversion 1.7.7. "mine" file becomes added @@ -322,22 +322,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertEquals(NodeKind.DIR, leftVersion.getKind()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertEquals(NodeKind.NONE, version.getKind()); }*/ @Test @@ -350,22 +350,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { final Change change = changeListManager.getChange(new FilePathImpl(new File(myWorkingCopyDir.getPath(), conflictFile), true)); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isDirectory()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -380,22 +380,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.DELETE, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.DELETE, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isDirectory()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.NONE, version.getKind()); + Assert.assertTrue(version.isNone()); } @Test @@ -410,21 +410,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -437,22 +437,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { final Change change = changeListManager.getChange(new FilePathImpl(new File(myWorkingCopyDir.getPath(), conflictFile), true)); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.EDIT, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNotNull(leftVersion); - Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + Assert.assertTrue(leftVersion.isDirectory()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -465,22 +465,22 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { final Change change = changeListManager.getChange(new FilePathImpl(new File(myWorkingCopyDir.getPath(), conflictFile), true)); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - //Assert.assertEquals(SVNNodeKind.DIR, leftVersion.getKind()); + //Assert.assertEquals(NodeKind.DIR, leftVersion.getKind()); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } //--------------------------------- @Test @@ -498,21 +498,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -530,21 +530,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -562,21 +562,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -594,21 +594,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } @Test @@ -626,21 +626,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.DIR, version.getKind()); + Assert.assertTrue(version.isDirectory()); } //****************************************** // dir -> file (mine, theirs) @@ -659,21 +659,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -691,21 +691,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -723,21 +723,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -755,21 +755,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } @Test @@ -787,21 +787,21 @@ public class SvnTreeConflictDataTest extends Svn17TestCase { Assert.assertNotNull(vf); final Change change = changeListManager.getChange(vf); Assert.assertTrue(change instanceof ConflictedSvnChange); - SVNTreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); + TreeConflictDescription beforeDescription = ((ConflictedSvnChange)change).getBeforeDescription(); Assert.assertNotNull(beforeDescription); - final SVNTreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); + final TreeConflictDescription afterDescription = ((ConflictedSvnChange)change).getAfterDescription(); Assert.assertNull(afterDescription); - Assert.assertEquals(SVNOperation.UPDATE, beforeDescription.getOperation()); - Assert.assertEquals(SVNConflictAction.ADD, beforeDescription.getConflictAction()); + Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation()); + Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction()); Assert.assertTrue(beforeDescription.isTreeConflict()); - SVNConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); + ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion(); Assert.assertNull(leftVersion); - final SVNConflictVersion version = beforeDescription.getSourceRightVersion(); + final ConflictVersion version = beforeDescription.getSourceRightVersion(); Assert.assertNotNull(version); - Assert.assertEquals(SVNNodeKind.FILE, version.getKind()); + Assert.assertTrue(version.isFile()); } private void createSubTree() throws Exception { diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java index 2114e0e0b82b..178253bf58bf 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn/TreeConflictData.java @@ -15,7 +15,7 @@ */ package org.jetbrains.idea.svn; -import org.tmatesoft.svn.core.wc.SVNStatusType; +import org.jetbrains.idea.svn.status.StatusType; import java.util.ArrayList; import java.util.Arrays; @@ -51,8 +51,8 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "added.txt", new FileData[]{new FileData("added.txt", "unversioned text", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "added.txt", new FileData[]{new FileData("added.txt", "unversioned text", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_EDIT_THEIRS_DELETE = new Data("Index: root/source/s1.txt\n" + @@ -62,8 +62,8 @@ public interface TreeConflictData { "@@ -1,1 +0,0 @@\n" + "-123\n" + "\\ No newline at end of file\n", "root/source/s1.txt", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_DELETE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + @@ -73,24 +73,24 @@ public interface TreeConflictData { "\\ No newline at end of file\n" + "+1*2*3\n" + "\\ No newline at end of file\n", "root/source/s1.txt", - new FileData[] {new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, false)}); + new FileData[] {new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false)}); Data MINE_EDIT_THEIRS_MOVE = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + "+++ root/source/s1renamed.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source/s1.txt", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_UNV_THEIRS_MOVE = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + "+++ root/source/s1renamed.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source/s1renamed.txt", - new FileData[] {new FileData("root/source/s1renamed.txt", "1*2*3", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData[] {new FileData("root/source/s1renamed.txt", "1*2*3", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + @@ -102,10 +102,10 @@ public interface TreeConflictData { "+1*2*3\n" + // conflict would be marked by svn on s1.txt, but here we put s1moved.txt, for change list manager to find the change "\\ No newline at end of file\n", "root/source/s1moved.txt", - new FileData[] {new FileData("root/source/s1moved.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, false, "root/source/s1.txt"), - new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, false)}); + new FileData[] {new FileData("root/source/s1moved.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, false, "root/source/s1.txt"), + new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: root/source/s1moved.txt\n" + "===================================================================\n" + "--- root/source/s1moved.txt\t(revision )\n" + @@ -114,10 +114,10 @@ public interface TreeConflictData { "+added text\n" + "\\ No newline at end of file\n", "root/source/s1moved.txt", - new FileData[] {new FileData("root/source/s1moved.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, false, "root/source/s1.txt"), - new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, false)}) { + new FileData[] {new FileData("root/source/s1moved.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, false, "root/source/s1.txt"), + new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false)}) { @Override protected void afterInit() { setExcludeFromToTheirsCheck("root\\source\\s1.txt"); @@ -133,11 +133,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", null, SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir", new FileData[]{new FileData("addedDir", null, StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("addedDir/unv.txt", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("addedDir/unv.txt", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_EDIT_THEIRS_DELETE = new Data("Index: root/source/s1.txt\n" + @@ -154,8 +154,8 @@ public interface TreeConflictData { "@@ -1,1 +0,0 @@\n" + "-abc\n" + "\\ No newline at end of file\n", "root/source", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_DELETE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + "===================================================================\n" + "--- root/source/s1.txt\t(revision 358)\n" + @@ -165,8 +165,8 @@ public interface TreeConflictData { "\\ No newline at end of file\n" + "+1*2*3\n" + "\\ No newline at end of file\n", "root/source", - new FileData[] {new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}); + new FileData[] {new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}); Data MINE_EDIT_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -180,8 +180,8 @@ public interface TreeConflictData { "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source", - new FileData[] {new FileData("root/source/s1.txt", "1*2*3", SVNStatusType.STATUS_NORMAL, - SVNStatusType.STATUS_MODIFIED, SVNStatusType.STATUS_NORMAL, false)}); + new FileData[] {new FileData("root/source/s1.txt", "1*2*3", StatusType.STATUS_NORMAL, + StatusType.STATUS_MODIFIED, StatusType.STATUS_NORMAL, false)}); Data MINE_UNV_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -194,11 +194,11 @@ public interface TreeConflictData { "--- root/source/s2.txt\t(revision 358)\n" + "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", "root/source1", - new FileData[] {new FileData("root/source1", null, SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData[] {new FileData("root/source1", null, StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("root/source1/unv.txt", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("root/source1/unv.txt", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_EDIT = new Data("Index: root/source/s1.txt\n" + @@ -211,10 +211,10 @@ public interface TreeConflictData { "+1*2*3\n" + "\\ No newline at end of file\n", "root/source", new FileData[] { - new FileData("root/sourceNew", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, true, "root/source"), - new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}); + new FileData("root/sourceNew", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, true, "root/source"), + new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: root/sourceNew/added.txt\n" + "===================================================================\n" + "--- root/sourceNew/added.txt\t(revision )\n" + @@ -223,10 +223,10 @@ public interface TreeConflictData { "+added text\n" + "\\ No newline at end of file\n", "root/sourceNew", new FileData[] { - new FileData("root/sourceNew", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, true, "root/source"), - new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}) { + new FileData("root/sourceNew", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, true, "root/source"), + new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}) { @Override protected void afterInit() { setExcludeFromToTheirsCheck("root\\source", "root\\source\\s1.txt", "root\\source\\s2.txt"); @@ -243,8 +243,8 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir", new FileData[]{new FileData("addedDir", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_ADD = new Data("Index: addedDir/added.txt\n" + @@ -254,8 +254,8 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", "unversioned", SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir", new FileData[]{new FileData("addedDir", "unversioned", StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_UNV_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -268,8 +268,8 @@ public interface TreeConflictData { "--- root/source/s2.txt\t(revision 358)\n" + "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", - "root/source1", new FileData[]{new FileData("root/source1", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "root/source1", new FileData[]{new FileData("root/source1", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -282,8 +282,8 @@ public interface TreeConflictData { "--- root/source/s2.txt\t(revision 358)\n" + "+++ root/source1/s2.txt\t(revision )\n" + "@@ -1,0 +1,0 @@\n", - "root/source1", new FileData[]{new FileData("root/source1", "unversioned", SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "root/source1", new FileData[]{new FileData("root/source1", "unversioned", StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: addedDir/added.txt\n" + "===================================================================\n" + @@ -292,11 +292,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir", new FileData[]{new FileData("addedDir", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, + "addedDir", new FileData[]{new FileData("addedDir", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, false, "root/source/s1.txt"), - new FileData("root/source/s1.txt", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, + new FileData("root/source/s1.txt", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, false, null)}) { @Override protected void afterInit() { @@ -314,11 +314,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("addedDir.txt/unv.txt", "unversioned", SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("addedDir.txt/unv.txt", "unversioned", StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_ADD = new Data("Index: addedDir.txt\n" + @@ -328,11 +328,11 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), - new FileData("addedDir.txt/unv.txt", "unversioned", SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + new FileData("addedDir.txt/unv.txt", "unversioned", StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_UNV_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -342,12 +342,12 @@ public interface TreeConflictData { "@@ -1,0 +1,0 @@\n" + "\\ No newline at end of file\n", "root/source/s1renamed.txt", new FileData[]{new FileData("root/source/s1renamed.txt", null, - SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), new FileData("root/source/s1renamed.txt/file.txt", "unversioned", - SVNStatusType.STATUS_UNVERSIONED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_ADD_THEIRS_MOVE = new Data( "Index: root/source/s1.txt\n" + @@ -357,12 +357,12 @@ public interface TreeConflictData { "@@ -1,0 +1,0 @@\n" + "\\ No newline at end of file\n", "root/source/s1renamed.txt", new FileData[]{new FileData("root/source/s1renamed.txt", null, - SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, true), new FileData("root/source/s1renamed.txt/file.txt", "unversioned", - SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_UNVERSIONED, SVNStatusType.STATUS_UNVERSIONED, + StatusType.STATUS_ADDED, + StatusType.STATUS_UNVERSIONED, StatusType.STATUS_UNVERSIONED, false)}); Data MINE_MOVE_THEIRS_ADD = new Data("Index: addedDir.txt\n" + @@ -372,10 +372,10 @@ public interface TreeConflictData { "@@ -0,0 +1,1 @@\n" + "+added text\n" + "\\ No newline at end of file\n", - "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, SVNStatusType.STATUS_ADDED, - SVNStatusType.STATUS_ADDED, SVNStatusType.STATUS_ADDED, true, "root/source"), - new FileData("root/source", null, SVNStatusType.STATUS_DELETED, - SVNStatusType.STATUS_DELETED, SVNStatusType.STATUS_DELETED, true)}) { + "addedDir.txt", new FileData[]{new FileData("addedDir.txt", null, StatusType.STATUS_ADDED, + StatusType.STATUS_ADDED, StatusType.STATUS_ADDED, true, "root/source"), + new FileData("root/source", null, StatusType.STATUS_DELETED, + StatusType.STATUS_DELETED, StatusType.STATUS_DELETED, true)}) { @Override protected void afterInit() { setExcludeFromToTheirsCheck("root\\source", "root\\source\\s1.txt", "root\\source\\s2.txt"); @@ -424,26 +424,26 @@ public interface TreeConflictData { public final String myRelativePath; public final String myContents; public final String myCopyFrom; - public final SVNStatusType myNodeStatus; - public final SVNStatusType myContentsStatus; + public final StatusType myNodeStatus; + public final StatusType myContentsStatus; // not used for now - public final SVNStatusType myPropertiesStatus; + public final StatusType myPropertiesStatus; public boolean myIsDir; public FileData(String relativePath, String contents, - SVNStatusType nodeStatus, - SVNStatusType contentsStatus, - SVNStatusType propertiesStatus, + StatusType nodeStatus, + StatusType contentsStatus, + StatusType propertiesStatus, boolean isDir) { this(relativePath, contents, nodeStatus, contentsStatus, propertiesStatus, isDir, null); } public FileData(String relativePath, String contents, - SVNStatusType nodeStatus, - SVNStatusType contentsStatus, - SVNStatusType propertiesStatus, + StatusType nodeStatus, + StatusType contentsStatus, + StatusType propertiesStatus, boolean isDir, final String copyFrom) { myRelativePath = relativePath; myContents = contents; diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java index 749ee38c9336..c5f7b9d4757e 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnCachingRevisionsTest.java @@ -10,7 +10,6 @@ import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase; import org.jetbrains.idea.svn.SvnApplicationSettings; import org.jetbrains.idea.svn.SvnUtil; import org.jetbrains.idea.svn.history.*; -import org.tmatesoft.svn.core.SVNLogEntry; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNRevision; @@ -38,8 +37,9 @@ public class SvnCachingRevisionsTest extends CodeInsightFixtureTestCase { } private SvnChangeList createList(final long revision) { - return new SvnChangeList(null, myLocation, - new SVNLogEntry(Collections.emptyMap(), revision, AUTHOR, new Date(System.currentTimeMillis()), ""), ROOT.toDecodedString()); + LogEntry entry = + new LogEntry.Builder().setRevision(revision).setAuthor(AUTHOR).setDate(new Date(System.currentTimeMillis())).setMessage("").build(); + return new SvnChangeList(null, myLocation, entry, ROOT.toDecodedString()); } private class MockSvnLogLoader implements SvnLogLoader { diff --git a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java index cab82d7fc929..028b8c5c631a 100644 --- a/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java +++ b/plugins/svn4idea/testSource/org/jetbrains/idea/svn16/SvnMergeInfoTest.java @@ -25,6 +25,7 @@ import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.svn.*; +import org.jetbrains.idea.svn.api.Depth; import org.jetbrains.idea.svn.dialogs.MergeContext; import org.jetbrains.idea.svn.dialogs.WCInfo; import org.jetbrains.idea.svn.history.SvnChangeList; @@ -34,7 +35,6 @@ import org.jetbrains.idea.svn.mergeinfo.OneShotMergeInfoHelper; import org.jetbrains.idea.svn.mergeinfo.SvnMergeInfoCache; import org.junit.Assert; import org.junit.Test; -import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.SVNInfo; import org.tmatesoft.svn.core.wc.SVNPropertyData; @@ -65,7 +65,7 @@ public class SvnMergeInfoTest extends Svn16TestCase { VirtualFile vcsRoot = LocalFileSystem.getInstance().findFileByIoFile(myBranchVcsRoot); Node node = new Node(vcsRoot, SVNURL.parseURIEncoded(myRepoUrl + "/branch"), SVNURL.parseURIEncoded(myRepoUrl)); RootUrlInfo root = new RootUrlInfo(node, WorkingCopyFormat.ONE_DOT_SIX, vcsRoot, null); - myWCInfo = new WCInfo(root, true, SVNDepth.INFINITY); + myWCInfo = new WCInfo(root, true, Depth.INFINITY); myMergeContext = new MergeContext(SvnVcs.getInstance(myProject), myRepoUrl + "/trunk", myWCInfo, "trunk", vcsRoot); myOneShotMergeInfoHelper = new OneShotMergeInfoHelper(myMergeContext); diff --git a/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java b/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java index 5a0aa95bdec7..30ecaf19f2da 100644 --- a/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java +++ b/plugins/tasks/tasks-api/src/com/intellij/tasks/impl/BaseRepositoryImpl.java @@ -1,9 +1,11 @@ package com.intellij.tasks.impl; +import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.tasks.TaskRepositoryType; import com.intellij.tasks.config.TaskSettings; import com.intellij.util.net.HttpConfigurable; +import com.intellij.util.net.ssl.CertificateManager; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.auth.AuthScope; import org.jetbrains.annotations.NotNull; @@ -51,6 +53,11 @@ public abstract class BaseRepositoryImpl extends BaseRepository { private HttpClient createClient() { HttpClient client = new HttpClient(new MultiThreadedHttpConnectionManager()); configureHttpClient(client); + // After CertificateManager became application service it no longer "automagically" preliminarily + // initializes default SSL context as required for trackers written in httpclient 3.x. + // Clients that use httpclient 4.x (see NewBaseRepositoryImpl.getHttpClient) install SSL context explicitly though. + // This workaround allows to install context properly as soon as HTTP client is needed. + ServiceManager.getService(CertificateManager.class); return client; } @@ -76,7 +83,8 @@ public abstract class BaseRepositoryImpl extends BaseRepository { client.getParams().setCredentialCharset("UTF-8"); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(getUsername(), getPassword())); - } else { + } + else { client.getState().clearCredentials(); client.getParams().setAuthenticationPreemptive(false); } diff --git a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRemoteApi.java b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRemoteApi.java index 22e93a9d26ee..8ee9c97512a1 100644 --- a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRemoteApi.java +++ b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRemoteApi.java @@ -5,7 +5,7 @@ import com.intellij.tasks.Task; import com.intellij.tasks.TaskState; import com.intellij.tasks.jira.rest.api2.JiraRestApi2; import com.intellij.tasks.jira.rest.api20alpha1.JiraRestApi20Alpha1; -import com.intellij.tasks.jira.soap.JiraSoapApi; +import com.intellij.tasks.jira.soap.JiraLegacyApi; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,11 +47,11 @@ public abstract class JiraRemoteApi { public abstract ApiType getType(); public enum ApiType { - SOAP("SOAP") { + LEGACY("XML-RPC + RSS") { @NotNull @Override - public JiraSoapApi createApi(@NotNull JiraRepository repository) { - return new JiraSoapApi(repository); + public JiraLegacyApi createApi(@NotNull JiraRepository repository) { + return new JiraLegacyApi(repository); } }, REST_2_0("REST 2.0") { diff --git a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepository.java b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepository.java index c5a469a40c33..b8004ca70023 100644 --- a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepository.java +++ b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepository.java @@ -15,23 +15,31 @@ import com.intellij.tasks.impl.BaseRepositoryImpl; import com.intellij.tasks.impl.TaskUtil; import com.intellij.tasks.impl.gson.GsonUtil; import com.intellij.tasks.jira.rest.JiraRestApi; -import com.intellij.tasks.jira.soap.JiraSoapApi; +import com.intellij.tasks.jira.soap.JiraLegacyApi; import com.intellij.util.ArrayUtil; import com.intellij.util.containers.ContainerUtil; import com.intellij.util.xmlb.annotations.Tag; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.xmlrpc.CommonsXmlRpcTransport; +import org.apache.xmlrpc.XmlRpcClient; +import org.apache.xmlrpc.XmlRpcRequest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.InputStream; +import java.net.URL; +import java.util.Collections; +import java.util.Hashtable; import java.util.List; +import java.util.Vector; import java.util.regex.Pattern; /** * @author Dmitry Avdeev */ +@SuppressWarnings("UseOfObsoleteCollectionType") @Tag("JIRA") public class JiraRepository extends BaseRepositoryImpl { @@ -51,6 +59,7 @@ public class JiraRepository extends BaseRepositoryImpl { private String mySearchQuery = TaskBundle.message("jira.default.query"); private JiraRemoteApi myApiVersion; + private String myJiraVersion; /** * Serialization constructor @@ -69,6 +78,7 @@ public class JiraRepository extends BaseRepositoryImpl { private JiraRepository(JiraRepository other) { super(other); mySearchQuery = other.mySearchQuery; + myJiraVersion = other.myJiraVersion; if (other.myApiVersion != null) { myApiVersion = other.myApiVersion.getType().createApi(this); } @@ -77,8 +87,13 @@ public class JiraRepository extends BaseRepositoryImpl { @Override public boolean equals(Object o) { if (!super.equals(o)) return false; - if (o.getClass() != getClass()) return false; - return Comparing.equal(mySearchQuery, ((JiraRepository)o).mySearchQuery); + if (!(o instanceof JiraRepository)) return false; + + JiraRepository repository = (JiraRepository)o; + + if (!Comparing.equal(mySearchQuery, repository.getSearchQuery())) return false; + if (!Comparing.equal(myJiraVersion, repository.getJiraVersion())) return false; + return true; } @@ -149,7 +164,7 @@ public class JiraRepository extends BaseRepositoryImpl { public JiraRemoteApi discoverApiVersion() throws Exception { if (LEGACY_API_ONLY) { LOG.info("Intentionally using only legacy JIRA API"); - return new JiraSoapApi(this); + return createLegacyApi(); } String responseBody; @@ -164,7 +179,7 @@ public class JiraRepository extends BaseRepositoryImpl { // not the way to check it safely. StatusLine status = method.getStatusLine(); if (status != null && status.getStatusCode() == HttpStatus.SC_NOT_FOUND) { - return new JiraSoapApi(this); + return createLegacyApi(); } else { throw e; @@ -173,13 +188,31 @@ public class JiraRepository extends BaseRepositoryImpl { JsonObject object = GSON.fromJson(responseBody, JsonObject.class); // when JIRA 4.x support will be dropped 'versionNumber' array in response // may be used instead version string parsing - JiraRestApi restApi = JiraRestApi.fromJiraVersion(object.get("version").getAsString(), this); + myJiraVersion = object.get("version").getAsString(); + JiraRestApi restApi = JiraRestApi.fromJiraVersion(myJiraVersion, this); if (restApi == null) { throw new Exception(TaskBundle.message("jira.failure.no.REST")); } return restApi; } + private JiraLegacyApi createLegacyApi() { + try { + XmlRpcClient client = new XmlRpcClient(getUrl()); + Vector<String> parameters = new Vector<String>(Collections.singletonList("")); + XmlRpcRequest request = new XmlRpcRequest("jira1.getServerInfo", parameters); + @SuppressWarnings("unchecked") Hashtable<String, Object> response = + (Hashtable<String, Object>)client.execute(request, new CommonsXmlRpcTransport(new URL(getUrl()), getHttpClient())); + if (response != null) { + myJiraVersion = (String)response.get("version"); + } + } + catch (Exception e) { + LOG.error("Cannot find out JIRA version via XML-RPC", e); + } + return new JiraLegacyApi(this); + } + private void ensureApiVersionDiscovered() throws Exception { if (myApiVersion == null || LEGACY_API_ONLY || REDISCOVER_API) { myApiVersion = discoverApiVersion(); @@ -275,7 +308,7 @@ public class JiraRepository extends BaseRepositoryImpl { } private boolean isRestApiSupported() { - return myApiVersion != null && myApiVersion.getType() != JiraRemoteApi.ApiType.SOAP; + return myApiVersion != null && myApiVersion.getType() != JiraRemoteApi.ApiType.LEGACY; } public boolean isJqlSupported() { @@ -322,6 +355,16 @@ public class JiraRepository extends BaseRepositoryImpl { } } + @Nullable + public String getJiraVersion() { + return myJiraVersion; + } + + @SuppressWarnings("UnusedDeclaration") + public void setJiraVersion(@Nullable String jiraVersion) { + myJiraVersion = jiraVersion; + } + public String getRestUrl(String... parts) { return getUrl() + REST_API_PATH + "/" + StringUtil.join(parts, "/"); } diff --git a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepositoryEditor.java b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepositoryEditor.java index 3299ac427432..a8ed1f880bf7 100644 --- a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepositoryEditor.java +++ b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/JiraRepositoryEditor.java @@ -16,7 +16,7 @@ package com.intellij.tasks.jira; import com.intellij.openapi.project.Project; -import com.intellij.tasks.TaskBundle; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.tasks.config.BaseRepositoryEditor; import com.intellij.tasks.jira.jql.JqlLanguage; import com.intellij.ui.EditorTextField; @@ -35,6 +35,7 @@ import javax.swing.*; public class JiraRepositoryEditor extends BaseRepositoryEditor<JiraRepository> { private EditorTextField mySearchQueryField; private JBLabel mySearchLabel; + private JBLabel myNoteLabel; public JiraRepositoryEditor(Project project, JiraRepository repository, Consumer<JiraRepository> changeListener) { super(project, repository, changeListener); @@ -53,6 +54,7 @@ public class JiraRepositoryEditor extends BaseRepositoryEditor<JiraRepository> { if (connectionSuccessful) { enableJqlSearchIfSupported(); } + updateNote(); } @Nullable @@ -62,14 +64,20 @@ public class JiraRepositoryEditor extends BaseRepositoryEditor<JiraRepository> { enableJqlSearchIfSupported(); installListener(mySearchQueryField); mySearchLabel = new JBLabel("Search:", SwingConstants.RIGHT); - JBLabel note = new JBLabel(TaskBundle.message("jira.failure.no.JQL")); - note.setComponentStyle(UIUtil.ComponentStyle.SMALL); + myNoteLabel = new JBLabel(); + myNoteLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL); + updateNote(); return FormBuilder.createFormBuilder() .addLabeledComponent(mySearchLabel, mySearchQueryField) - .addComponentToRightColumn(note) + .addComponentToRightColumn(myNoteLabel) .getPanel(); } + private void updateNote() { + myNoteLabel.setText("JQL search cannot be used in JIRA versions prior 4.2. " + + String.format("Your version: %s.", StringUtil.notNullize(myRepository.getJiraVersion(), "unknown"))); + } + @Override public void setAnchor(@Nullable final JComponent anchor) { super.setAnchor(anchor); diff --git a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/soap/JiraSoapApi.java b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/soap/JiraLegacyApi.java index 148432902a86..e8cbee842cda 100644 --- a/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/soap/JiraSoapApi.java +++ b/plugins/tasks/tasks-core/jira/src/com/intellij/tasks/jira/soap/JiraLegacyApi.java @@ -22,18 +22,18 @@ import org.jetbrains.annotations.Nullable; import java.util.List; /** - * Legacy SOAP connector restored due to IDEA-120595. + * Legacy integration restored due to IDEA-120595. * * @author Mikhail Golubev */ -public class JiraSoapApi extends JiraRemoteApi { +public class JiraLegacyApi extends JiraRemoteApi { - private static final Logger LOG = Logger.getInstance(JiraSoapApi.class); + private static final Logger LOG = Logger.getInstance(JiraLegacyApi.class); @NonNls private static final String RSS_SEARCH_PATH = "/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml"; public static final String RSS_ISSUE_PATH = "/si/jira.issueviews:issue-xml/"; - public JiraSoapApi(@NotNull JiraRepository repository) { + public JiraLegacyApi(@NotNull JiraRepository repository) { super(repository); } @@ -99,7 +99,7 @@ public class JiraSoapApi extends JiraRemoteApi { @NotNull @Override public final ApiType getType() { - return ApiType.SOAP; + return ApiType.LEGACY; } @Override diff --git a/plugins/tasks/tasks-core/src/META-INF/plugin.xml b/plugins/tasks/tasks-core/src/META-INF/plugin.xml index 36268b408073..6f3ac82f463a 100644 --- a/plugins/tasks/tasks-core/src/META-INF/plugin.xml +++ b/plugins/tasks/tasks-core/src/META-INF/plugin.xml @@ -103,7 +103,7 @@ <extensions defaultExtensionNs="com.intellij"> <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/> - <projectConfigurable instance="com.intellij.tasks.config.TaskConfigurable" id="tasks" displayName="Tasks" nonDefaultProject="true"> + <projectConfigurable groupId="tools" instance="com.intellij.tasks.config.TaskConfigurable" id="tasks" displayName="Tasks" nonDefaultProject="true"> <configurable instance="com.intellij.tasks.config.TaskRepositoriesConfigurable" displayName="Servers" id="tasks.servers"/> </projectConfigurable> diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java index f7723a9f96fa..eafe341d3989 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/TrelloRepository.java @@ -107,8 +107,8 @@ public final class TrelloRepository extends BaseRepositoryImpl { } @Override - public Task[] getIssues(@Nullable String query, int max, long since) throws Exception { - List<TrelloCard> cards = fetchCards(); + public Task[] getIssues(@Nullable String query, int offset, int limit, boolean withClosed) throws Exception { + List<TrelloCard> cards = fetchCards(offset + limit, withClosed); return ContainerUtil.map2Array(cards, Task.class, new Function<TrelloCard, Task>() { @Override public Task fun(TrelloCard card) { @@ -120,17 +120,24 @@ public final class TrelloRepository extends BaseRepositoryImpl { @Nullable @Override public Task findTask(@NotNull String id) throws Exception { - String url = TRELLO_API_BASE_URL + "/cards/" + id + "?actions=commentCard&fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS) ; + TrelloCard card = fetchCardById(id); + return card != null ? new TrelloTask(card, this) : null; + } + + @Nullable + public TrelloCard fetchCardById(@NotNull String id) throws Exception { + String url = TRELLO_API_BASE_URL + "/cards/" + id + "?actions=commentCard&fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS); try { - return new TrelloTask(makeRequestAndDeserializeJsonResponse(url, TrelloCard.class), this); + return makeRequestAndDeserializeJsonResponse(url, TrelloCard.class); } // Trello returns string "The requested resource was not found." or "invalid id" - // if card can't be found + // if card can't be found, which not only cannot be deserialized, but also not valid JSON at all. catch (JsonParseException e) { return null; } } + @Nullable public TrelloUser getCurrentUser() { return myCurrentUser; @@ -241,7 +248,7 @@ public final class TrelloRepository extends BaseRepositoryImpl { } @NotNull - private List<TrelloCard> fetchCards() throws Exception { + public List<TrelloCard> fetchCards(int limit, boolean withClosed) throws Exception { boolean fromList = false; // choose most appropriate card provider String baseUrl; @@ -258,8 +265,10 @@ public final class TrelloRepository extends BaseRepositoryImpl { else { throw new IllegalStateException("Not configured"); } - String allCardsUrl = baseUrl + "?filter=all&fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS); - List<TrelloCard> cards = makeRequestAndDeserializeJsonResponse(allCardsUrl, TrelloUtil.LIST_OF_CARDS_TYPE); + String fetchCardsUrl = baseUrl + "?fields=" + encodeUrl(TrelloCard.REQUIRED_FIELDS) + "&limit" + limit; + // 'visible' filter for some reason is not supported for lists + fetchCardsUrl += withClosed || fromList ? "&filter=all" : "&filter=visible"; + List<TrelloCard> cards = makeRequestAndDeserializeJsonResponse(fetchCardsUrl, TrelloUtil.LIST_OF_CARDS_TYPE); LOG.debug("Total " + cards.size() + " cards downloaded"); if (!myIncludeAllCards) { cards = ContainerUtil.filter(cards, new Condition<TrelloCard>() { @@ -270,7 +279,10 @@ public final class TrelloRepository extends BaseRepositoryImpl { }); LOG.debug("Total " + cards.size() + " cards after filtering"); } - if (!fromList) { + if (!cards.isEmpty()) { + if (fromList) { + baseUrl = TRELLO_API_BASE_URL + "/boards/" + cards.get(0).getIdBoard() + "/cards"; + } // fix for IDEA-111470 and IDEA-111475 // Select IDs of visible cards, e.d. cards that either archived explicitly, belong to archived list or closed board. // This information can't be extracted from single card description, because its 'closed' field diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java index f4fc18d42500..4aebd6a67385 100644 --- a/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java +++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/trello/model/TrelloCard.java @@ -44,7 +44,6 @@ public class TrelloCard extends TrelloModel { @SerializedName("desc") private String description; private String url; - @SerializedName("due") private boolean closed; private Date dateLastActivity; private List<TrelloLabel> labels; @@ -91,7 +90,7 @@ public class TrelloCard extends TrelloModel { } @Override - public void setName(String name) { + public void setName(@NotNull String name) { this.name = name; } diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/live/LiveIntegrationTestCase.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/live/LiveIntegrationTestCase.java new file mode 100644 index 000000000000..c5793503cfcd --- /dev/null +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/live/LiveIntegrationTestCase.java @@ -0,0 +1,22 @@ +package com.intellij.tasks.integration.live; + +import com.intellij.tasks.TaskManagerTestCase; +import com.intellij.tasks.TaskRepository; + +/** + * @author Mikhail Golubev + */ +public abstract class LiveIntegrationTestCase<T extends TaskRepository> extends TaskManagerTestCase { + protected T myRepository; + + @Override + public void setUp() throws Exception { + super.setUp(); + myRepository = createRepository(); + } + + /** + * @return new instance of task repository <b>with authenticated user<b/> + */ + protected abstract T createRepository() throws Exception; +} diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/live/TrelloIntegrationTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/live/TrelloIntegrationTest.java new file mode 100644 index 000000000000..3da6ad3d82d7 --- /dev/null +++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/integration/live/TrelloIntegrationTest.java @@ -0,0 +1,142 @@ +package com.intellij.tasks.integration.live; + +import com.intellij.openapi.util.Condition; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.tasks.trello.TrelloRepository; +import com.intellij.tasks.trello.TrelloRepositoryType; +import com.intellij.tasks.trello.model.*; +import com.intellij.util.Function; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; +import java.util.List; + +/** + * @author Mikhail Golubev + */ +public class TrelloIntegrationTest extends LiveIntegrationTestCase<TrelloRepository> { + + private static final String BOARD_1_NAME = "Board 1"; + private static final String BOARD_1_ID = "53c416a8a6e5a78753562043"; + + private static final String LIST_1_1_NAME = "List 1-1"; + private static final String LIST_1_1_ID = "53c416a8a6e5a78753562044"; + + private static final String CARD_1_1_1_NAME = "Card 1-1-1"; + private static final String CARD_1_1_1_ID = "53c416d8b4bd36fb078446e5"; + + @Override + protected TrelloRepository createRepository() throws Exception { + TrelloRepository repository = new TrelloRepository(new TrelloRepositoryType()); + String token = System.getProperty("tasks.tests.trello.token"); + if (StringUtil.isEmpty(token)) { + throw new AssertionError("Authorization token is not set"); + } + repository.setPassword(token); + TrelloUser user = repository.fetchUserByToken(); + assertNotNull(user); + repository.setCurrentUser(user); + return repository; + } + + // TODO Check closed tasks exclusion + // TODO Check various cards visibility corner cases + + public void testFetchBoard() throws Exception { + TrelloBoard board = myRepository.fetchBoardById(BOARD_1_ID); + assertNotNull(board); + assertEquals(BOARD_1_NAME, board.getName()); + } + + public void testFetchList() throws Exception { + TrelloList list = myRepository.fetchListById(LIST_1_1_ID); + assertNotNull(list); + assertEquals(LIST_1_1_NAME, list.getName()); + } + + public void testFetchCard() throws Exception { + TrelloCard card = myRepository.fetchCardById(CARD_1_1_1_ID); + assertNotNull(card); + assertEquals(CARD_1_1_1_NAME, card.getName()); + } + + public void testFetchBoardsOfUser() throws Exception { + List<TrelloBoard> boards = myRepository.fetchUserBoards(); + assertEquals(2, boards.size()); + assertObjectsNamed("All boards of the user should be included", boards, "Board 1", "Board 2"); + } + + public void testFetchListsOfBoard() throws Exception { + TrelloBoard selectedBoard = myRepository.fetchBoardById(BOARD_1_ID); + assertNotNull(selectedBoard); + myRepository.setCurrentBoard(selectedBoard); + List<TrelloList> lists = myRepository.fetchBoardLists(); + assertEquals(3, lists.size()); + assertObjectsNamed("All lists of the board should be included", lists, "List 1-1", "List 1-2", "List 1-3"); + } + + @NotNull + private List<TrelloCard> fetchCards(@Nullable String boardId, @Nullable String listId, boolean withClosed) throws Exception { + if (boardId != null) { + TrelloBoard selectedBoard = myRepository.fetchBoardById(BOARD_1_ID); + assertNotNull(selectedBoard); + myRepository.setCurrentBoard(selectedBoard); + } + if (listId != null) { + TrelloList selectedList = myRepository.fetchListById(LIST_1_1_ID); + assertNotNull(selectedList); + myRepository.setCurrentList(selectedList); + } + return myRepository.fetchCards(100, withClosed); + } + + public void testFetchingCardsOfUser() throws Exception { + myRepository.setIncludeAllCards(true); + List<TrelloCard> cards = fetchCards(null, null, true); + assertObjectsNamed("All cards assigned to user should be included", cards, "Card 1-1-1"); + } + + public void testFetchingCardsOfBoard() throws Exception { + myRepository.setIncludeAllCards(true); + List<TrelloCard> cards = fetchCards(BOARD_1_ID, null, true); + assertObjectsNamed("All cards of the board should be included", + cards, "Card 1-1-1", "Card 1-1-2", "Card 1-2-1", "Card 1-3-1", "Archived Card"); + } + + public void testCardsFilteringByMembership() throws Exception { + myRepository.setIncludeAllCards(true); + List<TrelloCard> allCards = fetchCards(BOARD_1_ID, LIST_1_1_ID, true); + assertObjectsNamed("All cards of the list should be included", allCards, "Card 1-1-1", "Card 1-1-2", "Archived Card"); + + myRepository.setIncludeAllCards(false); + List<TrelloCard> assignedCards = fetchCards(BOARD_1_ID, LIST_1_1_ID, true); + assertObjectsNamed("Only cards of the list assigned to user should be included", assignedCards, "Card 1-1-1"); + } + + public void testCardsFilteringByStatus() throws Exception { + myRepository.setIncludeAllCards(true); + List<TrelloCard> allCards = fetchCards(BOARD_1_ID, LIST_1_1_NAME, true); + assertObjectsNamed("All cards of the list should be included", allCards, "Card 1-1-1", "Card 1-1-2", "Archived Card"); + + TrelloCard card = ContainerUtil.find(allCards, new Condition<TrelloCard>() { + @Override + public boolean value(TrelloCard card) { + return card.getName().equals("Archived Card"); + } + }); + assertNotNull(card); + assertTrue(card.isClosed()); + assertFalse(card.isVisible()); + } + + static void assertObjectsNamed(@NotNull String message, @NotNull Collection<? extends TrelloModel> objects, @NotNull String... names) { + assertEquals(message, ContainerUtil.newHashSet(names), ContainerUtil.map2Set(objects, new Function<TrelloModel, String>() { + @Override + public String fun(TrelloModel model) { + return model.getName(); + } + })); + } +} diff --git a/plugins/terminal/resources/META-INF/terminal.xml b/plugins/terminal/resources/META-INF/terminal.xml index ed2a2b56ec64..11a18e18d81f 100644 --- a/plugins/terminal/resources/META-INF/terminal.xml +++ b/plugins/terminal/resources/META-INF/terminal.xml @@ -11,7 +11,7 @@ <toolWindow id="Terminal" anchor="bottom" icon="TerminalIcons.OpenTerminal_13x13" factoryClass="org.jetbrains.plugins.terminal.TerminalToolWindowFactory" secondary="false"/> - <projectConfigurable instance="org.jetbrains.plugins.terminal.TerminalOptionsConfigurable"/> + <projectConfigurable groupId="tools" displayName="Terminal" instance="org.jetbrains.plugins.terminal.TerminalOptionsConfigurable"/> <fileEditorProvider implementation="org.jetbrains.plugins.terminal.vfs.TerminalSessionEditorProvider"/> </extensions> diff --git a/plugins/typeMigration/src/META-INF/plugin.xml b/plugins/typeMigration/src/META-INF/plugin.xml deleted file mode 100644 index 93ad2032892c..000000000000 --- a/plugins/typeMigration/src/META-INF/plugin.xml +++ /dev/null @@ -1,39 +0,0 @@ -<idea-plugin> - <name>Type Migration</name> - <description> - <![CDATA[ - This plugin adds the type migration refactoring. - The following features are available: - <ul> - <li>Dedicated Refactoring Dialog. (Refactor | Type Migration)</li> - <li>Ability to review type migration results. (Refactor | Migration | Preview)</li> - <li>Ability to automatically change a member type or data flow dependent type entries.</li> - <li>Ability to convert variable or method return type between arrays and collections.</li> - </ul> - ]]> - </description> - <vendor>JetBrains</vendor> - <extensions defaultExtensionNs="com.intellij"> - <errorHandler implementation="com.intellij.diagnostic.ITNReporter"/> - <codeInsight.changeVariableTypeQuickFixProvider - implementation="com.intellij.refactoring.typeMigration.TypeMigrationVariableTypeFixProvider"/> - <conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.ListArrayConversionRule"/> - <conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.AtomicConversionRule"/> - <conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.BoxingTypeConversionRule"/> - <conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.ElementToArrayConversionRule"/> - <conversion.rule implementation="com.intellij.refactoring.typeMigration.rules.ThreadLocalConversionRule"/> - <intentionAction> - <className>com.intellij.refactoring.typeMigration.intentions.ConvertFieldToAtomicIntention</className> - <category>Concurrency</category> - </intentionAction> - <intentionAction> - <className>com.intellij.refactoring.typeMigration.intentions.ConvertFieldToThreadLocalIntention</className> - <category>Concurrency</category> - </intentionAction> - <intentionAction> - <className>com.intellij.refactoring.typeMigration.intentions.ChangeClassParametersIntention</className> - <category>Declaration</category> - </intentionAction> - </extensions> - <depends>Structural Search</depends> -</idea-plugin> diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/TypeConversionDescriptor.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/TypeConversionDescriptor.java deleted file mode 100644 index d116c3ce30fe..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/TypeConversionDescriptor.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.intellij.refactoring.typeMigration; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.project.Project; -import com.intellij.psi.JavaPsiFacade; -import com.intellij.psi.PsiExpression; -import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import com.intellij.structuralsearch.MatchOptions; -import com.intellij.structuralsearch.plugin.replace.ReplaceOptions; -import com.intellij.structuralsearch.plugin.replace.impl.Replacer; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NonNls; - -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Sep 28, 2004 - * Time: 7:13:53 PM - * To change this template use File | Settings | File Templates. - */ -public class TypeConversionDescriptor extends TypeConversionDescriptorBase { - private static final Logger LOG = Logger.getInstance("#" + TypeConversionDescriptor.class.getName()); - - private String myStringToReplace = null; - private String myReplaceByString = "$"; - private PsiExpression myExpression; - - public TypeConversionDescriptor(@NonNls final String stringToReplace, @NonNls final String replaceByString) { - myStringToReplace = stringToReplace; - myReplaceByString = replaceByString; - } - - public TypeConversionDescriptor(@NonNls final String stringToReplace, @NonNls final String replaceByString, final PsiExpression expression) { - myStringToReplace = stringToReplace; - myReplaceByString = replaceByString; - myExpression = expression; - } - - public void setStringToReplace(String stringToReplace) { - myStringToReplace = stringToReplace; - } - - public void setReplaceByString(String replaceByString) { - myReplaceByString = replaceByString; - } - - public String getStringToReplace() { - return myStringToReplace; - } - - public String getReplaceByString() { - return myReplaceByString; - } - - public PsiExpression getExpression() { - return myExpression; - } - - public void setExpression(final PsiExpression expression) { - myExpression = expression; - } - - @Override - public void replace(PsiExpression expression) { - if (getExpression() != null) expression = getExpression(); - final Project project = expression.getProject(); - final ReplaceOptions options = new ReplaceOptions(); - options.setMatchOptions(new MatchOptions()); - final Replacer replacer = new Replacer(project, null); - try { - final String replacement = replacer.testReplace(expression.getText(), getStringToReplace(), getReplaceByString(), options); - try { - JavaCodeStyleManager.getInstance(project).shortenClassReferences(expression.replace( - JavaPsiFacade.getInstance(project).getElementFactory().createExpressionFromText(replacement, expression))); - } - catch (IncorrectOperationException e) { - LOG.error(e); - } - } - catch (IncorrectOperationException e) { - LOG.error(e); - } - } - - @Override - public String toString() { - StringBuffer buf = new StringBuffer(); - if (myReplaceByString != null) { - buf.append(myReplaceByString); - } - if (myStringToReplace != null) { - if (buf.length() > 0) buf.append(" "); - buf.append(myStringToReplace); - } - if (myExpression != null) { - if (buf.length() > 0) buf.append(" "); - buf.append(myExpression.getText()); - } - return buf.toString(); - } -} diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java deleted file mode 100644 index d84320e4cd08..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/TypeMigrationVariableTypeFixProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * User: anna - * Date: 27-Aug-2009 - */ -package com.intellij.refactoring.typeMigration; - -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.daemon.impl.quickfix.VariableTypeFix; -import com.intellij.codeInsight.intention.IntentionAction; -import com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider; -import com.intellij.openapi.command.undo.UndoUtil; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiType; -import com.intellij.psi.PsiVariable; -import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class TypeMigrationVariableTypeFixProvider implements ChangeVariableTypeQuickFixProvider { - private static final Logger LOG1 = Logger.getInstance("#" + TypeMigrationVariableTypeFixProvider.class.getName()); - - @NotNull - public IntentionAction[] getFixes(@NotNull PsiVariable variable, @NotNull PsiType toReturn) { - return new IntentionAction[]{new VariableTypeFix(variable, toReturn) { - @NotNull - @Override - public String getText() { - return "Migrate \'" + myName + "\' type to \'" + getReturnType().getCanonicalText() + "\'"; - } - - @Override - public void invoke(@NotNull Project project, - @NotNull PsiFile file, - @Nullable("is null when called from inspection") Editor editor, - @NotNull PsiElement startElement, - @NotNull PsiElement endElement) { - final PsiVariable myVariable = (PsiVariable)startElement; - - if (!FileModificationService.getInstance().prepareFileForWrite(myVariable.getContainingFile())) return; - try { - myVariable.normalizeDeclaration(); - final TypeMigrationRules rules = new TypeMigrationRules(TypeMigrationLabeler.getElementType(myVariable)); - rules.setMigrationRootType(getReturnType()); - rules.setBoundScope(GlobalSearchScope.projectScope(project)); - TypeMigrationProcessor.runHighlightingTypeMigration(project, editor, rules, myVariable); - JavaCodeStyleManager.getInstance(project).shortenClassReferences(myVariable); - UndoUtil.markPsiFileForUndo(file); - } - catch (IncorrectOperationException e) { - LOG1.error(e); - } - } - }}; - } -} diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java deleted file mode 100644 index 9571807cd229..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.intellij.refactoring.typeMigration.intentions; - -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.hint.HintManager; -import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; -import com.intellij.codeInsight.intention.impl.TypeExpression; -import com.intellij.codeInsight.template.*; -import com.intellij.codeInsight.template.impl.TemplateState; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Document; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.*; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.refactoring.typeMigration.TypeMigrationProcessor; -import com.intellij.refactoring.typeMigration.TypeMigrationRules; -import com.intellij.util.ArrayUtil; -import com.intellij.util.IncorrectOperationException; -import org.jetbrains.annotations.NotNull; - -/** - * @author anna - */ -public class ChangeClassParametersIntention extends PsiElementBaseIntentionAction { - - private static final Logger LOG = Logger.getInstance("#" + ChangeClassParametersIntention.class); - - @NotNull - @Override - public String getText() { - return getFamilyName(); - } - - @NotNull - @Override - public String getFamilyName() { - return "Change class type parameter"; - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { - final PsiTypeElement typeElement = PsiTreeUtil.getTopmostParentOfType(element, PsiTypeElement.class); - final PsiElement parent = typeElement != null ? typeElement.getParent() : null; - final PsiReferenceParameterList parameterList = parent instanceof PsiReferenceParameterList ? (PsiReferenceParameterList)parent : null; - if (parameterList != null && parameterList.getTypeArguments().length > 0) { - final PsiMember member = PsiTreeUtil.getParentOfType(parameterList, PsiMember.class); - if (member instanceof PsiAnonymousClass) { - final PsiClassType.ClassResolveResult result = ((PsiAnonymousClass)member).getBaseClassType().resolveGenerics(); - return result.getElement() != null && ((PsiAnonymousClass)member).getBaseClassReference().getParameterList() == parameterList; - } - } - return false; - } - - @Override - public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { - if (!FileModificationService.getInstance().preparePsiElementsForWrite(element)) return; - - final PsiTypeElement typeElement = PsiTreeUtil.getTopmostParentOfType(element, PsiTypeElement.class); - final PsiReferenceParameterList parameterList = PsiTreeUtil.getParentOfType(element, PsiReferenceParameterList.class); - if (parameterList != null && typeElement != null) { - final PsiClass aClass = PsiTreeUtil.getParentOfType(element, PsiClass.class); - if (aClass instanceof PsiAnonymousClass) { - editor.getCaretModel().moveToOffset(aClass.getTextOffset()); - final PsiTypeElement[] typeElements = parameterList.getTypeParameterElements(); - final int changeIdx = ArrayUtil.find(typeElements, typeElement); - - final PsiClassType.ClassResolveResult result = ((PsiAnonymousClass)aClass).getBaseClassType().resolveGenerics(); - final PsiClass baseClass = result.getElement(); - LOG.assertTrue(baseClass != null); - final PsiTypeParameter typeParameter = baseClass.getTypeParameters()[changeIdx]; - - final TemplateBuilderImpl templateBuilder = (TemplateBuilderImpl)TemplateBuilderFactory.getInstance().createTemplateBuilder(aClass); - - final String oldTypeText = typeElement.getText(); - final String varName = "param"; - templateBuilder.replaceElement(typeElement, varName, new TypeExpression(project, new PsiType[]{typeElement.getType()}), true); - - final Template template = templateBuilder.buildInlineTemplate(); - TemplateManager.getInstance(project).startTemplate(editor, template, false, null, new TemplateEditingAdapter() { - private String myNewType; - - @Override - public void beforeTemplateFinished(TemplateState state, Template template) { - final TextResult value = state.getVariableValue(varName); - myNewType = value != null ? value.getText() : ""; - final int segmentsCount = state.getSegmentsCount(); - final Document document = state.getEditor().getDocument(); - for (int i = 0; i < segmentsCount; i++) { - final TextRange segmentRange = state.getSegmentRange(i); - document.replaceString(segmentRange.getStartOffset(), segmentRange.getEndOffset(), oldTypeText); - } - } - - @Override - public void templateFinished(Template template, boolean brokenOff) { - if (!brokenOff) { - final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(project); - try { - final PsiType targetParam = elementFactory.createTypeFromText(myNewType, aClass); - final TypeMigrationRules myRules = new TypeMigrationRules(((PsiAnonymousClass)aClass).getBaseClassType()); - final PsiSubstitutor substitutor = result.getSubstitutor().put(typeParameter, targetParam); - final PsiType targetClassType = elementFactory.createType(baseClass, substitutor); - myRules.setMigrationRootType(targetClassType); - myRules.setBoundScope(new LocalSearchScope(aClass)); - new TypeMigrationProcessor(project, ((PsiAnonymousClass)aClass).getBaseClassReference().getParameterList(), myRules).run(); - } - catch (IncorrectOperationException e) { - HintManager.getInstance().showErrorHint(editor, "Incorrect type"); - } - } - } - }); - } - } - } - - @Override - public boolean startInWriteAction() { - return true; - } -} diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ConvertFieldToAtomicIntention.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ConvertFieldToAtomicIntention.java deleted file mode 100644 index d794d59f9943..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ConvertFieldToAtomicIntention.java +++ /dev/null @@ -1,218 +0,0 @@ -package com.intellij.refactoring.typeMigration.intentions; - -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.intention.LowPriorityAction; -import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; -import com.intellij.lang.java.JavaLanguage; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.psi.*; -import com.intellij.psi.codeStyle.CodeStyleSettingsManager; -import com.intellij.psi.codeStyle.JavaCodeStyleManager; -import com.intellij.psi.impl.AllowedApiFilterExtension; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.searches.ReferencesSearch; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.TypeConversionUtil; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptor; -import com.intellij.refactoring.typeMigration.TypeMigrationReplacementUtil; -import com.intellij.refactoring.typeMigration.rules.AtomicConversionRule; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.Query; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.*; - -import static com.intellij.psi.util.TypeConversionUtil.isBinaryOperatorApplicable; -import static com.intellij.util.ObjectUtils.assertNotNull; - -/** - * @author anna - * @since 26-Aug-2009 - */ -public class ConvertFieldToAtomicIntention extends PsiElementBaseIntentionAction implements LowPriorityAction { - private static final Logger LOG = Logger.getInstance("#" + ConvertFieldToAtomicIntention.class.getName()); - - private final Map<PsiType, String> myFromToMap = ContainerUtil.newHashMap(); - { - myFromToMap.put(PsiType.INT, AtomicInteger.class.getName()); - myFromToMap.put(PsiType.LONG, AtomicLong.class.getName()); - myFromToMap.put(PsiType.BOOLEAN, AtomicBoolean.class.getName()); - myFromToMap.put(PsiType.INT.createArrayType(), AtomicIntegerArray.class.getName()); - myFromToMap.put(PsiType.LONG.createArrayType(), AtomicLongArray.class.getName()); - } - - @NotNull - @Override - public String getText() { - return "Convert to atomic"; - } - - @NotNull - @Override - public String getFamilyName() { - return getText(); - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { - PsiVariable psiVariable = getVariable(element); - if (psiVariable == null || psiVariable instanceof PsiResourceVariable) return false; - if (psiVariable.getLanguage() != JavaLanguage.INSTANCE) return false; - if (psiVariable.getTypeElement() == null) return false; - if (!PsiUtil.isLanguageLevel5OrHigher(psiVariable)) return false; - final PsiType psiType = psiVariable.getType(); - final PsiClass psiTypeClass = PsiUtil.resolveClassInType(psiType); - if (psiTypeClass != null) { - final String qualifiedName = psiTypeClass.getQualifiedName(); - if (qualifiedName != null) { //is already atomic - if (myFromToMap.values().contains(qualifiedName) || - qualifiedName.equals(AtomicReference.class.getName()) || - qualifiedName.equals(AtomicReferenceArray.class.getName())) { - return false; - } - } - } - else if (!myFromToMap.containsKey(psiType)) { - return false; - } - return AllowedApiFilterExtension.isClassAllowed(AtomicReference.class.getName(), element); - } - - private static PsiVariable getVariable(PsiElement element) { - if (element instanceof PsiIdentifier) { - final PsiElement parent = element.getParent(); - if (parent instanceof PsiLocalVariable || parent instanceof PsiField) { - return (PsiVariable)parent; - } - } - return null; - } - - @Override - public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { - final PsiVariable psiVariable = getVariable(element); - LOG.assertTrue(psiVariable != null); - - final Query<PsiReference> refs = ReferencesSearch.search(psiVariable); - - final Set<PsiElement> elements = new HashSet<PsiElement>(); - elements.add(element); - for (PsiReference reference : refs) { - elements.add(reference.getElement()); - } - if (!FileModificationService.getInstance().preparePsiElementsForWrite(elements)) return; - - final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); - final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); - final PsiType fromType = psiVariable.getType(); - PsiClassType toType; - final String atomicQualifiedName = myFromToMap.get(fromType); - if (atomicQualifiedName != null) { - final PsiClass atomicClass = psiFacade.findClass(atomicQualifiedName, GlobalSearchScope.allScope(project)); - if (atomicClass == null) {//show warning - return; - } - toType = factory.createType(atomicClass); - } - else if (fromType instanceof PsiArrayType) { - final PsiClass atomicReferenceArrayClass = - psiFacade.findClass(AtomicReferenceArray.class.getName(), GlobalSearchScope.allScope(project)); - if (atomicReferenceArrayClass == null) {//show warning - return; - } - final Map<PsiTypeParameter, PsiType> substitutor = ContainerUtil.newHashMap(); - final PsiTypeParameter[] typeParameters = atomicReferenceArrayClass.getTypeParameters(); - if (typeParameters.length == 1) { - PsiType componentType = ((PsiArrayType)fromType).getComponentType(); - if (componentType instanceof PsiPrimitiveType) componentType = ((PsiPrimitiveType)componentType).getBoxedType(element); - substitutor.put(typeParameters[0], componentType); - } - toType = factory.createType(atomicReferenceArrayClass, factory.createSubstitutor(substitutor)); - } - else { - final PsiClass atomicReferenceClass = psiFacade.findClass(AtomicReference.class.getName(), GlobalSearchScope.allScope(project)); - if (atomicReferenceClass == null) {//show warning - return; - } - final Map<PsiTypeParameter, PsiType> substitutor = ContainerUtil.newHashMap(); - final PsiTypeParameter[] typeParameters = atomicReferenceClass.getTypeParameters(); - if (typeParameters.length == 1) { - PsiType type = fromType; - if (type instanceof PsiPrimitiveType) type = ((PsiPrimitiveType)fromType).getBoxedType(element); - substitutor.put(typeParameters[0], type); - } - toType = factory.createType(atomicReferenceClass, factory.createSubstitutor(substitutor)); - } - - try { - for (PsiReference reference : refs) { - PsiElement psiElement = reference.getElement(); - if (psiElement instanceof PsiExpression) { - final PsiElement parent = psiElement.getParent(); - if (parent instanceof PsiExpression && !(parent instanceof PsiReferenceExpression || parent instanceof PsiPolyadicExpression)) { - psiElement = parent; - } - if (psiElement instanceof PsiBinaryExpression) { - PsiBinaryExpression binary = (PsiBinaryExpression)psiElement; - if (isBinaryOperatorApplicable(binary.getOperationTokenType(), binary.getLOperand(), binary.getROperand(), true)) { - continue; - } - } - else if (psiElement instanceof PsiAssignmentExpression) { - final PsiAssignmentExpression assignment = (PsiAssignmentExpression)psiElement; - final IElementType opSign = TypeConversionUtil.convertEQtoOperation(assignment.getOperationTokenType()); - if (opSign != null && isBinaryOperatorApplicable(opSign, assignment.getLExpression(), assignment.getRExpression(), true)) { - continue; - } - } - final TypeConversionDescriptor directConversion = AtomicConversionRule.findDirectConversion(psiElement, toType, fromType); - if (directConversion != null) { - TypeMigrationReplacementUtil.replaceExpression((PsiExpression)psiElement, project, directConversion); - } - } - } - - final PsiExpression initializer = psiVariable.getInitializer(); - if (initializer != null) { - final TypeConversionDescriptor directConversion = AtomicConversionRule.wrapWithNewExpression(toType, fromType, null, element); - if (directConversion != null) { - TypeMigrationReplacementUtil.replaceExpression(initializer, project, directConversion); - } - } - else if (!assertNotNull(psiVariable.getModifierList()).hasModifierProperty(PsiModifier.FINAL)) { - final PsiExpression newInitializer = factory.createExpressionFromText("new " + toType.getCanonicalText() + "()", psiVariable); - if (psiVariable instanceof PsiLocalVariable) { - ((PsiLocalVariable)psiVariable).setInitializer(newInitializer); - } - else if (psiVariable instanceof PsiField) { - ((PsiField)psiVariable).setInitializer(newInitializer); - } - JavaCodeStyleManager.getInstance(project).shortenClassReferences(psiVariable.getInitializer()); - } - - PsiElement replaced = assertNotNull(psiVariable.getTypeElement()).replace(factory.createTypeElement(toType)); - JavaCodeStyleManager.getInstance(project).shortenClassReferences(replaced); - - if (psiVariable instanceof PsiField || CodeStyleSettingsManager.getSettings(project).GENERATE_FINAL_LOCALS) { - final PsiModifierList modifierList = assertNotNull(psiVariable.getModifierList()); - modifierList.setModifierProperty(PsiModifier.FINAL, true); - modifierList.setModifierProperty(PsiModifier.VOLATILE, false); - } - } - catch (IncorrectOperationException e) { - LOG.error(e); - } - } - - @Override - public boolean startInWriteAction() { - return true; - } -} diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ConvertFieldToThreadLocalIntention.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ConvertFieldToThreadLocalIntention.java deleted file mode 100644 index e01aaadae7d8..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ConvertFieldToThreadLocalIntention.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * User: anna - * Date: 26-Aug-2009 - */ -package com.intellij.refactoring.typeMigration.intentions; - -import com.intellij.codeInsight.FileModificationService; -import com.intellij.codeInsight.intention.LowPriorityAction; -import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; -import com.intellij.lang.java.JavaLanguage; -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.editor.Editor; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Comparing; -import com.intellij.psi.*; -import com.intellij.psi.codeStyle.CodeStyleManager; -import com.intellij.psi.impl.AllowedApiFilterExtension; -import com.intellij.psi.impl.PsiDiamondTypeUtil; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.searches.ReferencesSearch; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.util.PsiUtil; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptor; -import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; -import com.intellij.refactoring.typeMigration.TypeMigrationReplacementUtil; -import com.intellij.refactoring.typeMigration.TypeMigrationRules; -import com.intellij.refactoring.typeMigration.rules.ThreadLocalConversionRule; -import com.intellij.util.IncorrectOperationException; -import com.intellij.util.Query; -import com.intellij.util.containers.ContainerUtil; -import org.jetbrains.annotations.NotNull; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import static com.intellij.util.ObjectUtils.assertNotNull; - -public class ConvertFieldToThreadLocalIntention extends PsiElementBaseIntentionAction implements LowPriorityAction { - private static final Logger LOG = Logger.getInstance("#" + ConvertFieldToThreadLocalIntention.class.getName()); - - @NotNull - @Override - public String getText() { - return "Convert to ThreadLocal"; - } - - @NotNull - @Override - public String getFamilyName() { - return getText(); - } - - @Override - public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) { - if (!(element instanceof PsiIdentifier)) return false; - final PsiField psiField = PsiTreeUtil.getParentOfType(element, PsiField.class); - if (psiField == null) return false; - if (psiField.getLanguage() != JavaLanguage.INSTANCE) return false; - if (psiField.getTypeElement() == null) return false; - final PsiType fieldType = psiField.getType(); - final PsiClass fieldTypeClass = PsiUtil.resolveClassInType(fieldType); - if (fieldType instanceof PsiPrimitiveType || fieldType instanceof PsiArrayType) return true; - return fieldTypeClass != null && !Comparing.strEqual(fieldTypeClass.getQualifiedName(), ThreadLocal.class.getName()) - && AllowedApiFilterExtension.isClassAllowed(ThreadLocal.class.getName(), element); - } - - @Override - public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException { - final PsiField psiField = PsiTreeUtil.getParentOfType(element, PsiField.class); - LOG.assertTrue(psiField != null); - final Query<PsiReference> refs = ReferencesSearch.search(psiField); - - final Set<PsiElement> elements = new HashSet<PsiElement>(); - elements.add(element); - for (PsiReference reference : refs) { - elements.add(reference.getElement()); - } - if (!FileModificationService.getInstance().preparePsiElementsForWrite(elements)) return; - - final JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); - final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project); - final PsiType fromType = psiField.getType(); - - final PsiClass threadLocalClass = psiFacade.findClass(ThreadLocal.class.getName(), GlobalSearchScope.allScope(project)); - if (threadLocalClass == null) {//show warning - return; - } - final Map<PsiTypeParameter, PsiType> substitutor = ContainerUtil.newHashMap(); - final PsiTypeParameter[] typeParameters = threadLocalClass.getTypeParameters(); - if (typeParameters.length == 1) { - PsiType type = fromType; - if (fromType instanceof PsiPrimitiveType) type = ((PsiPrimitiveType)fromType).getBoxedType(element); - substitutor.put(typeParameters[0], type); - } - final PsiClassType toType = factory.createType(threadLocalClass, factory.createSubstitutor(substitutor)); - - try { - final TypeMigrationRules rules = new TypeMigrationRules(fromType); - rules.setMigrationRootType(toType); - rules.setBoundScope(GlobalSearchScope.fileScope(element.getContainingFile())); - final TypeMigrationLabeler labeler = new TypeMigrationLabeler(rules); - labeler.getMigratedUsages(false, psiField); - for (PsiReference reference : refs) { - PsiElement psiElement = reference.getElement(); - if (psiElement instanceof PsiExpression) { - final PsiElement parent = psiElement.getParent(); - if (parent instanceof PsiExpression && !(parent instanceof PsiReferenceExpression || parent instanceof PsiPolyadicExpression)) { - psiElement = parent; - } - final TypeConversionDescriptor conversion = ThreadLocalConversionRule.findDirectConversion(psiElement, toType, fromType, labeler); - if (conversion != null) { - TypeMigrationReplacementUtil.replaceExpression((PsiExpression)psiElement, project, conversion); - } - } - } - - final PsiExpression initializer = psiField.getInitializer(); - if (initializer != null) { - final TypeConversionDescriptor conversion = ThreadLocalConversionRule.wrapWithNewExpression(toType, fromType, initializer); - TypeMigrationReplacementUtil.replaceExpression(initializer, project, conversion); - CodeStyleManager.getInstance(project).reformat(psiField); - } - else if (!assertNotNull(psiField.getModifierList()).hasModifierProperty(PsiModifier.FINAL)) { - final String text = "new " + PsiDiamondTypeUtil.getCollapsedType(toType, psiField) + "()"; - final PsiExpression newInitializer = factory.createExpressionFromText(text, psiField); - psiField.setInitializer(newInitializer); - } - - assertNotNull(psiField.getTypeElement()).replace(factory.createTypeElement(toType)); - - final PsiModifierList modifierList = assertNotNull(psiField.getModifierList()); - modifierList.setModifierProperty(PsiModifier.FINAL, true); - modifierList.setModifierProperty(PsiModifier.VOLATILE, false); - } - catch (IncorrectOperationException e) { - LOG.error(e); - } - } - - @Override - public boolean startInWriteAction() { - return true; - } -} diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/AtomicConversionRule.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/AtomicConversionRule.java deleted file mode 100644 index a4ec46e44838..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/AtomicConversionRule.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * User: anna - * Date: 18-Aug-2009 - */ -package com.intellij.refactoring.typeMigration.rules; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Comparing; -import com.intellij.psi.*; -import com.intellij.psi.impl.PsiDiamondTypeUtil; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.TypeConversionUtil; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptor; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptorBase; -import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.concurrent.atomic.*; - -public class AtomicConversionRule extends TypeConversionRule { - private static final Logger LOG = Logger.getInstance("#" + AtomicConversionRule.class.getName()); - - - @Override - public TypeConversionDescriptorBase findConversion(PsiType from, - PsiType to, - PsiMember member, - PsiExpression context, - TypeMigrationLabeler labeler) { - if (to instanceof PsiClassType && isAtomicTypeMigration(from, (PsiClassType)to, context)) { - return findDirectConversion(context, to, from); - } - else if (from instanceof PsiClassType && isAtomicTypeMigration(to, (PsiClassType)from, context)) { - return findReverseConversion(context); - } - return null; - } - - private static boolean isAtomicTypeMigration(PsiType from, PsiClassType to, PsiExpression context) { - if (from == PsiType.INT && to.getCanonicalText().equals(AtomicInteger.class.getName())) { - return true; - } - if (from.equals(PsiType.INT.createArrayType()) && to.getCanonicalText().equals(AtomicIntegerArray.class.getName())) { - return true; - } - if (from == PsiType.LONG && to.getCanonicalText().equals(AtomicLong.class.getName())) { - return true; - } - if (from.equals(PsiType.LONG.createArrayType()) && to.getCanonicalText().equals(AtomicLongArray.class.getName())) { - return true; - } - if (from == PsiType.BOOLEAN && to.getCanonicalText().equals(AtomicBoolean.class.getName())) { - return true; - } - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(to); - final PsiClass atomicClass = resolveResult.getElement(); - - if (atomicClass != null) { - final String typeQualifiedName = atomicClass.getQualifiedName(); - if (!Comparing.strEqual(typeQualifiedName, AtomicReference.class.getName()) && - !Comparing.strEqual(typeQualifiedName, AtomicReferenceArray.class.getName())) { - return false; - } - final PsiTypeParameter[] typeParameters = atomicClass.getTypeParameters(); - if (typeParameters.length != 1) return false; - final PsiType toTypeParameterValue = resolveResult.getSubstitutor().substitute(typeParameters[0]); - if (toTypeParameterValue != null) { - if (from.getDeepComponentType() instanceof PsiPrimitiveType) { - final PsiPrimitiveType unboxedInitialType = PsiPrimitiveType.getUnboxedType(toTypeParameterValue); - if (unboxedInitialType != null) { - return TypeConversionUtil.areTypesConvertible(from.getDeepComponentType(), unboxedInitialType); - } - } - else { - return TypeConversionUtil.isAssignable(from.getDeepComponentType(), PsiUtil.captureToplevelWildcards(toTypeParameterValue, context)); - } - } - } - return false; - } - - @Nullable - public static TypeConversionDescriptor findDirectConversion(PsiElement context, PsiType to, PsiType from) { - final PsiClass toTypeClass = PsiUtil.resolveClassInType(to); - LOG.assertTrue(toTypeClass != null); - final String qualifiedName = toTypeClass.getQualifiedName(); - if (qualifiedName != null) { - if (qualifiedName.equals(AtomicInteger.class.getName()) || qualifiedName.equals(AtomicLong.class.getName())) { - - if (context instanceof PsiPostfixExpression) { - final IElementType operationSign = ((PsiPostfixExpression)context).getOperationTokenType(); - if (operationSign == JavaTokenType.MINUSMINUS) { - return new TypeConversionDescriptor("$qualifier$--", "$qualifier$.getAndDecrement()"); - } - if (operationSign == JavaTokenType.PLUSPLUS) { - return new TypeConversionDescriptor("$qualifier$++", "$qualifier$.getAndIncrement()"); - } - - } - else if (context instanceof PsiPrefixExpression) { - final IElementType operationSign = ((PsiPrefixExpression)context).getOperationTokenType(); - if (operationSign == JavaTokenType.MINUSMINUS) { - return new TypeConversionDescriptor("--$qualifier$", "$qualifier$.decrementAndGet()"); - } - if (operationSign == JavaTokenType.PLUSPLUS) { - return new TypeConversionDescriptor("++$qualifier$", "$qualifier$.incrementAndGet()"); - } - - } - else if (context instanceof PsiAssignmentExpression) { - final PsiJavaToken signToken = ((PsiAssignmentExpression)context).getOperationSign(); - final IElementType operationSign = signToken.getTokenType(); - final String sign = signToken.getText(); - if (operationSign == JavaTokenType.PLUSEQ || operationSign == JavaTokenType.MINUSEQ) { - return new TypeConversionDescriptor("$qualifier$ " + sign + " $val$", "$qualifier$.getAndAdd(" + - (operationSign == JavaTokenType.MINUSEQ ? "-" : "") + - "($val$))"); - } - } - } - else if (qualifiedName.equals(AtomicIntegerArray.class.getName()) || qualifiedName.equals(AtomicLongArray.class.getName())) { - PsiElement parentExpression = context.getParent(); - if (parentExpression instanceof PsiPostfixExpression) { - final IElementType operationSign = ((PsiPostfixExpression)parentExpression).getOperationTokenType(); - if (operationSign == JavaTokenType.MINUSMINUS) { - return new TypeConversionDescriptor("$qualifier$[$idx$]--", "$qualifier$.getAndDecrement($idx$)", - (PsiExpression)parentExpression); - } - if (operationSign == JavaTokenType.PLUSPLUS) { - return new TypeConversionDescriptor("$qualifier$[$idx$]++", "$qualifier$.getAndIncrement($idx$)", - (PsiExpression)parentExpression); - } - - } - else if (parentExpression instanceof PsiPrefixExpression) { - final IElementType operationSign = ((PsiPrefixExpression)parentExpression).getOperationTokenType(); - if (operationSign == JavaTokenType.MINUSMINUS) { - return new TypeConversionDescriptor("--$qualifier$[$idx$]", "$qualifier$.decrementAndGet($idx$)", - (PsiExpression)parentExpression); - } - if (operationSign == JavaTokenType.PLUSPLUS) { - return new TypeConversionDescriptor("++$qualifier$[$idx$]", "$qualifier$.incrementAndGet($idx$)", - (PsiExpression)parentExpression); - } - - } - else if (parentExpression instanceof PsiAssignmentExpression) { - final PsiJavaToken signToken = ((PsiAssignmentExpression)parentExpression).getOperationSign(); - final IElementType operationSign = signToken.getTokenType(); - final String sign = signToken.getText(); - if (operationSign == JavaTokenType.PLUSEQ || operationSign == JavaTokenType.MINUSEQ) { - return new TypeConversionDescriptor("$qualifier$[$idx$] " + sign + " $val$", "$qualifier$.getAndAdd($idx$, " + - (operationSign == JavaTokenType.MINUSEQ - ? "-" - : "") + - "($val$))", (PsiExpression)parentExpression); - } - } - } - } - return from instanceof PsiArrayType - ? findDirectConversionForAtomicReferenceArray(context, to, from) - : findDirectConversionForAtomicReference(context, to, from); - } - - @Nullable - private static TypeConversionDescriptor findDirectConversionForAtomicReference(PsiElement context, PsiType to, PsiType from) { - final PsiElement parent = context.getParent(); - if (parent instanceof PsiAssignmentExpression) { - final IElementType operationSign = ((PsiAssignmentExpression)parent).getOperationTokenType(); - if (operationSign == JavaTokenType.EQ) { - return new TypeConversionDescriptor("$qualifier$ = $val$", "$qualifier$.set($val$)", (PsiAssignmentExpression)parent); - } - } - - if (context instanceof PsiReferenceExpression) { - final PsiExpression qualifierExpression = ((PsiReferenceExpression)context).getQualifierExpression(); - final PsiExpression expression = context.getParent() instanceof PsiMethodCallExpression && qualifierExpression != null - ? qualifierExpression - : (PsiExpression)context; - return new TypeConversionDescriptor("$qualifier$", "$qualifier$.get()", expression); - } - else if (context instanceof PsiAssignmentExpression) { - final PsiJavaToken signToken = ((PsiAssignmentExpression)context).getOperationSign(); - final IElementType operationSign = signToken.getTokenType(); - final String sign = signToken.getText(); - if (parent instanceof PsiExpressionStatement) { - if (operationSign == JavaTokenType.EQ) { - final PsiExpression lExpression = ((PsiAssignmentExpression)context).getLExpression(); - if (lExpression instanceof PsiReferenceExpression) { - final PsiElement element = ((PsiReferenceExpression)lExpression).resolve(); - if (element instanceof PsiVariable && ((PsiVariable)element).hasModifierProperty(PsiModifier.FINAL)) { - return wrapWithNewExpression(to, from, ((PsiAssignmentExpression)context).getRExpression(), element); - } - } - return new TypeConversionDescriptor("$qualifier$ = $val$", "$qualifier$.set($val$)"); - } - else { - return new TypeConversionDescriptor("$qualifier$" + sign + "$val$", "$qualifier$.set(" + - getBoxedWrapper(from, to, "$qualifier$.get() " + - sign.charAt(0) + - " $val$") + - ")"); - } - } //else should be a conflict - } - else if (context instanceof PsiPostfixExpression) { - final String sign = ((PsiPostfixExpression)context).getOperationSign().getText(); - return new TypeConversionDescriptor("$qualifier$" + sign, "$qualifier$.getAndSet(" + - getBoxedWrapper(from, to, "$qualifier$.get() " + sign.charAt(0) + " 1") + - ")"); - } - else if (context instanceof PsiPrefixExpression) { - final PsiJavaToken operationSign = ((PsiPrefixExpression)context).getOperationSign(); - if (operationSign.getTokenType() == JavaTokenType.EXCL) { - return new TypeConversionDescriptor("!$qualifier$", "!$qualifier$.get()"); - } - final String sign = operationSign.getText(); - return new TypeConversionDescriptor(sign + "$qualifier$", "$qualifier$.set(" + //todo reject? - getBoxedWrapper(from, to, "$qualifier$.get() " + sign.charAt(0) + " 1") + - ")"); - } else if (context instanceof PsiBinaryExpression) { - final String sign = ((PsiBinaryExpression)context).getOperationSign().getText(); - return new TypeConversionDescriptor("$qualifier$" + sign + "$val$", "$qualifier$.get() " + sign + " $val$"); - } - - if (parent instanceof PsiVariable) { - return wrapWithNewExpression(to, from, null, parent); - } - return null; - } - - public static TypeConversionDescriptor wrapWithNewExpression(PsiType to, PsiType from, @Nullable PsiExpression expression, PsiElement context) { - final String typeText = PsiDiamondTypeUtil.getCollapsedType(to, context); - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(to); - final PsiClass atomicClass = resolveResult.getElement(); - LOG.assertTrue(atomicClass != null); - final PsiTypeParameter[] typeParameters = atomicClass.getTypeParameters(); - if (typeParameters.length == 1) { - final PsiType initial = resolveResult.getSubstitutor().substitute(typeParameters[0]); - final PsiPrimitiveType unboxedInitialType = PsiPrimitiveType.getUnboxedType(initial); - if (unboxedInitialType != null) { - LOG.assertTrue(initial != null); - if (from instanceof PsiPrimitiveType) { - final PsiClassType boxedFromType = ((PsiPrimitiveType)from).getBoxedType(atomicClass); - LOG.assertTrue(boxedFromType != null); - if (!TypeConversionUtil.isAssignable(initial, boxedFromType)) { - return new TypeConversionDescriptor("$val$", "new " + typeText + "((" + unboxedInitialType.getCanonicalText() + ")$val$)", expression); - } - } - } - } - return new TypeConversionDescriptor("$val$", "new " + typeText + "($val$)", expression); - } - - @Nullable - private static TypeConversionDescriptor findDirectConversionForAtomicReferenceArray(PsiElement context, PsiType to, PsiType from) { - LOG.assertTrue(from instanceof PsiArrayType); - from = ((PsiArrayType)from).getComponentType(); - final PsiElement parent = context.getParent(); - final PsiElement parentParent = parent.getParent(); - - if (parent instanceof PsiAssignmentExpression) { - final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)parent; - final IElementType operationSign = assignmentExpression.getOperationTokenType(); - final String sign = assignmentExpression.getOperationSign().getText(); - if (context instanceof PsiArrayAccessExpression) { - if (parentParent instanceof PsiExpressionStatement) { - if (assignmentExpression.getLExpression() == context) { - if (operationSign == JavaTokenType.EQ) { - return new TypeConversionDescriptor("$qualifier$[$idx$] = $val$", "$qualifier$.set($idx$, $val$)", assignmentExpression); - } - else { - return new TypeConversionDescriptor("$qualifier$[$idx$]" + sign + "$val$", - "$qualifier$.set($idx$, " + getBoxedWrapper(from, to, "$qualifier$.get($idx$) " + sign.charAt(0) + " $val$") + ")", - assignmentExpression); - } - } - } //else should be a conflict - } - else { - final PsiExpression rExpression = assignmentExpression.getRExpression(); - if (rExpression == context && operationSign == JavaTokenType.EQ) { //array = new T[l]; - return wrapWithNewExpression(to, from, rExpression, context); - } - } - } else if (parent instanceof PsiVariable) { - if (((PsiVariable)parent).getInitializer() == context) { - return wrapWithNewExpression(to, from, (PsiExpression)context, context); - } - } - - if (parentParent instanceof PsiExpressionStatement) { - if (parent instanceof PsiPostfixExpression) { - final String sign = ((PsiPostfixExpression)parent).getOperationSign().getText(); - return new TypeConversionDescriptor("$qualifier$[$idx$]" + sign, "$qualifier$.getAndSet($idx$, " + - getBoxedWrapper(from, to, - "$qualifier$.get($idx$) " + sign.charAt(0) + " 1") + - ")", (PsiExpression)parent); - } - else if (parent instanceof PsiPrefixExpression) { - final String sign = ((PsiPrefixExpression)parent).getOperationSign().getText(); - return new TypeConversionDescriptor(sign + "$qualifier$[$idx$]", "$qualifier$.set($idx$, " + - getBoxedWrapper(from, to, - "$qualifier$.get($idx$) " + sign.charAt(0) + " 1") + - ")", (PsiExpression)parent); - } - else if (parent instanceof PsiBinaryExpression) { - final String sign = ((PsiBinaryExpression)parent).getOperationSign().getText(); - return new TypeConversionDescriptor("$qualifier$[$idx$]" + sign + "$val$", "$qualifier$.set($idx$, " + - getBoxedWrapper(from, to, "$qualifier$.get($idx$) " + - sign + - " $val$)") + - ")", (PsiExpression)parent); - } - } - - if (context instanceof PsiArrayAccessExpression) { - return new TypeConversionDescriptor("$qualifier$[$idx$]", "$qualifier$.get($idx$)", (PsiExpression)context); - } - return null; - } - - private static String getBoxedWrapper(final PsiType from, final PsiType to, @NotNull String arg) { - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(to); - final PsiClass atomicClass = resolveResult.getElement(); - LOG.assertTrue(atomicClass != null); - final PsiTypeParameter[] typeParameters = atomicClass.getTypeParameters(); - if (typeParameters.length == 1) { - final PsiSubstitutor substitutor = resolveResult.getSubstitutor(); - LOG.assertTrue(substitutor.isValid()); - final PsiType initial = substitutor.substitute(typeParameters[0]); - final PsiPrimitiveType unboxedInitialType = PsiPrimitiveType.getUnboxedType(initial); - if (unboxedInitialType != null) { - LOG.assertTrue(initial != null); - if (from instanceof PsiPrimitiveType) { - final PsiClassType boxedFromType = ((PsiPrimitiveType)from).getBoxedType(atomicClass); - LOG.assertTrue(boxedFromType != null); - return "new " + initial.getPresentableText() + "((" + unboxedInitialType.getCanonicalText() + ")(" + arg + "))"; - } - } - } - return arg; - } - - @Nullable - private static TypeConversionDescriptor findReverseConversion(PsiElement context) { - if (context instanceof PsiReferenceExpression) { - if (context.getParent() instanceof PsiMethodCallExpression) { - return findReverseConversionForMethodCall(context); - } - } - else if (context instanceof PsiNewExpression) { - return new TypeConversionDescriptor("new $type$($qualifier$)", "$qualifier$"); - } - else if (context instanceof PsiMethodCallExpression) { - return findReverseConversionForMethodCall(((PsiMethodCallExpression)context).getMethodExpression()); - } - return null; - } - - @Nullable - private static TypeConversionDescriptor findReverseConversionForMethodCall(PsiElement context) { - final PsiElement resolved = ((PsiReferenceExpression)context).resolve(); - if (resolved instanceof PsiMethod) { - final PsiMethod method = (PsiMethod)resolved; - final int parametersCount = method.getParameterList().getParametersCount(); - final String resolvedName = method.getName(); - if (Comparing.strEqual(resolvedName, "get")) { - return parametersCount == 0 ? - new TypeConversionDescriptor("$qualifier$.get()", "$qualifier$") : - new TypeConversionDescriptor("$qualifier$.get($idx$)", "$qualifier$[$idx$]"); - } - else if (Comparing.strEqual(resolvedName, "set")) { - return parametersCount == 1 ? - new TypeConversionDescriptor("$qualifier$.set($val$)", "$qualifier$ = $val$") : - new TypeConversionDescriptor("$qualifier$.set($idx$, $val$)", "$qualifier$[$idx$] = $val$"); - } - else if (Comparing.strEqual(resolvedName, "addAndGet")) { - return parametersCount == 1 ? - new TypeConversionDescriptor("$qualifier$.addAndGet($delta$)", "$qualifier$ + $delta$") : - new TypeConversionDescriptor("$qualifier$.addAndGet($idx$, $delta$)", "$qualifier$[$idx$] + $delta$"); - } - else if (Comparing.strEqual(resolvedName, "incrementAndGet")) { - return parametersCount == 0 ? - new TypeConversionDescriptor("$qualifier$.incrementAndGet()", "++$qualifier$") : - new TypeConversionDescriptor("$qualifier$.incrementAndGet($idx$)", "++$qualifier$[$idx$]"); - } - else if (Comparing.strEqual(resolvedName, "decrementAndGet")) { - return parametersCount == 0 ? - new TypeConversionDescriptor("$qualifier$.decrementAndGet()", "--$qualifier$") : - new TypeConversionDescriptor("$qualifier$.decrementAndGet($idx$)", "--$qualifier$[$idx$]"); - } - else if (Comparing.strEqual(resolvedName, "getAndIncrement")) { - return parametersCount == 0 ? - new TypeConversionDescriptor("$qualifier$.getAndIncrement()", "$qualifier$++") : - new TypeConversionDescriptor("$qualifier$.getAndIncrement($idx$)", "$qualifier$[$idx$]++"); - } - else if (Comparing.strEqual(resolvedName, "getAndDecrement")) { - return parametersCount == 0 ? - new TypeConversionDescriptor("$qualifier$.getAndDecrement()", "$qualifier$--") : - new TypeConversionDescriptor("$qualifier$.getAndDecrement($idx$)", "$qualifier$[$idx$]--"); - } - else if (Comparing.strEqual(resolvedName, "getAndAdd")) { - return parametersCount == 1? - new TypeConversionDescriptor("$qualifier$.getAndAdd($val$)", "$qualifier$ += $val$") : - new TypeConversionDescriptor("$qualifier$.getAndAdd($idx$, $val$)", "$qualifier$[$idx$] += $val$"); - } - else if (Comparing.strEqual(resolvedName, "getAndSet")) { - return parametersCount == 1 ? - new TypeConversionDescriptor("$qualifier$.getAndSet($val$)", "$qualifier$ = $val$") : - new TypeConversionDescriptor("$qualifier$.getAndSet($idx$, $val$)", "$qualifier$[$idx$] = $val$"); - } - } - return null; - } - -} diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/BoxingTypeConversionRule.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/BoxingTypeConversionRule.java deleted file mode 100644 index 4353bf602e04..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/BoxingTypeConversionRule.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * User: anna - * Date: 08-Aug-2008 - */ -package com.intellij.refactoring.typeMigration.rules; - -import com.intellij.openapi.util.Comparing; -import com.intellij.psi.*; -import com.intellij.psi.util.PsiUtil; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptor; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptorBase; -import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; - -public class BoxingTypeConversionRule extends TypeConversionRule { - - public TypeConversionDescriptorBase findConversion(final PsiType from, final PsiType to, final PsiMember member, final PsiExpression context, - final TypeMigrationLabeler labeler) { - if (to instanceof PsiClassType && from instanceof PsiPrimitiveType) { - if (!PsiUtil.isLanguageLevel5OrHigher(context)) { - final String boxedTypeName = ((PsiPrimitiveType)from).getBoxedTypeName(); - if (Comparing.strEqual(boxedTypeName, to.getCanonicalText())) { - return new TypeConversionDescriptor("$qualifier$", boxedTypeName + ".valueOf($qualifier$)"); - } - } - } - else if (from instanceof PsiClassType && to instanceof PsiPrimitiveType) { - if (!PsiUtil.isLanguageLevel5OrHigher(context)) { - final String boxedTypeName = ((PsiPrimitiveType)to).getBoxedTypeName(); - if (Comparing.strEqual(boxedTypeName, from.getCanonicalText())) { - return new TypeConversionDescriptor("$qualifier$", "($qualifier$)." + to.getCanonicalText() + "Value()"); - } - } - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ElementToArrayConversionRule.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ElementToArrayConversionRule.java deleted file mode 100644 index 0d25df778bcc..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ElementToArrayConversionRule.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * User: anna - * Date: 25-Aug-2008 - */ -package com.intellij.refactoring.typeMigration.rules; - -import com.intellij.psi.*; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.TypeConversionUtil; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptor; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptorBase; -import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; - -public class ElementToArrayConversionRule extends TypeConversionRule{ - public TypeConversionDescriptorBase findConversion(final PsiType from, final PsiType to, final PsiMember member, final PsiExpression context, - final TypeMigrationLabeler labeler) { - if (member == null && to instanceof PsiArrayType && TypeConversionUtil.isAssignable(((PsiArrayType)to).getComponentType(), from)) { - TypeConversionDescriptor wrapDescription = - new TypeConversionDescriptor("$qualifier$", "new " + from.getCanonicalText() + "[]{$qualifier$}", context); - if (((PsiArrayType)to).getComponentType() instanceof PsiClassType && from instanceof PsiPrimitiveType) { - final String boxedTypeName = ((PsiPrimitiveType)from).getBoxedTypeName(); - final String normalizedArrayInitializer = - PsiUtil.isLanguageLevel5OrHigher(context) ? "$qualifier$" : boxedTypeName + ".valueOf($qualifier$)"; - wrapDescription = new TypeConversionDescriptor("$qualifier$", "new " + boxedTypeName + "[]{" + normalizedArrayInitializer + "}", context); - } - final PsiElement parent = context.getParent(); - if ((context instanceof PsiLiteralExpression || context instanceof PsiReferenceExpression) && parent instanceof PsiStatement) { - return wrapDescription; - } - if (parent instanceof PsiAssignmentExpression && ((PsiAssignmentExpression)parent).getRExpression() == context) { - return wrapDescription; - } - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ListArrayConversionRule.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ListArrayConversionRule.java deleted file mode 100644 index 0aa639ba28cb..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ListArrayConversionRule.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * User: anna - * Date: 08-Aug-2008 - */ -package com.intellij.refactoring.typeMigration.rules; - -import com.intellij.openapi.util.Pair; -import com.intellij.psi.*; -import com.intellij.psi.impl.PsiImplUtil; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.util.InheritanceUtil; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.TypeConversionUtil; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptor; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptorBase; -import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; - -public class ListArrayConversionRule extends TypeConversionRule { - public TypeConversionDescriptorBase findConversion(final PsiType from, - final PsiType to, - PsiMember member, - final PsiExpression context, - final TypeMigrationLabeler labeler) { - PsiExpression expression = context; - PsiClassType classType = from instanceof PsiClassType ? (PsiClassType)from : to instanceof PsiClassType ? (PsiClassType)to : null; - PsiArrayType arrayType = from instanceof PsiArrayType ? (PsiArrayType)from : to instanceof PsiArrayType ? (PsiArrayType)to : null; - - if (classType == null || arrayType == null) return null; - final PsiType collectionType = evaluateCollectionsType(classType, expression); - if (collectionType == null) return null; - - if (member == null) { - final PsiMethodCallExpression callExpression = PsiTreeUtil.getParentOfType(context, PsiMethodCallExpression.class); - if (callExpression != null) { - member = callExpression.resolveMethod(); - expression = callExpression; - } - } - if (member instanceof PsiMethod) { - TypeConversionDescriptor descriptor = changeCollectionCallsToArray((PsiMethod)member, context, collectionType, arrayType); - if (descriptor != null) return descriptor; - - @NonNls final String memberName = member.getName(); - assert memberName != null; - if (memberName.equals("sort")) { - if (((PsiMethod)member).getParameterList().getParametersCount() == 1) { - descriptor = new TypeConversionDescriptor("Arrays.sort($qualifier$)", "Collections.sort($qualifier$)", expression); - } - else { - descriptor = - new TypeConversionDescriptor("Arrays.sort($qualifier$, $expr$)", "Collections.sort($qualifier$, $expr$)", expression); - } - } - else if (memberName.equals("binarySearch")) { - if (((PsiMethod)member).getParameterList().getParametersCount() == 2) { - descriptor = - new TypeConversionDescriptor("Arrays.binarySearch($qualifier$, $key$)", "Collections.binarySearch($qualifier$, $key$)", - expression); - } - else { - descriptor = new TypeConversionDescriptor("Arrays.binarySearch($qualifier$, $key$, $comparator$)", - "Collections.binarySearch($qualifier$, $key$, $comparator$)", expression); - } - } - else if (memberName.equals("asList")) { - if (((PsiMethod)member).getParameterList().getParametersCount() == 1) { - descriptor = - new TypeConversionDescriptor("Arrays.asList($qualifier$)", "$qualifier$", expression); - } - } - else if (memberName.equals("fill")) { - descriptor = new TypeConversionDescriptor("Arrays.fill($qualifier$, $filler$)", "Collections.fill($qualifier$, $filler$)", expression); - } - if (descriptor != null) { - return from instanceof PsiClassType - ? new TypeConversionDescriptor(descriptor.getReplaceByString(), descriptor.getStringToReplace(), descriptor.getExpression()) - : descriptor; - } - } - - if (member instanceof PsiField && member.getName().equals("length")) { - return new TypeConversionDescriptor("$qualifier$.length", "$qualifier$.size()"); - } - - final PsiElement parent = context.getParent(); - if (parent instanceof PsiAssignmentExpression && ((PsiAssignmentExpression)parent).getLExpression() == context) { - if (TypeConversionUtil.isAssignable(collectionType, arrayType.getComponentType())) { - return new TypeConversionDescriptor("$qualifier$[$idx$] = $expr$", "$qualifier$.set($idx$, $expr$)", - (PsiExpression)parent); - } - } - else if (context instanceof PsiArrayAccessExpression && TypeConversionUtil.isAssignable(arrayType.getComponentType(), collectionType)) { - return new TypeConversionDescriptor("$qualifier$[$idx$]", "$qualifier$.get($idx$)"); - } - - return null; - } - - @Nullable - public static PsiType evaluateCollectionsType(PsiClassType classType, PsiExpression expression) { - final PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(classType); - if (classResolveResult != null) { - final PsiClass psiClass = classResolveResult.getElement(); - if (psiClass != null) { - final GlobalSearchScope allScope = GlobalSearchScope.allScope(psiClass.getProject()); - final PsiClass collectionClass = - JavaPsiFacade.getInstance(psiClass.getProject()).findClass(CommonClassNames.JAVA_UTIL_LIST, allScope); - if (collectionClass != null && InheritanceUtil.isInheritorOrSelf(psiClass, collectionClass, true)) { - final PsiSubstitutor derivedSubstitutor = classResolveResult.getSubstitutor(); - if (PsiUtil.isRawSubstitutor(psiClass, derivedSubstitutor)) return null; - final PsiSubstitutor substitutor = - TypeConversionUtil.getClassSubstitutor(collectionClass, psiClass, derivedSubstitutor); - assert substitutor != null; - final PsiType type = substitutor.substitute(collectionClass.getTypeParameters()[0]); - assert type != null; - return PsiImplUtil.normalizeWildcardTypeByPosition(type, expression); - } - } - } - return null; - } - - @Override - public Pair<PsiType, PsiType> bindTypeParameters(final PsiType from, - final PsiType to, - final PsiMethod method, - final PsiExpression context, - final TypeMigrationLabeler labeler) { - if (findConversion(from, to, method, context, labeler) == null) return null; - if (from instanceof PsiArrayType && to instanceof PsiClassType) { - final PsiType collectionType = evaluateCollectionsType((PsiClassType)to, context); - if (collectionType != null) { - return Pair.create(((PsiArrayType)from).getComponentType(), collectionType); - } - } - if (to instanceof PsiArrayType && from instanceof PsiClassType) { - final PsiType collectionType = evaluateCollectionsType((PsiClassType)from, context); - if (collectionType != null) { - return Pair.create(collectionType, ((PsiArrayType)to).getComponentType()); - - } - } - return null; - } - - @Nullable - private static TypeConversionDescriptor changeCollectionCallsToArray(final PsiMethod method, - final PsiElement context, - PsiType collectionType, - PsiArrayType arrayType) { - @NonNls final String methodName = method.getName(); - if (methodName.equals("toArray")) { - if (method.getParameterList().getParameters().length == 0) { - return new TypeConversionDescriptor("$qualifier$.toArray()", "$qualifier$"); - } - return new TypeConversionDescriptor("$qualifier$.toArray($expr$)", "$qualifier$"); - } - else if (methodName.equals("size")) { - return new TypeConversionDescriptor("$qualifier$.size()", "$qualifier$.length"); - } - else if (methodName.equals("get")) { - if (TypeConversionUtil.isAssignable(collectionType, arrayType.getComponentType())) { - return new TypeConversionDescriptor("$qualifier$.get($i$)", "$qualifier$[$i$]", PsiTreeUtil.getParentOfType(context, PsiMethodCallExpression.class)); - } - } - else if (methodName.equals("set")) { - if (TypeConversionUtil.isAssignable(arrayType.getComponentType(), collectionType)) { - return new TypeConversionDescriptor("$qualifier$.set($i$, $val$)", "$qualifier$[$i$] = $val$"); - } - } - return null; - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ThreadLocalConversionRule.java b/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ThreadLocalConversionRule.java deleted file mode 100644 index 2fb305147d02..000000000000 --- a/plugins/typeMigration/src/com/intellij/refactoring/typeMigration/rules/ThreadLocalConversionRule.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * User: anna - * Date: 18-Aug-2009 - */ -package com.intellij.refactoring.typeMigration.rules; - -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Comparing; -import com.intellij.psi.*; -import com.intellij.psi.impl.PsiDiamondTypeUtil; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiUtil; -import com.intellij.psi.util.TypeConversionUtil; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptor; -import com.intellij.refactoring.typeMigration.TypeConversionDescriptorBase; -import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class ThreadLocalConversionRule extends TypeConversionRule { - private static final Logger LOG = Logger.getInstance("#" + ThreadLocalConversionRule.class.getName()); - - - @Override - public TypeConversionDescriptorBase findConversion(PsiType from, - PsiType to, - PsiMember member, - PsiExpression context, - TypeMigrationLabeler labeler) { - if (to instanceof PsiClassType && isThreadLocalTypeMigration(from, (PsiClassType)to, context)) { - return findDirectConversion(context, to, from, labeler); - } - return null; - } - - private static boolean isThreadLocalTypeMigration(PsiType from, PsiClassType to, PsiExpression context) { - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(to); - final PsiClass threadLocalClass = resolveResult.getElement(); - - if (threadLocalClass != null) { - final String typeQualifiedName = threadLocalClass.getQualifiedName(); - if (!Comparing.strEqual(typeQualifiedName, ThreadLocal.class.getName())) { - return false; - } - final PsiTypeParameter[] typeParameters = threadLocalClass.getTypeParameters(); - if (typeParameters.length != 1) return !PsiUtil.isLanguageLevel5OrHigher(context); - final PsiType toTypeParameterValue = resolveResult.getSubstitutor().substitute(typeParameters[0]); - if (toTypeParameterValue != null) { - if (from instanceof PsiPrimitiveType) { - final PsiPrimitiveType unboxedInitialType = PsiPrimitiveType.getUnboxedType(toTypeParameterValue); - if (unboxedInitialType != null) { - return TypeConversionUtil.areTypesConvertible(from, unboxedInitialType); - } - } - else { - return TypeConversionUtil.isAssignable(from, PsiUtil.captureToplevelWildcards(toTypeParameterValue, context)); - } - } - return !PsiUtil.isLanguageLevel5OrHigher(context); - } - return false; - } - - @Nullable - public static TypeConversionDescriptor findDirectConversion(PsiElement context, PsiType to, PsiType from, TypeMigrationLabeler labeler) { - final PsiClass toTypeClass = PsiUtil.resolveClassInType(to); - LOG.assertTrue(toTypeClass != null); - - if (context instanceof PsiArrayAccessExpression) { - return new TypeConversionDescriptor("$qualifier$[$val$]", "$qualifier$.get()[$val$]"); - } - final PsiElement parent = context.getParent(); - if (parent instanceof PsiAssignmentExpression) { - final IElementType operationSign = ((PsiAssignmentExpression)parent).getOperationTokenType(); - if (operationSign == JavaTokenType.EQ) { - return new TypeConversionDescriptor("$qualifier$ = $val$", "$qualifier$.set(" + toBoxed("$val$", from, context)+")", (PsiAssignmentExpression)parent); - } - } - - if (context instanceof PsiReferenceExpression) { - final PsiExpression qualifierExpression = ((PsiReferenceExpression)context).getQualifierExpression(); - final PsiExpression expression = context.getParent() instanceof PsiMethodCallExpression && qualifierExpression != null - ? qualifierExpression - : (PsiExpression)context; - return new TypeConversionDescriptor("$qualifier$", toPrimitive("$qualifier$.get()", from, context), expression); - } - else if (context instanceof PsiBinaryExpression) { - final PsiBinaryExpression binaryExpression = (PsiBinaryExpression)context; - final String sign = binaryExpression.getOperationSign().getText(); - return new TypeConversionDescriptor("$qualifier$" + sign + "$val$", toPrimitive("$qualifier$.get()", from, context) + " " + sign + " $val$"); - } - - if (parent instanceof PsiExpressionStatement) { - if (context instanceof PsiPostfixExpression) { - final PsiPostfixExpression postfixExpression = (PsiPostfixExpression)context; - final String sign = postfixExpression.getOperationSign().getText(); - - return new TypeConversionDescriptor("$qualifier$" + sign, "$qualifier$.set(" + - getBoxedWrapper(from, to, toPrimitive("$qualifier$.get()", from, context) + " " + sign.charAt(0) + " 1", - labeler, context, postfixExpression.getOperand().getText() + - sign.charAt(0) + - " 1") + - ")"); - } - else if (context instanceof PsiPrefixExpression) { - final PsiPrefixExpression prefixExpression = (PsiPrefixExpression)context; - final PsiJavaToken operationSign = ((PsiPrefixExpression)context).getOperationSign(); - if (operationSign.getTokenType() == JavaTokenType.EXCL) { - return new TypeConversionDescriptor("!$qualifier$", "!$qualifier$.get()"); - } - final String sign = operationSign.getText(); - final PsiExpression operand = prefixExpression.getOperand(); - return new TypeConversionDescriptor(sign + "$qualifier$", "$qualifier$.set(" + - getBoxedWrapper(from, to, toPrimitive("$qualifier$.get()", from, context) + " " + sign.charAt(0) + " 1", - labeler, context, operand != null ? operand.getText() + - sign.charAt(0) + - " 1" : null) + - ")"); - } - else if (context instanceof PsiAssignmentExpression) { - final PsiAssignmentExpression assignmentExpression = (PsiAssignmentExpression)context; - final PsiJavaToken signToken = assignmentExpression.getOperationSign(); - final IElementType operationSign = signToken.getTokenType(); - final String sign = signToken.getText(); - final PsiExpression lExpression = assignmentExpression.getLExpression(); - if (operationSign == JavaTokenType.EQ) { - if (lExpression instanceof PsiReferenceExpression) { - final PsiElement element = ((PsiReferenceExpression)lExpression).resolve(); - if (element instanceof PsiVariable && ((PsiVariable)element).hasModifierProperty(PsiModifier.FINAL)) { - return wrapWithNewExpression(to, from, ((PsiAssignmentExpression)context).getRExpression()); - } - } - return new TypeConversionDescriptor("$qualifier$ = $val$", "$qualifier$.set(" + - toBoxed("$val$", from, context) + - ")"); - } - else { - final PsiExpression rExpression = assignmentExpression.getRExpression(); - return new TypeConversionDescriptor("$qualifier$" + sign + "$val$", "$qualifier$.set(" + - getBoxedWrapper(from, to, toPrimitive("$qualifier$.get()", from, context) + - " " + sign.charAt(0) + - " $val$", labeler, context, - rExpression != null - ? lExpression - .getText() + - sign.charAt(0) + - rExpression.getText() - : null) + - ")"); - } - } - } - return null; - } - - public static TypeConversionDescriptor wrapWithNewExpression(PsiType to, PsiType from, PsiExpression initializer) { - final String boxedTypeName = from instanceof PsiPrimitiveType ? ((PsiPrimitiveType)from).getBoxedTypeName() : from.getCanonicalText(); - return new TypeConversionDescriptor("$qualifier$", "new " + - to.getCanonicalText() + - "() {\n" + - "@Override \n" + - "protected " + - boxedTypeName + - " initialValue() {\n" + - " return " + - (PsiUtil.isLanguageLevel5OrHigher(initializer) - ? initializer.getText() - : (from instanceof PsiPrimitiveType ? "new " + - ((PsiPrimitiveType)from).getBoxedTypeName() + - "(" + - initializer.getText() + - ")" : initializer.getText())) + - ";\n" + - "}\n" + - "}", initializer); - } - - private static String toPrimitive(String replaceByArg, PsiType from, PsiElement context) { - return PsiUtil.isLanguageLevel5OrHigher(context) - ? replaceByArg - : from instanceof PsiPrimitiveType ? "((" + - ((PsiPrimitiveType)from).getBoxedTypeName() + - ")" + - replaceByArg + - ")." + - from.getCanonicalText() + - "Value()" : "((" + from.getCanonicalText() + ")" + replaceByArg + ")"; - } - - private static String toBoxed(String replaceByArg, PsiType from, PsiElement context) { - return PsiUtil.isLanguageLevel5OrHigher(context) - ? replaceByArg - : from instanceof PsiPrimitiveType ? "new " + ((PsiPrimitiveType)from).getBoxedTypeName() + - "(" + - replaceByArg + - ")" - : replaceByArg; - } - - private static String getBoxedWrapper(final PsiType from, - final PsiType to, - @NotNull String arg, - TypeMigrationLabeler labeler, - PsiElement context, - @Nullable String tryType) { - if (from instanceof PsiPrimitiveType) { - final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(to); - final PsiClass threadLocalClass = resolveResult.getElement(); - LOG.assertTrue(threadLocalClass != null); - final PsiTypeParameter[] typeParameters = threadLocalClass.getTypeParameters(); - if (typeParameters.length == 1) { - final PsiType initial = resolveResult.getSubstitutor().substitute(typeParameters[0]); - final PsiPrimitiveType unboxedInitialType = PsiPrimitiveType.getUnboxedType(initial); - if (unboxedInitialType != null) { - LOG.assertTrue(initial != null); - if (tryType != null) { - final PsiType exprType = labeler.getTypeEvaluator().evaluateType( - JavaPsiFacade.getElementFactory(threadLocalClass.getProject()).createExpressionFromText(tryType, context)); - if (exprType != null && unboxedInitialType.isAssignableFrom(exprType)) { - return toBoxed(arg, from, context); - } - } - return "new " + initial.getCanonicalText() + "((" + unboxedInitialType.getCanonicalText() + ")(" + arg + "))"; - } - } - } - return toBoxed(arg, from, context); - } - - -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template b/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template deleted file mode 100644 index 413db792c422..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/after.java.template +++ /dev/null @@ -1,10 +0,0 @@ -public class X { - { - new Comparable<String>() { - @Override - public int compareTo(String o) { - return 0; - } - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template b/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template deleted file mode 100644 index 96eb1b46dbd2..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/before.java.template +++ /dev/null @@ -1,10 +0,0 @@ -public class X { - { - new Comparable<<spam>Object</spam>>() { - @Override - public int compareTo(Object o) { - return 0; - } - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/description.html b/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/description.html deleted file mode 100644 index d4dc0a283bf8..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ChangeClassParametersIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -Changes anonymous class type parameters in live template. -</body> -</html>
\ No newline at end of file diff --git a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/after.java.template b/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/after.java.template deleted file mode 100644 index 53cfaf5be80c..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/after.java.template +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.concurrent.atomic.*; -public class X { - AtomicInteger count = new AtomicInteger(0); -} diff --git a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/before.java.template b/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/before.java.template deleted file mode 100644 index 9e6048be8324..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/before.java.template +++ /dev/null @@ -1,3 +0,0 @@ -public class X { - <spot>int count = 0;</spot> -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/description.html b/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/description.html deleted file mode 100644 index 0f799f7b36a8..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToAtomicIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -This intention replaces variable type with corresponding atomic type. -</body> -</html> diff --git a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/after.java.template b/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/after.java.template deleted file mode 100644 index 377017bd41c6..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/after.java.template +++ /dev/null @@ -1,15 +0,0 @@ -import java.text.*; -import java.util.Date; - -class X { - private static final ThreadLocal<DateFormat> dateFormat = new ThreadLocal<DateFormat>() { - @Override - protected DateFormat initialValue() { - return new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); - } - }; - - public String getDateString() { - return dateFormat.get().format(new Date()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/before.java.template b/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/before.java.template deleted file mode 100644 index 14fae704762b..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/before.java.template +++ /dev/null @@ -1,10 +0,0 @@ -import java.text.*; -import java.util.Date; - -public class X { - private static DateFormat <spot>dateFormat</spot> = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z"); - - public String getDateString() { - return dateFormat.format(new Date()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/description.html b/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/description.html deleted file mode 100644 index 930467e5df1b..000000000000 --- a/plugins/typeMigration/src/intentionDescriptions/ConvertFieldToThreadLocalIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -This intention replaces field type with corresponding thread local. -</body> -</html> diff --git a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToAtomicIntentionTest.java b/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToAtomicIntentionTest.java deleted file mode 100644 index 4a0b73dde767..000000000000 --- a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToAtomicIntentionTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.intellij.codeInsight; - -import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; -import com.intellij.openapi.application.PluginPathManager; -import org.jetbrains.annotations.NotNull; - -/** - * @author anna - */ -public class ConvertToAtomicIntentionTest extends LightQuickFixParameterizedTestCase { - @Override - protected boolean shouldBeAvailableAfterExecution() { - return true; - } - - @Override - protected String getBasePath() { - return "/intentions/atomic"; - } - - @NotNull - @Override - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("typeMigration") + "/testData"; - } - - public void test() throws Exception { - doAllTests(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToThreadLocalIntentionTest.java b/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToThreadLocalIntentionTest.java deleted file mode 100644 index 389ced7354af..000000000000 --- a/plugins/typeMigration/test/com/intellij/codeInsight/ConvertToThreadLocalIntentionTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.intellij.codeInsight; - -import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase; -import com.intellij.openapi.application.PluginPathManager; -import org.jetbrains.annotations.NotNull; - -/** - * @author anna - */ -public class ConvertToThreadLocalIntentionTest extends LightQuickFixParameterizedTestCase { - @Override - protected boolean shouldBeAvailableAfterExecution() { - return true; - } - - @Override - protected String getBasePath() { - return "/intentions/threadLocal"; - } - - @NotNull - @Override - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("typeMigration") + "/testData"; - } - - public void test() throws Exception { - doAllTests(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/test/com/intellij/refactoring/AllTypeMigrationTests.java b/plugins/typeMigration/test/com/intellij/refactoring/AllTypeMigrationTests.java deleted file mode 100644 index 2fb8d9054628..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/AllTypeMigrationTests.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * User: anna - * Date: 04-Aug-2008 - */ -package com.intellij.refactoring; - -import com.intellij.codeInsight.ConvertToAtomicIntentionTest; -import com.intellij.codeInsight.ConvertToThreadLocalIntentionTest; -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTypeMigrationTests { - @SuppressWarnings({"UnusedDeclaration"}) - public static Test suite() { - final TestSuite suite = new TestSuite(); - suite.addTestSuite(TypeMigrationTest.class); - suite.addTestSuite(TypeMigrationByAtomicRuleTest.class); - suite.addTestSuite(TypeMigrationByThreadLocalRuleTest.class); - suite.addTestSuite(MigrateTypeSignatureTest.class); - suite.addTestSuite(ChangeTypeSignatureTest.class); - suite.addTestSuite(WildcardTypeMigrationTest.class); - suite.addTestSuite(ConvertToAtomicIntentionTest.class); - suite.addTestSuite(ConvertToThreadLocalIntentionTest.class); - return suite; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java b/plugins/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java deleted file mode 100644 index e85b2f79fd30..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/ChangeTypeSignatureTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * User: anna - * Date: 18-Mar-2008 - */ -package com.intellij.refactoring; - -import com.intellij.openapi.application.PluginPathManager; -import com.intellij.psi.*; -import com.intellij.psi.impl.source.PsiImmediateClassType; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.refactoring.typeMigration.TypeMigrationLabeler; -import com.intellij.refactoring.typeMigration.TypeMigrationProcessor; -import com.intellij.refactoring.typeMigration.TypeMigrationRules; -import com.intellij.testFramework.LightCodeInsightTestCase; -import org.jetbrains.annotations.NotNull; - -public class ChangeTypeSignatureTest extends LightCodeInsightTestCase { - @NotNull - @Override - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("typeMigration") + "/testData"; - } - - private void doTest(boolean success, String migrationTypeText) throws Exception { - String dataPath = "/refactoring/changeTypeSignature/"; - configureByFile(dataPath + getTestName(false) + ".java"); - final PsiFile file = getFile(); - final PsiElement element = file.findElementAt(getEditor().getCaretModel().getOffset()); - final PsiReferenceParameterList parameterList = PsiTreeUtil.getParentOfType(element, PsiReferenceParameterList.class); - assert parameterList != null; - final PsiClass superClass = (PsiClass)((PsiJavaCodeReferenceElement)parameterList.getParent()).resolve(); - assert superClass != null; - - PsiType migrationType = getJavaFacade().getElementFactory().createTypeFromText(migrationTypeText, null); - - try { - final TypeMigrationRules rules = new TypeMigrationRules(TypeMigrationLabeler.getElementType(parameterList)); - rules.setMigrationRootType(PsiSubstitutor.EMPTY.put(superClass.getTypeParameters()[0], migrationType).substitute(new PsiImmediateClassType(superClass, PsiSubstitutor.EMPTY))); - rules.setBoundScope(GlobalSearchScope.projectScope(getProject())); - new TypeMigrationProcessor(getProject(), parameterList, rules).run(); - if (success) { - checkResultByFile(dataPath + getTestName(false) + ".java.after"); - } else { - fail("Conflicts should be detected"); - } - } - catch (RuntimeException e) { - if (success) { - e.printStackTrace(); - fail("Conflicts should not appear"); - } - } - } - - private void doTest(boolean success) throws Exception { - doTest(success, CommonClassNames.JAVA_LANG_OBJECT); - } - - public void testListTypeArguments() throws Exception { - doTest(true); - } - - public void testFieldUsage() throws Exception { - doTest(true); - } - - public void testFieldUsage1() throws Exception { - doTest(true); - } - - public void testReturnType() throws Exception { - doTest(true); - } - - public void testReturnType1() throws Exception { - doTest(true); - } - - public void testReturnType2() throws Exception { - doTest(true); - } - - public void testPassedParameter() throws Exception { - doTest(true); - } - - public void testPassedParameter1() throws Exception { - doTest(true, "java.lang.Integer"); - } - - public void testPassedParameter2() throws Exception { - doTest(true); - } - - public void testUsedInSuper() throws Exception { - doTest(true); - } - - public void testCompositeReturnType() throws Exception { - doTest(true); - } - - public void testTypeHierarchy() throws Exception { - doTest(true); - } - - public void testTypeHierarchy1() throws Exception { - doTest(true); - } - - public void testTypeHierarchy2() throws Exception { - doTest(true); - } - - public void testTypeHierarchyFieldUsage() throws Exception { - doTest(true); - } - - public void testTypeHierarchyFieldUsageConflict() throws Exception { - doTest(true); - } - - public void testParameterMigration() throws Exception { - doTest(true); - } - - public void testParameterMigration1() throws Exception { - doTest(true, "java.lang.Integer"); - } - - public void testParameterMigration2() throws Exception { - doTest(true, "java.lang.Integer"); - } - - public void testFieldTypeMigration() throws Exception { - doTest(true, "java.lang.String"); - } - - public void testMethodReturnTypeMigration() throws Exception { - doTest(true, "java.lang.Integer"); - } - - @Override - protected boolean isRunInWriteAction() { - return false; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/test/com/intellij/refactoring/MigrateTypeSignatureTest.java b/plugins/typeMigration/test/com/intellij/refactoring/MigrateTypeSignatureTest.java deleted file mode 100644 index 7889306ed6f0..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/MigrateTypeSignatureTest.java +++ /dev/null @@ -1,561 +0,0 @@ -/* - * User: anna - * Date: 30-Apr-2008 - */ -package com.intellij.refactoring; - -import com.intellij.psi.CommonClassNames; -import com.intellij.psi.PsiEllipsisType; -import com.intellij.psi.PsiType; -import org.jetbrains.annotations.NotNull; - -public class MigrateTypeSignatureTest extends TypeMigrationTestBase { - @NotNull - @Override - public String getTestRoot() { - return "/refactoring/migrateTypeSignature/"; - } - - public void testExprAccess2Lvalue() throws Exception { - doTestFieldType("myForAccess", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null), - myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null)); - } - - public void testExprAccess2Rvalue() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null), - myJavaFacade.getElementFactory().createTypeFromText("ClassGrandChild", null)); - } - - public void testExprAccessParent2Lvalue() throws Exception { - doTestFieldType("myForSuperAccess", "Ession", - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null), - myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null)); - } - - public void testExprAccessParent2Rvalue() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null), - myJavaFacade.getElementFactory().createTypeFromText("ClassGrandChild", null)); - } - - public void testExprArrayAccessNegative() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.DOUBLE); - } - - public void testExprArrayAccessPositive() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.CHAR); - } - - public void testExprCalcBooleanBoolean() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.BOOLEAN, PsiType.INT); - } - - public void testExprCalcBooleanNumeric() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - public void testExprCalcBooleanReference() throws Exception { - doTestFirstParamType("meth", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null), - PsiType.DOUBLE); - } - - public void testExprCalcNumeric2Boolean() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.BOOLEAN); - } - - public void testExprCalcNumeric2Floating() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.FLOAT); - } - - public void testExprCalcNumeric2Int() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, PsiType.LONG); - } - - public void testExprCalcNumeric2String() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testExprCast2LvalueNeg() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.BYTE, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testExprCast2LvaluePos() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.BYTE, PsiType.INT); - } - - public void testExprConcatNumeric2Reference() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - public void testExprConcatNumeric2String() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testExprConcatString2Numeric() throws Exception { - doTestFirstParamType("meth", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null), - PsiType.INT); - } - - public void testExprConcatString2Reference() throws Exception { - doTestFirstParamType("meth", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null), - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - public void testExprInstanceofNeg() throws Exception { - doTestFirstParamType("meth", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null), - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null)); - } - - public void testExprInstanceofPos() throws Exception { - doTestFirstParamType("meth", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_MAP, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.AbstractMap", null)); - } - - public void testExprLiteralBoolean() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.BOOLEAN); - } - - public void testExprLiteralByte() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.BYTE); - } - - public void testExprLiteralChar() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.CHAR); - } - - public void testExprLiteralClassExtends() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<? extends java.util.Collection[]>", null)); - } - - public void testExprLiteralClassPrimitive() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<Integer>", null)); - } - - public void testExprLiteralClassPrimitiveArray() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<int[]>", null)); - } - - public void testExprLiteralClassRaw() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class", null)); - } - - public void testExprLiteralClassReference() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<java.util.Set>", null)); - } - - public void testExprLiteralClassReferenceArray() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<java.util.Set[]>", null)); - } - - public void testExprLiteralClassSuper() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Class<? super java.util.AbstractSet[]>", null)); - } - - public void testExprLiteralDouble() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.DOUBLE); - } - - public void testExprLiteralFloat() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.FLOAT); - } - - public void testExprLiteralInt() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.INT); - } - - public void testExprLiteralLong() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.LONG); - } - - public void testExprLiteralShort() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - PsiType.SHORT); - } - - public void testExprLiteralString() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testExprNewArrayArray2Lvalue() throws Exception { - doTestFirstParamType("meth", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null).createArrayType()); - } - - public void testExprNewArrayArray2Rvalue() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null).createArrayType().createArrayType().createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null).createArrayType().createArrayType().createArrayType()); - } - - public void testExprNewArrayGen2Rvalue() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<java.lang.Integer>", null).createArrayType()); - } - - public void testExprNewArrayPrimitive2Lvalue() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.BOOLEAN, PsiType.INT); - } - - public void testExprNewArrayPrimitive2Rvalue() throws Exception { - doTestFieldType("myField", "Expr", - PsiType.BOOLEAN.createArrayType().createArrayType(), - PsiType.INT.createArrayType().createArrayType()); - } - - public void testExprNewArrayReftype2Lvalue() throws Exception { - doTestFirstParamType("meth", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null), - myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null)); - } - - public void testExprNewArrayReftype2Rvalue() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null).createArrayType().createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null).createArrayType().createArrayType()); - } - - public void testExprNewGen() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Subject>", null)); - } - - public void testExprNewGenExtends() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? extends Subject>", null)); - } - - public void testExprNewGenSuper() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? super Subject>", null)); - } - - public void testExprNewReference() throws Exception { - doTestFieldType("myField", "Expr", - myJavaFacade.getElementFactory().createTypeFromText("Expr.Ancestor", null), - myJavaFacade.getElementFactory().createTypeFromText("Expr.Subject", null)); - } - - public void testExprReturn2Lvalue() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.INT, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testExprReturn2Rvalue() throws Exception { - doTestMethodType("meth", "Expr", PsiType.INT, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testExprTernary() throws Exception { - doTestFirstParamType("meth", "Expr", PsiType.DOUBLE, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testOverridingDown() throws Exception { - doTestMethodType("getInt", "Parent", PsiType.INT, PsiType.BYTE); - } - - public void testOverridingUp() throws Exception { - doTestMethodType("getInt", "Child", PsiType.INT, PsiType.BYTE); - } - - public void testSpecJavadoc() throws Exception { - doTestFirstParamType("meth", "Spec", PsiType.DOUBLE, - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null)); - } - - public void testSpecNotUsed() throws Exception { - doTestFieldType("myField", "Spec", PsiType.INT, PsiType.BOOLEAN); - } - - public void testTypeArrayReftype2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText("Descendant", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("Subject", null).createArrayType()); - } - - public void testTypeArrayReftype2Rvalue() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText("Ancestor", null).createArrayType().createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("Subject", null).createArrayType().createArrayType()); - } - - public void testTypeArrayRoots2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText("Holder", null), - myJavaFacade.getElementFactory().createTypeFromText("Holder", null).createArrayType()); - } - - public void testTypeArrayVararg2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText("Descendant", null).createArrayType(), - new PsiEllipsisType(myJavaFacade.getElementFactory().createTypeFromText("Subject", null))); - } - - public void testTypeArrayVararg2RvalueNeg() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText("Ancestor", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("Descendant", null).createArrayType()); - } - - public void testTypeArrayVararg2RvaluePos() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText("Ancestor", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("Subject", null).createArrayType()); - } - - public void testTypeAutoboxBoolean2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BOOLEAN, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Boolean", null)); - } - - public void testTypeAutoboxBoolean2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Boolean", null), - PsiType.BOOLEAN); - } - - public void testTypeAutoboxByte2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BYTE, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Byte", null)); - } - - public void testTypeAutoboxByte2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Byte", null), - PsiType.BYTE); - } - - public void testTypeAutoboxChar2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.CHAR, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Character", null)); - } - - public void testTypeAutoboxChar2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Character", null), - PsiType.CHAR); - } - - public void testTypeAutoboxDouble2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.DOUBLE, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Double", null)); - } - - public void testTypeAutoboxDouble2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Double", null), - PsiType.DOUBLE); - } - - public void testTypeAutoboxFloat2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.FLOAT, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Float", null)); - } - - public void testTypeAutoboxFloat2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Float", null), - PsiType.FLOAT); - } - - public void testTypeAutoboxInt2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.INT, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null)); - } - - public void testTypeAutoboxInt2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null), - PsiType.INT); - } - - public void testTypeAutoboxLong2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.LONG, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Long", null)); - } - - public void testTypeAutoboxLong2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Long", null), - PsiType.LONG); - } - - public void testTypeAutoboxShort2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.SHORT, - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Short", null)); - } - - public void testTypeAutoboxShort2Rvalue() throws Exception { - doTestFieldType("myField", "Type", myJavaFacade.getElementFactory().createTypeFromText("java.lang.Short", null), - PsiType.SHORT); - } - - public void testTypeGenAncestor2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Subject>", null)); - } - - public void testTypeGenAncestorWildcard2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? extends Subject>", null)); - } - - public void testTypeGenDescendant2Rvalue() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Subject>", null)); - } - - public void testTypeGenDescendantWildcard2Rvalue() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? super Subject>", null)); - } - - public void testTypeGenRaw2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Any>", null), - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null)); - } - - public void testTypeGenRaw2Rvalue() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<Any>", null), - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null)); - } - - public void testTypePrimsubBoolean2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.INT, PsiType.BOOLEAN); - } - - public void testTypePrimsubBoolean2Rvalue() throws Exception { - doTestFieldType("myField", "Type", PsiType.INT, PsiType.BOOLEAN); - } - - public void testTypePrimsubByte2Rvalue() throws Exception { - doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.BYTE); - } - - public void testTypePrimsubChar2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.CHAR); - } - - public void testTypePrimsubChar2Rvalue() throws Exception { - doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.CHAR); - } - - public void testTypePrimsubDouble2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.DOUBLE); - } - - public void testTypePrimsubFloat2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.FLOAT); - } - - public void testTypePrimsubFloat2Rvalue() throws Exception { - doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.FLOAT); - } - - public void testTypePrimsubInt2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.INT); - } - - public void testTypePrimsubInt2Rvalue() throws Exception { - doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.INT); - } - - public void testTypePrimsubLong2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.LONG); - } - - public void testTypePrimsubLong2Rvalue() throws Exception { - doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.LONG); - } - - public void testTypePrimsubShort2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", PsiType.BYTE, PsiType.SHORT); - } - - public void testTypePrimsubShort2Rvalue() throws Exception { - doTestFieldType("myField", "Type", PsiType.DOUBLE, PsiType.SHORT); - } - - public void testTypeRefClassChild2Rvalue() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null), - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null)); - } - - public void testTypeRefClassParent2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null), - myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null)); - } - - public void testTypeRefClassParent2Rvalue() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null), - myJavaFacade.getElementFactory().createTypeFromText("ClassParent", null)); - } - - public void testTypeRefFaceChild2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null), - myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null)); - } - - public void testTypeRefFaceChild2Rvalue() throws Exception { - doTestFieldType("myField", "Type", - myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null), - myJavaFacade.getElementFactory().createTypeFromText("FaceChild", null)); - } - - public void testTypeRefFaceParent2Lvalue() throws Exception { - doTestFirstParamType("meth", "Type", - myJavaFacade.getElementFactory().createTypeFromText("ClassChild", null), - myJavaFacade.getElementFactory().createTypeFromText("FaceParent", null)); - } -} diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java deleted file mode 100644 index 80658077e986..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByAtomicRuleTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * User: anna - * Date: 19-Aug-2009 - */ -package com.intellij.refactoring; - -import com.intellij.psi.PsiType; -import org.jetbrains.annotations.NotNull; - -import java.util.concurrent.atomic.AtomicReferenceArray; -import java.util.concurrent.atomic.AtomicIntegerArray; - -public class TypeMigrationByAtomicRuleTest extends TypeMigrationTestBase{ - @NotNull - @Override - protected String getTestRoot() { - return "/refactoring/typeMigrationByAtomic/"; - } - - private void doTestDirectMigration() throws Exception { - doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicInteger", null)); - } - - - public void testDirectIncrementDecrement() throws Exception { - doTestDirectMigration(); - } - - public void testDirectAssignments() throws Exception { - doTestDirectMigration(); - } - - public void testDirectConditions() throws Exception { - doTestFieldType("b", PsiType.BOOLEAN, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicBoolean", null)); - } - - - public void testDirectByte() throws Exception { - doTestFieldType("b", PsiType.BYTE, myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.Byte>", null)); - } - - public void testDirectString() throws Exception { - doTestFieldType("s", myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.String>", null)); - } - - public void testDirectForeach() throws Exception { - doTestFieldType("lst", myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.String>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.util.List<java.lang.String>>", null)); - } - - public void testDirectStringArray() throws Exception { - doTestFieldType("s", myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText(AtomicReferenceArray.class.getName() + "<java.lang.String>", null)); - } - - public void testDirectIntArray() throws Exception { - doTestFieldType("a", PsiType.INT.createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText(AtomicIntegerArray.class.getName(), null)); - } - - private void doTestReverseMigration() throws Exception { - doTestFieldType("i", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicInteger", null), PsiType.INT); - } - - - public void testReverseIncrementDecrement() throws Exception { - doTestReverseMigration(); - } - - public void testReverseAssignments() throws Exception { - doTestReverseMigration(); - } - - public void testReverseConditions() throws Exception { - doTestFieldType("b", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicBoolean", null), PsiType.BOOLEAN); - } - - public void testReverseByte() throws Exception { - doTestFieldType("b", myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.Byte>", null), PsiType.BYTE); - } - - public void testReverseString() throws Exception { - doTestFieldType("s", - myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReference<java.lang.String>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null)); - } - - public void testReverseStringArray() throws Exception { - doTestFieldType("s", - myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicReferenceArray<java.lang.String>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null).createArrayType()); - } - - public void testReverseIntArray() throws Exception { - doTestFieldType("a", - myJavaFacade.getElementFactory().createTypeFromText("java.util.concurrent.atomic.AtomicIntegerArray", null), - PsiType.INT.createArrayType()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java deleted file mode 100644 index 5d002d3fcced..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationByThreadLocalRuleTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * User: anna - * Date: 19-Aug-2009 - */ -package com.intellij.refactoring; - -import com.intellij.psi.PsiType; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import org.jetbrains.annotations.NotNull; - -public class TypeMigrationByThreadLocalRuleTest extends TypeMigrationTestBase{ - @NotNull - @Override - protected String getTestRoot() { - return "/refactoring/typeMigrationByThreadLocal/"; - } - - - public void testDirectInt() throws Exception { - doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.Integer>", null)); - } - - public void testDirectByte() throws Exception { - doTestFieldType("i", PsiType.BYTE, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.Byte>", null)); - } - - public void testDirectString() throws Exception { - doTestFieldType("myS", PsiType.getJavaLangString(myPsiManager, GlobalSearchScope.allScope(myProject)), myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.lang.String>", null)); - } - - public void testLanguageLevel() throws Exception { - final LanguageLevelProjectExtension extension = LanguageLevelProjectExtension.getInstance(getProject()); - final LanguageLevel languageLevel = extension.getLanguageLevel(); - try { - extension.setLanguageLevel(LanguageLevel.JDK_1_3); - doTestFieldType("i", PsiType.INT, myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal", null)); - } - finally { - extension.setLanguageLevel(languageLevel); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTest.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTest.java deleted file mode 100644 index b3c36dca19f2..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTest.java +++ /dev/null @@ -1,883 +0,0 @@ -package com.intellij.refactoring; - -import com.intellij.openapi.roots.LanguageLevelProjectExtension; -import com.intellij.pom.java.LanguageLevel; -import com.intellij.psi.*; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.refactoring.typeMigration.TypeMigrationRules; -import org.jetbrains.annotations.NotNull; - -/** - * @author db - * @since 22.07.2003 - */ -public class TypeMigrationTest extends TypeMigrationTestBase { - private PsiElementFactory myFactory; - - @NotNull - @Override - public String getTestRoot() { - return "/refactoring/typeMigration/"; - } - - @Override - public void setUp() throws Exception { - super.setUp(); - LanguageLevelProjectExtension.getInstance(getProject()).setLanguageLevel(LanguageLevel.HIGHEST); - myFactory = myJavaFacade.getElementFactory(); - } - - public void testT07() { - doTestFieldType("f", - PsiType.INT.createArrayType(), - myFactory.createTypeFromText("java.lang.Integer", null).createArrayType()); - } - - public void testT08() { - doTestFieldType("f", - myFactory.createTypeFromText("java.lang.Integer", null).createArrayType(), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - public void testT09() { - doTestFieldType("f", - myFactory.createTypeFromText("java.lang.Integer", null).createArrayType(), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - public void testT10() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null), - myFactory.createTypeFromText("java.util.List<java.lang.String>", null)); - } - - public void testT11() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Map<java.lang.Integer, java.lang.Integer>", null), - myFactory.createTypeFromText("java.util.Map<java.lang.String, java.lang.Integer>", null)); - } - - public void testT12() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null), - myFactory.createTypeFromText("java.util.List<java.lang.String>", null)); - } - - public void testT13() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null)); - } - - public void testT14() { - doTestFieldType("f", - myFactory.createTypeFromText("B", null), - myFactory.createTypeFromText("A", null)); - } - - //do not touch javadoc refs etc - public void testT15() { - doTestFieldType("f", - myFactory.createTypeFromText("B", null), - myFactory.createTypeFromText("A", null)); - } - - //do not touch signature with method type parameters - public void testT16() { - doTestFieldType("f", - myFactory.createTypeFromText("A", null), - myFactory.createTypeFromText("B", null)); - } - - //change method signature inspired by call on parameters - public void testT17() { - doTestFieldType("f", - myFactory.createTypeFromText("A", null), - myFactory.createTypeFromText("B", null)); - } - - //extending iterable -> used in foreach statement - public void testT18() { - doTestFieldType("f", - myFactory.createTypeFromText("A", null), - myFactory.createTypeFromText("B", null)); - } - - public void testT19() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Map<java.lang.String, java.lang.String>", null), - myFactory.createTypeFromText("java.util.HashMap<java.lang.Integer, java.lang.Integer>", null)); - } - - public void testT20() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.HashMap<java.lang.Integer, java.lang.Integer>", null), - myFactory.createTypeFromText("java.util.Map<java.lang.String, java.lang.String>", null)); - } - - public void testT21() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Map<java.lang.String, java.util.List<java.lang.String>>", - null), - myFactory.createTypeFromText("java.util.Map<java.lang.String, java.util.Set<java.lang.String>>", - null) - ); - } - - //varargs : removed after migration?! - public void testT22() { - doTestFieldType("f", - myFactory.createTypeFromText("java.lang.String", null), - myFactory.createTypeFromText("java.lang.Integer", null)); - } - - //substitution from super class: type params substitution needed - public void testT23() { - doTestFieldType("f", - myFactory.createTypeFromText("HashMap<java.lang.String, java.util.Set<java.lang.String>>", null), - myFactory.createTypeFromText("HashMap<java.lang.String, java.util.List<java.lang.String>>", null)); - } - - //check return type unchanged when it is possible - public void testT24() { - doTestFieldType("f", - myFactory.createTypeFromText("C", null), - myFactory.createTypeFromText("D", null)); - } - - public void testT25() { - doTestFieldType("f", - myFactory.createTypeFromText("C", null), - myFactory.createTypeFromText("D", null)); - } - - //check param type change - public void testT26() { - doTestFieldType("f", - myFactory.createTypeFromText("C", null), - myFactory.createTypeFromText("D", null)); - } - - public void testT27() { - doTestFieldType("f", - myFactory.createTypeFromText("C", null), - myFactory.createTypeFromText("D", null)); - } - - //list --> array - public void testT28() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - public void testT29() { - doTestMethodType("get", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText("java.util.List<java.lang.String>", null)); - } - - public void testT30() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - - public void testT31() { - doTestFieldType("f", - myFactory.createTypeFromText("Test", null), - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - //non code usages - public void testT32() { - doTestFirstParamType("bar", - myFactory.createTypeFromText("long", null), - myFactory.createTypeFromText("int", null)); - } - - //change type arguments for new expressions: l = new ArrayList<String>() -> l = new ArrayList<Integer>() - public void testT33() { - doTestFieldType("l", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null)); - } - - //new expression new ArrayList<String>() should be left without modifications - public void testT34() { - doTestFieldType("l", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.util.AbstractList<java.lang.String>", null)); - } - - public void testT35() { - doTestFieldType("myParent", - myFactory.createTypeFromText("Test", null), - myFactory.createTypeFromText("TestImpl", null)); - } - - //co-variant/contra-variant positions for primitive types 36-39 - public void testT36() { - doTestFirstParamType("foo", PsiType.INT, PsiType.BYTE); - } - - public void testT37() { - doTestFirstParamType("foo", PsiType.SHORT, PsiType.INT); - } - - public void testT38() { - doTestFirstParamType("foo", PsiType.SHORT, PsiType.LONG); - } - - public void testT39() { - doTestFirstParamType("foo", PsiType.SHORT, PsiType.BYTE); - } - - //Set s = new HashSet() -> HashSet s = new HashSet(); - public void testT40() { - doTestFieldType("l", - myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null), - myFactory.createTypeFromText("java.util.ArrayList", null)); - } - - //Set s = new HashSet<String>() -> HashSet s = new HashSet<String>(); - public void testT41() { - doTestFieldType("l", - myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null), - myFactory.createTypeFromText("java.util.ArrayList", null)); - } - - //Set s = new HashSet() -> HashSet<String> s = new HashSet(); - public void testT42() { - doTestFieldType("l", - myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_LIST, null), - myFactory.createTypeFromText("java.util.ArrayList<java.lang.String>", null)); - } - - //long l; Object o = l -> long l; Long o = l; - public void testT43() { - doTestFieldType("o", - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myFactory.createTypeFromText("java.lang.Long", null)); - } - - //long l; int i; l = i; -> long l; byte i; l = i; - public void testT44() { - doTestFieldType("i", PsiType.INT, PsiType.BYTE); - } - - //long l; int i; l = i; -> byte l; -> byte i; l = i; - public void testT45() { - doTestFieldType("l", PsiType.LONG, PsiType.BYTE); - } - - //byte i; long j = i; -> byte i; int j = i; - public void testT46() { - doTestFieldType("j", PsiType.LONG, PsiType.INT); - } - - //o = null -? int o = null - public void testT47() { - doTestFieldType("o", myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), PsiType.INT); - } - - //co-variant/contra-variant assignments: leave types if possible change generics signature only 48-49 - // foo(AbstractSet<String> s){Set<String> ss = s} -> foo(AbstractSet<Integer> s){Set<Integer> ss = s} - public void testT48() { - doTestFirstParamType("foo", - myFactory.createTypeFromText("java.util.AbstractSet<A>", null), - myFactory.createTypeFromText("java.util.AbstractSet<B>", null)); - } - - // Set<String> f; foo(AbstractSet<String> s){f = s} -> Set<Integer>f; foo(AbstractSet<Integer> s){f = s} - public void testT49() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Set<A>", null), - myFactory.createTypeFromText("java.util.Set<B>", null)); - } - - //captured wildcard: Set<? extends JComponent> s; Set<? extends JComponent> c1 = s; -> - // Set<? extends JButton> s; Set<? extends JButton> c1 = s; - public void testT50() { - doTestFieldType("c1", - myFactory.createTypeFromText("java.util.Set<? extends JComponent>", null), - myFactory.createTypeFromText("java.util.Set<? extends JButton>", null)); - } - - //array initialization: 51-52 - public void testT51() { - doTestFieldType("f", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null).createArrayType()); - } - - public void testT52() { - doTestFieldType("f", - myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null).createArrayType(), - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null).createArrayType()); - } - - //generic type promotion to array initializer - public void testT53() { - doTestFieldType("f", - PsiType.DOUBLE.createArrayType(), - myFactory.createTypeFromText("java.util.Set<java.lang.String>", null).createArrayType()); - } - - //wildcard type promotion to expressions 54-55 - public void testT54() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Set<java.lang.Object>", null), - myFactory.createTypeFromText("java.util.Set<? extends java.lang.Integer>", null)); - } - - public void testT55() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Set<java.lang.Object>", null), - myFactory.createTypeFromText("java.util.Set<?>", null)); - } - - //array index should be integer 56-57 - public void testT56() { - doTestFirstParamType("foo", PsiType.INT, PsiType.DOUBLE); - } - - public void testT57() { - doTestFirstParamType("foo", PsiType.INT, PsiType.BYTE); - } - - //Arrays can be assignable to Object/Serializable/Cloneable 58-59; ~ 60 varargs - public void testT58() { - doTestFieldType("f", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - public void testT59() { - doTestFieldType("f", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText("java.lang.Cloneable", null)); - } - - public void testT60() { - doTestFieldType("p", - PsiType.INT.createArrayType(), - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - //change parameter type -> vararg; assignment changed to array - public void testT61() { - doTestFirstParamType("foo", PsiType.INT, new PsiEllipsisType(PsiType.INT)); - } - - //change field type -> change vararg parameter type due to assignment: 62-63 - public void testT62() { - doTestFieldType("p", PsiType.INT.createArrayType(), myFactory.createTypeFromText( - CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - public void testT63() { - doTestFieldType("p", PsiType.INT.createArrayType(), PsiType.DOUBLE.createArrayType()); - } - - //remove vararg type: 64-66 - public void testT64() { - doTestFirstParamType("foo", new PsiEllipsisType(PsiType.INT), PsiType.INT); - } - - public void testT65() { - doTestFirstParamType("foo", - new PsiEllipsisType(PsiType.INT), - myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT115() { - doTestFirstParamType("foo", - new PsiEllipsisType(myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)), - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.String", null))); - } - - public void testT66() { - doTestFirstParamType("foo", new PsiEllipsisType(PsiType.INT), PsiType.INT); - } - - public void testT67() { - doTestFirstParamType("methMemAcc", - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT68() { - doTestFirstParamType("foo", PsiType.INT, PsiType.DOUBLE); - } - - public void testT69() { - doTestFirstParamType("foo", PsiType.INT, PsiType.BYTE); - } - - public void testT70() { - doTestFieldType("a", PsiType.INT.createArrayType().createArrayType(), PsiType.FLOAT.createArrayType().createArrayType()); - } - - public void testT71() { - doTestFieldType("f", - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_CLASS, null), - myFactory.createTypeFromText("java.lang.Class<? extends java.lang.Number>", null)); - } - - public void testT72() { - doTestFieldType("f", - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_CLASS, null), - myFactory.createTypeFromText("java.lang.Class<java.lang.Integer>", null)); - } - - public void testT73() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Set<javax.swing.JComponent>", null).createArrayType().createArrayType(), - myFactory.createTypeFromText("java.util.Set<java.awt.Component>", null).createArrayType().createArrayType()); - } - - //prefix/postfix expression; binary expressions 74-76 - public void testT74() { - doTestFirstParamType("meth", PsiType.INT, PsiType.FLOAT); - } - - public void testT75() { - doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT76() { - doTestFirstParamType("meth", PsiType.BYTE, PsiType.FLOAT); - } - - //+= , etc 77-78 - public void testT77() { - doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - public void testT78() { - doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText("java.lang.String", null)); - } - - //casts 79-80,83 - public void testT79() { - doTestFirstParamType("meth", PsiType.INT, PsiType.BYTE); - } - - public void testT80() { - doTestFirstParamType("meth", PsiType.INT, PsiType.DOUBLE); - } - - public void testT83() { - doTestFirstParamType("meth", PsiType.INT, myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null)); - } - - //instanceofs 81-82 - public void testT81() { - doTestFirstParamType("foo", - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myFactory.createTypeFromText("A", null)); - } - - public void testT82() { - doTestFirstParamType("foo", - myFactory.createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null), - myFactory.createTypeFromText("C", null)); - } - - public void testT84() { - doTestFirstParamType("meth", - myFactory.createTypeFromText(CommonClassNames.JAVA_UTIL_SET, null), - myFactory.createTypeFromText("java.util.Set<? extends java.util.Set>", null)); - } - - public void testT85() { - doTestFieldType("str", - myFactory.createTypeFromText("java.lang.String", null), - myFactory.createTypeFromText("java.lang.Integer", null)); - } - - //array <-> list 86-89;94;95 - public void testT86() { - doTestMethodType("getArray", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText("java.util.List<java.lang.String>", null)); - } - - public void testT87() { - doTestMethodType("getArray", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - public void testT88() { - doTestMethodType("getArray", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText("java.util.List<java.lang.String>", null)); - } - - public void testT89() { - doTestMethodType("getArray", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - public void testT94() { - doTestMethodType("getArray", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - public void testT95() { - doTestMethodType("getArray", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText("java.util.List<java.lang.String>", null)); - } - - - public void testT90() { - doTestFieldType("l", - myFactory.createTypeFromText("java.util.List<B>", null), - myFactory.createTypeFromText("java.util.List<A>", null)); - } - - //element type -> element type array - public void testT91() { - doTestMethodType("foo", - myFactory.createTypeFromText("java.lang.String", null), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - //List<S>=new ArrayList<S>{}; -> List<I>=new ArrayList<I>{}; anonymous - public void testT92() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.List<java.lang.String>", null), - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null)); - } - - //generics signature do not support primitives: Map<Boolean, String> - Map<boolean, String> - public void testT93() { - doTestFirstParamType("foo", myFactory.createTypeFromText("java.lang.Boolean", null), PsiType.BOOLEAN); - } - - //field initializers procession - public void testT96() { - doTestFieldType("f1", - myFactory.createTypeFromText("java.lang.Integer", null), - myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT97() { - doTestFieldType("f1", myFactory.createTypeFromText("java.lang.Integer", null).createArrayType(), PsiType.INT); - } - - //list <-> array conversion in assignment statements - public void testT98() { - doTestMethodType("getArray", - myFactory.createTypeFromText("java.lang.String", null).createArrayType(), - myFactory.createTypeFromText("java.util.List<java.lang.String>", null)); - } - - //escape pattern from [] - public void testT99() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Set<java.util.List<char[]>>", null), - myFactory.createTypeFromText("java.util.Set<java.util.List<int[]>>", null)); - } - - //non formatted type - public void testT100() { - doTestFieldType("f", - myFactory.createTypeFromText("java.util.Map<java.lang.String,java.lang.String>", null), - myFactory.createTypeFromText("java.util.Map<java.lang.String,java.lang.Integer>", null)); - } - - //param List -> Array[] - public void testT101() { - doTestFirstParamType("meth", - myFactory.createTypeFromText("java.util.List<java.util.ArrayList<java.lang.Integer>>", null), - myFactory.createTypeFromText("java.util.ArrayList<java.lang.Integer>[]", null)); - } - - //param Set.add() -> Array[] with conflict - public void testT102() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.Set<? extends java.lang.Object>", null), - myFactory.createTypeFromText("java.lang.Object[]", null)); - } - - //set(1, "") should be assignment-checked over String - public void testT103() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.ArrayList<java.lang.String>", null), - myFactory.createTypeFromText("java.lang.Integer", null).createArrayType()); - } - - //raw list type now should not be changed - public void testT104() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.ArrayList", null), - myFactory.createTypeFromText("java.lang.String", null).createArrayType()); - } - - //implicit type parameter change 105-107 - public void testT105() { - doTestFieldType("t", - myFactory.createTypeFromText("T", null), - myFactory.createTypeFromText("java.lang.String", null)); - } - - - public void testT106() { - doTestFieldType("t", - myFactory.createTypeFromText("T", null), - myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT107() { - doTestFieldType("t", - myFactory.createTypeFromText("T", null), - myFactory.createTypeFromText("java.lang.Integer", null)); - } - - //foreach && wildcards: 108-110 - public void testT108() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null), - myFactory.createTypeFromText("java.util.List<? extends java.lang.Number>", null)); - } - - public void testT109() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null), - myFactory.createTypeFromText("java.util.List<? super java.lang.Number>", null)); - } - - public void testT110() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null), - myFactory.createTypeFromText("java.util.List<? extends java.lang.String>", null)); - } - - //wrap with array creation only literals and refs outside of binary/unary expressions - public void testT111() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.lang.Integer", null), - myFactory.createTypeFromText("java.lang.Integer", null).createArrayType()); - } - - public void testT112() { - doTestMethodType("method", - myFactory.createTypeFromText("java.lang.Integer", null), - myFactory.createTypeFromText("java.lang.Integer", null).createArrayType()); - } - - //varargs - public void testT113() { - doTestFirstParamType("method", - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null)), - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Number", null))); - } - - public void testT114() { - doTestFirstParamType("method", - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null)), - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.String", null))); - } - - //varargs && ArrayList - public void testT118() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.lang.Integer", null), - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null))); - } - - //varargs && arrays - public void testT119() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.lang.Integer", null), - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.Integer", null))); - } - - public void testT120() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.lang.Integer", null), - new PsiEllipsisType(myFactory.createTypeFromText("java.lang.String", null))); - } - - //change parameter type in foreach statement: 116 - array, 117 - list - public void testT116() { - doTestFieldType("str", - myFactory.createTypeFromText("java.lang.Number", null), - myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT117() { - doTestFieldType("str", - myFactory.createTypeFromText("java.lang.Number", null), - myFactory.createTypeFromText("java.lang.String", null)); - } - - - public void testT121() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.ArrayList<java.lang.Number>", null), - myFactory.createTypeFromText("java.util.ArrayList<java.lang.Float>", null)); - } - - public void testT122() { - doTestFirstParamType("method", - myFactory.createTypeFromText("java.util.List<java.util.ArrayList<java.lang.Integer>>", null), - myFactory.createTypeFromText("java.util.List<java.lang.Integer>", null).createArrayType()); - } - - public void testT123() { - doTestFieldType("n", - myFactory.createTypeFromText("java.lang.Number", null), - myFactory.createTypeFromText("java.lang.Integer", null)); - } - - //124,125 - do not change formal method return type - public void testT124() { - doTestFirstParamType("meth", - myFactory.createTypeFromText("T", null), - myFactory.createTypeFromText("java.lang.Integer", null)); - } - - public void testT125() { - doTestFirstParamType("meth", - myFactory.createTypeFromText("T", null), - myFactory.createTypeFromText("java.lang.Integer", null)); - } - - public void testT126() { - doTestMethodType("meth", - myFactory.createTypeFromText("java.lang.String", null), - myFactory.createTypeFromText("T", null)); - } - - // Checking preserving method parameters alignment - public void testT127() { - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS = true; - getCurrentCodeStyleSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; - doTestMethodType("test234", - myFactory.createTypeFromText("int", null), - myFactory.createTypeFromText("long", null)); - } - - // test type migration from disjunction type - public void testT128() { - doTestCatchParameter(myFactory.createTypeFromText("Test.E1 | Test.E2", null), - myFactory.createTypeFromText("Test.E", null)); - } - - // test type migration to disjunction type - public void testT129() { - doTestCatchParameter(myFactory.createTypeFromText("Test.E", null), - myFactory.createTypeFromText("Test.E1 | Test.E2", null)); - } - - // test type migration from disjunction type with interfaces - public void testT130() { - doTestCatchParameter(myFactory.createTypeFromText("Test.E1 | Test.E2", null), - myFactory.createTypeFromText("Test.E", null)); - } - - // test type migration between disjunction types - public void testT131() { - doTestCatchParameter(myFactory.createTypeFromText("Test.E1 | Test.E2", null), - myFactory.createTypeFromText("Test.E2 | Test.E1", null)); - } - - private void doTestCatchParameter(final PsiType rootType, final PsiType migrationType) { - start(new RulesProvider() { - @Override - public TypeMigrationRules provide() { - final TypeMigrationRules rules = new TypeMigrationRules(rootType); - rules.setMigrationRootType(migrationType); - return rules; - } - - @Override - public PsiElement victims(final PsiClass aClass) { - final PsiCatchSection catchSection = PsiTreeUtil.findChildOfType(aClass, PsiCatchSection.class); - assert catchSection != null : aClass.getText(); - final PsiParameter parameter = catchSection.getParameter(); - assert parameter != null : catchSection.getText(); - return parameter; - } - }); - } - - // IDEA-72420 - public void testT132() { - doTestFirstParamType("h", "Test", - myFactory.createTypeFromText("J", null), - myFactory.createTypeFromText("I", null)); - } - - public void testT133() { - doTestFirstParamType("h", "Test", - myFactory.createTypeFromText("J", null), - myFactory.createTypeFromText("I", null)); - } - - public void testT134() { - doTestFirstParamType("buzz", "Test", - PsiType.INT, - myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT135() { - doTestFieldType("foo", "Test", PsiType.LONG, PsiType.INT); - } - - public void testT136() { - final GlobalSearchScope scope = GlobalSearchScope.allScope(myProject); - doTestFirstParamType("foo", "Test", - myFactory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_INTEGER, scope), - PsiType.getJavaLangString(myPsiManager, scope)); - } - - public void testT137() { - doTestFirstParamType("foo", "Test", PsiType.INT, myFactory.createTypeFromText("java.lang.String", null)); - } - - public void testT138() { - doTestFirstParamType("foo", "Test", - myFactory.createTypeFromText("java.util.Set<java.lang.String>", null), - myFactory.createTypeFromText("java.util.Collection<java.lang.String>", null)); - } - - public void testT139() { - doTestForeachParameter(myFactory.createTypeFromText("java.lang.String", null), - myFactory.createTypeFromText("java.lang.Integer", null)); - } - - private void doTestForeachParameter(final PsiType rootType, final PsiType migrationType) { - start(new RulesProvider() { - @Override - public TypeMigrationRules provide() { - final TypeMigrationRules rules = new TypeMigrationRules(rootType); - rules.setMigrationRootType(migrationType); - return rules; - } - - @Override - public PsiElement victims(final PsiClass aClass) { - final PsiForeachStatement foreachStatement = PsiTreeUtil.findChildOfType(aClass, PsiForeachStatement.class); - assert foreachStatement != null : aClass.getText(); - return foreachStatement.getIterationParameter(); - } - }); - } - - - public void testTypeAnno() { - doTestFieldType("list", "Test", - myFactory.createTypeFromText("java.util.ArrayList<java.lang.@TA Integer>", null), - myFactory.createTypeFromText("java.util.Collection<java.lang.@TA Integer>", null)); - } -} diff --git a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java b/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java deleted file mode 100644 index 8f75c4921a1c..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/TypeMigrationTestBase.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.intellij.refactoring; - -import com.intellij.openapi.application.PluginPathManager; -import com.intellij.openapi.command.WriteCommandAction; -import com.intellij.openapi.fileEditor.FileDocumentManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiClass; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiField; -import com.intellij.psi.PsiType; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.search.LocalSearchScope; -import com.intellij.refactoring.typeMigration.TypeMigrationProcessor; -import com.intellij.refactoring.typeMigration.TypeMigrationRules; -import com.intellij.usageView.UsageInfo; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.PrintWriter; - -/** - * @author anna - * Date: 30-Apr-2008 - */ -public abstract class TypeMigrationTestBase extends MultiFileTestCase { - @Override - protected String getTestDataPath() { - return PluginPathManager.getPluginHomePath("typeMigration") + "/testData"; - } - - protected void doTestFieldType(@NonNls String fieldName, PsiType fromType, PsiType toType) { - doTestFieldType(fieldName, "Test", fromType, toType); - } - - protected void doTestFieldType(@NonNls final String fieldName, String className, final PsiType rootType, final PsiType migrationType) { - final RulesProvider provider = new RulesProvider() { - @Override - public TypeMigrationRules provide() throws Exception { - final TypeMigrationRules rules = new TypeMigrationRules(rootType); - rules.setMigrationRootType(migrationType); - return rules; - } - - @Override - public PsiElement victims(PsiClass aClass) { - final PsiField field = aClass.findFieldByName(fieldName, false); - assert field != null : fieldName + " not found in " + aClass; - return field; - } - }; - - start(provider, className); - } - - protected void doTestMethodType(@NonNls final String methodName, final PsiType rootType, final PsiType migrationType) { - doTestMethodType(methodName, "Test", rootType, migrationType); - } - - protected void doTestMethodType(@NonNls final String methodName, @NonNls String className, final PsiType rootType, final PsiType migrationType) { - final RulesProvider provider = new RulesProvider() { - @Override - public TypeMigrationRules provide() throws Exception { - final TypeMigrationRules rules = new TypeMigrationRules(rootType); - rules.setMigrationRootType(migrationType); - return rules; - } - - @Override - public PsiElement victims(PsiClass aClass) { - return aClass.findMethodsByName(methodName, false)[0]; - } - }; - - start(provider, className); - } - - protected void doTestFirstParamType(@NonNls final String methodName, final PsiType rootType, final PsiType migrationType) { - doTestFirstParamType(methodName, "Test", rootType, migrationType); - } - - protected void doTestFirstParamType(@NonNls final String methodName, String className, final PsiType rootType, final PsiType migrationType) { - final RulesProvider provider = new RulesProvider() { - @Override - public TypeMigrationRules provide() throws Exception { - final TypeMigrationRules rules = new TypeMigrationRules(rootType); - rules.setMigrationRootType(migrationType); - return rules; - } - - @Override - public PsiElement victims(PsiClass aClass) { - return aClass.findMethodsByName(methodName, false)[0].getParameterList().getParameters()[0]; - } - }; - - start(provider, className); - } - - public void start(final RulesProvider provider) { - start(provider, "Test"); - } - - public void start(final RulesProvider provider, final String className) { - doTest(new PerformAction() { - @Override - public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception { - TypeMigrationTestBase.this.performAction(className, rootDir.getName(), provider); - } - }); - } - - private void performAction(String className, String rootDir, RulesProvider provider) throws Exception { - PsiClass aClass = myJavaFacade.findClass(className, GlobalSearchScope.allScope(getProject())); - - assertNotNull("Class " + className + " not found", aClass); - - final TypeMigrationRules rules = provider.provide(); - rules.setBoundScope(new LocalSearchScope(aClass.getContainingFile())); - final TestTypeMigrationProcessor pr = new TestTypeMigrationProcessor(getProject(), provider.victims(aClass), rules); - - final UsageInfo[] usages = pr.findUsages(); - final String report = pr.getLabeler().getMigrationReport(); - - WriteCommandAction.runWriteCommandAction(null, new Runnable() { - public void run() { - pr.performRefactoring(usages); - } - }); - - - String itemName = className + ".items"; - String patternName = getTestDataPath() + getTestRoot() + getTestName(true) + "/after/" + itemName; - - File patternFile = new File(patternName); - - if (!patternFile.exists()) { - PrintWriter writer = new PrintWriter(new FileOutputStream(patternFile)); - try { - writer.print(report); - writer.close(); - } - finally { - writer.close(); - } - - System.out.println("Pattern not found, file " + patternName + " created."); - - LocalFileSystem.getInstance().refreshAndFindFileByIoFile(patternFile); - } - - File graFile = new File(FileUtil.getTempDirectory() + File.separator + rootDir + File.separator + itemName); - - PrintWriter writer = new PrintWriter(new FileOutputStream(graFile)); - try { - writer.print(report); - writer.close(); - } - finally { - writer.close(); - } - - LocalFileSystem.getInstance().refreshAndFindFileByIoFile(graFile); - FileDocumentManager.getInstance().saveAllDocuments(); - } - - interface RulesProvider { - TypeMigrationRules provide() throws Exception; - - PsiElement victims(PsiClass aClass); - } - - private static class TestTypeMigrationProcessor extends TypeMigrationProcessor { - public TestTypeMigrationProcessor(final Project project, final PsiElement root, final TypeMigrationRules rules) { - super(project, root, rules); - } - - @NotNull - @Override - public UsageInfo[] findUsages() { - return super.findUsages(); - } - - @Override - public void performRefactoring(final UsageInfo[] usages) { - super.performRefactoring(usages); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/test/com/intellij/refactoring/WildcardTypeMigrationTest.java b/plugins/typeMigration/test/com/intellij/refactoring/WildcardTypeMigrationTest.java deleted file mode 100644 index d66320623f83..000000000000 --- a/plugins/typeMigration/test/com/intellij/refactoring/WildcardTypeMigrationTest.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * User: anna - * Date: 19-Aug-2009 - */ -package com.intellij.refactoring; - -import com.intellij.psi.CommonClassNames; -import org.jetbrains.annotations.NotNull; - -public class WildcardTypeMigrationTest extends TypeMigrationTestBase{ - @NotNull - @Override - protected String getTestRoot() { - return "/refactoring/wildcard/"; - } - - public void testProducerExtends() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null)); - } - - public void testProducerSuper() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Integer>", null)); - } - - public void testProducerUnbounded() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null)); - } - - public void testProducerCollectionChanged() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? super java.lang.Integer>", null)); - } - - public void testProducerExtendsCollectionChanged() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.Set<? extends java.lang.Object>", null)); - } - - public void testProducerStopAtWildcard() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Number>", null)); - } - - public void testProducerFailToStopAtWildcard() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Integer>", null)); - } - - public void testProducerExtendsFailToStopAtWildcard() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? super java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<? extends java.lang.Number>", null)); - } - - - public void testConsumerExtends() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null)); - } - - public void testConsumerSuper() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Number>", null)); - } - - public void testConsumerUnbounded() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null)); - } - - // array -> list - public void testAssignmentExtends() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Integer>", null)); - } - - public void testAssignmentSuper() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Integer>", null)); - } - - public void testAssignmentUnbounded() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null)); - } - - public void testGetExtends() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Integer>", null)); - } - - public void testGetSuper() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? super java.lang.Integer>", null)); - } - - public void testGetUnbounded() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null)); - - } - - public void testLengthSize() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType(), - myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<?>", null)); - - } - - //list -> array - public void testGetAssignmentExtendsToType() throws Exception { - doTestFirstParamType("method", myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Number", null).createArrayType()); - } - - public void testGetAssignmentExtendsToSuperType() throws Exception { - doTestFirstParamType("method", myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText(CommonClassNames.JAVA_LANG_OBJECT, null).createArrayType()); - } - - public void testGetAssignmentExtendsToChildType() throws Exception { - doTestFirstParamType("method", myJavaFacade.getElementFactory().createTypeFromText("java.util.ArrayList<? extends java.lang.Number>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.Integer", null).createArrayType()); - } - - // -> threadlocal with wildcard - public void testThreadLocalProducerExtends() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.String>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.util.List<? extends String>>", null)); - } - - //List<? super String> is not assignable to List<String> though it is possible to pass string where ? super String was - public void _testThreadLocalProducerSuper() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.util.List<java.lang.String>", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<java.util.List<? super String>>", null)); - } - - public void testThreadLocalConsumerSuper() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<? super String>", null)); - } - - public void testThreadLocalConsumerExtends() throws Exception { - doTestFirstParamType("method", - myJavaFacade.getElementFactory().createTypeFromText("java.lang.String", null), - myJavaFacade.getElementFactory().createTypeFromText("java.lang.ThreadLocal<? extends String>", null)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after1.java b/plugins/typeMigration/testData/intentions/atomic/after1.java deleted file mode 100644 index 853f715fd8c4..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after1.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.concurrent.atomic.AtomicIntegerArray; - -// "Convert to atomic" "true" -class Test { - final AtomicIntegerArray field= new AtomicIntegerArray(foo()); - int[] foo() { - return null; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after10.java b/plugins/typeMigration/testData/intentions/atomic/after10.java deleted file mode 100644 index 685e3fb710e2..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after10.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - final AtomicInteger o = new AtomicInteger(0); - - void foo() { - boolean b = this.o.get() == 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after12.java b/plugins/typeMigration/testData/intentions/atomic/after12.java deleted file mode 100644 index 8accafd9fa10..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after12.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - - { - AtomicInteger i = new AtomicInteger(0); - Integer j = 0; - - assert j == i.get(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after13.java b/plugins/typeMigration/testData/intentions/atomic/after13.java deleted file mode 100644 index dea58d02e88c..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after13.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - final AtomicInteger i = new AtomicInteger(0); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after14.java b/plugins/typeMigration/testData/intentions/atomic/after14.java deleted file mode 100644 index 6109d4106e9b..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after14.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.concurrent.atomic.AtomicLong; - -// "Convert to atomic" "true" -class T { - private final AtomicLong l = new AtomicLong(10L); - - public synchronized void update(long m) { - l.set(m); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after2.java b/plugins/typeMigration/testData/intentions/atomic/after2.java deleted file mode 100644 index 2c2ad94beeb0..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after2.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.concurrent.atomic.AtomicReferenceArray; - -// "Convert to atomic" "true" -class Test { - final AtomicReferenceArray<Object> field= new AtomicReferenceArray<>(foo()); - Object[] foo() { - return null; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after3.java b/plugins/typeMigration/testData/intentions/atomic/after3.java deleted file mode 100644 index 505349d5dc36..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after3.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.concurrent.atomic.AtomicIntegerArray; - -// "Convert to atomic" "true" -class Test { - final AtomicIntegerArray field= new AtomicIntegerArray(new int[]{1}); - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after4.java b/plugins/typeMigration/testData/intentions/atomic/after4.java deleted file mode 100644 index e268b2604404..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after4.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - final AtomicInteger i = new AtomicInteger(0); - - int j = i.get() + 5; - String s = "i = " + i.get(); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after5.java b/plugins/typeMigration/testData/intentions/atomic/after5.java deleted file mode 100644 index 82ff84c68e75..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after5.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - final AtomicInteger i = new AtomicInteger(0 + 8); - - int j = i.get() + 5; - String s = "i = " + i.get(); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after6.java b/plugins/typeMigration/testData/intentions/atomic/after6.java deleted file mode 100644 index f0120300e0f9..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after6.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.concurrent.atomic.AtomicIntegerArray; - -// "Convert to atomic" "true" -class Test { - final AtomicIntegerArray i = new AtomicIntegerArray(new int[0]); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after7.java b/plugins/typeMigration/testData/intentions/atomic/after7.java deleted file mode 100644 index 19336f0bc61b..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after7.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - final AtomicInteger o = new AtomicInteger(0); - int j = o.get(); - - void foo() { - while ((o = j) != 0) {} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after8.java b/plugins/typeMigration/testData/intentions/atomic/after8.java deleted file mode 100644 index bdfbd5b03a4d..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after8.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - final AtomicInteger o = new AtomicInteger(); - int j = o.get(); - - void foo() { - while ((o = j) != 0) {} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/after9.java b/plugins/typeMigration/testData/intentions/atomic/after9.java deleted file mode 100644 index c462a10961d4..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/after9.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -// "Convert to atomic" "true" -class Test { - final AtomicInteger o; - int j = o.get(); - - Test(int o) { - this.o = new AtomicInteger(o); - } - - void foo() { - while ((o = j) != 0) {} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/afterExcl.java b/plugins/typeMigration/testData/intentions/atomic/afterExcl.java deleted file mode 100644 index 72f91198ce3d..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/afterExcl.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.concurrent.atomic.AtomicBoolean; - -// "Convert to atomic" "true" -class Test { - final AtomicBoolean field= new AtomicBoolean(false); - { - boolean b = !field.get(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/afterTA1.java b/plugins/typeMigration/testData/intentions/atomic/afterTA1.java deleted file mode 100644 index a90ed666ea30..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/afterTA1.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Convert to atomic" "true" -import java.lang.annotation.*; -import java.util.concurrent.atomic.AtomicReference; - -@Target(value = ElementType.TYPE_USE) -public @interface TA { int value(); } - -class T { - final AtomicReference<@TA(42) String> v = new AtomicReference<String>(); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before1.java b/plugins/typeMigration/testData/intentions/atomic/before1.java deleted file mode 100644 index d3b926f29fb3..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before1.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to atomic" "true" -class Test { - int[] <caret>field=foo(); - int[] foo() { - return null; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before10.java b/plugins/typeMigration/testData/intentions/atomic/before10.java deleted file mode 100644 index a4e7c9db6b75..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before10.java +++ /dev/null @@ -1,8 +0,0 @@ -// "Convert to atomic" "true" -class Test { - final int <caret>o = 0; - - void foo() { - boolean b = this.o == 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before11.java b/plugins/typeMigration/testData/intentions/atomic/before11.java deleted file mode 100644 index b1abb55f9503..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before11.java +++ /dev/null @@ -1,8 +0,0 @@ -// "Convert to atomic" "false" -class Test { - void foo() { - try (AutoCloseable <caret>r = null) { - System.out.println(r); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before12.java b/plugins/typeMigration/testData/intentions/atomic/before12.java deleted file mode 100644 index 2c634df22c2f..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before12.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Convert to atomic" "true" -class Test { - - { - int <caret>i = 0; - Integer j = 0; - - assert j == i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before13.java b/plugins/typeMigration/testData/intentions/atomic/before13.java deleted file mode 100644 index 179e2b165252..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before13.java +++ /dev/null @@ -1,4 +0,0 @@ -// "Convert to atomic" "true" -class Test { - volatile int <caret>i = 0; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before14.java b/plugins/typeMigration/testData/intentions/atomic/before14.java deleted file mode 100644 index 042b4c4dd2a1..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before14.java +++ /dev/null @@ -1,8 +0,0 @@ -// "Convert to atomic" "true" -class T { - private long <caret>l = 10L; - - public synchronized void update(long m) { - l = m; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before2.java b/plugins/typeMigration/testData/intentions/atomic/before2.java deleted file mode 100644 index d33fffc40e20..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before2.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to atomic" "true" -class Test { - Object[] <caret>field=foo(); - Object[] foo() { - return null; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before3.java b/plugins/typeMigration/testData/intentions/atomic/before3.java deleted file mode 100644 index 661dbdd63fb2..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before3.java +++ /dev/null @@ -1,5 +0,0 @@ -// "Convert to atomic" "true" -class Test { - int[] <caret>field= new int[]{1}; - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before4.java b/plugins/typeMigration/testData/intentions/atomic/before4.java deleted file mode 100644 index ecf4b985a5d2..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before4.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to atomic" "true" -class Test { - int <caret>i = 0; - - int j = i + 5; - String s = "i = " + i; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before5.java b/plugins/typeMigration/testData/intentions/atomic/before5.java deleted file mode 100644 index 7ace336aa8be..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before5.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to atomic" "true" -class Test { - int <caret>i = 0 + 8; - - int j = i + 5; - String s = "i = " + i; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before6.java b/plugins/typeMigration/testData/intentions/atomic/before6.java deleted file mode 100644 index abc59802e025..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before6.java +++ /dev/null @@ -1,4 +0,0 @@ -// "Convert to atomic" "true" -class Test { - int[] <caret>i = new int[0]; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before7.java b/plugins/typeMigration/testData/intentions/atomic/before7.java deleted file mode 100644 index fd2d066a4337..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before7.java +++ /dev/null @@ -1,9 +0,0 @@ -// "Convert to atomic" "true" -class Test { - int <caret>o = 0; - int j = o; - - void foo() { - while ((o = j) != 0) {} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before8.java b/plugins/typeMigration/testData/intentions/atomic/before8.java deleted file mode 100644 index d2ef50810f7e..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before8.java +++ /dev/null @@ -1,9 +0,0 @@ -// "Convert to atomic" "true" -class Test { - int <caret>o; - int j = o; - - void foo() { - while ((o = j) != 0) {} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/before9.java b/plugins/typeMigration/testData/intentions/atomic/before9.java deleted file mode 100644 index a9f693800f81..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/before9.java +++ /dev/null @@ -1,13 +0,0 @@ -// "Convert to atomic" "true" -class Test { - final int <caret>o; - int j = o; - - Test(int o) { - this.o = o; - } - - void foo() { - while ((o = j) != 0) {} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/beforeExcl.java b/plugins/typeMigration/testData/intentions/atomic/beforeExcl.java deleted file mode 100644 index 3df455583c35..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/beforeExcl.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to atomic" "true" -class Test { - boolean <caret>field=false; - { - boolean b = !field; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/atomic/beforeTA1.java b/plugins/typeMigration/testData/intentions/atomic/beforeTA1.java deleted file mode 100644 index 10bdd5df4822..000000000000 --- a/plugins/typeMigration/testData/intentions/atomic/beforeTA1.java +++ /dev/null @@ -1,9 +0,0 @@ -// "Convert to atomic" "true" -import java.lang.annotation.*; - -@Target(value = ElementType.TYPE_USE) -public @interface TA { int value(); } - -class T { - @TA(42) String <caret>v; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after1.java b/plugins/typeMigration/testData/intentions/threadLocal/after1.java deleted file mode 100644 index b5df8fd35214..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after1.java +++ /dev/null @@ -1,12 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - final ThreadLocal<Integer> field = new ThreadLocal<Integer>() { - @Override - protected Integer initialValue() { - return 0; - } - }; - void foo() { - field.set(field.get() + 1); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after2.java b/plugins/typeMigration/testData/intentions/threadLocal/after2.java deleted file mode 100644 index 3a546c5b0c9a..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after2.java +++ /dev/null @@ -1,12 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - final ThreadLocal<String> field = new ThreadLocal<String>() { - @Override - protected String initialValue() { - return ""; - } - }; - void foo() { - System.out.println(field.get()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after3.java b/plugins/typeMigration/testData/intentions/threadLocal/after3.java deleted file mode 100644 index 9fc0f825ac4b..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after3.java +++ /dev/null @@ -1,12 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - final ThreadLocal<Integer> field = new ThreadLocal<Integer>() { - @Override - protected Integer initialValue() { - return new Integer(0); - } - }; - void foo() { - if (field.get() == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after4.java b/plugins/typeMigration/testData/intentions/threadLocal/after4.java deleted file mode 100644 index 8410a1c33c0e..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after4.java +++ /dev/null @@ -1,12 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - final ThreadLocal<String> field = new ThreadLocal<String>() { - @Override - protected String initialValue() { - return ""; - } - }; - void foo() { - if (field.get().indexOf("a") == -1) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after5.java b/plugins/typeMigration/testData/intentions/threadLocal/after5.java deleted file mode 100644 index 435e1b6a50e6..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after5.java +++ /dev/null @@ -1,12 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - final ThreadLocal<Integer> field = new ThreadLocal<Integer>() { - @Override - protected Integer initialValue() { - return new Integer(0); - } - }; - void foo(Test t) { - if (t.field.get() == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after6.java b/plugins/typeMigration/testData/intentions/threadLocal/after6.java deleted file mode 100644 index 1879a46be16d..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after6.java +++ /dev/null @@ -1,12 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - static final ThreadLocal<Integer> field; - static { - field = new ThreadLocal<Integer>() { - @Override - protected Integer initialValue() { - return new Integer(0); - } - }; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after7.java b/plugins/typeMigration/testData/intentions/threadLocal/after7.java deleted file mode 100644 index 5398ff5e2991..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after7.java +++ /dev/null @@ -1,15 +0,0 @@ -// "Convert to ThreadLocal" "true" -class X { - private final ThreadLocal<byte[]> bytes = new ThreadLocal<byte[]>() { - @Override - protected byte[] initialValue() { - return new byte[10]; - } - }; - - byte foo(byte b) { - bytes.get()[0] = 1; - foo(bytes.get()[1]) - return bytes.get()[2]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/after8.java b/plugins/typeMigration/testData/intentions/threadLocal/after8.java deleted file mode 100644 index d158894b6130..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/after8.java +++ /dev/null @@ -1,9 +0,0 @@ -// "Convert to ThreadLocal" "true" -class X { - final ThreadLocal<Integer> i = new ThreadLocal<Integer>() { - @Override - protected Integer initialValue() { - return 0; - } - }; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/afterTA1.java b/plugins/typeMigration/testData/intentions/threadLocal/afterTA1.java deleted file mode 100644 index 0e3687e146b6..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/afterTA1.java +++ /dev/null @@ -1,14 +0,0 @@ -// "Convert to ThreadLocal" "true" -import java.lang.annotation.*; - -@Target(value = ElementType.TYPE_USE) -public @interface TA { int value(); } - -class Test { - final ThreadLocal<@TA(42) Integer> field = new ThreadLocal<Integer>() { - @Override - protected Integer initialValue() { - return 0; - } - }; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before1.java b/plugins/typeMigration/testData/intentions/threadLocal/before1.java deleted file mode 100644 index e35925390137..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before1.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - int <caret>field=0; - void foo() { - field++; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before2.java b/plugins/typeMigration/testData/intentions/threadLocal/before2.java deleted file mode 100644 index 47c6471739d7..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before2.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - String <caret>field=""; - void foo() { - System.out.println(field); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before3.java b/plugins/typeMigration/testData/intentions/threadLocal/before3.java deleted file mode 100644 index 19d296cffa36..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before3.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - Integer <caret>field=new Integer(0); - void foo() { - if (field == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before4.java b/plugins/typeMigration/testData/intentions/threadLocal/before4.java deleted file mode 100644 index 66d2efa6230a..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before4.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - String <caret>field=""; - void foo() { - if (field.indexOf("a") == -1) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before5.java b/plugins/typeMigration/testData/intentions/threadLocal/before5.java deleted file mode 100644 index c459443241e4..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before5.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - Integer <caret>field=new Integer(0); - void foo(Test t) { - if (t.field == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before6.java b/plugins/typeMigration/testData/intentions/threadLocal/before6.java deleted file mode 100644 index 74427e6e4f06..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before6.java +++ /dev/null @@ -1,7 +0,0 @@ -// "Convert to ThreadLocal" "true" -class Test { - static final Integer <caret>field; - static { - field = new Integer(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before7.java b/plugins/typeMigration/testData/intentions/threadLocal/before7.java deleted file mode 100644 index dfff0417b272..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before7.java +++ /dev/null @@ -1,10 +0,0 @@ -// "Convert to ThreadLocal" "true" -class X { - private final byte[] <caret>bytes = new byte[10]; - - byte foo(byte b) { - bytes[0] = 1; - foo(bytes[1]) - return bytes[2]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/before8.java b/plugins/typeMigration/testData/intentions/threadLocal/before8.java deleted file mode 100644 index af321e0da56c..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/before8.java +++ /dev/null @@ -1,4 +0,0 @@ -// "Convert to ThreadLocal" "true" -class X { - volatile int <caret>i = 0; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/intentions/threadLocal/beforeTA1.java b/plugins/typeMigration/testData/intentions/threadLocal/beforeTA1.java deleted file mode 100644 index ac3409c2e759..000000000000 --- a/plugins/typeMigration/testData/intentions/threadLocal/beforeTA1.java +++ /dev/null @@ -1,9 +0,0 @@ -// "Convert to ThreadLocal" "true" -import java.lang.annotation.*; - -@Target(value = ElementType.TYPE_USE) -public @interface TA { int value(); } - -class Test { - @TA(42) int <caret>field = 0; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/CompositeReturnType.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/CompositeReturnType.java deleted file mode 100644 index 051e42810e3d..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/CompositeReturnType.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.List; -class A<T> { - List<T> getKey(){return null;} -} -public class B extends A<S<caret>tring> { - List<String> getKey() { - return new List<String>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/CompositeReturnType.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/CompositeReturnType.java.after deleted file mode 100644 index 8966bc1ee03d..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/CompositeReturnType.java.after +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.List; -class A<T> { - List<T> getKey(){return null;} -} -public class B extends A<Object> { - List<Object> getKey() { - return new List<>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldTypeMigration.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldTypeMigration.java deleted file mode 100644 index fabb24302b8d..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldTypeMigration.java +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - interface A<T> { - void foo(T t); - } - - class B implements A<Inte<caret>ger> { - Integer str; - public void foo(Integer s) { - str = s; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldTypeMigration.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldTypeMigration.java.after deleted file mode 100644 index 01a6bf49322e..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldTypeMigration.java.after +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - interface A<T> { - void foo(T t); - } - - class B implements A<String> { - String str; - public void foo(String s) { - str = s; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage.java deleted file mode 100644 index 92864f163560..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.List; - -class A<T> { - T t; - List<T> list = new List<T>(); -} - -class B extends A<S<caret>tring> { - void foo() { - if (t == null) return; - if (list == null) return; - for (String s : list) { - //do nothing - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage.java.after deleted file mode 100644 index 07ee7a4e9351..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage.java.after +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.List; - -class A<T> { - T t; - List<T> list = new List<T>(); -} - -class B extends A<Object> { - void foo() { - if (t == null) return; - if (list == null) return; - for (Object s : list) { - //do nothing - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage1.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage1.java deleted file mode 100644 index bff01e33a9e3..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage1.java +++ /dev/null @@ -1,17 +0,0 @@ -import java.util.*; - -class A<T> { - protected T t; - protected List<T> list = new ArrayList<T>(); -} - -public class B extends A<S<caret>tring> { - void foo() { - if (t == null) return; - if (list == null) return; - System.out.println(t); - for (String s : list) { - //do nothing - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage1.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage1.java.after deleted file mode 100644 index b3764fda80de..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/FieldUsage1.java.after +++ /dev/null @@ -1,17 +0,0 @@ -import java.util.*; - -class A<T> { - protected T t; - protected List<T> list = new ArrayList<T>(); -} - -public class B extends A<Object> { - void foo() { - if (t == null) return; - if (list == null) return; - System.out.println(t); - for (Object s : list) { - //do nothing - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ListTypeArguments.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ListTypeArguments.java deleted file mode 100644 index 98b178156750..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ListTypeArguments.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.List; -class ListTypeArguments implements List<I<caret>nteger> { - public boolean add(Integer o){return true;} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ListTypeArguments.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ListTypeArguments.java.after deleted file mode 100644 index 535acf216d57..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ListTypeArguments.java.after +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.List; -class ListTypeArguments implements List<Object> { - public boolean add(Object o){return true;} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/MethodReturnTypeMigration.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/MethodReturnTypeMigration.java deleted file mode 100644 index 8183831c3ff3..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/MethodReturnTypeMigration.java +++ /dev/null @@ -1,16 +0,0 @@ -class Test { - interface A<T> { - T foo(); - } - - class B implements A<Stri<caret>ng> { - public String foo() { - return null; - } - - public void bar() { - String s = foo(); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/MethodReturnTypeMigration.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/MethodReturnTypeMigration.java.after deleted file mode 100644 index 405cd8a74384..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/MethodReturnTypeMigration.java.after +++ /dev/null @@ -1,16 +0,0 @@ -class Test { - interface A<T> { - T foo(); - } - - class B implements A<Integer> { - public Integer foo() { - return null; - } - - public void bar() { - Integer s = foo(); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration.java deleted file mode 100644 index fdce63b995a8..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration.java +++ /dev/null @@ -1,29 +0,0 @@ -import java.util.*; - -class Test { - class C<T> { - List<T> l; - - void bar(Map<T, T> t){} - - void f(T t){} - - } - - class D extends C<Strin<caret>g> { - void foo(String s) { - f(s); - } - - public void main() { - for (String integer : l) { - - } - } - - void bar(Map<String, String> t) { - super.bar(t); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration.java.after deleted file mode 100644 index ff031aa42904..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration.java.after +++ /dev/null @@ -1,29 +0,0 @@ -import java.util.*; - -class Test { - class C<T> { - List<T> l; - - void bar(Map<T, T> t){} - - void f(T t){} - - } - - class D extends C<Object> { - void foo(String s) { - f(s); - } - - public void main() { - for (Object integer : l) { - - } - } - - void bar(Map<Object, Object> t) { - super.bar(t); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration1.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration1.java deleted file mode 100644 index fdce63b995a8..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration1.java +++ /dev/null @@ -1,29 +0,0 @@ -import java.util.*; - -class Test { - class C<T> { - List<T> l; - - void bar(Map<T, T> t){} - - void f(T t){} - - } - - class D extends C<Strin<caret>g> { - void foo(String s) { - f(s); - } - - public void main() { - for (String integer : l) { - - } - } - - void bar(Map<String, String> t) { - super.bar(t); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration1.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration1.java.after deleted file mode 100644 index f3cef5b65bba..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration1.java.after +++ /dev/null @@ -1,29 +0,0 @@ -import java.util.*; - -class Test { - class C<T> { - List<T> l; - - void bar(Map<T, T> t){} - - void f(T t){} - - } - - class D extends C<Integer> { - void foo(Integer s) { - f(s); - } - - public void main() { - for (Integer integer : l) { - - } - } - - void bar(Map<Integer, Integer> t) { - super.bar(t); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration2.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration2.java deleted file mode 100644 index 278b80eb95d5..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration2.java +++ /dev/null @@ -1,31 +0,0 @@ -import java.util.*; - -class Test { - class C<T> { - List<T> l; - - void bar(Map<T, T> t){ - for (T t1 : t.keySet()) {} - } - - void f(T t){} - - } - - class D extends C<Strin<caret>g> { - void foo(String s) { - f(s); - } - - public void main() { - for (String integer : l) { - - } - } - - void bar(Map<String, String> t) { - super.bar(t); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration2.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration2.java.after deleted file mode 100644 index 5978a88ee283..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ParameterMigration2.java.after +++ /dev/null @@ -1,31 +0,0 @@ -import java.util.*; - -class Test { - class C<T> { - List<T> l; - - void bar(Map<T, T> t){ - for (T t1 : t.keySet()) {} - } - - void f(T t){} - - } - - class D extends C<Integer> { - void foo(Integer s) { - f(s); - } - - public void main() { - for (Integer integer : l) { - - } - } - - void bar(Map<Integer, Integer> t) { - super.bar(t); - } - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter.java deleted file mode 100644 index 416bf0f810b8..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter.java +++ /dev/null @@ -1,16 +0,0 @@ -class A<T> { - void foo(T t){} - void bar(T t, int i){} -} - -class B extends A<S<caret>tring>{ - void foo(String t) { - super.foo(t); - } - - void bar(String t, int i){ - foo(t); - int k = i; - super.bar(t, k); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter.java.after deleted file mode 100644 index 64847ab2afd1..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter.java.after +++ /dev/null @@ -1,16 +0,0 @@ -class A<T> { - void foo(T t){} - void bar(T t, int i){} -} - -class B extends A<Object> { - void foo(Object t) { - super.foo(t); - } - - void bar(Object t, int i){ - foo(t); - int k = i; - super.bar(t, k); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter1.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter1.java deleted file mode 100644 index f9bdb275f3aa..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter1.java +++ /dev/null @@ -1,20 +0,0 @@ -class A<T> { - void foo(T t){} - void bar(T t, int i){} -} - -class B extends A<S<caret>tring>{ - void foo(String t) { - super.foo(t); - } - - void bar(String t, int i){ - foo(t); - int k = i; - super.bar(t, k); - } - - void bar1(String s) { - foo(s); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter1.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter1.java.after deleted file mode 100644 index 1777cb6da9d8..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter1.java.after +++ /dev/null @@ -1,20 +0,0 @@ -class A<T> { - void foo(T t){} - void bar(T t, int i){} -} - -class B extends A<Integer> { - void foo(Integer t) { - super.foo(t); - } - - void bar(Integer t, int i){ - foo(t); - int k = i; - super.bar(t, k); - } - - void bar1(Integer s) { - foo(s); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter2.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter2.java deleted file mode 100644 index 62c7cf4da263..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter2.java +++ /dev/null @@ -1,12 +0,0 @@ -class A<T> { - T bar(){} -} - -class B extends A<S<caret>tring>{ - void barInner(String s) { - } - - void foo() { - barInner(bar()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter2.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter2.java.after deleted file mode 100644 index e5ed5910c2c1..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/PassedParameter2.java.after +++ /dev/null @@ -1,12 +0,0 @@ -class A<T> { - T bar(){} -} - -class B extends A<Object> { - void barInner(Object s) { - } - - void foo() { - barInner(bar()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType.java deleted file mode 100644 index 17960b186a46..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType.java +++ /dev/null @@ -1,14 +0,0 @@ -class A<T> { - T foo(){ - return null; - } -} - -class B extends A<S<caret>tring> { - String foo(){return null;} - - void bar() { - foo(); - if (foo() == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType.java.after deleted file mode 100644 index 1758610f1571..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType.java.after +++ /dev/null @@ -1,14 +0,0 @@ -class A<T> { - T foo(){ - return null; - } -} - -class B extends A<Object> { - Object foo(){return null;} - - void bar() { - foo(); - if (foo() == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType1.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType1.java deleted file mode 100644 index 9e01a295be05..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType1.java +++ /dev/null @@ -1,15 +0,0 @@ -class A<T> { - T foo(){ - return null; - } -} - -public class B extends A<S<caret>tring> { - String foo(){return null;} - - void bar() { - foo(); - if (foo() == null) return; - System.out.println(foo()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType1.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType1.java.after deleted file mode 100644 index 8a584bdca610..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType1.java.after +++ /dev/null @@ -1,15 +0,0 @@ -class A<T> { - T foo(){ - return null; - } -} - -public class B extends A<Object> { - Object foo(){return null;} - - void bar() { - foo(); - if (foo() == null) return; - System.out.println(foo()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType2.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType2.java deleted file mode 100644 index 83b7294972fc..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType2.java +++ /dev/null @@ -1,14 +0,0 @@ -class A<T> { - T foo(){ - return null; - } -} - -class B extends A<S<caret>tring> { - String foo(){return super.foo();} - - void bar() { - foo(); - if (foo() == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType2.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType2.java.after deleted file mode 100644 index a26f7d3f1655..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/ReturnType2.java.after +++ /dev/null @@ -1,14 +0,0 @@ -class A<T> { - T foo(){ - return null; - } -} - -class B extends A<Object> { - Object foo(){return super.foo();} - - void bar() { - foo(); - if (foo() == null) return; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy.java deleted file mode 100644 index 2bfa264828c0..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy.java +++ /dev/null @@ -1,18 +0,0 @@ -abstract class A<E> { - abstract E foo(); -} - -abstract class B<T> extends A<T> { -} - -class C extends B<S<caret>tring> { - String foo() { - return null; - } - - void bar() { - if (foo() == null) { - //do smth - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy.java.after deleted file mode 100644 index 4c4736302857..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy.java.after +++ /dev/null @@ -1,18 +0,0 @@ -abstract class A<E> { - abstract E foo(); -} - -abstract class B<T> extends A<T> { -} - -class C extends B<Object> { - Object foo() { - return null; - } - - void bar() { - if (foo() == null) { - //do smth - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy1.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy1.java deleted file mode 100644 index 5396a7c59422..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy1.java +++ /dev/null @@ -1,19 +0,0 @@ -abstract class A<E> { - public abstract E foo(); -} - -abstract class B<T> extends A<T> { -} - -public class C extends B<S<caret>tring> { - public String foo() { - return null; - } - - void bar() { - if (foo() == null) { - //do smth - } - System.out.println(foo()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy1.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy1.java.after deleted file mode 100644 index 16a02ae4ea3d..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy1.java.after +++ /dev/null @@ -1,19 +0,0 @@ -abstract class A<E> { - public abstract E foo(); -} - -abstract class B<T> extends A<T> { -} - -public class C extends B<Object> { - public Object foo() { - return null; - } - - void bar() { - if (foo() == null) { - //do smth - } - System.out.println(foo()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy2.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy2.java deleted file mode 100644 index 2eb6d429915e..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy2.java +++ /dev/null @@ -1,18 +0,0 @@ -public class Test extends B<S<caret>tring>{ - String foo() { - return null; - } - - void bar() { - if (foo() == null) {} - } -} - -abstract class A<T> { - abstract T foo(); -} - -abstract class B<E extends Object> extends A<E> { -} - - diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy2.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy2.java.after deleted file mode 100644 index b30ab01e5594..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchy2.java.after +++ /dev/null @@ -1,18 +0,0 @@ -public class Test extends B<Object> { - Object foo() { - return null; - } - - void bar() { - if (foo() == null) {} - } -} - -abstract class A<T> { - abstract T foo(); -} - -abstract class B<E extends Object> extends A<E> { -} - - diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsage.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsage.java deleted file mode 100644 index 3bf853421127..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsage.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.List; -class A<E> { - E e; - List<E> list = new List<E>(); -} - -class B<T> extends A<T> {} - -class C extends B <S<caret>tring> { - void foo() { - if (e == null && list != null) { - //do smth - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsage.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsage.java.after deleted file mode 100644 index 5eeea8234a2e..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsage.java.after +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.List; -class A<E> { - E e; - List<E> list = new List<E>(); -} - -class B<T> extends A<T> {} - -class C extends B<Object> { - void foo() { - if (e == null && list != null) { - //do smth - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsageConflict.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsageConflict.java deleted file mode 100644 index bf9237fe6fb3..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsageConflict.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.List; -class A<E> { - E e; - List<E> list = new List<E>(); -} - -class B<T> extends A<T> {} - -class C extends B <S<caret>tring> { - void foo() { - if (e == null && list != null) { - for (String s : list) { - } - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsageConflict.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsageConflict.java.after deleted file mode 100644 index ffecf75c7f20..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/TypeHierarchyFieldUsageConflict.java.after +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.List; -class A<E> { - E e; - List<E> list = new List<E>(); -} - -class B<T> extends A<T> {} - -class C extends B<Object> { - void foo() { - if (e == null && list != null) { - for (Object s : list) { - } - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/UsedInSuper.java b/plugins/typeMigration/testData/refactoring/changeTypeSignature/UsedInSuper.java deleted file mode 100644 index 4cbee666c3cb..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/UsedInSuper.java +++ /dev/null @@ -1,9 +0,0 @@ -class A<T> { - T foo(){return null;} - T bar(){return foo();} -} - -class B extends A<S<caret>tring> { - String foo(){return super.bar();} - String bar(){return super.foo();} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/changeTypeSignature/UsedInSuper.java.after b/plugins/typeMigration/testData/refactoring/changeTypeSignature/UsedInSuper.java.after deleted file mode 100644 index d321e6520dc0..000000000000 --- a/plugins/typeMigration/testData/refactoring/changeTypeSignature/UsedInSuper.java.after +++ /dev/null @@ -1,9 +0,0 @@ -class A<T> { - T foo(){return null;} - T bar(){return foo();} -} - -class B extends A<Object> { - Object foo(){return super.bar();} - Object bar(){return super.foo();} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/after/Expr.items deleted file mode 100644 index 7ce904f6afe4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/after/Expr.items +++ /dev/null @@ -1,33 +0,0 @@ -Types: -PsiField:myForAccess : ClassParent -PsiLocalVariable:vf : ClassParent -PsiLocalVariable:vfcthis : ClassParent -PsiLocalVariable:vfnew : ClassParent -PsiLocalVariable:vfparen : ClassParent -PsiLocalVariable:vfthis : ClassParent -PsiLocalVariable:vm : ClassParent -PsiLocalVariable:vmcthis : ClassParent -PsiLocalVariable:vmnew : ClassParent -PsiLocalVariable:vmparen : ClassParent -PsiLocalVariable:vmthis : ClassParent -PsiMethod:forAccess : ClassParent -PsiMethodCallExpression:(this).forAccess() : ClassParent -PsiMethodCallExpression:Expr.this.forAccess() : ClassParent -PsiMethodCallExpression:forAccess() : ClassParent -PsiMethodCallExpression:forAccess() : ClassParent -PsiMethodCallExpression:forAccess() : ClassParent -PsiMethodCallExpression:new Expr().forAccess() : ClassParent -PsiMethodCallExpression:this.forAccess() : ClassParent -PsiReferenceExpression:(this).myForAccess : ClassParent -PsiReferenceExpression:Expr.this.myForAccess : ClassParent -PsiReferenceExpression:myForAccess : ClassParent -PsiReferenceExpression:myForAccess : ClassParent -PsiReferenceExpression:new Expr().myForAccess : ClassParent -PsiReferenceExpression:this.myForAccess : ClassParent - -Conversions: - -New expression type changes: -Fails: -forAccess()->ClassParent -forAccess()->ClassParent diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/after/Expr.java deleted file mode 100644 index 65fd52a3e86e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/after/Expr.java +++ /dev/null @@ -1,35 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent { - public void forAccess2() { - } - - public int myForAccess; -} -class ClassGrandChild extends ClassChild {} - -class Expr { - public ClassParent myForAccess; - public ClassParent forAccess() { - return myForAccess; - } - - public void methMemAcc() { - ClassParent vf = myForAccess; - ClassParent vm = forAccess(); - - ClassParent vfthis = this.myForAccess; - ClassParent vmthis = this.forAccess(); - - ClassParent vfcthis = Expr.this.myForAccess; - ClassParent vmcthis = Expr.this.forAccess(); - - ClassParent vfparen = (this).myForAccess; - ClassParent vmparen = (this).forAccess(); - - ClassParent vfnew = new Expr().myForAccess; - ClassParent vmnew = new Expr().forAccess(); - - int v = forAccess().myForAccess; - forAccess().forAccess2(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/before/Expr.java deleted file mode 100644 index 1c13032fa121..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Lvalue/before/Expr.java +++ /dev/null @@ -1,35 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent { - public void forAccess2() { - } - - public int myForAccess; -} -class ClassGrandChild extends ClassChild {} - -class Expr { - public ClassChild myForAccess; - public ClassChild forAccess() { - return myForAccess; - } - - public void methMemAcc() { - ClassChild vf = myForAccess; - ClassChild vm = forAccess(); - - ClassChild vfthis = this.myForAccess; - ClassChild vmthis = this.forAccess(); - - ClassChild vfcthis = Expr.this.myForAccess; - ClassChild vmcthis = Expr.this.forAccess(); - - ClassChild vfparen = (this).myForAccess; - ClassChild vmparen = (this).forAccess(); - - ClassChild vfnew = new Expr().myForAccess; - ClassChild vmnew = new Expr().forAccess(); - - int v = forAccess().myForAccess; - forAccess().forAccess2(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/after/Expr.items deleted file mode 100644 index d79df57fc220..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/after/Expr.items +++ /dev/null @@ -1,37 +0,0 @@ -Types: -PsiField:myField : ClassGrandChild -PsiField:myForAccess1 : ClassGrandChild -PsiField:myForAccess2 : ClassGrandChild -PsiField:myForAccess3 : ClassGrandChild -PsiField:myForAccess4 : ClassGrandChild -PsiField:myForAccess5 : ClassGrandChild -PsiMethod:forAccess1 : ClassGrandChild -PsiMethod:forAccess2 : ClassGrandChild -PsiMethod:forAccess3 : ClassGrandChild -PsiMethod:forAccess4 : ClassGrandChild -PsiMethod:forAccess5 : ClassGrandChild -PsiMethodCallExpression:(this).forAccess4() : ClassGrandChild -PsiMethodCallExpression:Expr.this.forAccess3() : ClassGrandChild -PsiMethodCallExpression:forAccess1() : ClassGrandChild -PsiMethodCallExpression:new Expr().forAccess5() : ClassGrandChild -PsiMethodCallExpression:this.forAccess2() : ClassGrandChild -PsiReferenceExpression:(this).myForAccess4 : ClassGrandChild -PsiReferenceExpression:Expr.this.myForAccess3 : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myForAccess1 : ClassGrandChild -PsiReferenceExpression:new Expr().myForAccess5 : ClassGrandChild -PsiReferenceExpression:this.myForAccess2 : ClassGrandChild - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/after/Expr.java deleted file mode 100644 index 11599a2cd3a6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/after/Expr.java +++ /dev/null @@ -1,54 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent { - public void forAccess2() { - } - - public int myForAccess; -} -class ClassGrandChild extends ClassChild {} - -class Expr { - private ClassGrandChild myField; - - public ClassGrandChild myForAccess1; - public ClassGrandChild forAccess1() { - return null; - } - - public ClassGrandChild myForAccess2; - public ClassGrandChild forAccess2() { - return null; - } - - public ClassGrandChild myForAccess3; - public ClassGrandChild forAccess3() { - return null; - } - - public ClassGrandChild myForAccess4; - public ClassGrandChild forAccess4() { - return null; - } - - public ClassGrandChild myForAccess5; - public ClassGrandChild forAccess5() { - return null; - } - - public void methMemAcc() { - myField = myForAccess1; - myField = forAccess1(); - - myField = this.myForAccess2; - myField = this.forAccess2(); - - myField = Expr.this.myForAccess3; - myField = Expr.this.forAccess3(); - - myField = (this).myForAccess4; - myField = (this).forAccess4(); - - myField = new Expr().myForAccess5; - myField = new Expr().forAccess5(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/before/Expr.java deleted file mode 100644 index 64998cf198c8..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccess2Rvalue/before/Expr.java +++ /dev/null @@ -1,54 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent { - public void forAccess2() { - } - - public int myForAccess; -} -class ClassGrandChild extends ClassChild {} - -class Expr { - private ClassChild myField; - - public ClassChild myForAccess1; - public ClassChild forAccess1() { - return null; - } - - public ClassChild myForAccess2; - public ClassChild forAccess2() { - return null; - } - - public ClassChild myForAccess3; - public ClassChild forAccess3() { - return null; - } - - public ClassChild myForAccess4; - public ClassChild forAccess4() { - return null; - } - - public ClassChild myForAccess5; - public ClassChild forAccess5() { - return null; - } - - public void methMemAcc() { - myField = myForAccess1; - myField = forAccess1(); - - myField = this.myForAccess2; - myField = this.forAccess2(); - - myField = Expr.this.myForAccess3; - myField = Expr.this.forAccess3(); - - myField = (this).myForAccess4; - myField = (this).forAccess4(); - - myField = new Expr().myForAccess5; - myField = new Expr().forAccess5(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/after/Ession.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/after/Ession.items deleted file mode 100644 index 15e80380b536..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/after/Ession.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myForSuperAccess : ClassParent -PsiLocalVariable:vfcsuper : ClassParent -PsiLocalVariable:vfsuper : ClassParent -PsiLocalVariable:vmcsuper : ClassParent -PsiLocalVariable:vmsuper : ClassParent -PsiMethod:forSuperAccess : ClassParent -PsiMethodCallExpression:Expr.super.forSuperAccess() : ClassParent -PsiMethodCallExpression:super.forSuperAccess() : ClassParent -PsiReferenceExpression:Expr.super.myForSuperAccess : ClassParent -PsiReferenceExpression:myForSuperAccess : ClassParent -PsiReferenceExpression:super.myForSuperAccess : ClassParent - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/after/Expr.java deleted file mode 100644 index 3a9531d8f9d8..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/after/Expr.java +++ /dev/null @@ -1,20 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent {} -class ClassGrandChild extends ClassChild {} - -class Ession { - public ClassParent myForSuperAccess; - public ClassParent forSuperAccess() { - return myForSuperAccess; - } -} - -class Expr extends Ession { - public void methMemAcc() { - ClassParent vfsuper = super.myForSuperAccess; - ClassParent vmsuper = super.forSuperAccess(); - - ClassParent vfcsuper = Expr.super.myForSuperAccess; - ClassParent vmcsuper = Expr.super.forSuperAccess(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/before/Expr.java deleted file mode 100644 index 898b41a6ab6f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Lvalue/before/Expr.java +++ /dev/null @@ -1,20 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent {} -class ClassGrandChild extends ClassChild {} - -class Ession { - public ClassChild myForSuperAccess; - public ClassChild forSuperAccess() { - return myForSuperAccess; - } -} - -class Expr extends Ession { - public void methMemAcc() { - ClassChild vfsuper = super.myForSuperAccess; - ClassChild vmsuper = super.forSuperAccess(); - - ClassChild vfcsuper = Expr.super.myForSuperAccess; - ClassChild vmcsuper = Expr.super.forSuperAccess(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/after/Expr.items deleted file mode 100644 index 95bf149e7b68..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/after/Expr.items +++ /dev/null @@ -1,19 +0,0 @@ -Types: -PsiField:myField : ClassGrandChild -PsiField:myForSuperAccess1 : ClassGrandChild -PsiField:myForSuperAccess2 : ClassGrandChild -PsiMethod:forSuperAccess1 : ClassGrandChild -PsiMethod:forSuperAccess2 : ClassGrandChild -PsiMethodCallExpression:Expr.super.forSuperAccess2() : ClassGrandChild -PsiMethodCallExpression:super.forSuperAccess1() : ClassGrandChild -PsiReferenceExpression:Expr.super.myForSuperAccess2 : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:myField : ClassGrandChild -PsiReferenceExpression:super.myForSuperAccess1 : ClassGrandChild - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/after/Expr.java deleted file mode 100644 index 9ffe2e3a7332..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/after/Expr.java +++ /dev/null @@ -1,26 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent {} -class ClassGrandChild extends ClassChild {} - -class Ession { - public ClassGrandChild myForSuperAccess1; - public ClassGrandChild forSuperAccess1() { - return null; - } - - public ClassGrandChild myForSuperAccess2; - public ClassGrandChild forSuperAccess2() { - return null; - } -} - -class Expr extends Ession { - private ClassGrandChild myField; - public void methMemAcc() { - myField = super.myForSuperAccess1; - myField = super.forSuperAccess1(); - - myField = Expr.super.myForSuperAccess2; - myField = Expr.super.forSuperAccess2(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/before/Expr.java deleted file mode 100644 index 0a244c6448bd..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprAccessParent2Rvalue/before/Expr.java +++ /dev/null @@ -1,26 +0,0 @@ -class ClassParent {} -class ClassChild extends ClassParent {} -class ClassGrandChild extends ClassChild {} - -class Ession { - public ClassChild myForSuperAccess1; - public ClassChild forSuperAccess1() { - return null; - } - - public ClassChild myForSuperAccess2; - public ClassChild forSuperAccess2() { - return null; - } -} - -class Expr extends Ession { - private ClassChild myField; - public void methMemAcc() { - myField = super.myForSuperAccess1; - myField = super.forSuperAccess1(); - - myField = Expr.super.myForSuperAccess2; - myField = Expr.super.forSuperAccess2(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/after/Expr.items deleted file mode 100644 index 0f10ca83564b..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : double -PsiReferenceExpression:p : double - -Conversions: - -New expression type changes: -Fails: -p->double diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/after/Expr.java deleted file mode 100644 index 9258f512d2b1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/after/Expr.java +++ /dev/null @@ -1,6 +0,0 @@ -class Expr { - public void meth(double p) { - String[] sa = new String[]{"0", "1"}; - String s = sa[p]; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/before/Expr.java deleted file mode 100644 index 57fde1c6b34c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessNegative/before/Expr.java +++ /dev/null @@ -1,6 +0,0 @@ -class Expr { - public void meth(int p) { - String[] sa = new String[]{"0", "1"}; - String s = sa[p]; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/after/Expr.items deleted file mode 100644 index afc565fc6df7..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/after/Expr.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:p : char -PsiReferenceExpression:p : char - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/after/Expr.java deleted file mode 100644 index 7971b5e9e770..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/after/Expr.java +++ /dev/null @@ -1,6 +0,0 @@ -class Expr { - public void meth(char p) { - String[] sa = new String[]{"0", "1"}; - String s = sa[p]; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/before/Expr.java deleted file mode 100644 index 57fde1c6b34c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprArrayAccessPositive/before/Expr.java +++ /dev/null @@ -1,6 +0,0 @@ -class Expr { - public void meth(int p) { - String[] sa = new String[]{"0", "1"}; - String s = sa[p]; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/after/Expr.items deleted file mode 100644 index 4e6bf57cbb3e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/after/Expr.items +++ /dev/null @@ -1,30 +0,0 @@ -Types: -PsiLocalVariable:vba : int -PsiLocalVariable:vbb : int -PsiLocalVariable:vbc : int -PsiParameter:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int -PsiReferenceExpression:pb : int - -Conversions: - -New expression type changes: -Fails: -pb->int -pb->int -pb->int -pb->int -pb->int -pb->int -pb->int diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/after/Expr.java deleted file mode 100644 index d0dd0e83a559..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/after/Expr.java +++ /dev/null @@ -1,16 +0,0 @@ -class Expr { - public void meth(int pb) { - int vba = pb & pb; - int vbb = pb ^ pb; - int vbc = pb | pb; - boolean vbd = pb && pb; - boolean vbe = pb || pb; - - boolean vn1 = false; - vn1 &= pb; - boolean vn2 = false; - vn2 ^= pb; - boolean vn3 = false; - vn3 |= pb; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/before/Expr.java deleted file mode 100644 index d0364a40ca25..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanBoolean/before/Expr.java +++ /dev/null @@ -1,16 +0,0 @@ -class Expr { - public void meth(boolean pb) { - boolean vba = pb & pb; - boolean vbb = pb ^ pb; - boolean vbc = pb | pb; - boolean vbd = pb && pb; - boolean vbe = pb || pb; - - boolean vn1 = false; - vn1 &= pb; - boolean vn2 = false; - vn2 ^= pb; - boolean vn3 = false; - vn3 |= pb; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/after/Expr.items deleted file mode 100644 index 21ecfb0d65a5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/after/Expr.items +++ /dev/null @@ -1,19 +0,0 @@ -Types: -PsiParameter:pi : java.lang.Object -PsiReferenceExpression:pi : java.lang.Object -PsiReferenceExpression:pi : java.lang.Object -PsiReferenceExpression:pi : java.lang.Object -PsiReferenceExpression:pi : java.lang.Object -PsiReferenceExpression:pi : java.lang.Object -PsiReferenceExpression:pi : java.lang.Object - -Conversions: - -New expression type changes: -Fails: -pi->java.lang.Object -pi->java.lang.Object -pi->java.lang.Object -pi->java.lang.Object -pi->java.lang.Object -pi->java.lang.Object diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/after/Expr.java deleted file mode 100644 index c54d809c3906..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/after/Expr.java +++ /dev/null @@ -1,10 +0,0 @@ -class Expr { - public void meth(Object pi) { - boolean vb1 = pi > 0; - boolean vb2 = pi >= 0; - boolean vb3 = pi < 0; - boolean vb4 = pi <= 0; - boolean vb6 = pi == 0; - boolean vb7 = pi != 0; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/before/Expr.java deleted file mode 100644 index 1b113b43a3e6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanNumeric/before/Expr.java +++ /dev/null @@ -1,10 +0,0 @@ -class Expr { - public void meth(int pi) { - boolean vb1 = pi > 0; - boolean vb2 = pi >= 0; - boolean vb3 = pi < 0; - boolean vb4 = pi <= 0; - boolean vb6 = pi == 0; - boolean vb7 = pi != 0; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/after/Expr.items deleted file mode 100644 index 815d62ca7530..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/after/Expr.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiParameter:ps : double -PsiReferenceExpression:ps : double -PsiReferenceExpression:ps : double -PsiReferenceExpression:ps : double -PsiReferenceExpression:ps : double - -Conversions: - -New expression type changes: -Fails: -ps->double -ps->double -ps->double -ps->double diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/after/Expr.java deleted file mode 100644 index bc4c04967759..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/after/Expr.java +++ /dev/null @@ -1,8 +0,0 @@ -class Expr { - public void meth(double ps) { - boolean vb5 = ps instanceof CharSequence; - boolean vb8 = ps == "string"; - boolean vb9 = ps != "string"; - boolean vbf = (1 >= 0) && (ps instanceof CharSequence); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/before/Expr.java deleted file mode 100644 index 6def87eb9709..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcBooleanReference/before/Expr.java +++ /dev/null @@ -1,8 +0,0 @@ -class Expr { - public void meth(String ps) { - boolean vb5 = ps instanceof CharSequence; - boolean vb8 = ps == "string"; - boolean vb9 = ps != "string"; - boolean vbf = (1 >= 0) && (ps instanceof CharSequence); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/after/Expr.items deleted file mode 100644 index aeddc71515d9..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/after/Expr.items +++ /dev/null @@ -1,58 +0,0 @@ -Types: -PsiLocalVariable:vb9 : boolean -PsiLocalVariable:vba : boolean -PsiLocalVariable:vbb : boolean -PsiParameter:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean -PsiReferenceExpression:p : boolean - -Conversions: - -New expression type changes: -Fails: -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean -p->boolean diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/after/Expr.java deleted file mode 100644 index c90c55120370..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/after/Expr.java +++ /dev/null @@ -1,35 +0,0 @@ -class Expr { - public void meth(boolean p) { - int vb1 = p * p; - int vb2 = p / p; - int vb3 = p % p; - int vb4 = p + p; - int vb5 = p - p; - boolean vb9 = p & p; - boolean vba = p ^ p; - boolean vbb = p | p; - - int vn1 = 0; - vn1 *= p; - int vn2 = 0; - vn2 /= p; - int vn3 = 0; - vn3 %= p; - int vn4 = 0; - vn4 += p; - int vn5 = 0; - vn5 -= p; - int vn6 = 0; - vn6 <<= p; - int vn7 = 0; - vn7 >>= p; - int vn8 = 0; - vn8 >>>= p; - int vn9 = 0; - vn9 &= p; - int vna = 0; - vna ^= p; - int vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/before/Expr.java deleted file mode 100644 index 057b284248a0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Boolean/before/Expr.java +++ /dev/null @@ -1,35 +0,0 @@ -class Expr { - public void meth(int p) { - int vb1 = p * p; - int vb2 = p / p; - int vb3 = p % p; - int vb4 = p + p; - int vb5 = p - p; - int vb9 = p & p; - int vba = p ^ p; - int vbb = p | p; - - int vn1 = 0; - vn1 *= p; - int vn2 = 0; - vn2 /= p; - int vn3 = 0; - vn3 %= p; - int vn4 = 0; - vn4 += p; - int vn5 = 0; - vn5 -= p; - int vn6 = 0; - vn6 <<= p; - int vn7 = 0; - vn7 >>= p; - int vn8 = 0; - vn8 >>>= p; - int vn9 = 0; - vn9 &= p; - int vna = 0; - vna ^= p; - int vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/after/Expr.items deleted file mode 100644 index 0fdb9d1291e9..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/after/Expr.items +++ /dev/null @@ -1,78 +0,0 @@ -Types: -PsiLocalVariable:vb1 : float -PsiLocalVariable:vb2 : float -PsiLocalVariable:vb3 : float -PsiLocalVariable:vb4 : float -PsiLocalVariable:vb5 : float -PsiLocalVariable:vn1 : float -PsiLocalVariable:vn2 : float -PsiLocalVariable:vn3 : float -PsiLocalVariable:vn4 : float -PsiLocalVariable:vn5 : float -PsiLocalVariable:vu1 : float -PsiLocalVariable:vu2 : float -PsiLocalVariable:vu3 : float -PsiLocalVariable:vu4 : float -PsiLocalVariable:vu5 : float -PsiLocalVariable:vu6 : float -PsiParameter:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:vn1 : float -PsiReferenceExpression:vn2 : float -PsiReferenceExpression:vn3 : float -PsiReferenceExpression:vn4 : float -PsiReferenceExpression:vn5 : float - -Conversions: -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ - -New expression type changes: -Fails: -p->float -p->float -p->float -p->float -p->float -p->float -p->float -p->float -p->float -p->float -p->float -p->float diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/after/Expr.java deleted file mode 100644 index 8e16d5b5d974..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/after/Expr.java +++ /dev/null @@ -1,42 +0,0 @@ -class Expr { - public void meth(float p) { - float vu1 = p++; - float vu2 = p--; - float vu3 = ++p; - float vu4 = --p; - float vu5 = -p; - float vu6 = +p; - - float vb1 = p * p; - float vb2 = p / p; - float vb3 = p % p; - float vb4 = p + p; - float vb5 = p - p; - int vb9 = p & p; - int vba = p ^ p; - int vbb = p | p; - - float vn1 = 0; - vn1 *= p; - float vn2 = 0; - vn2 /= p; - float vn3 = 0; - vn3 %= p; - float vn4 = 0; - vn4 += p; - float vn5 = 0; - vn5 -= p; - int vn6 = 0; - vn6 <<= p; - int vn7 = 0; - vn7 >>= p; - int vn8 = 0; - vn8 >>>= p; - int vn9 = 0; - vn9 &= p; - int vna = 0; - vna ^= p; - int vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/before/Expr.java deleted file mode 100644 index 4088b28a0060..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Floating/before/Expr.java +++ /dev/null @@ -1,42 +0,0 @@ -class Expr { - public void meth(int p) { - int vu1 = p++; - int vu2 = p--; - int vu3 = ++p; - int vu4 = --p; - int vu5 = -p; - int vu6 = +p; - - int vb1 = p * p; - int vb2 = p / p; - int vb3 = p % p; - int vb4 = p + p; - int vb5 = p - p; - int vb9 = p & p; - int vba = p ^ p; - int vbb = p | p; - - int vn1 = 0; - vn1 *= p; - int vn2 = 0; - vn2 /= p; - int vn3 = 0; - vn3 %= p; - int vn4 = 0; - vn4 += p; - int vn5 = 0; - vn5 -= p; - int vn6 = 0; - vn6 <<= p; - int vn7 = 0; - vn7 >>= p; - int vn8 = 0; - vn8 >>>= p; - int vn9 = 0; - vn9 &= p; - int vna = 0; - vna ^= p; - int vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/after/Expr.items deleted file mode 100644 index 36e79ff677b4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/after/Expr.items +++ /dev/null @@ -1,98 +0,0 @@ -Types: -PsiLocalVariable:vb1 : long -PsiLocalVariable:vb2 : long -PsiLocalVariable:vb3 : long -PsiLocalVariable:vb4 : long -PsiLocalVariable:vb5 : long -PsiLocalVariable:vb6 : long -PsiLocalVariable:vb7 : long -PsiLocalVariable:vb8 : long -PsiLocalVariable:vb9 : long -PsiLocalVariable:vba : long -PsiLocalVariable:vbb : long -PsiLocalVariable:vn1 : long -PsiLocalVariable:vn2 : long -PsiLocalVariable:vn3 : long -PsiLocalVariable:vn4 : long -PsiLocalVariable:vn5 : long -PsiLocalVariable:vn6 : long -PsiLocalVariable:vn7 : long -PsiLocalVariable:vn8 : long -PsiLocalVariable:vn9 : long -PsiLocalVariable:vna : long -PsiLocalVariable:vnb : long -PsiLocalVariable:vu1 : long -PsiLocalVariable:vu2 : long -PsiLocalVariable:vu3 : long -PsiLocalVariable:vu4 : long -PsiLocalVariable:vu5 : long -PsiLocalVariable:vu6 : long -PsiLocalVariable:vu7 : long -PsiParameter:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:vn1 : long -PsiReferenceExpression:vn2 : long -PsiReferenceExpression:vn3 : long -PsiReferenceExpression:vn4 : long -PsiReferenceExpression:vn5 : long -PsiReferenceExpression:vn6 : long -PsiReferenceExpression:vn7 : long -PsiReferenceExpression:vn8 : long -PsiReferenceExpression:vn9 : long -PsiReferenceExpression:vna : long -PsiReferenceExpression:vnb : long - -Conversions: -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ -0 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/after/Expr.java deleted file mode 100644 index 323dad23d5d3..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/after/Expr.java +++ /dev/null @@ -1,46 +0,0 @@ -class Expr { - public void meth(long p) { - long vu1 = p++; - long vu2 = p--; - long vu3 = ++p; - long vu4 = --p; - long vu5 = -p; - long vu6 = +p; - long vu7 = ~p; - - long vb1 = p * p; - long vb2 = p / p; - long vb3 = p % p; - long vb4 = p + p; - long vb5 = p - p; - long vb6 = p << p; - long vb7 = p >> p; - long vb8 = p >>> p; - long vb9 = p & p; - long vba = p ^ p; - long vbb = p | p; - - long vn1 = 0; - vn1 *= p; - long vn2 = 0; - vn2 /= p; - long vn3 = 0; - vn3 %= p; - long vn4 = 0; - vn4 += p; - long vn5 = 0; - vn5 -= p; - long vn6 = 0; - vn6 <<= p; - long vn7 = 0; - vn7 >>= p; - long vn8 = 0; - vn8 >>>= p; - long vn9 = 0; - vn9 &= p; - long vna = 0; - vna ^= p; - long vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/before/Expr.java deleted file mode 100644 index 716f4b7e60e1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2Int/before/Expr.java +++ /dev/null @@ -1,46 +0,0 @@ -class Expr { - public void meth(int p) { - int vu1 = p++; - int vu2 = p--; - int vu3 = ++p; - int vu4 = --p; - int vu5 = -p; - int vu6 = +p; - int vu7 = ~p; - - int vb1 = p * p; - int vb2 = p / p; - int vb3 = p % p; - int vb4 = p + p; - int vb5 = p - p; - int vb6 = p << p; - int vb7 = p >> p; - int vb8 = p >>> p; - int vb9 = p & p; - int vba = p ^ p; - int vbb = p | p; - - int vn1 = 0; - vn1 *= p; - int vn2 = 0; - vn2 /= p; - int vn3 = 0; - vn3 %= p; - int vn4 = 0; - vn4 += p; - int vn5 = 0; - vn5 -= p; - int vn6 = 0; - vn6 <<= p; - int vn7 = 0; - vn7 >>= p; - int vn8 = 0; - vn8 >>>= p; - int vn9 = 0; - vn9 &= p; - int vna = 0; - vna ^= p; - int vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/after/Expr.items deleted file mode 100644 index 406008949bd1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/after/Expr.items +++ /dev/null @@ -1,62 +0,0 @@ -Types: -PsiLocalVariable:vb4 : java.lang.String -PsiLocalVariable:vn4 : java.lang.String -PsiParameter:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:vn4 : java.lang.String - -Conversions: - -New expression type changes: -Fails: -0->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String -p->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/after/Expr.java deleted file mode 100644 index 62fd2ff0b0ff..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/after/Expr.java +++ /dev/null @@ -1,35 +0,0 @@ -class Expr { - public void meth(String p) { - int vb1 = p * p; - int vb2 = p / p; - int vb3 = p % p; - String vb4 = p + p; - int vb5 = p - p; - int vb9 = p & p; - int vba = p ^ p; - int vbb = p | p; - - int vn1 = 0; - vn1 *= p; - int vn2 = 0; - vn2 /= p; - int vn3 = 0; - vn3 %= p; - String vn4 = 0; - vn4 += p; - int vn5 = 0; - vn5 -= p; - int vn6 = 0; - vn6 <<= p; - int vn7 = 0; - vn7 >>= p; - int vn8 = 0; - vn8 >>>= p; - int vn9 = 0; - vn9 &= p; - int vna = 0; - vna ^= p; - int vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/before/Expr.java deleted file mode 100644 index 057b284248a0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCalcNumeric2String/before/Expr.java +++ /dev/null @@ -1,35 +0,0 @@ -class Expr { - public void meth(int p) { - int vb1 = p * p; - int vb2 = p / p; - int vb3 = p % p; - int vb4 = p + p; - int vb5 = p - p; - int vb9 = p & p; - int vba = p ^ p; - int vbb = p | p; - - int vn1 = 0; - vn1 *= p; - int vn2 = 0; - vn2 /= p; - int vn3 = 0; - vn3 %= p; - int vn4 = 0; - vn4 += p; - int vn5 = 0; - vn5 -= p; - int vn6 = 0; - vn6 <<= p; - int vn7 = 0; - vn7 >>= p; - int vn8 = 0; - vn8 >>>= p; - int vn9 = 0; - vn9 &= p; - int vna = 0; - vna ^= p; - int vnb = 0; - vnb |= p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/after/Expr.items deleted file mode 100644 index 01f325b2852d..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.lang.String -PsiReferenceExpression:p : java.lang.String - -Conversions: - -New expression type changes: -Fails: -(short) p->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/after/Expr.java deleted file mode 100644 index 5a7343152288..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/after/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public void meth(String p) { - short v = (short) p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/before/Expr.java deleted file mode 100644 index e3519b4bb4bf..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvalueNeg/before/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public void meth(byte p) { - short v = (short) p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/after/Expr.items deleted file mode 100644 index f69d09024863..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/after/Expr.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:p : int -PsiReferenceExpression:p : int - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/after/Expr.java deleted file mode 100644 index 64aecc896b80..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/after/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public void meth(int p) { - short v = (short) p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/before/Expr.java deleted file mode 100644 index e3519b4bb4bf..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprCast2LvaluePos/before/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public void meth(byte p) { - short v = (short) p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/after/Expr.items deleted file mode 100644 index 0b73994dece5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:pns : java.lang.Object -PsiReferenceExpression:pns : java.lang.Object -PsiReferenceExpression:pns : java.lang.Object - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/after/Expr.java deleted file mode 100644 index cf844f4eddf2..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/after/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private String myString; - public void meth(Object pns, String ps) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/before/Expr.java deleted file mode 100644 index 71b89f955e59..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2Reference/before/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private String myString; - public void meth(int pns, String ps) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/after/Expr.items deleted file mode 100644 index 46d6b1f5a15f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:pns : java.lang.String -PsiReferenceExpression:pns : java.lang.String -PsiReferenceExpression:pns : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/after/Expr.java deleted file mode 100644 index 5ce2b795d268..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/after/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private String myString; - public void meth(String pns, String ps) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/before/Expr.java deleted file mode 100644 index 71b89f955e59..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatNumeric2String/before/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private String myString; - public void meth(int pns, String ps) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/after/Expr.items deleted file mode 100644 index 3bb9c1ebf19a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/after/Expr.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myString : int -PsiParameter:ps : int -PsiReferenceExpression:myString : int -PsiReferenceExpression:myString : int -PsiReferenceExpression:myString : int -PsiReferenceExpression:myString : int -PsiReferenceExpression:ps : int -PsiReferenceExpression:ps : int -PsiReferenceExpression:ps : int -PsiReferenceExpression:ps : int -PsiReferenceExpression:ps : int - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/after/Expr.java deleted file mode 100644 index ac05959f3c08..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/after/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private int myString; - public void meth(int ps, int pns) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/before/Expr.java deleted file mode 100644 index bb57398b961c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Numeric/before/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private String myString; - public void meth(String ps, int pns) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/after/Expr.items deleted file mode 100644 index 302e3c9da48c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/after/Expr.items +++ /dev/null @@ -1,23 +0,0 @@ -Types: -PsiField:myString : int -PsiParameter:ps : java.lang.Object -PsiReferenceExpression:myString : int -PsiReferenceExpression:myString : int -PsiReferenceExpression:myString : int -PsiReferenceExpression:myString : int -PsiReferenceExpression:ps : java.lang.Object -PsiReferenceExpression:ps : java.lang.Object -PsiReferenceExpression:ps : java.lang.Object -PsiReferenceExpression:ps : java.lang.Object -PsiReferenceExpression:ps : java.lang.Object - -Conversions: - -New expression type changes: -Fails: -myString->int -ps->java.lang.Object -ps->java.lang.Object -ps->java.lang.Object -ps->java.lang.Object -ps->java.lang.Object diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/after/Expr.java deleted file mode 100644 index c23893bd5b63..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/after/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private int myString; - public void meth(Object ps, int pns) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/before/Expr.java deleted file mode 100644 index bb57398b961c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprConcatString2Reference/before/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -class Expr { - private String myString; - public void meth(String ps, int pns) { - myString = ps + ps; - myString = ps + pns; - myString = pns + ps; - myString += ps; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/after/Expr.items deleted file mode 100644 index 7712b490ec9a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.util.List -PsiReferenceExpression:p : java.util.List - -Conversions: - -New expression type changes: -Fails: -p->java.util.List diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/after/Expr.java deleted file mode 100644 index 93da179e0c37..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/after/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -class Expr { - public void meth(List p) { - boolean b = p instanceof HashSet; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/before/Expr.java deleted file mode 100644 index 72af0a04ab0b..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofNeg/before/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -class Expr { - public void meth(Set p) { - boolean b = p instanceof HashSet; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/after/Expr.items deleted file mode 100644 index 5b608c5c0b1a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/after/Expr.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:p : java.util.AbstractMap -PsiReferenceExpression:p : java.util.AbstractMap - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/after/Expr.java deleted file mode 100644 index e7f8a225bd9e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/after/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Map; - -class Expr { - public void meth(AbstractMap p) { - boolean b = p instanceof HashMap; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/before/Expr.java deleted file mode 100644 index fa8ab953a084..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprInstanceofPos/before/Expr.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Map; - -class Expr { - public void meth(Map p) { - boolean b = p instanceof HashMap; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/after/Expr.items deleted file mode 100644 index b446d1101a06..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/after/Expr.items +++ /dev/null @@ -1,35 +0,0 @@ -Types: -PsiField:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:myField : boolean - -Conversions: - -New expression type changes: -Fails: -"#"->boolean -'#'->boolean -043->boolean -043F->boolean -043L->boolean -0x23->boolean -0x23F->boolean -0x23L->boolean -35->boolean -35.0->boolean -35F->boolean -35L->boolean -null->boolean diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/after/Expr.java deleted file mode 100644 index d0d0a2d12326..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private boolean myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralBoolean/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/after/Expr.items deleted file mode 100644 index efc0c3bb0c41..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/after/Expr.items +++ /dev/null @@ -1,37 +0,0 @@ -Types: -PsiField:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte - -Conversions: - -New expression type changes: -Fails: -"#"->byte -'#'->byte -043->byte -043F->byte -043L->byte -0x23->byte -0x23F->byte -0x23L->byte -35->byte -35.0->byte -35F->byte -35L->byte -false->byte -null->byte -true->byte diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/after/Expr.java deleted file mode 100644 index 6288f06f450a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private byte myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralByte/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/after/Expr.items deleted file mode 100644 index 62960ffeacf8..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/after/Expr.items +++ /dev/null @@ -1,36 +0,0 @@ -Types: -PsiField:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char - -Conversions: - -New expression type changes: -Fails: -"#"->char -043->char -043F->char -043L->char -0x23->char -0x23F->char -0x23L->char -35->char -35.0->char -35F->char -35L->char -false->char -null->char -true->char diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/after/Expr.java deleted file mode 100644 index eab5b7cf5059..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private char myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralChar/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/after/Expr.items deleted file mode 100644 index 2a1f903ca5ab..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/after/Expr.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myField : java.lang.Class<? extends java.util.Collection[]> -PsiReferenceExpression:myField : java.lang.Class<? extends java.util.Collection[]> -PsiReferenceExpression:myField : java.lang.Class<? extends java.util.Collection[]> -PsiReferenceExpression:myField : java.lang.Class<? extends java.util.Collection[]> -PsiReferenceExpression:myField : java.lang.Class<? extends java.util.Collection[]> -PsiReferenceExpression:myField : java.lang.Class<? extends java.util.Collection[]> - -Conversions: -Set[].class -> $ - -New expression type changes: -Fails: -Set.class->java.lang.Class<? extends java.util.Collection[]> -int.class->java.lang.Class<? extends java.util.Collection[]> -int[].class->java.lang.Class<? extends java.util.Collection[]> -void.class->java.lang.Class<? extends java.util.Collection[]> diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/after/Expr.java deleted file mode 100644 index a9f761e2bd1f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/after/Expr.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.Collection; -import java.util.Set; - -class Expr { - private Class<? extends Collection[]> myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/before/Expr.java deleted file mode 100644 index 202ef9ef2da6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassExtends/before/Expr.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.Collection; -import java.util.Set; - -class Expr { - private Object myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/after/Expr.items deleted file mode 100644 index 485a0f5d91a4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/after/Expr.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myField : java.lang.Class<java.lang.Integer> -PsiReferenceExpression:myField : java.lang.Class<java.lang.Integer> -PsiReferenceExpression:myField : java.lang.Class<java.lang.Integer> -PsiReferenceExpression:myField : java.lang.Class<java.lang.Integer> -PsiReferenceExpression:myField : java.lang.Class<java.lang.Integer> -PsiReferenceExpression:myField : java.lang.Class<java.lang.Integer> - -Conversions: - -New expression type changes: -Fails: -Set.class->java.lang.Class<java.lang.Integer> -Set[].class->java.lang.Class<java.lang.Integer> -int[].class->java.lang.Class<java.lang.Integer> -void.class->java.lang.Class<java.lang.Integer> diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/after/Expr.java deleted file mode 100644 index 44edef75bfe4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/after/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Class<Integer> myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/before/Expr.java deleted file mode 100644 index 35a3d63f8dea..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitive/before/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Object myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/after/Expr.items deleted file mode 100644 index cd609774cf24..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/after/Expr.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myField : java.lang.Class<int[]> -PsiReferenceExpression:myField : java.lang.Class<int[]> -PsiReferenceExpression:myField : java.lang.Class<int[]> -PsiReferenceExpression:myField : java.lang.Class<int[]> -PsiReferenceExpression:myField : java.lang.Class<int[]> -PsiReferenceExpression:myField : java.lang.Class<int[]> - -Conversions: - -New expression type changes: -Fails: -Set.class->java.lang.Class<int[]> -Set[].class->java.lang.Class<int[]> -int.class->java.lang.Class<int[]> -void.class->java.lang.Class<int[]> diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/after/Expr.java deleted file mode 100644 index 9939d2f3d410..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/after/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Class<int[]> myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/before/Expr.java deleted file mode 100644 index 35a3d63f8dea..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassPrimitiveArray/before/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Object myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/after/Expr.items deleted file mode 100644 index 0bda2fd18195..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/after/Expr.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myField : java.lang.Class -PsiReferenceExpression:myField : java.lang.Class -PsiReferenceExpression:myField : java.lang.Class -PsiReferenceExpression:myField : java.lang.Class -PsiReferenceExpression:myField : java.lang.Class -PsiReferenceExpression:myField : java.lang.Class - -Conversions: -Set.class -> $ -Set[].class -> $ -int.class -> $ -int[].class -> $ -void.class -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/after/Expr.java deleted file mode 100644 index 9edcf9d47a31..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/after/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Class myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/before/Expr.java deleted file mode 100644 index 35a3d63f8dea..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassRaw/before/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Object myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/after/Expr.items deleted file mode 100644 index ee8fece53e89..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/after/Expr.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myField : java.lang.Class<java.util.Set> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set> - -Conversions: - -New expression type changes: -Fails: -Set[].class->java.lang.Class<java.util.Set> -int.class->java.lang.Class<java.util.Set> -int[].class->java.lang.Class<java.util.Set> -void.class->java.lang.Class<java.util.Set> diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/after/Expr.java deleted file mode 100644 index 45fd995735ae..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/after/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Class<Set> myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/before/Expr.java deleted file mode 100644 index 35a3d63f8dea..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReference/before/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Object myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/after/Expr.items deleted file mode 100644 index 26be6c5d8e6f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/after/Expr.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myField : java.lang.Class<java.util.Set[]> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set[]> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set[]> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set[]> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set[]> -PsiReferenceExpression:myField : java.lang.Class<java.util.Set[]> - -Conversions: - -New expression type changes: -Fails: -Set.class->java.lang.Class<java.util.Set[]> -int.class->java.lang.Class<java.util.Set[]> -int[].class->java.lang.Class<java.util.Set[]> -void.class->java.lang.Class<java.util.Set[]> diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/after/Expr.java deleted file mode 100644 index 46b110d7f75f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/after/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Class<Set[]> myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/before/Expr.java deleted file mode 100644 index 35a3d63f8dea..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassReferenceArray/before/Expr.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Expr { - private Object myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/after/Expr.items deleted file mode 100644 index 61336d444497..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/after/Expr.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myField : java.lang.Class<? super java.util.AbstractSet[]> -PsiReferenceExpression:myField : java.lang.Class<? super java.util.AbstractSet[]> -PsiReferenceExpression:myField : java.lang.Class<? super java.util.AbstractSet[]> -PsiReferenceExpression:myField : java.lang.Class<? super java.util.AbstractSet[]> -PsiReferenceExpression:myField : java.lang.Class<? super java.util.AbstractSet[]> -PsiReferenceExpression:myField : java.lang.Class<? super java.util.AbstractSet[]> - -Conversions: -Set[].class -> $ - -New expression type changes: -Fails: -Set.class->java.lang.Class<? super java.util.AbstractSet[]> -int.class->java.lang.Class<? super java.util.AbstractSet[]> -int[].class->java.lang.Class<? super java.util.AbstractSet[]> -void.class->java.lang.Class<? super java.util.AbstractSet[]> diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/after/Expr.java deleted file mode 100644 index 3ae94c8c1228..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/after/Expr.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.AbstractSet; -import java.util.Set; - -class Expr { - private Class<? super AbstractSet[]> myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/before/Expr.java deleted file mode 100644 index 1e5b26a44e4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralClassSuper/before/Expr.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.AbstractSet; -import java.util.Set; - -class Expr { - private Object myField; - public void meth() { - myField = int.class; - myField = int[].class; - myField = Set.class; - myField = Set[].class; - myField = void.class; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/after/Expr.items deleted file mode 100644 index eb7229ef905e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/after/Expr.items +++ /dev/null @@ -1,36 +0,0 @@ -Types: -PsiField:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double -PsiReferenceExpression:myField : double - -Conversions: -'#' -> $ -043 -> $ -043F -> $ -043L -> $ -0x23 -> $ -0x23F -> $ -0x23L -> $ -35 -> $ -35F -> $ -35L -> $ - -New expression type changes: -Fails: -"#"->double -false->double -null->double -true->double diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/after/Expr.java deleted file mode 100644 index a1fafc25fe6e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private double myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralDouble/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/after/Expr.items deleted file mode 100644 index dcf1562d69b7..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/after/Expr.items +++ /dev/null @@ -1,35 +0,0 @@ -Types: -PsiField:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float - -Conversions: -'#' -> $ -043 -> $ -043L -> $ -0x23 -> $ -0x23F -> $ -0x23L -> $ -35 -> $ -35L -> $ - -New expression type changes: -Fails: -"#"->float -35.0->float -false->float -null->float -true->float diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/after/Expr.java deleted file mode 100644 index 8210b283c426..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private float myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralFloat/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/after/Expr.items deleted file mode 100644 index 6969f1efd214..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/after/Expr.items +++ /dev/null @@ -1,33 +0,0 @@ -Types: -PsiField:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int - -Conversions: -'#' -> $ - -New expression type changes: -Fails: -"#"->int -043F->int -043L->int -0x23L->int -35.0->int -35F->int -35L->int -false->int -null->int -true->int diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/after/Expr.java deleted file mode 100644 index 51bce6ac6430..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private int myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralInt/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/after/Expr.items deleted file mode 100644 index 71718fa25bb1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/after/Expr.items +++ /dev/null @@ -1,34 +0,0 @@ -Types: -PsiField:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long - -Conversions: -'#' -> $ -043 -> $ -0x23 -> $ -0x23F -> $ -35 -> $ - -New expression type changes: -Fails: -"#"->long -043F->long -35.0->long -35F->long -false->long -null->long -true->long diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/after/Expr.java deleted file mode 100644 index 1556e9f05ffb..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private long myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralLong/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/after/Expr.items deleted file mode 100644 index f282b956c933..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/after/Expr.items +++ /dev/null @@ -1,37 +0,0 @@ -Types: -PsiField:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short - -Conversions: - -New expression type changes: -Fails: -"#"->short -'#'->short -043->short -043F->short -043L->short -0x23->short -0x23F->short -0x23L->short -35->short -35.0->short -35F->short -35L->short -false->short -null->short -true->short diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/after/Expr.java deleted file mode 100644 index 39b549b335bb..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private short myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralShort/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/after/Expr.items deleted file mode 100644 index 6bb1edafdfa8..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/after/Expr.items +++ /dev/null @@ -1,35 +0,0 @@ -Types: -PsiField:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String -PsiReferenceExpression:myField : java.lang.String - -Conversions: - -New expression type changes: -Fails: -'#'->java.lang.String -043->java.lang.String -043F->java.lang.String -043L->java.lang.String -0x23->java.lang.String -0x23F->java.lang.String -0x23L->java.lang.String -35->java.lang.String -35.0->java.lang.String -35F->java.lang.String -35L->java.lang.String -false->java.lang.String -true->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/after/Expr.java deleted file mode 100644 index 3adc44418ad4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/after/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private String myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/before/Expr.java deleted file mode 100644 index 05b89dc47d4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprLiteralString/before/Expr.java +++ /dev/null @@ -1,27 +0,0 @@ -class Expr { - private Object myField; - public void meth() { - myField = null; - - myField = false; - myField = true; - - myField = 043; - myField = 35; - myField = 0x23; - - myField = '#'; - - myField = 043L; - myField = 35L; - myField = 0x23L; - - myField = 043F; - myField = 35F; - myField = 0x23F; - - myField = 35.0; - - myField = "#"; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/after/Expr.items deleted file mode 100644 index 444531918ce0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/after/Expr.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiArrayInitializerExpression:{pfc} : FaceParent[][] -PsiArrayInitializerExpression:{pfc} : FaceParent[][] -PsiArrayInitializerExpression:{{pfc}} : FaceParent[][][] -PsiField:myArrayOne : FaceParent[][] -PsiField:myArrayTwo : FaceParent[][][] -PsiNewExpression:new FaceChild[][][]{{pfc}} : FaceParent[][][] -PsiNewExpression:new FaceChild[][]{pfc} : FaceParent[][] -PsiParameter:pfc : FaceParent[] -PsiReferenceExpression:myArrayOne : FaceParent[][] -PsiReferenceExpression:myArrayTwo : FaceParent[][][] -PsiReferenceExpression:pfc : FaceParent[] -PsiReferenceExpression:pfc : FaceParent[] - -Conversions: -pfc -> $ -pfc -> $ - -New expression type changes: -new FaceChild[][][]{{pfc}} -> FaceParent[][][] -new FaceChild[][]{pfc} -> FaceParent[][] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/after/Expr.java deleted file mode 100644 index 570367998bd1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/after/Expr.java +++ /dev/null @@ -1,11 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} - -class Expr { - private FaceParent[][] myArrayOne; - private FaceParent[][][] myArrayTwo; - public void meth(FaceParent[] pfc) { - myArrayOne = new FaceParent[][]{pfc}; - myArrayTwo = new FaceParent[][][]{{pfc}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/before/Expr.java deleted file mode 100644 index d88808766d7d..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Lvalue/before/Expr.java +++ /dev/null @@ -1,11 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} - -class Expr { - private FaceChild[][] myArrayOne; - private FaceChild[][][] myArrayTwo; - public void meth(FaceChild[] pfc) { - myArrayOne = new FaceChild[][]{pfc}; - myArrayTwo = new FaceChild[][][]{{pfc}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/after/Expr.items deleted file mode 100644 index 4b4b9036abb0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/after/Expr.items +++ /dev/null @@ -1,14 +0,0 @@ -Types: -PsiArrayInitializerExpression:{null} : ClassParent[][] -PsiArrayInitializerExpression:{pfc} : ClassParent[][] -PsiField:myField : ClassParent[][][] -PsiNewExpression:new FaceChild[][][]{{pfc}, {null}, null} : ClassParent[][][] -PsiParameter:pfc : ClassParent[] -PsiReferenceExpression:myField : ClassParent[][][] -PsiReferenceExpression:pfc : ClassParent[] - -Conversions: - -New expression type changes: -new FaceChild[][][]{{pfc}, {null}, null} -> ClassParent[][][] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/after/Expr.java deleted file mode 100644 index fc54bb6ca9d6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/after/Expr.java +++ /dev/null @@ -1,11 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Expr { - private ClassParent[][][] myField; - public void meth(ClassParent[] pfc) { - myField = new ClassParent[][][]{{pfc}, {null}, null}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/before/Expr.java deleted file mode 100644 index 8c4093e44d75..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayArray2Rvalue/before/Expr.java +++ /dev/null @@ -1,11 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Expr { - private FaceChild[][][] myField; - public void meth(FaceChild[] pfc) { - myField = new FaceChild[][][]{{pfc}, {null}, null}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/after/Expr.items deleted file mode 100644 index 825ef4f10f19..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : java.util.Set<java.lang.Integer>[] -PsiReferenceExpression:myField : java.util.Set<java.lang.Integer>[] - -Conversions: - -New expression type changes: -Fails: -new Set[1]->java.util.Set<java.lang.Integer>[] diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/after/Expr.java deleted file mode 100644 index 5083896eb293..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/after/Expr.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Set; - -class Expr { - private Set<Integer>[] myField; - public void meth() { - myField = new Set[1]; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/before/Expr.java deleted file mode 100644 index c2301a434ec9..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayGen2Rvalue/before/Expr.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.Set; - -class Expr { - private Set[] myField; - public void meth() { - myField = new Set[1]; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/after/Expr.items deleted file mode 100644 index d5976f11c486..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/after/Expr.items +++ /dev/null @@ -1,25 +0,0 @@ -Types: -PsiArrayInitializerExpression:{!p} : int[] -PsiArrayInitializerExpression:{p} : int[] -PsiArrayInitializerExpression:{p} : int[] -PsiArrayInitializerExpression:{{p}, {!p}} : int[][] -PsiField:myArrayOne : int[] -PsiField:myArrayTwo : int[][] -PsiNewExpression:new boolean[][]{{p}, {!p}} : int[][] -PsiNewExpression:new boolean[]{p} : int[] -PsiParameter:p : int -PsiReferenceExpression:myArrayOne : int[] -PsiReferenceExpression:myArrayTwo : int[][] -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int - -Conversions: -p -> $ -p -> $ - -New expression type changes: -new boolean[][]{{p}, {!p}} -> int[][] -new boolean[]{p} -> int[] -Fails: -!p->int diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/after/Expr.java deleted file mode 100644 index 0c6c31bf4929..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/after/Expr.java +++ /dev/null @@ -1,8 +0,0 @@ -class Expr { - private int[] myArrayOne; - private int[][] myArrayTwo; - public void meth(int p) { - myArrayOne = new int[]{p}; - myArrayTwo = new int[][]{{p}, {!p}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/before/Expr.java deleted file mode 100644 index e7724ca422f4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Lvalue/before/Expr.java +++ /dev/null @@ -1,8 +0,0 @@ -class Expr { - private boolean[] myArrayOne; - private boolean[][] myArrayTwo; - public void meth(boolean p) { - myArrayOne = new boolean[]{p}; - myArrayTwo = new boolean[][]{{p}, {!p}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/after/Expr.items deleted file mode 100644 index 5f371c0c6430..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/after/Expr.items +++ /dev/null @@ -1,21 +0,0 @@ -Types: -PsiArrayInitializerExpression:{!p} : int[] -PsiArrayInitializerExpression:{0} : int[] -PsiArrayInitializerExpression:{p} : int[] -PsiArrayInitializerExpression:{true} : int[] -PsiArrayInitializerExpression:{{p}, {!p}, {true}, {0}} : int[][] -PsiField:myField : int[][] -PsiNewExpression:new boolean[][]{{p}, {!p}, {true}, {0}} : int[][] -PsiParameter:p : int -PsiReferenceExpression:myField : int[][] -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int - -Conversions: -p -> $ - -New expression type changes: -new boolean[][]{{p}, {!p}, {true}, {0}} -> int[][] -Fails: -!p->int -true->int diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/after/Expr.java deleted file mode 100644 index 58017644820c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/after/Expr.java +++ /dev/null @@ -1,6 +0,0 @@ -class Expr { - private int[][] myField; - public void meth(int p) { - myField = new int[][]{{p}, {!p}, {true}, {0}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/before/Expr.java deleted file mode 100644 index cb1e0d64aa4b..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayPrimitive2Rvalue/before/Expr.java +++ /dev/null @@ -1,6 +0,0 @@ -class Expr { - private boolean[][] myField; - public void meth(boolean p) { - myField = new boolean[][]{{p}, {!p}, {true}, {0}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/after/Expr.items deleted file mode 100644 index a1472a46da67..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/after/Expr.items +++ /dev/null @@ -1,34 +0,0 @@ -Types: -PsiArrayInitializerExpression:{pcc} : FaceParent[] -PsiArrayInitializerExpression:{pcp} : FaceParent[] -PsiArrayInitializerExpression:{pfc, pcp, pcc} : FaceParent[] -PsiArrayInitializerExpression:{pfc} : FaceParent[] -PsiArrayInitializerExpression:{{pfc}, {pcp}, {pcc}} : FaceParent[][] -PsiField:myArrayOne : FaceParent[] -PsiField:myArrayTwo : FaceParent[][] -PsiNewExpression:new FaceChild[][]{{pfc}, {pcp}, {pcc}} : FaceParent[][] -PsiNewExpression:new FaceChild[]{pfc, pcp, pcc} : FaceParent[] -PsiParameter:pcc : ClassChild -PsiParameter:pcp : ClassParent -PsiParameter:pfc : FaceParent -PsiReferenceExpression:myArrayOne : FaceParent[] -PsiReferenceExpression:myArrayTwo : FaceParent[][] -PsiReferenceExpression:pcc : ClassChild -PsiReferenceExpression:pcc : ClassChild -PsiReferenceExpression:pcp : ClassParent -PsiReferenceExpression:pcp : ClassParent -PsiReferenceExpression:pfc : FaceParent -PsiReferenceExpression:pfc : FaceParent - -Conversions: -pcc -> $ -pcc -> $ -pcp -> $ -pcp -> $ -pfc -> $ -pfc -> $ - -New expression type changes: -new FaceChild[][]{{pfc}, {pcp}, {pcc}} -> FaceParent[][] -new FaceChild[]{pfc, pcp, pcc} -> FaceParent[] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/after/Expr.java deleted file mode 100644 index bfae5390508e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/after/Expr.java +++ /dev/null @@ -1,13 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Expr { - private FaceParent[] myArrayOne; - private FaceParent[][] myArrayTwo; - public void meth(FaceParent pfc, ClassParent pcp, ClassChild pcc) { - myArrayOne = new FaceParent[]{pfc, pcp, pcc}; - myArrayTwo = new FaceParent[][]{{pfc}, {pcp}, {pcc}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/before/Expr.java deleted file mode 100644 index 5cb70f7265f7..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Lvalue/before/Expr.java +++ /dev/null @@ -1,13 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Expr { - private FaceChild[] myArrayOne; - private FaceChild[][] myArrayTwo; - public void meth(FaceChild pfc, ClassParent pcp, ClassChild pcc) { - myArrayOne = new FaceChild[]{pfc, pcp, pcc}; - myArrayTwo = new FaceChild[][]{{pfc}, {pcp}, {pcc}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/after/Expr.items deleted file mode 100644 index 4dabd7d9161e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/after/Expr.items +++ /dev/null @@ -1,18 +0,0 @@ -Types: -PsiArrayInitializerExpression:{null} : ClassParent[] -PsiArrayInitializerExpression:{pcc} : ClassParent[] -PsiArrayInitializerExpression:{pcp} : ClassParent[] -PsiArrayInitializerExpression:{pfc} : ClassParent[] -PsiField:myField : ClassParent[][] -PsiNewExpression:new FaceChild[][]{{pfc}, {pcp}, {pcc}, {null}} : ClassParent[][] -PsiParameter:pcc : ClassChild -PsiParameter:pfc : ClassParent -PsiReferenceExpression:myField : ClassParent[][] -PsiReferenceExpression:pcc : ClassChild -PsiReferenceExpression:pfc : ClassParent - -Conversions: - -New expression type changes: -new FaceChild[][]{{pfc}, {pcp}, {pcc}, {null}} -> ClassParent[][] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/after/Expr.java deleted file mode 100644 index f2d53b50f272..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/after/Expr.java +++ /dev/null @@ -1,11 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Expr { - private ClassParent[][] myField; - public void meth(ClassParent pfc, ClassParent pcp, ClassChild pcc) { - myField = new ClassParent[][]{{pfc}, {pcp}, {pcc}, {null}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/before/Expr.java deleted file mode 100644 index 9e973b7925a0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewArrayReftype2Rvalue/before/Expr.java +++ /dev/null @@ -1,11 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Expr { - private FaceChild[][] myField; - public void meth(FaceChild pfc, ClassParent pcp, ClassChild pcc) { - myField = new FaceChild[][]{{pfc}, {pcp}, {pcc}, {null}}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/after/Expr.items deleted file mode 100644 index d19a8ab094b7..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/after/Expr.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myField : java.util.Set<Subject> -PsiNewExpression:new Set() : java.util.Set -PsiNewExpression:new Set<Ancestor>() : java.util.Set<Subject> -PsiNewExpression:new Set<Descendant>() : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> - -Conversions: - -New expression type changes: -new Set() -> java.util.Set -new Set<Ancestor>() -> java.util.Set<Subject> -new Set<Descendant>() -> java.util.Set<Subject> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/after/Expr.java deleted file mode 100644 index aab73939b929..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/after/Expr.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.Set; - -class Ancestor {} -class Subject extends Ancestor {} -class Descendant extends Subject {} - -class Expr { - private Set<Subject> myField; - public void meth() { - myField = new Set(); - myField = new Set<Subject>(); - myField = new Set<Subject>(); - myField = new Set<Subject>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/before/Expr.java deleted file mode 100644 index e38d8aa7229f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGen/before/Expr.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.Set; - -class Ancestor {} -class Subject extends Ancestor {} -class Descendant extends Subject {} - -class Expr { - private Object myField; - public void meth() { - myField = new Set(); - myField = new Set<Ancestor>(); - myField = new Set<Subject>(); - myField = new Set<Descendant>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/after/Expr.items deleted file mode 100644 index 9003258e73a5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/after/Expr.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myField : java.util.Set<? extends Subject> -PsiNewExpression:new Set() : java.util.Set -PsiNewExpression:new Set<Ancestor>() : java.util.Set<Subject> -PsiNewExpression:new Set<Subject>() : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<? extends Subject> -PsiReferenceExpression:myField : java.util.Set<? extends Subject> -PsiReferenceExpression:myField : java.util.Set<? extends Subject> - -Conversions: - -New expression type changes: -new Set() -> java.util.Set -new Set<Ancestor>() -> java.util.Set<Subject> -new Set<Subject>() -> java.util.Set<Subject> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/after/Expr.java deleted file mode 100644 index f939534d6972..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/after/Expr.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.Set; - -class Ancestor {} -class Subject extends Ancestor {} -class Descendant extends Subject {} - -class Expr { - private Set<? extends Subject> myField; - public void meth() { - myField = new Set(); - myField = new Set<Subject>(); - myField = new Set<Subject>(); - // myField = new Set<Descendant>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/before/Expr.java deleted file mode 100644 index e65ce8b9a8fc..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenExtends/before/Expr.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.Set; - -class Ancestor {} -class Subject extends Ancestor {} -class Descendant extends Subject {} - -class Expr { - private Object myField; - public void meth() { - myField = new Set(); - myField = new Set<Ancestor>(); - myField = new Set<Subject>(); - // myField = new Set<Descendant>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/after/Expr.items deleted file mode 100644 index ca323d833a2c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/after/Expr.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:myField : java.util.Set<? super Subject> -PsiNewExpression:new Set() : java.util.Set -PsiReferenceExpression:myField : java.util.Set<? super Subject> - -Conversions: - -New expression type changes: -new Set() -> java.util.Set -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/after/Expr.java deleted file mode 100644 index 4f5a29eecc6c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/after/Expr.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.Set; - -class Ancestor {} -class Subject extends Ancestor {} -class Descendant extends Subject {} - -class Expr { - private Set<? super Subject> myField; - public void meth() { - myField = new Set(); - // myField = new Set<Ancestor>(); - // myField = new Set<Subject>(); - // myField = new Set<Descendant>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/before/Expr.java deleted file mode 100644 index 73a22ebeccde..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewGenSuper/before/Expr.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.Set; - -class Ancestor {} -class Subject extends Ancestor {} -class Descendant extends Subject {} - -class Expr { - private Object myField; - public void meth() { - myField = new Set(); - // myField = new Set<Ancestor>(); - // myField = new Set<Subject>(); - // myField = new Set<Descendant>(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/after/Expr.items deleted file mode 100644 index cab7f8173076..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/after/Expr.items +++ /dev/null @@ -1,27 +0,0 @@ -Types: -PsiField:myField : Expr.Subject -PsiNewExpression:new Descendant() : Expr.Descendant -PsiNewExpression:new Descendant() {} : Expr.Descendant -PsiNewExpression:new Subject() {} : Expr.Subject -PsiNewExpression:this.new Descendant() : Expr.Descendant -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject -PsiReferenceExpression:myField : Expr.Subject - -Conversions: - -New expression type changes: -new Descendant() -> Expr.Descendant -new Descendant() {} -> Expr.Descendant -new Subject() {} -> Expr.Subject -this.new Descendant() -> Expr.Descendant -Fails: -new Ancestor()->Expr.Subject -new Ancestor() {}->Expr.Subject -this.new Ancestor()->Expr.Subject diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/after/Expr.java deleted file mode 100644 index 5cc9c87ec7e4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/after/Expr.java +++ /dev/null @@ -1,21 +0,0 @@ -class Expr { - private class Ancestor {} - private class Subject extends Ancestor {} - private class Descendant extends Subject {} - - private Subject myField; - - public void meth() { - myField = new Ancestor(); - myField = this.new Ancestor(); - myField = new Ancestor() {}; - - myField = new Subject(); - myField = this.new Subject(); - myField = new Subject() {}; - - myField = new Descendant(); - myField = this.new Descendant(); - myField = new Descendant() {}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/before/Expr.java deleted file mode 100644 index ed03e4ddc1d3..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprNewReference/before/Expr.java +++ /dev/null @@ -1,21 +0,0 @@ -class Expr { - private class Ancestor {} - private class Subject extends Ancestor {} - private class Descendant extends Subject {} - - private Ancestor myField; - - public void meth() { - myField = new Ancestor(); - myField = this.new Ancestor(); - myField = new Ancestor() {}; - - myField = new Subject(); - myField = this.new Subject(); - myField = new Subject() {}; - - myField = new Descendant(); - myField = this.new Descendant(); - myField = new Descendant() {}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/after/Expr.items deleted file mode 100644 index e91631f5c332..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiMethod:meth : java.lang.String -PsiParameter:p : java.lang.String -PsiReferenceExpression:p : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/after/Expr.java deleted file mode 100644 index 37c310d405e3..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/after/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public String meth(String p) { - return p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/before/Expr.java deleted file mode 100644 index 76e26b5c15bb..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Lvalue/before/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public int meth(int p) { - return p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/after/Expr.items deleted file mode 100644 index e91631f5c332..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/after/Expr.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiMethod:meth : java.lang.String -PsiParameter:p : java.lang.String -PsiReferenceExpression:p : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/after/Expr.java deleted file mode 100644 index 37c310d405e3..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/after/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public String meth(String p) { - return p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/before/Expr.java deleted file mode 100644 index 76e26b5c15bb..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprReturn2Rvalue/before/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public int meth(int p) { - return p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/after/Expr.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/after/Expr.items deleted file mode 100644 index 6e445ca2c431..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/after/Expr.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiLocalVariable:v : java.lang.String -PsiParameter:pd : java.lang.String -PsiReferenceExpression:pd : java.lang.String -PsiReferenceExpression:pd : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/after/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/after/Expr.java deleted file mode 100644 index 1e75f910f300..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/after/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public void meth(String pd, int pp) { - String v = pp > 0 ? pd : pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/before/Expr.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/before/Expr.java deleted file mode 100644 index 3a714e5334a4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/exprTernary/before/Expr.java +++ /dev/null @@ -1,5 +0,0 @@ -class Expr { - public void meth(double pd, int pp) { - double v = pp > 0 ? pd : pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/after/Overriding.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/after/Overriding.java deleted file mode 100644 index 9fb5b2161ba1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/after/Overriding.java +++ /dev/null @@ -1,13 +0,0 @@ -class Parent { - private byte myInt; - public byte getInt() { - return myInt; - } -} - -class Child extends Parent { - private byte myInt; - public byte getInt() { - return myInt; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/after/Parent.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/after/Parent.items deleted file mode 100644 index 0857363a2808..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/after/Parent.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:myInt : byte -PsiField:myInt : byte -PsiMethod:getInt : byte -PsiMethod:getInt : byte -PsiReferenceExpression:myInt : byte -PsiReferenceExpression:myInt : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/before/Overriding.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/before/Overriding.java deleted file mode 100644 index 212ce8080636..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingDown/before/Overriding.java +++ /dev/null @@ -1,13 +0,0 @@ -class Parent { - private int myInt; - public int getInt() { - return myInt; - } -} - -class Child extends Parent { - private int myInt; - public int getInt() { - return myInt; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/after/Child.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/after/Child.items deleted file mode 100644 index 0857363a2808..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/after/Child.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:myInt : byte -PsiField:myInt : byte -PsiMethod:getInt : byte -PsiMethod:getInt : byte -PsiReferenceExpression:myInt : byte -PsiReferenceExpression:myInt : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/after/Overriding.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/after/Overriding.java deleted file mode 100644 index 9fb5b2161ba1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/after/Overriding.java +++ /dev/null @@ -1,13 +0,0 @@ -class Parent { - private byte myInt; - public byte getInt() { - return myInt; - } -} - -class Child extends Parent { - private byte myInt; - public byte getInt() { - return myInt; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/before/Overriding.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/before/Overriding.java deleted file mode 100644 index 212ce8080636..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/overridingUp/before/Overriding.java +++ /dev/null @@ -1,13 +0,0 @@ -class Parent { - private int myInt; - public int getInt() { - return myInt; - } -} - -class Child extends Parent { - private int myInt; - public int getInt() { - return myInt; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/after/Spec.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/after/Spec.items deleted file mode 100644 index 4428712f4683..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/after/Spec.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:p : java.util.Set - -Conversions: -#meth(double) -> PsiMethod:meth - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/after/Spec.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/after/Spec.java deleted file mode 100644 index b6c748c1e749..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/after/Spec.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Spec { - /** - * @see #meth(java.util.Set) - */ - public void methRef() { - } - - public void meth(Set p) { - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/before/Spec.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/before/Spec.java deleted file mode 100644 index 45080dc2dec1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specJavadoc/before/Spec.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.Set; - -class Spec { - /** - * @see #meth(double) - */ - public void methRef() { - } - - public void meth(double p) { - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/after/Spec.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/after/Spec.items deleted file mode 100644 index 8ffc5c9a6744..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/after/Spec.items +++ /dev/null @@ -1,7 +0,0 @@ -Types: -PsiField:myField : boolean - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/after/Spec.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/after/Spec.java deleted file mode 100644 index 03d0dc267246..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/after/Spec.java +++ /dev/null @@ -1,3 +0,0 @@ -class Spec { - private boolean myField; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/before/Spec.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/before/Spec.java deleted file mode 100644 index 36a606c54faa..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/specNotUsed/before/Spec.java +++ /dev/null @@ -1,3 +0,0 @@ -class Spec { - private int myField; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/after/Type.items deleted file mode 100644 index e56da57e1062..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/after/Type.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiField:myDescendants : Subject[] -PsiParameter:p : Subject[] -PsiReferenceExpression:myDescendants : Subject[] -PsiReferenceExpression:p : Subject[] -PsiReferenceExpression:p : Subject[] -PsiReferenceExpression:p : Subject[] - -Conversions: -myAncestors -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/after/Type.java deleted file mode 100644 index 5b667afd7284..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/after/Type.java +++ /dev/null @@ -1,15 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Ancestor[] myAncestors; - private Subject[] mySubjects; - private Subject[] myDescendants; - - public void meth(Subject[] p) { - myAncestors = p; - mySubjects = p; - myDescendants = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/before/Type.java deleted file mode 100644 index 6c0ad8e907ae..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Lvalue/before/Type.java +++ /dev/null @@ -1,15 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Ancestor[] myAncestors; - private Subject[] mySubjects; - private Descendant[] myDescendants; - - public void meth(Descendant[] p) { - myAncestors = p; - mySubjects = p; - myDescendants = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/after/Type.items deleted file mode 100644 index aa0545cd97f1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/after/Type.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiField:myField : Subject[][] -PsiParameter:pa : Subject[][] -PsiReferenceExpression:myField : Subject[][] -PsiReferenceExpression:myField : Subject[][] -PsiReferenceExpression:myField : Subject[][] -PsiReferenceExpression:pa : Subject[][] - -Conversions: -pd -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/after/Type.java deleted file mode 100644 index 1dc9d19b69d7..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Subject[][] myField; - public void meth(Subject[][] pa, Subject[][] ps, Descendant[][] pd) { - myField = pa; - myField = ps; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/before/Type.java deleted file mode 100644 index b84f5fada9b6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayReftype2Rvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Ancestor[][] myField; - public void meth(Ancestor[][] pa, Subject[][] ps, Descendant[][] pd) { - myField = pa; - myField = ps; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/after/Type.items deleted file mode 100644 index bfcf79449245..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/after/Type.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myHolder : Holder[] -PsiParameter:p : Holder[] -PsiReferenceExpression:myHolder : Holder[] -PsiReferenceExpression:p : Holder[] -PsiReferenceExpression:p : Holder[] -PsiReferenceExpression:p : Holder[] -PsiReferenceExpression:p : Holder[] - -Conversions: -myCloneable -> $ -myObject -> $ -mySerializable -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/after/Type.java deleted file mode 100644 index ea67626d3e12..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/after/Type.java +++ /dev/null @@ -1,15 +0,0 @@ -class Holder implements Cloneable, java.io.Serializable {} - -class Type { - private Object myObject; - private Cloneable myCloneable; - private java.io.Serializable mySerializable; - private Holder[] myHolder; - - public void meth(Holder[] p) { - myObject = p; - myCloneable = p; - mySerializable = p; - myHolder = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/before/Type.java deleted file mode 100644 index 41bb17f7fec2..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayRoots2Lvalue/before/Type.java +++ /dev/null @@ -1,15 +0,0 @@ -class Holder implements Cloneable, java.io.Serializable {} - -class Type { - private Object myObject; - private Cloneable myCloneable; - private java.io.Serializable mySerializable; - private Holder myHolder; - - public void meth(Holder p) { - myObject = p; - myCloneable = p; - mySerializable = p; - myHolder = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/after/Type.items deleted file mode 100644 index 9bcbf6e3ccf2..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/after/Type.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiField:myDescendants : Subject[] -PsiParameter:p : Subject... -PsiReferenceExpression:myDescendants : Subject[] -PsiReferenceExpression:p : Subject[] -PsiReferenceExpression:p : Subject[] -PsiReferenceExpression:p : Subject[] - -Conversions: -myAncestors -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/after/Type.java deleted file mode 100644 index 82714edc14eb..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/after/Type.java +++ /dev/null @@ -1,15 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Ancestor[] myAncestors; - private Subject[] mySubjects; - private Subject[] myDescendants; - - public void meth(Subject... p) { - myAncestors = p; - mySubjects = p; - myDescendants = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/before/Type.java deleted file mode 100644 index 6c0ad8e907ae..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2Lvalue/before/Type.java +++ /dev/null @@ -1,15 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Ancestor[] myAncestors; - private Subject[] mySubjects; - private Descendant[] myDescendants; - - public void meth(Descendant[] p) { - myAncestors = p; - mySubjects = p; - myDescendants = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/after/Type.items deleted file mode 100644 index 8e16567f6b52..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/after/Type.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:myField : Descendant[] -PsiParameter:p : Descendant[] -PsiReferenceExpression:myField : Descendant[] -PsiReferenceExpression:p : Descendant[] - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/after/Type.java deleted file mode 100644 index b14ffa0b66b9..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/after/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Descendant[] myField; - public void meth(Descendant[] p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/before/Type.java deleted file mode 100644 index 299d07095294..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvalueNeg/before/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Ancestor[] myField; - public void meth(Subject... p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/after/Type.items deleted file mode 100644 index fa58313766a2..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/after/Type.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:myField : Subject[] -PsiReferenceExpression:myField : Subject[] - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/after/Type.java deleted file mode 100644 index b17f19ce9366..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/after/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Subject[] myField; - public void meth(Subject... p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/before/Type.java deleted file mode 100644 index 299d07095294..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeArrayVararg2RvaluePos/before/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Ancestor[] myField; - public void meth(Subject... p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/after/Type.items deleted file mode 100644 index d2a5bdf18da5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/after/Type.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiParameter:p : java.lang.Boolean -PsiReferenceExpression:p : java.lang.Boolean -PsiReferenceExpression:p : java.lang.Boolean - -Conversions: -myField -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/after/Type.java deleted file mode 100644 index 256ad8ae87ba..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/after/Type.java +++ /dev/null @@ -1,8 +0,0 @@ -class Type { - private boolean myField; - private Object myFieldSuper3; - public void meth(Boolean p) { - myField = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/before/Type.java deleted file mode 100644 index e27196d88750..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Lvalue/before/Type.java +++ /dev/null @@ -1,8 +0,0 @@ -class Type { - private boolean myField; - private Object myFieldSuper3; - public void meth(boolean p) { - myField = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/after/Type.items deleted file mode 100644 index ddbe17fb4ffc..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : boolean -PsiReferenceExpression:myField : boolean - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/after/Type.java deleted file mode 100644 index d58f3df69336..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private boolean myField; - public void meth(Boolean p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/before/Type.java deleted file mode 100644 index fcfe89fe9eca..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxBoolean2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Boolean myField; - public void meth(Boolean p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/after/Type.items deleted file mode 100644 index 1c80a5546782..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/after/Type.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiParameter:p : java.lang.Byte -PsiReferenceExpression:p : java.lang.Byte -PsiReferenceExpression:p : java.lang.Byte -PsiReferenceExpression:p : java.lang.Byte -PsiReferenceExpression:p : java.lang.Byte - -Conversions: -myField -> $ -myFieldSuper1 -> $ -myFieldSuper2 -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/after/Type.java deleted file mode 100644 index 40e19f5b4a68..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private byte myField; - private short myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(Byte p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/before/Type.java deleted file mode 100644 index c525d82e6f19..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Lvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private byte myField; - private short myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(byte p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/after/Type.items deleted file mode 100644 index 192b82591e68..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : byte -PsiReferenceExpression:myField : byte - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/after/Type.java deleted file mode 100644 index 435b929c8591..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private byte myField; - public void meth(Byte p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/before/Type.java deleted file mode 100644 index c0c7993580df..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxByte2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Byte myField; - public void meth(Byte p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/after/Type.items deleted file mode 100644 index 3499c81915b3..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/after/Type.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiParameter:p : java.lang.Character -PsiReferenceExpression:p : java.lang.Character -PsiReferenceExpression:p : java.lang.Character -PsiReferenceExpression:p : java.lang.Character - -Conversions: -myField -> $ -myFieldSuper1 -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/after/Type.java deleted file mode 100644 index c075b5ea1ae1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/after/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -class Type { - private char myField; - private int myFieldSuper1; - private Object myFieldSuper3; - public void meth(Character p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/before/Type.java deleted file mode 100644 index c821e8a38b8e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Lvalue/before/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -class Type { - private char myField; - private int myFieldSuper1; - private Object myFieldSuper3; - public void meth(char p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/after/Type.items deleted file mode 100644 index 8f1b31f74f05..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : char -PsiReferenceExpression:myField : char - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/after/Type.java deleted file mode 100644 index bec7b611e95a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private char myField; - public void meth(Character p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/before/Type.java deleted file mode 100644 index a98d2a5fa05a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxChar2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Character myField; - public void meth(Character p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/after/Type.items deleted file mode 100644 index c961b407f293..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/after/Type.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiParameter:p : java.lang.Double -PsiReferenceExpression:p : java.lang.Double -PsiReferenceExpression:p : java.lang.Double -PsiReferenceExpression:p : java.lang.Double - -Conversions: -myField -> $ -myFieldSuper2 -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/after/Type.java deleted file mode 100644 index c2cc8485f4f5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/after/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -class Type { - private double myField; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(Double p) { - myField = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/before/Type.java deleted file mode 100644 index 56ec2d53eb99..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Lvalue/before/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -class Type { - private double myField; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(double p) { - myField = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/after/Type.items deleted file mode 100644 index 2c80921ecfcb..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : double -PsiReferenceExpression:myField : double - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/after/Type.java deleted file mode 100644 index ac0e3c68ebdb..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private double myField; - public void meth(Double p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/before/Type.java deleted file mode 100644 index 4950dcb0d5bd..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxDouble2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Double myField; - public void meth(Double p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/after/Type.items deleted file mode 100644 index d51dd6bd244e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/after/Type.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiParameter:p : java.lang.Float -PsiReferenceExpression:p : java.lang.Float -PsiReferenceExpression:p : java.lang.Float -PsiReferenceExpression:p : java.lang.Float -PsiReferenceExpression:p : java.lang.Float - -Conversions: -myField -> $ -myFieldSuper1 -> $ -myFieldSuper2 -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/after/Type.java deleted file mode 100644 index 4e06d3369857..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private float myField; - private double myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(Float p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/before/Type.java deleted file mode 100644 index 24ec9a945603..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Lvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private float myField; - private double myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(float p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/after/Type.items deleted file mode 100644 index 1b905928d822..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : float -PsiReferenceExpression:myField : float - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/after/Type.java deleted file mode 100644 index 1db8edb10bed..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private float myField; - public void meth(Float p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/before/Type.java deleted file mode 100644 index 078b103e8df1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxFloat2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Float myField; - public void meth(Float p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/after/Type.items deleted file mode 100644 index 24c52d5796ed..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/after/Type.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiParameter:p : java.lang.Integer -PsiReferenceExpression:p : java.lang.Integer -PsiReferenceExpression:p : java.lang.Integer -PsiReferenceExpression:p : java.lang.Integer -PsiReferenceExpression:p : java.lang.Integer - -Conversions: -myField -> $ -myFieldSuper1 -> $ -myFieldSuper2 -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/after/Type.java deleted file mode 100644 index e0075f597b24..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private int myField; - private long myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(Integer p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/before/Type.java deleted file mode 100644 index 9c2f74c3f26f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Lvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private int myField; - private long myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(int p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/after/Type.items deleted file mode 100644 index d95e0af0768c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : int -PsiReferenceExpression:myField : int - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/after/Type.java deleted file mode 100644 index 4bf28b31788c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private int myField; - public void meth(Integer p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/before/Type.java deleted file mode 100644 index 87273262b496..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxInt2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Integer myField; - public void meth(Integer p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/after/Type.items deleted file mode 100644 index 29939f335f62..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/after/Type.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiParameter:p : java.lang.Long -PsiReferenceExpression:p : java.lang.Long -PsiReferenceExpression:p : java.lang.Long -PsiReferenceExpression:p : java.lang.Long -PsiReferenceExpression:p : java.lang.Long - -Conversions: -myField -> $ -myFieldSuper1 -> $ -myFieldSuper2 -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/after/Type.java deleted file mode 100644 index 695801b1bc4f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private long myField; - private float myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(Long p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/before/Type.java deleted file mode 100644 index c6a909f7c46a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Lvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private long myField; - private float myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(long p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/after/Type.items deleted file mode 100644 index 0fa3e3feb520..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : long -PsiReferenceExpression:myField : long - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/after/Type.java deleted file mode 100644 index 6f407a2591a1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private long myField; - public void meth(Long p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/before/Type.java deleted file mode 100644 index ceceb07caa8e..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxLong2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Long myField; - public void meth(Long p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/after/Type.items deleted file mode 100644 index c6a4cc9b70c8..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/after/Type.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiParameter:p : java.lang.Short -PsiReferenceExpression:p : java.lang.Short -PsiReferenceExpression:p : java.lang.Short -PsiReferenceExpression:p : java.lang.Short -PsiReferenceExpression:p : java.lang.Short - -Conversions: -myField -> $ -myFieldSuper1 -> $ -myFieldSuper2 -> $ -myFieldSuper3 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/after/Type.java deleted file mode 100644 index 50d61183a785..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private short myField; - private int myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(Short p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/before/Type.java deleted file mode 100644 index 52eb7aa5b30c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Lvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private short myField; - private int myFieldSuper1; - private Number myFieldSuper2; - private Object myFieldSuper3; - public void meth(short p) { - myField = p; - myFieldSuper1 = p; - myFieldSuper2 = p; - myFieldSuper3 = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/after/Type.items deleted file mode 100644 index 28ba15701be6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : short -PsiReferenceExpression:myField : short - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/after/Type.java deleted file mode 100644 index ba146982c723..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private short myField; - public void meth(Short p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/before/Type.java deleted file mode 100644 index 9ca0f4947260..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeAutoboxShort2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private Short myField; - public void meth(Short p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/after/Type.items deleted file mode 100644 index 6106a705cdd8..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/after/Type.items +++ /dev/null @@ -1,33 +0,0 @@ -Types: -PsiField:myAncestorSupers : java.util.Set<Subject> -PsiField:myAncestors : java.util.Set<Subject> -PsiField:myCollection : java.util.Collection<Subject> -PsiField:myDescendantExtends : java.util.Set<Subject> -PsiField:myDescendants : java.util.Set<Subject> -PsiParameter:p : java.util.Set<Subject> -PsiReferenceExpression:myAncestorSupers : java.util.Set<Subject> -PsiReferenceExpression:myAncestors : java.util.Set<Subject> -PsiReferenceExpression:myCollection : java.util.Collection<Subject> -PsiReferenceExpression:myDescendantExtends : java.util.Set<Subject> -PsiReferenceExpression:myDescendants : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> -PsiReferenceExpression:p : java.util.Set<Subject> - -Conversions: -myAncestorExtends -> $ -myDescendantSupers -> $ -mySet -> $ -mySubjectExtends -> $ -mySubjectSupers -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/after/Type.java deleted file mode 100644 index 7e3eeb9770ca..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/after/Type.java +++ /dev/null @@ -1,40 +0,0 @@ -import java.util.Collection; -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set<Subject> myAncestors; - private Set<? extends Ancestor> myAncestorExtends; - private Set<Subject> myAncestorSupers; - - private Set<Subject> mySubjects; - private Set<? extends Subject> mySubjectExtends; - private Set<? super Subject> mySubjectSupers; - - private Set<Subject> myDescendants; - private Set<Subject> myDescendantExtends; - private Set<? super Descendant> myDescendantSupers; - - private Set mySet; - private Collection<Subject> myCollection; - - public void meth(Set<Subject> p) { - myAncestors = p; - myAncestorExtends = p; - myAncestorSupers = p; - - mySubjects = p; - mySubjectExtends = p; - mySubjectSupers = p; - - myDescendants = p; - myDescendantExtends = p; - myDescendantSupers = p; - - mySet = p; - myCollection = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/before/Type.java deleted file mode 100644 index 2e63240580ca..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestor2Lvalue/before/Type.java +++ /dev/null @@ -1,40 +0,0 @@ -import java.util.Collection; -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set<Ancestor> myAncestors; - private Set<? extends Ancestor> myAncestorExtends; - private Set<? super Ancestor> myAncestorSupers; - - private Set<Subject> mySubjects; - private Set<? extends Subject> mySubjectExtends; - private Set<? super Subject> mySubjectSupers; - - private Set<Descendant> myDescendants; - private Set<? extends Descendant> myDescendantExtends; - private Set<? super Descendant> myDescendantSupers; - - private Set mySet; - private Collection<Ancestor> myCollection; - - public void meth(Set p) { - myAncestors = p; - myAncestorExtends = p; - myAncestorSupers = p; - - mySubjects = p; - mySubjectExtends = p; - mySubjectSupers = p; - - myDescendants = p; - myDescendantExtends = p; - myDescendantSupers = p; - - mySet = p; - myCollection = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/after/Type.items deleted file mode 100644 index 6cb2f2be0d34..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/after/Type.items +++ /dev/null @@ -1,33 +0,0 @@ -Types: -PsiField:myAncestorSupers : java.util.Set<? extends Subject> -PsiField:myAncestors : java.util.Set<? extends Subject> -PsiField:myDescendantExtends : java.util.Set<? extends Subject> -PsiField:myDescendantSupers : java.util.Set<? extends Subject> -PsiField:myDescendants : java.util.Set<? extends Subject> -PsiField:mySubjectSupers : java.util.Set<? extends Subject> -PsiField:mySubjects : java.util.Set<? extends Subject> -PsiParameter:p : java.util.Set<? extends Subject> -PsiReferenceExpression:myAncestorSupers : java.util.Set<? extends Subject> -PsiReferenceExpression:myAncestors : java.util.Set<? extends Subject> -PsiReferenceExpression:myDescendantExtends : java.util.Set<? extends Subject> -PsiReferenceExpression:myDescendantSupers : java.util.Set<? extends Subject> -PsiReferenceExpression:myDescendants : java.util.Set<? extends Subject> -PsiReferenceExpression:mySubjectSupers : java.util.Set<? extends Subject> -PsiReferenceExpression:mySubjects : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> -PsiReferenceExpression:p : java.util.Set<? extends Subject> - -Conversions: -myAncestorExtends -> $ -mySet -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/after/Type.java deleted file mode 100644 index 2ffef9b4e9ad..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/after/Type.java +++ /dev/null @@ -1,37 +0,0 @@ -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set<? extends Subject> myAncestors; - private Set<? extends Ancestor> myAncestorExtends; - private Set<? extends Subject> myAncestorSupers; - - private Set<? extends Subject> mySubjects; - private Set<? extends Subject> mySubjectExtends; - private Set<? extends Subject> mySubjectSupers; - - private Set<? extends Subject> myDescendants; - private Set<? extends Subject> myDescendantExtends; - private Set<? extends Subject> myDescendantSupers; - - private Set mySet; - - public void meth(Set<? extends Subject> p) { - myAncestors = p; - myAncestorExtends = p; - myAncestorSupers = p; - - mySubjects = p; - mySubjectExtends = p; - mySubjectSupers = p; - - myDescendants = p; - myDescendantExtends = p; - myDescendantSupers = p; - - mySet = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/before/Type.java deleted file mode 100644 index 4fc8d5baf167..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenAncestorWildcard2Lvalue/before/Type.java +++ /dev/null @@ -1,37 +0,0 @@ -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set<Ancestor> myAncestors; - private Set<? extends Ancestor> myAncestorExtends; - private Set<? super Ancestor> myAncestorSupers; - - private Set<Subject> mySubjects; - private Set<? extends Subject> mySubjectExtends; - private Set<? super Subject> mySubjectSupers; - - private Set<Descendant> myDescendants; - private Set<? extends Descendant> myDescendantExtends; - private Set<? super Descendant> myDescendantSupers; - - private Set mySet; - - public void meth(Set p) { - myAncestors = p; - myAncestorExtends = p; - myAncestorSupers = p; - - mySubjects = p; - mySubjectExtends = p; - mySubjectSupers = p; - - myDescendants = p; - myDescendantExtends = p; - myDescendantSupers = p; - - mySet = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/after/Type.items deleted file mode 100644 index ab6a62095446..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/after/Type.items +++ /dev/null @@ -1,37 +0,0 @@ -Types: -PsiField:myField : java.util.Set<Subject> -PsiLocalVariable:ancestorExtends : java.util.Set<Subject> -PsiLocalVariable:ancestorSupers : java.util.Set<Subject> -PsiLocalVariable:ancestors : java.util.Set<Subject> -PsiLocalVariable:descendantExtends : java.util.Set<Subject> -PsiLocalVariable:descendantSupers : java.util.Set<Subject> -PsiLocalVariable:descendants : java.util.Set<Subject> -PsiLocalVariable:myCollection : java.util.AbstractSet<Subject> -PsiLocalVariable:subjectExtends : java.util.Set<Subject> -PsiLocalVariable:subjectSupers : java.util.Set<Subject> -PsiReferenceExpression:ancestorExtends : java.util.Set<Subject> -PsiReferenceExpression:ancestorSupers : java.util.Set<Subject> -PsiReferenceExpression:ancestors : java.util.Set<Subject> -PsiReferenceExpression:descendantExtends : java.util.Set<Subject> -PsiReferenceExpression:descendantSupers : java.util.Set<Subject> -PsiReferenceExpression:descendants : java.util.Set<Subject> -PsiReferenceExpression:myCollection : java.util.AbstractSet<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:myField : java.util.Set<Subject> -PsiReferenceExpression:subjectExtends : java.util.Set<Subject> -PsiReferenceExpression:subjectSupers : java.util.Set<Subject> - -Conversions: -set -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/after/Type.java deleted file mode 100644 index 119e65ca61b5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/after/Type.java +++ /dev/null @@ -1,39 +0,0 @@ -import java.util.AbstractSet; -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set<Subject> myField; - - public void meth() { - Set<Subject> ancestors = null; - myField = ancestors; - Set<Subject> ancestorExtends = null; - myField = ancestorExtends; - Set<Subject> ancestorSupers = null; - myField = ancestorSupers; - - // turning everything into Set<Subject> is actually too strict, but correct - Set<Subject> subjects = null; - myField = subjects; - Set<Subject> subjectExtends = null; - myField = subjectExtends; - Set<Subject> subjectSupers = null; - myField = subjectSupers; - - Set<Subject> descendants = null; - myField = descendants; - Set<Subject> descendantExtends = null; - myField = descendantExtends; - Set<Subject> descendantSupers = null; - myField = descendantSupers; - - Set set = null; - myField = set; - AbstractSet<Subject> myCollection = null; - myField = myCollection; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/before/Type.java deleted file mode 100644 index e53aa1d3cd1b..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendant2Rvalue/before/Type.java +++ /dev/null @@ -1,39 +0,0 @@ -import java.util.AbstractSet; -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set myField; - - public void meth() { - Set<Ancestor> ancestors = null; - myField = ancestors; - Set<? extends Ancestor> ancestorExtends = null; - myField = ancestorExtends; - Set<? super Ancestor> ancestorSupers = null; - myField = ancestorSupers; - - // turning everything into Set<Subject> is actually too strict, but correct - Set<Subject> subjects = null; - myField = subjects; - Set<? extends Subject> subjectExtends = null; - myField = subjectExtends; - Set<? super Subject> subjectSupers = null; - myField = subjectSupers; - - Set<Descendant> descendants = null; - myField = descendants; - Set<? extends Descendant> descendantExtends = null; - myField = descendantExtends; - Set<? super Descendant> descendantSupers = null; - myField = descendantSupers; - - Set set = null; - myField = set; - AbstractSet<Descendant> myCollection = null; - myField = myCollection; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/after/Type.items deleted file mode 100644 index e34aedf887d3..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/after/Type.items +++ /dev/null @@ -1,32 +0,0 @@ -Types: -PsiField:myField : java.util.Set<? super Subject> -PsiLocalVariable:ancestorExtends : java.util.Set<? super Subject> -PsiLocalVariable:descendantExtends : java.util.Set<? super Subject> -PsiLocalVariable:descendantSupers : java.util.Set<? super Subject> -PsiLocalVariable:descendants : java.util.Set<? super Subject> -PsiLocalVariable:subjectExtends : java.util.Set<? super Subject> -PsiReferenceExpression:ancestorExtends : java.util.Set<? super Subject> -PsiReferenceExpression:descendantExtends : java.util.Set<? super Subject> -PsiReferenceExpression:descendantSupers : java.util.Set<? super Subject> -PsiReferenceExpression:descendants : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:myField : java.util.Set<? super Subject> -PsiReferenceExpression:subjectExtends : java.util.Set<? super Subject> - -Conversions: -ancestorSupers -> $ -ancestors -> $ -set -> $ -subjectSupers -> $ -subjects -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/after/Type.java deleted file mode 100644 index a0982c89aa5c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/after/Type.java +++ /dev/null @@ -1,35 +0,0 @@ -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set<? super Subject> myField; - - public void meth() { - Set<Ancestor> ancestors = null; - myField = ancestors; - Set<? super Subject> ancestorExtends = null; - myField = ancestorExtends; - Set<? super Ancestor> ancestorSupers = null; - myField = ancestorSupers; - - Set<Subject> subjects = null; - myField = subjects; - Set<? super Subject> subjectExtends = null; - myField = subjectExtends; - Set<? super Subject> subjectSupers = null; - myField = subjectSupers; - - Set<? super Subject> descendants = null; - myField = descendants; - Set<? super Subject> descendantExtends = null; - myField = descendantExtends; - Set<? super Subject> descendantSupers = null; - myField = descendantSupers; - - Set set = null; - myField = set; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/before/Type.java deleted file mode 100644 index 79f4d219b47c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenDescendantWildcard2Rvalue/before/Type.java +++ /dev/null @@ -1,35 +0,0 @@ -import java.util.Set; - -interface Ancestor {} -interface Subject extends Ancestor {} -class Descendant implements Subject {} - -class Type { - private Set myField; - - public void meth() { - Set<Ancestor> ancestors = null; - myField = ancestors; - Set<? extends Ancestor> ancestorExtends = null; - myField = ancestorExtends; - Set<? super Ancestor> ancestorSupers = null; - myField = ancestorSupers; - - Set<Subject> subjects = null; - myField = subjects; - Set<? extends Subject> subjectExtends = null; - myField = subjectExtends; - Set<? super Subject> subjectSupers = null; - myField = subjectSupers; - - Set<Descendant> descendants = null; - myField = descendants; - Set<? extends Descendant> descendantExtends = null; - myField = descendantExtends; - Set<? super Descendant> descendantSupers = null; - myField = descendantSupers; - - Set set = null; - myField = set; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/after/Type.items deleted file mode 100644 index 9da02a3b248c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.util.Set -PsiReferenceExpression:p : java.util.Set - -Conversions: -myField -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/after/Type.java deleted file mode 100644 index f66a7c1fadc0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/after/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.Set; - -class Any {} - -class Type { - private Set<Any> myField; - public void meth(Set p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/before/Type.java deleted file mode 100644 index 968d7e85e0b7..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Lvalue/before/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.Set; - -class Any {} - -class Type { - private Set<Any> myField; - public void meth(Set<Any> p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/after/Type.items deleted file mode 100644 index a3dd46449c57..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/after/Type.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:myField : java.util.Set -PsiReferenceExpression:myField : java.util.Set - -Conversions: -p -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/after/Type.java deleted file mode 100644 index f78a0b3d5a68..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/after/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.Set; - -class Any {} - -class Type { - private Set myField; - public void meth(Set<Any> p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/before/Type.java deleted file mode 100644 index 968d7e85e0b7..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeGenRaw2Rvalue/before/Type.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.Set; - -class Any {} - -class Type { - private Set<Any> myField; - public void meth(Set<Any> p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/after/Type.items deleted file mode 100644 index 361d3837f2da..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/after/Type.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:myField : boolean -PsiParameter:p : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:p : boolean - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/after/Type.java deleted file mode 100644 index 8a5b062df2e6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private boolean myField; - public void meth(boolean p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/before/Type.java deleted file mode 100644 index b9185a0c81ed..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Lvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private int myField; - public void meth(int p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/after/Type.items deleted file mode 100644 index 361d3837f2da..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/after/Type.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:myField : boolean -PsiParameter:p : boolean -PsiReferenceExpression:myField : boolean -PsiReferenceExpression:p : boolean - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/after/Type.java deleted file mode 100644 index 8a5b062df2e6..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/after/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private boolean myField; - public void meth(boolean p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/before/Type.java deleted file mode 100644 index b9185a0c81ed..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubBoolean2Rvalue/before/Type.java +++ /dev/null @@ -1,6 +0,0 @@ -class Type { - private int myField; - public void meth(int p) { - myField = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/after/Type.items deleted file mode 100644 index 71e76cc5a1e9..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/after/Type.items +++ /dev/null @@ -1,26 +0,0 @@ -Types: -PsiField:myField : byte -PsiParameter:pc : byte -PsiParameter:pd : byte -PsiParameter:pf : byte -PsiParameter:pi : byte -PsiParameter:pl : byte -PsiParameter:ps : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:myField : byte -PsiReferenceExpression:pc : byte -PsiReferenceExpression:pd : byte -PsiReferenceExpression:pf : byte -PsiReferenceExpression:pi : byte -PsiReferenceExpression:pl : byte -PsiReferenceExpression:ps : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/after/Type.java deleted file mode 100644 index ac3a40879f5b..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private byte myField; - public void meth(byte pb, byte ps, byte pc, byte pi, byte pl, byte pf, byte pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/before/Type.java deleted file mode 100644 index f7edce2eea98..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubByte2Rvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private double myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, float pf, double pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/after/Type.items deleted file mode 100644 index 521321c601c1..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/after/Type.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiField:myByte : char -PsiField:myShort : char -PsiParameter:p : char -PsiReferenceExpression:myByte : char -PsiReferenceExpression:myShort : char -PsiReferenceExpression:p : char -PsiReferenceExpression:p : char -PsiReferenceExpression:p : char -PsiReferenceExpression:p : char -PsiReferenceExpression:p : char -PsiReferenceExpression:p : char -PsiReferenceExpression:p : char - -Conversions: -myDouble -> $ -myFloat -> $ -myInt -> $ -myLong -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/after/Type.java deleted file mode 100644 index 8b94e45d5626..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private char myByte; - private char myShort; - private char myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(char p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/before/Type.java deleted file mode 100644 index 2d55ceaa511a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private byte myByte; - private short myShort; - private char myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(byte p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/after/Type.items deleted file mode 100644 index 404f84f33867..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/after/Type.items +++ /dev/null @@ -1,26 +0,0 @@ -Types: -PsiField:myField : char -PsiParameter:pb : char -PsiParameter:pd : char -PsiParameter:pf : char -PsiParameter:pi : char -PsiParameter:pl : char -PsiParameter:ps : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:myField : char -PsiReferenceExpression:pb : char -PsiReferenceExpression:pd : char -PsiReferenceExpression:pf : char -PsiReferenceExpression:pi : char -PsiReferenceExpression:pl : char -PsiReferenceExpression:ps : char - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/after/Type.java deleted file mode 100644 index dc346a77074c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private char myField; - public void meth(char pb, char ps, char pc, char pi, char pl, char pf, char pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/before/Type.java deleted file mode 100644 index f7edce2eea98..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubChar2Rvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private double myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, float pf, double pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/after/Type.items deleted file mode 100644 index 6946fcefbac0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/after/Type.items +++ /dev/null @@ -1,26 +0,0 @@ -Types: -PsiField:myByte : double -PsiField:myChar : double -PsiField:myFloat : double -PsiField:myInt : double -PsiField:myLong : double -PsiField:myShort : double -PsiParameter:p : double -PsiReferenceExpression:myByte : double -PsiReferenceExpression:myChar : double -PsiReferenceExpression:myFloat : double -PsiReferenceExpression:myInt : double -PsiReferenceExpression:myLong : double -PsiReferenceExpression:myShort : double -PsiReferenceExpression:p : double -PsiReferenceExpression:p : double -PsiReferenceExpression:p : double -PsiReferenceExpression:p : double -PsiReferenceExpression:p : double -PsiReferenceExpression:p : double -PsiReferenceExpression:p : double - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/after/Type.java deleted file mode 100644 index 8a5035c81e4d..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private double myByte; - private double myShort; - private double myChar; - private double myInt; - private double myLong; - private double myFloat; - private double myDouble; - public void meth(double p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/before/Type.java deleted file mode 100644 index 2d55ceaa511a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubDouble2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private byte myByte; - private short myShort; - private char myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(byte p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/after/Type.items deleted file mode 100644 index c479836287e0..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/after/Type.items +++ /dev/null @@ -1,25 +0,0 @@ -Types: -PsiField:myByte : float -PsiField:myChar : float -PsiField:myInt : float -PsiField:myLong : float -PsiField:myShort : float -PsiParameter:p : float -PsiReferenceExpression:myByte : float -PsiReferenceExpression:myChar : float -PsiReferenceExpression:myInt : float -PsiReferenceExpression:myLong : float -PsiReferenceExpression:myShort : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float - -Conversions: -myDouble -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/after/Type.java deleted file mode 100644 index 8b59184de85f..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private float myByte; - private float myShort; - private float myChar; - private float myInt; - private float myLong; - private float myFloat; - private double myDouble; - public void meth(float p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/before/Type.java deleted file mode 100644 index 2d55ceaa511a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private byte myByte; - private short myShort; - private char myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(byte p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/after/Type.items deleted file mode 100644 index 7a22f6771caf..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/after/Type.items +++ /dev/null @@ -1,21 +0,0 @@ -Types: -PsiField:myField : float -PsiParameter:pd : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:myField : float -PsiReferenceExpression:pd : float - -Conversions: -pb -> $ -pc -> $ -pi -> $ -pl -> $ -ps -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/after/Type.java deleted file mode 100644 index 0b933cce77dd..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private float myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, float pf, float pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/before/Type.java deleted file mode 100644 index f7edce2eea98..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubFloat2Rvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private double myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, float pf, double pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/after/Type.items deleted file mode 100644 index 200b3b8b3fb5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/after/Type.items +++ /dev/null @@ -1,23 +0,0 @@ -Types: -PsiField:myByte : int -PsiField:myChar : int -PsiField:myShort : int -PsiParameter:p : int -PsiReferenceExpression:myByte : int -PsiReferenceExpression:myChar : int -PsiReferenceExpression:myShort : int -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int -PsiReferenceExpression:p : int - -Conversions: -myDouble -> $ -myFloat -> $ -myLong -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/after/Type.java deleted file mode 100644 index b15830da724d..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private int myByte; - private int myShort; - private int myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(int p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/before/Type.java deleted file mode 100644 index 2d55ceaa511a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private byte myByte; - private short myShort; - private char myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(byte p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/after/Type.items deleted file mode 100644 index b7c45d6a6aff..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/after/Type.items +++ /dev/null @@ -1,23 +0,0 @@ -Types: -PsiField:myField : int -PsiParameter:pd : int -PsiParameter:pf : int -PsiParameter:pl : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:myField : int -PsiReferenceExpression:pd : int -PsiReferenceExpression:pf : int -PsiReferenceExpression:pl : int - -Conversions: -pb -> $ -pc -> $ -ps -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/after/Type.java deleted file mode 100644 index c13b0ab9bee2..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private int myField; - public void meth(byte pb, short ps, char pc, int pi, int pl, int pf, int pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/before/Type.java deleted file mode 100644 index f7edce2eea98..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubInt2Rvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private double myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, float pf, double pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/after/Type.items deleted file mode 100644 index 3f94bd20c6e8..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/after/Type.items +++ /dev/null @@ -1,24 +0,0 @@ -Types: -PsiField:myByte : long -PsiField:myChar : long -PsiField:myInt : long -PsiField:myShort : long -PsiParameter:p : long -PsiReferenceExpression:myByte : long -PsiReferenceExpression:myChar : long -PsiReferenceExpression:myInt : long -PsiReferenceExpression:myShort : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long -PsiReferenceExpression:p : long - -Conversions: -myDouble -> $ -myFloat -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/after/Type.java deleted file mode 100644 index 1b594666283c..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private long myByte; - private long myShort; - private long myChar; - private long myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(long p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/before/Type.java deleted file mode 100644 index 2d55ceaa511a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private byte myByte; - private short myShort; - private char myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(byte p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/after/Type.items deleted file mode 100644 index 98a3c92987b9..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/after/Type.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiField:myField : long -PsiParameter:pd : long -PsiParameter:pf : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:myField : long -PsiReferenceExpression:pd : long -PsiReferenceExpression:pf : long - -Conversions: -pb -> $ -pc -> $ -pi -> $ -ps -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/after/Type.java deleted file mode 100644 index e3e3b25d89b4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private long myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, long pf, long pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/before/Type.java deleted file mode 100644 index f7edce2eea98..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubLong2Rvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private double myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, float pf, double pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/after/Type.items deleted file mode 100644 index 8f0cd52a3560..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/after/Type.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiField:myByte : short -PsiField:myChar : short -PsiParameter:p : short -PsiReferenceExpression:myByte : short -PsiReferenceExpression:myChar : short -PsiReferenceExpression:p : short -PsiReferenceExpression:p : short -PsiReferenceExpression:p : short -PsiReferenceExpression:p : short -PsiReferenceExpression:p : short -PsiReferenceExpression:p : short -PsiReferenceExpression:p : short - -Conversions: -myDouble -> $ -myFloat -> $ -myInt -> $ -myLong -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/after/Type.java deleted file mode 100644 index ccbe23c4b4e2..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private short myByte; - private short myShort; - private short myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(short p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/before/Type.java deleted file mode 100644 index 2d55ceaa511a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -class Type { - private byte myByte; - private short myShort; - private char myChar; - private int myInt; - private long myLong; - private float myFloat; - private double myDouble; - public void meth(byte p) { - myByte = p; - myShort = p; - myChar = p; - myInt = p; - myLong = p; - myFloat = p; - myDouble = p; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/after/Type.items deleted file mode 100644 index 754060e723ec..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/after/Type.items +++ /dev/null @@ -1,25 +0,0 @@ -Types: -PsiField:myField : short -PsiParameter:pc : short -PsiParameter:pd : short -PsiParameter:pf : short -PsiParameter:pi : short -PsiParameter:pl : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:myField : short -PsiReferenceExpression:pc : short -PsiReferenceExpression:pd : short -PsiReferenceExpression:pf : short -PsiReferenceExpression:pi : short -PsiReferenceExpression:pl : short - -Conversions: -pb -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/after/Type.java deleted file mode 100644 index eb53bcd49ebc..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/after/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private short myField; - public void meth(byte pb, short ps, short pc, short pi, short pl, short pf, short pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/before/Type.java deleted file mode 100644 index f7edce2eea98..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typePrimsubShort2Rvalue/before/Type.java +++ /dev/null @@ -1,12 +0,0 @@ -class Type { - private double myField; - public void meth(byte pb, short ps, char pc, int pi, long pl, float pf, double pd) { - myField = pb; - myField = ps; - myField = pc; - myField = pi; - myField = pl; - myField = pf; - myField = pd; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/after/Type.items deleted file mode 100644 index 78431b6e4a4a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/after/Type.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myField : ClassChild -PsiParameter:pcp : ClassChild -PsiParameter:pfc : ClassChild -PsiParameter:pfp : ClassChild -PsiReferenceExpression:myField : ClassChild -PsiReferenceExpression:myField : ClassChild -PsiReferenceExpression:myField : ClassChild -PsiReferenceExpression:myField : ClassChild -PsiReferenceExpression:pcp : ClassChild -PsiReferenceExpression:pfc : ClassChild -PsiReferenceExpression:pfp : ClassChild - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/after/Type.java deleted file mode 100644 index f5d9434c07c4..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/after/Type.java +++ /dev/null @@ -1,14 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private ClassChild myField; - public void meth(ClassChild pcc, ClassChild pcp, ClassChild pfc, ClassChild pfp) { - myField = pcc; - myField = pcp; - myField = pfc; - myField = pfp; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/before/Type.java deleted file mode 100644 index e5cfab9f9af5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassChild2Rvalue/before/Type.java +++ /dev/null @@ -1,14 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private FaceParent myField; - public void meth(ClassChild pcc, ClassParent pcp, FaceChild pfc, FaceParent pfp) { - myField = pcc; - myField = pcp; - myField = pfc; - myField = pfp; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/after/Type.items deleted file mode 100644 index 18fce6b3d6ec..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/after/Type.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiField:myClassChild : ClassParent -PsiParameter:p : ClassParent -PsiReferenceExpression:myClassChild : ClassParent -PsiReferenceExpression:p : ClassParent -PsiReferenceExpression:p : ClassParent -PsiReferenceExpression:p : ClassParent -PsiReferenceExpression:p : ClassParent - -Conversions: -myFaceChild -> $ -myFaceParent -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/after/Type.java deleted file mode 100644 index 8d7fee567890..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private ClassParent myClassChild; - private ClassParent myClassParent; - private FaceChild myFaceChild; - private FaceParent myFaceParent; - - public void meth(ClassParent p) { - myClassChild = p; - myClassParent = p; - myFaceChild = p; - myFaceParent = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/before/Type.java deleted file mode 100644 index 074af076748d..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private ClassChild myClassChild; - private ClassParent myClassParent; - private FaceChild myFaceChild; - private FaceParent myFaceParent; - - public void meth(ClassChild p) { - myClassChild = p; - myClassParent = p; - myFaceChild = p; - myFaceParent = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/after/Type.items deleted file mode 100644 index 4e7bfb9a5f9a..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/after/Type.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myField : ClassParent -PsiParameter:pfc : ClassParent -PsiParameter:pfp : ClassParent -PsiReferenceExpression:myField : ClassParent -PsiReferenceExpression:myField : ClassParent -PsiReferenceExpression:myField : ClassParent -PsiReferenceExpression:myField : ClassParent -PsiReferenceExpression:pfc : ClassParent -PsiReferenceExpression:pfp : ClassParent - -Conversions: -pcc -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/after/Type.java deleted file mode 100644 index 9953f41083c5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/after/Type.java +++ /dev/null @@ -1,14 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private ClassParent myField; - public void meth(ClassChild pcc, ClassParent pcp, ClassParent pfc, ClassParent pfp) { - myField = pcc; - myField = pcp; - myField = pfc; - myField = pfp; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/before/Type.java deleted file mode 100644 index e5cfab9f9af5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefClassParent2Rvalue/before/Type.java +++ /dev/null @@ -1,14 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private FaceParent myField; - public void meth(ClassChild pcc, ClassParent pcp, FaceChild pfc, FaceParent pfp) { - myField = pcc; - myField = pcp; - myField = pfc; - myField = pfp; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/after/Type.items deleted file mode 100644 index 9dd227a952df..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/after/Type.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:myClassChild : FaceChild -PsiField:myClassParent : FaceChild -PsiParameter:p : FaceChild -PsiReferenceExpression:myClassChild : FaceChild -PsiReferenceExpression:myClassParent : FaceChild -PsiReferenceExpression:p : FaceChild -PsiReferenceExpression:p : FaceChild -PsiReferenceExpression:p : FaceChild -PsiReferenceExpression:p : FaceChild - -Conversions: -myFaceParent -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/after/Type.java deleted file mode 100644 index f4b8de1d6028..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private FaceChild myClassChild; - private FaceChild myClassParent; - private FaceChild myFaceChild; - private FaceParent myFaceParent; - - public void meth(FaceChild p) { - myClassChild = p; - myClassParent = p; - myFaceChild = p; - myFaceParent = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/before/Type.java deleted file mode 100644 index 074af076748d..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private ClassChild myClassChild; - private ClassParent myClassParent; - private FaceChild myFaceChild; - private FaceParent myFaceParent; - - public void meth(ClassChild p) { - myClassChild = p; - myClassParent = p; - myFaceChild = p; - myFaceParent = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/after/Type.items deleted file mode 100644 index 91683c097f98..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/after/Type.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiField:myField : FaceChild -PsiParameter:pfp : FaceChild -PsiReferenceExpression:myField : FaceChild -PsiReferenceExpression:myField : FaceChild -PsiReferenceExpression:myField : FaceChild -PsiReferenceExpression:myField : FaceChild -PsiReferenceExpression:pfp : FaceChild - -Conversions: -pcc -> $ -pcp -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/after/Type.java deleted file mode 100644 index f16470efa1df..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/after/Type.java +++ /dev/null @@ -1,14 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private FaceChild myField; - public void meth(ClassChild pcc, ClassParent pcp, FaceChild pfc, FaceChild pfp) { - myField = pcc; - myField = pcp; - myField = pfc; - myField = pfp; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/before/Type.java deleted file mode 100644 index e5cfab9f9af5..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceChild2Rvalue/before/Type.java +++ /dev/null @@ -1,14 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private FaceParent myField; - public void meth(ClassChild pcc, ClassParent pcp, FaceChild pfc, FaceParent pfp) { - myField = pcc; - myField = pcp; - myField = pfc; - myField = pfp; - } -} diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/after/Type.items b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/after/Type.items deleted file mode 100644 index a10aad579ef2..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/after/Type.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiField:myClassChild : FaceParent -PsiField:myClassParent : FaceParent -PsiField:myFaceChild : FaceParent -PsiParameter:p : FaceParent -PsiReferenceExpression:myClassChild : FaceParent -PsiReferenceExpression:myClassParent : FaceParent -PsiReferenceExpression:myFaceChild : FaceParent -PsiReferenceExpression:p : FaceParent -PsiReferenceExpression:p : FaceParent -PsiReferenceExpression:p : FaceParent -PsiReferenceExpression:p : FaceParent - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/after/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/after/Type.java deleted file mode 100644 index d53c072b9b56..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/after/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private FaceParent myClassChild; - private FaceParent myClassParent; - private FaceParent myFaceChild; - private FaceParent myFaceParent; - - public void meth(FaceParent p) { - myClassChild = p; - myClassParent = p; - myFaceChild = p; - myFaceParent = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/before/Type.java b/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/before/Type.java deleted file mode 100644 index 074af076748d..000000000000 --- a/plugins/typeMigration/testData/refactoring/migrateTypeSignature/typeRefFaceParent2Lvalue/before/Type.java +++ /dev/null @@ -1,18 +0,0 @@ -interface FaceParent {} -interface FaceChild extends FaceParent {} -class ClassParent implements FaceChild {} -class ClassChild extends ClassParent {} - -class Type { - private ClassChild myClassChild; - private ClassParent myClassParent; - private FaceChild myFaceChild; - private FaceParent myFaceParent; - - public void meth(ClassChild p) { - myClassChild = p; - myClassParent = p; - myFaceChild = p; - myFaceParent = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t01/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t01/after/Test.items deleted file mode 100644 index 702373b694d5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t01/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiMethodCallExpression:i.foo(new Integer[0]) : Foo -PsiParameter:i : Foo -PsiReferenceExpression:i : Foo - -Conversions: -i.foo -> PsiMethod:moo - -New expression type changes: -Fails: -new Integer[0]->int diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t01/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t01/after/test.java deleted file mode 100644 index cf8dd0203f05..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t01/after/test.java +++ /dev/null @@ -1,39 +0,0 @@ - -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Oct 16, 2004 - * Time: 10:10:35 PM - * To change this template use File | Settings | File Templates. - */ - -class Foo { - Moo moo(int i) { - return null; - } -} - -class Moo { - Foo foo(Integer[] j) { - return null; - } -} - -class P { - int f(int y) { - return y; - } -} - -class G extends P { - int f(int y) { - return y; - } -} - -public class Test { - Moo g(Foo i) { - Foo j = i.moo(new Integer[0]); - return null; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t01/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t01/before/test.java deleted file mode 100644 index 1f7a52e4aa63..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t01/before/test.java +++ /dev/null @@ -1,39 +0,0 @@ - -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Oct 16, 2004 - * Time: 10:10:35 PM - * To change this template use File | Settings | File Templates. - */ - -class Foo { - Moo moo(int i) { - return null; - } -} - -class Moo { - Foo foo(Integer[] j) { - return null; - } -} - -class P { - int f(int y) { - return y; - } -} - -class G extends P { - int f(int y) { - return y; - } -} - -public class Test { - Moo g(Moo i) { - Foo j = i.foo(new Integer[0]); - return null; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t02/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t02/after/Test.items deleted file mode 100644 index eb13633449ca..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t02/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethod:sum : java.lang.Integer -PsiMethodCallExpression:sum(n, k) : java.lang.Integer - -Conversions: -a -> $ -i + j -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t02/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t02/after/test.java deleted file mode 100644 index 5842b8fa99e0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t02/after/test.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - Integer sum(int i, int j) { - return i + j; - } - - int foo(int n, int k) { - int a; - - a = sum(n, k); - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t02/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t02/before/test.java deleted file mode 100644 index d0ebca58783c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t02/before/test.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - int sum(int i, int j) { - return i + j; - } - - int foo(int n, int k) { - int a; - - a = sum(n, k); - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t03/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t03/after/Test.items deleted file mode 100644 index f1747c90b2ed..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t03/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethod:sum : java.lang.Integer -PsiMethodCallExpression:sum(i, k) : java.lang.Integer - -Conversions: -a -> $ -i + j -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t03/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t03/after/test.java deleted file mode 100644 index 5fd61417ba05..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t03/after/test.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - Integer sum(int i, int j) { - return i + j; - } - - int[] foo(int n, int k) { - int[] a = new int[n]; - - for (int i = 0; i < a.length; i++) { - a[i] = sum(i, k); - } - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t03/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t03/before/test.java deleted file mode 100644 index 9e1559784bde..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t03/before/test.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - int sum(int i, int j) { - return i + j; - } - - int[] foo(int n, int k) { - int[] a = new int[n]; - - for (int i = 0; i < a.length; i++) { - a[i] = sum(i, k); - } - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t04/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t04/after/Test.items deleted file mode 100644 index edea723357ea..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t04/after/Test.items +++ /dev/null @@ -1,21 +0,0 @@ -Types: -PsiLocalVariable:a : java.lang.Long[][] -PsiMethod:bar : java.lang.Long[] -PsiMethod:foo : java.lang.Long[][] -PsiMethodCallExpression:bar() : java.lang.Long[] -PsiNewExpression:new Integer[0] : java.lang.Long[] -PsiNewExpression:new Integer[0] : java.lang.Long[] -PsiNewExpression:new Integer[0] : java.lang.Long[] -PsiNewExpression:new Integer[][] {new Integer[0], new Integer[0]} : java.lang.Long[][] -PsiReferenceExpression:a : java.lang.Long[][] -PsiReferenceExpression:a : java.lang.Long[][] -PsiReferenceExpression:a : java.lang.Long[][] - -Conversions: - -New expression type changes: -new Integer[0] -> java.lang.Long[] -new Integer[0] -> java.lang.Long[] -new Integer[0] -> java.lang.Long[] -new Integer[][] {new Integer[0], new Integer[0]} -> java.lang.Long[][] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t04/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t04/after/test.java deleted file mode 100644 index 080208fcbd6c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t04/after/test.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - Long[] bar() { - return new Long[0]; - } - - Long[][] foo(int n, int k) { - Long[][] a = new Long[][]{new Long[0], new Long[0]}; - - for (int i = 0; i < a.length; i++) { - a[i] = bar(); - } - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t04/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t04/before/test.java deleted file mode 100644 index 591b5a530d2b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t04/before/test.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - Integer[] bar() { - return new Integer[0]; - } - - Integer[] foo(int n, int k) { - Integer[][] a = new Integer[][] {new Integer[0], new Integer[0]}; - - for (int i = 0; i < a.length; i++) { - a[i] = bar(); - } - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t05/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t05/after/Test.items deleted file mode 100644 index 8152c1b711e7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t05/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:i : java.lang.Integer -PsiReferenceExpression:i : java.lang.Integer - -Conversions: -i -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t05/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t05/after/test.java deleted file mode 100644 index b74d13b84fda..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t05/after/test.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - int sum(Integer i, int j) { - return i + j; - } - - int[] foo(int n, int k) { - int[] a = new int[] {1, 2, 3, 4}; - - for (int i = 0; i < a.length; i++) { - a[i] = sum(i, k); - } - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t05/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t05/before/test.java deleted file mode 100644 index e8a96127f4fd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t05/before/test.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -public class Test { - int sum(int i, int j) { - return i + j; - } - - int[] foo(int n, int k) { - int[] a = new int[] {1, 2, 3, 4}; - - for (int i = 0; i < a.length; i++) { - a[i] = sum(i, k); - } - - return a; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t06/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t06/after/Test.items deleted file mode 100644 index 3ad4c0f7992f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t06/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiLocalVariable:a : B -PsiMethod:getA : B -PsiMethodCallExpression:getA () : B -PsiReferenceExpression:a : B - -Conversions: - -New expression type changes: -Fails: -new A ()->B diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t06/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t06/after/test.java deleted file mode 100644 index f4fa6ab1f876..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t06/after/test.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -class A {} -class B {} - -public class Test { - B getA() { - return new A (); - } - - int foo() { - B a = getA (); - - if (a != null){ - return 0; - } - - return 1; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t06/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t06/before/test.java deleted file mode 100644 index 862356ebd9cc..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t06/before/test.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Created by IntelliJ IDEA. - * User: db - * Date: Nov 15, 2004 - * Time: 5:40:02 PM - * To change this template use File | Settings | File Templates. - */ -class A {} -class B {} - -public class Test { - A getA() { - return new A (); - } - - int foo() { - A a = getA (); - - if (a != null){ - return 0; - } - - return 1; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t07/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t07/after/Test.items deleted file mode 100644 index 12252787a292..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t07/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.lang.Integer[] -PsiNewExpression:new int[0] : java.lang.Integer[] - -Conversions: - -New expression type changes: -new int[0] -> java.lang.Integer[] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t07/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t07/after/test.java deleted file mode 100644 index 09d7a0982009..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t07/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Test { - Integer[] f = new Integer[0]; -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t07/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t07/before/test.java deleted file mode 100644 index 87955af32435..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t07/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Test { - int[] f = new int[0]; -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t08/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t08/after/Test.items deleted file mode 100644 index 7c09ce5a46f7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t08/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : java.lang.String[] -PsiNewExpression:new Integer[0] : java.lang.String[] -PsiParameter:i : java.lang.String -PsiReferenceExpression:f : java.lang.String[] - -Conversions: - -New expression type changes: -new Integer[0] -> java.lang.String[] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t08/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t08/after/test.java deleted file mode 100644 index 9f13a80a2f2a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t08/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test { - String[] f = new String[0]; - void foo() { - for (String i : f) {} - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t08/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t08/before/test.java deleted file mode 100644 index e38a9aa3155d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t08/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test { - Integer[] f = new Integer[0]; - void foo() { - for (Integer i : f) {} - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t09/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t09/after/Test.items deleted file mode 100644 index 39394462b76e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t09/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:f : java.lang.String[] -PsiNewExpression:new Integer[0] : java.lang.String[] -PsiParameter:g : java.lang.String[] -PsiReferenceExpression:f : java.lang.String[] - -Conversions: -f -> $ - -New expression type changes: -new Integer[0] -> java.lang.String[] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t09/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t09/after/test.java deleted file mode 100644 index 5e779c9e12f5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t09/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Test { - String[] f = new String[0]; - void foo() { - bar(1, f); - } - - void bar(int i, String[] g){} -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t09/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t09/before/test.java deleted file mode 100644 index db3f02ed1976..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t09/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Test { - Integer[] f = new Integer[0]; - void foo() { - bar(1, f); - } - - void bar(int i, Integer[] g){} -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t10/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t10/after/Test.items deleted file mode 100644 index 77d161720fb5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t10/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.util.List<java.lang.String> -PsiParameter:i : java.lang.String -PsiReferenceExpression:f : java.util.List<java.lang.String> - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t10/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t10/after/test.java deleted file mode 100644 index 7820f54d0340..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t10/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.List; -public class Test { - List<String> f; - void foo() { - for (String i : f) {} - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t10/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t10/before/test.java deleted file mode 100644 index 726f23a4bf8d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t10/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.List; -public class Test { - List<Integer> f; - void foo() { - for (Integer i : f) {} - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t100/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t100/after/Test.items deleted file mode 100644 index 135dca6a135e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t100/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.util.Map<java.lang.String,java.lang.Integer> -PsiNewExpression:new HashMap<String,String>() : java.util.HashMap<java.lang.String,java.lang.Integer> - -Conversions: - -New expression type changes: -new HashMap<String,String>() -> java.util.HashMap<java.lang.String,java.lang.Integer> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t100/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t100/after/test.java deleted file mode 100644 index b2917c86149e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t100/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -public class Test { - Map<String, Integer> f = new HashMap<>(); - - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t100/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t100/before/test.java deleted file mode 100644 index 7bf03e3a27da..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t100/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -public class Test { - Map<String,String> f = new HashMap<String,String>(); - - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t101/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t101/after/Test.items deleted file mode 100644 index 285bc5b6ca51..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t101/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:p.get(0) : java.util.ArrayList<java.lang.Integer> -PsiParameter:p : java.util.ArrayList<java.lang.Integer>[] -PsiReferenceExpression:p : java.util.ArrayList<java.lang.Integer>[] - -Conversions: -p.get(0) -> $qualifier$[$i$] $qualifier$.get($i$) p.get(0) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t101/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t101/after/test.java deleted file mode 100644 index 6344b428b46c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t101/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -public class Test { - void meth(ArrayList<Integer>[] p) { - ArrayList<Integer> v = p[0]; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t101/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t101/before/test.java deleted file mode 100644 index e16f3d100bc9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t101/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -public class Test { - void meth(List<ArrayList<Integer>> p) { - ArrayList<Integer> v = p.get(0); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t102/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t102/after/Test.items deleted file mode 100644 index b9f794b195bf..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t102/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:s : java.lang.Object[] -PsiReferenceExpression:s : java.lang.Object[] - -Conversions: - -New expression type changes: -Fails: -s->java.lang.Object[] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t102/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t102/after/test.java deleted file mode 100644 index dcd056fcaf90..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t102/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -public class Test { - void method(Object[] s) { - s.add(null); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t102/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t102/before/test.java deleted file mode 100644 index f59b5db84644..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t102/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -public class Test { - void method(Set<? extends Object> s) { - s.add(null); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t103/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t103/after/Test.items deleted file mode 100644 index b13c3192a1d8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t103/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:l : java.lang.Integer[] -PsiReferenceExpression:l : java.lang.Integer[] - -Conversions: - -New expression type changes: -Fails: -l->java.lang.Integer[] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t103/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t103/after/test.java deleted file mode 100644 index af807d53c7b0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t103/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -public class Test { - void method(Integer[] l) { - l.set(1, ""); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t103/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t103/before/test.java deleted file mode 100644 index 7e5802d50574..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t103/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -public class Test { - void method(ArrayList<String> l) { - l.set(1, ""); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t104/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t104/after/Test.items deleted file mode 100644 index f085abb3c681..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t104/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:l : java.lang.String[] -PsiReferenceExpression:l : java.lang.String[] - -Conversions: - -New expression type changes: -Fails: -l->java.lang.String[] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t104/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t104/after/test.java deleted file mode 100644 index d70a09a513bd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t104/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -public class Test { - void method(String[] l) { - l.set(1, ""); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t104/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t104/before/test.java deleted file mode 100644 index bc4b40c061a2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t104/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -public class Test { - void method(ArrayList l) { - l.set(1, ""); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t105/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t105/after/Test.items deleted file mode 100644 index 7821f01df96c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t105/after/Test.items +++ /dev/null @@ -1,7 +0,0 @@ -Types: -PsiField:t : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t105/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t105/after/test.java deleted file mode 100644 index 71797316503f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t105/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Test<T> { - String t; -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t105/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t105/before/test.java deleted file mode 100644 index 763dc905176d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t105/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Test<T> { - T t; -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t106/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t106/after/Test.items deleted file mode 100644 index 2fab8a1f5fae..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t106/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:t : java.lang.String -PsiReferenceExpression:t : java.lang.String - -Conversions: - -New expression type changes: -Fails: -t->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t106/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t106/after/test.java deleted file mode 100644 index dafbfca4a742..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t106/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test<T extends Number> { - String t; - void foo() { - int i = t.intValue(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t106/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t106/before/test.java deleted file mode 100644 index 65ad21055710..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t106/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test<T extends Number> { - T t; - void foo() { - int i = t.intValue(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t107/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t107/after/Test.items deleted file mode 100644 index 93a16148be72..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t107/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:t : java.lang.Integer -PsiMethodCallExpression:t.intValue() : int -PsiReferenceExpression:t : java.lang.Integer - -Conversions: -t.intValue() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t107/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t107/after/test.java deleted file mode 100644 index ce44f19e2458..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t107/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test<T extends Number> { - Integer t; - void foo() { - int i = t.intValue(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t107/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t107/before/test.java deleted file mode 100644 index 65ad21055710..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t107/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -public class Test<T extends Number> { - T t; - void foo() { - int i = t.intValue(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t108/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t108/after/Test.items deleted file mode 100644 index a9f530ce25f7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t108/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiMethodCallExpression:integer.intValue() : int -PsiParameter:integer : java.lang.Number -PsiParameter:l : java.util.List<? extends java.lang.Number> -PsiReferenceExpression:integer : java.lang.Number -PsiReferenceExpression:l : java.util.List<? extends java.lang.Number> - -Conversions: -integer.intValue() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t108/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t108/after/test.java deleted file mode 100644 index 26b9322b4739..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t108/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - void method(List<? extends Number> l) { - for (Number integer : l) { - System.out.println(integer.intValue()); - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t108/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t108/before/test.java deleted file mode 100644 index 08a3229cd932..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t108/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - void method(List<Integer> l) { - for (Integer integer : l) { - System.out.println(integer.intValue()); - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t109/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t109/after/Test.items deleted file mode 100644 index 6a47f6675781..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t109/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiMethodCallExpression:integer.hashCode() : int -PsiParameter:integer : java.lang.Object -PsiParameter:l : java.util.List<? super java.lang.Number> -PsiReferenceExpression:integer : java.lang.Object -PsiReferenceExpression:l : java.util.List<? super java.lang.Number> - -Conversions: -integer.hashCode() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t109/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t109/after/test.java deleted file mode 100644 index bae70cd5b0d4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t109/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - void method(List<? super Number> l) { - for (Object integer : l) { - System.out.println(integer.hashCode()); - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t109/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t109/before/test.java deleted file mode 100644 index 26280e892cd0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t109/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - void method(List<Integer> l) { - for (Integer integer : l) { - System.out.println(integer.hashCode()); - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t11/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t11/after/Test.items deleted file mode 100644 index 4058a7862ff2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t11/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : java.util.Map<java.lang.String,java.lang.Integer> -PsiMethodCallExpression:f.keySet() : java.util.Set<java.lang.String> -PsiParameter:i : java.lang.String -PsiReferenceExpression:f : java.util.Map<java.lang.String,java.lang.Integer> - -Conversions: -f.keySet() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t11/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t11/after/test.java deleted file mode 100644 index 1491875ea2b7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t11/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.Map; -public class Test { - Map<String, Integer> f; - void foo() { - for (String i : f.keySet()) {} - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t11/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t11/before/test.java deleted file mode 100644 index b0aa7086f175..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t11/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.Map; -public class Test { - Map<Integer, Integer> f; - void foo() { - for (Integer i : f.keySet()) {} - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t110/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t110/after/Test.items deleted file mode 100644 index 3853e035e26b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t110/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiParameter:integer : java.lang.String -PsiParameter:l : java.util.List<? extends java.lang.String> -PsiReferenceExpression:integer : java.lang.String -PsiReferenceExpression:l : java.util.List<? extends java.lang.String> - -Conversions: - -New expression type changes: -Fails: -integer->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t110/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t110/after/test.java deleted file mode 100644 index cb813fd6567f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t110/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - void method(List<? extends String> l) { - for (String integer : l) { - System.out.println(integer.intValue()); - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t110/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t110/before/test.java deleted file mode 100644 index 08a3229cd932..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t110/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - void method(List<Integer> l) { - for (Integer integer : l) { - System.out.println(integer.intValue()); - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t111/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t111/after/Test.items deleted file mode 100644 index 29717a0b2377..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t111/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiParameter:i : java.lang.Integer[] -PsiReferenceExpression:i : java.lang.Integer[] -PsiReferenceExpression:i : java.lang.Integer[] - -Conversions: - -New expression type changes: -Fails: -i->java.lang.Integer[] -i++->java.lang.Integer[] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t111/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t111/after/test.java deleted file mode 100644 index e257e485d6bb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t111/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Test { - void method(Integer[] i) { - if (i == 0) { - i++; - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t111/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t111/before/test.java deleted file mode 100644 index 2620dd9f5d6a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t111/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Test { - void method(Integer i) { - if (i == 0) { - i++; - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t112/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t112/after/Test.items deleted file mode 100644 index 78f2ed729f10..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t112/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiMethod:method : java.lang.Integer[] - -Conversions: -112 -> new java.lang.Integer[]{$qualifier$} $qualifier$ 112 - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t112/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t112/after/test.java deleted file mode 100644 index c31ec11010c3..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t112/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Test { - Integer[] method() { - return new Integer[]{112}; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t112/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t112/before/test.java deleted file mode 100644 index e7bf28f0de1e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t112/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Test { - Integer method() { - return 112; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t113/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t113/after/Test.items deleted file mode 100644 index 1b69785be552..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t113/after/Test.items +++ /dev/null @@ -1,7 +0,0 @@ -Types: -PsiParameter:p : java.lang.Number... - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t113/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t113/after/test.java deleted file mode 100644 index 9f9bdcaffad7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t113/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Test { - void method(Number... p) {} - - public void doSmth() { - m(123); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t113/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t113/before/test.java deleted file mode 100644 index 6627e8d101de..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t113/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -public class Test { - void method(Integer... p) {} - - public void doSmth() { - m(123); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t114/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t114/after/Test.items deleted file mode 100644 index b6c70f112866..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t114/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.lang.String... -PsiReferenceExpression:p : java.lang.String[] - -Conversions: - -New expression type changes: -Fails: -p[0]->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t114/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t114/after/test.java deleted file mode 100644 index 6e2b9f24c22a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t114/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -public class Test { - void method(String... p) { - int i = p[0].intValue(); - } - - public void doSmth() { - m(123); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t114/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t114/before/test.java deleted file mode 100644 index f73951e56432..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t114/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -public class Test { - void method(Integer... p) { - int i = p[0].intValue(); - } - - public void doSmth() { - m(123); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t115/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t115/after/Test.items deleted file mode 100644 index b07cf0af793c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t115/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:i : java.lang.String... - -Conversions: - -New expression type changes: -Fails: -2->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t115/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t115/after/test.java deleted file mode 100644 index 8d69a2330c70..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t115/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -class Test { - void foo(String... i) { - } - - void bar() { - foo("str", 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t115/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t115/before/test.java deleted file mode 100644 index f585aba2e91c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t115/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -class Test { - void foo(Object... i) { - } - - void bar() { - foo("str", 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t116/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t116/after/Test.items deleted file mode 100644 index 0aee5ef814c6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t116/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:str : java.lang.String -PsiParameter:number : java.lang.String -PsiReferenceExpression:number : java.lang.String -PsiReferenceExpression:str : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t116/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t116/after/test.java deleted file mode 100644 index 95ddfb44251f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t116/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - String str; - - void foo(String[] p) { - for (String number : p) { - number = str; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t116/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t116/before/test.java deleted file mode 100644 index d68047e81823..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t116/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - Number str; - - void foo(String[] p) { - for (Number number : p) { - number = str; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t117/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t117/after/Test.items deleted file mode 100644 index 0aee5ef814c6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t117/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:str : java.lang.String -PsiParameter:number : java.lang.String -PsiReferenceExpression:number : java.lang.String -PsiReferenceExpression:str : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t117/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t117/after/test.java deleted file mode 100644 index 3172eaa133dc..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t117/after/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; -class Test { - String str; - - void foo(List<String> p) { - for (String number : p) { - number = str; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t117/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t117/before/test.java deleted file mode 100644 index 46cde69dca96..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t117/before/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; -class Test { - Number str; - - void foo(List<String> p) { - for (Number number : p) { - number = str; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t118/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t118/after/Test.items deleted file mode 100644 index dcd1be2928cb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t118/after/Test.items +++ /dev/null @@ -1,7 +0,0 @@ -Types: -PsiParameter:p : java.lang.Integer... - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t118/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t118/after/test.java deleted file mode 100644 index 37d684a97957..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t118/after/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; -class Test { - - void method(Integer... p) { - } - - public void doSmth(ArrayList<Integer> p) { - method(p.get(2)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t118/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t118/before/test.java deleted file mode 100644 index 012a188e5ad5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t118/before/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; -class Test { - - void method(Integer p) { - } - - public void doSmth(ArrayList<Integer> p) { - method(p.get(2)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t119/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t119/after/Test.items deleted file mode 100644 index dcd1be2928cb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t119/after/Test.items +++ /dev/null @@ -1,7 +0,0 @@ -Types: -PsiParameter:p : java.lang.Integer... - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t119/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t119/after/test.java deleted file mode 100644 index 28446b6bc761..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t119/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - - void method(Integer... p) { - } - - public void doSmth(Integer[] p) { - method(p[2]); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t119/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t119/before/test.java deleted file mode 100644 index 28aeed25cefa..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t119/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - - void method(Integer p) { - } - - public void doSmth(Integer[] p) { - method(p[2]); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t12/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t12/after/Test.items deleted file mode 100644 index a1b75e0f23ac..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t12/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.util.List<java.lang.String> -PsiLocalVariable:i : java.lang.String -PsiReferenceExpression:f : java.util.List<java.lang.String> - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t12/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t12/after/test.java deleted file mode 100644 index 657869206253..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t12/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -public class Test { - List<String> f; - void foo() { - String i = Collections.min(f); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t12/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t12/before/test.java deleted file mode 100644 index 24199ff02584..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t12/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -public class Test { - List<Integer> f; - void foo() { - Integer i = Collections.min(f); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t120/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t120/after/Test.items deleted file mode 100644 index 6f23d60f1d3c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t120/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiParameter:p : java.lang.String... -PsiParameter:p : java.lang.String[] -PsiReferenceExpression:p : java.lang.String[] -PsiReferenceExpression:p : java.lang.String[] - -Conversions: - -New expression type changes: -Fails: -p[3]->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t120/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t120/after/test.java deleted file mode 100644 index e40c1215581b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t120/after/test.java +++ /dev/null @@ -1,10 +0,0 @@ -class Test { - - void method(String... p) { - } - - public void doSmth(String[] p) { - method(p[2]); - System.out.println(p[3].intValue()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t120/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t120/before/test.java deleted file mode 100644 index 0f65e57d94ee..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t120/before/test.java +++ /dev/null @@ -1,10 +0,0 @@ -class Test { - - void method(Integer p) { - } - - public void doSmth(Integer[] p) { - method(p[2]); - System.out.println(p[3].intValue()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t121/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t121/after/Test.items deleted file mode 100644 index dadc2c72891a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t121/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiMethodCallExpression:p.add(8) : boolean -PsiParameter:p : java.util.ArrayList<java.lang.Float> -PsiReferenceExpression:p : java.util.ArrayList<java.lang.Float> - -Conversions: -8 -> $ -p.add(8) -> $ - -New expression type changes: -Fails: -8->java.lang.Float diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t121/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t121/after/test.java deleted file mode 100644 index e3a952e4d560..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t121/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - - void method(ArrayList<Float> p){ - p.add(8); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t121/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t121/before/test.java deleted file mode 100644 index aad87ca532b7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t121/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - - void method(ArrayList<Number> p){ - p.add(8); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t122/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t122/after/Test.items deleted file mode 100644 index 00092fc53a55..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t122/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.util.List<java.lang.Integer>[] -PsiReferenceExpression:p : java.util.List<java.lang.Integer>[] - -Conversions: - -New expression type changes: -Fails: -p->java.util.List<java.lang.Integer>[] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t122/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t122/after/test.java deleted file mode 100644 index 5784ee52e360..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t122/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - - void method(List<Integer>[] p){ - ArrayList<Integer> v = p.get(0); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t122/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t122/before/test.java deleted file mode 100644 index bb086dad2af8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t122/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - - void method(List<ArrayList<Integer>> p){ - ArrayList<Integer> v = p.get(0); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t123/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t123/after/Test.items deleted file mode 100644 index 691d3e6a1e26..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t123/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:n : java.lang.Integer -PsiParameter:number : java.lang.Integer -PsiParameter:p : java.lang.Integer[] -PsiReferenceExpression:n : java.lang.Integer -PsiReferenceExpression:number : java.lang.Integer -PsiReferenceExpression:p : java.lang.Integer[] - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t123/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t123/after/test.java deleted file mode 100644 index 883991ffec9d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t123/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - Integer n; - - void foo(Integer[] p) { - for (Integer number : p) { - n = number; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t123/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t123/before/test.java deleted file mode 100644 index 516fcf828234..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t123/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - Number n; - - void foo(Number[] p) { - for (Number number : p) { - n = number; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t124/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t124/after/Test.items deleted file mode 100644 index 4a7df94f76b2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t124/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.lang.Integer -PsiReferenceExpression:p : java.lang.Integer - -Conversions: - -New expression type changes: -Fails: -p->java.lang.Integer diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t124/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t124/after/test.java deleted file mode 100644 index f41fe88534f4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t124/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public <U> U meth(Integer p) { - return p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t124/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t124/before/test.java deleted file mode 100644 index b40d864d16c7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t124/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public <U> U meth(U p) { - return p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t125/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t125/after/Test.items deleted file mode 100644 index 3859bad4e428..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t125/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.lang.Integer -PsiReferenceExpression:p : java.lang.Integer - -Conversions: - -New expression type changes: -Fails: -Collections.singletonList(p)->java.util.List<java.lang.Integer> diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t125/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t125/after/test.java deleted file mode 100644 index 7854f476cc9e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t125/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - public <U> List<U> meth(Integer p) { - return Collections.singletonList(p); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t125/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t125/before/test.java deleted file mode 100644 index 30cf3914d62a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t125/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - public <U> List<U> meth(U p) { - return Collections.singletonList(p); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t126/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t126/after/Test.items deleted file mode 100644 index f870c21c0523..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t126/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiMethod:meth : T - -Conversions: - -New expression type changes: -Fails: -map.get(2)->T diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t126/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t126/after/test.java deleted file mode 100644 index 7b2814378d28..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t126/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.*; - -class Test<T> { - Map<Integer, String> map; - - T meth() { - return map.get(2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t126/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t126/before/test.java deleted file mode 100644 index 0dc76ccbdc72..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t126/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.*; - -class Test<T> { - Map<Integer, String> map; - - String meth() { - return map.get(2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t127/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t127/after/Test.items deleted file mode 100644 index 78aa0fbd396b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t127/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiLocalVariable:i : long -PsiMethod:test234 : long -PsiMethodCallExpression:test234(1, - 2) : long - -Conversions: -1 -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t127/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t127/after/test.java deleted file mode 100644 index 06a4d09a41a6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t127/after/test.java +++ /dev/null @@ -1,13 +0,0 @@ -public class Test { - - public long test234(int i, - int j) - { - return 1; - } - - public void foo() { - long i = test234(1, - 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t127/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t127/before/test.java deleted file mode 100644 index dd2c813fd38e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t127/before/test.java +++ /dev/null @@ -1,13 +0,0 @@ -public class Test { - - public int test234(int i, - int j) - { - return 1; - } - - public void foo() { - int i = test234(1, - 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t128/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t128/after/Test.items deleted file mode 100644 index 24ec208dbb43..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t128/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:e.printStackTrace() : void -PsiParameter:e : Test.E -PsiReferenceExpression:e : Test.E - -Conversions: -e.printStackTrace() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t128/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t128/after/test.java deleted file mode 100644 index 8f2ad153d911..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t128/after/test.java +++ /dev/null @@ -1,16 +0,0 @@ -class Test { - static class E extends Exception { } - static class E1 extends E { } - static class E2 extends E { } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E e) { - e.printStackTrace(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t128/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t128/before/test.java deleted file mode 100644 index 33bb6bf973c1..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t128/before/test.java +++ /dev/null @@ -1,16 +0,0 @@ -class Test { - static class E extends Exception { } - static class E1 extends E { } - static class E2 extends E { } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E1 | E2 e) { - e.printStackTrace(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t129/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t129/after/Test.items deleted file mode 100644 index 8ca26492b5bd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t129/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:e.printStackTrace() : void -PsiParameter:e : Test.E1 | Test.E2 -PsiReferenceExpression:e : Test.E1 | Test.E2 - -Conversions: -e.printStackTrace() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t129/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t129/after/test.java deleted file mode 100644 index 33bb6bf973c1..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t129/after/test.java +++ /dev/null @@ -1,16 +0,0 @@ -class Test { - static class E extends Exception { } - static class E1 extends E { } - static class E2 extends E { } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E1 | E2 e) { - e.printStackTrace(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t129/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t129/before/test.java deleted file mode 100644 index 8f2ad153d911..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t129/before/test.java +++ /dev/null @@ -1,16 +0,0 @@ -class Test { - static class E extends Exception { } - static class E1 extends E { } - static class E2 extends E { } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E e) { - e.printStackTrace(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t13/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t13/after/Test.items deleted file mode 100644 index ca5cc75efa2e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t13/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : java.util.List<java.lang.Integer> -PsiMethodCallExpression:f.add("val") : boolean -PsiReferenceExpression:f : java.util.List<java.lang.Integer> - -Conversions: -f.add("val") -> $ - -New expression type changes: -Fails: -"val"->java.lang.Integer diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t13/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t13/after/test.java deleted file mode 100644 index 53b97a29e38c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t13/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -public class Test { - List<Integer> f; - void foo() { - f.add("val"); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t13/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t13/before/test.java deleted file mode 100644 index 9024eab86966..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t13/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -public class Test { - List<String> f; - void foo() { - f.add("val"); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t130/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t130/after/Test.items deleted file mode 100644 index 056ae7968e06..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t130/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiMethodCallExpression:e.printStackTrace() : void -PsiParameter:e : Test.E -PsiReferenceExpression:e : Test.E -PsiReferenceExpression:e : Test.E - -Conversions: -e.printStackTrace() -> $ - -New expression type changes: -Fails: -e->Test.E diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t130/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t130/after/test.java deleted file mode 100644 index 67ed3db2315a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t130/after/test.java +++ /dev/null @@ -1,18 +0,0 @@ -class Test { - static class E extends Exception { } - static interface I { void i(); } - static class E1 extends E implements I { public void i() { } } - static class E2 extends E implements I { public void i() { } } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E e) { - e.printStackTrace(); - e.i(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t130/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t130/before/test.java deleted file mode 100644 index 7ee7852db3d4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t130/before/test.java +++ /dev/null @@ -1,18 +0,0 @@ -class Test { - static class E extends Exception { } - static interface I { void i(); } - static class E1 extends E implements I { public void i() { } } - static class E2 extends E implements I { public void i() { } } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E1 | E2 e) { - e.printStackTrace(); - e.i(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t131/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t131/after/Test.items deleted file mode 100644 index e8d3b6152d2d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t131/after/Test.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiMethodCallExpression:e.i() : void -PsiMethodCallExpression:e.printStackTrace() : void -PsiParameter:e : Test.E2 | Test.E1 -PsiReferenceExpression:e : Test.E2 | Test.E1 -PsiReferenceExpression:e : Test.E2 | Test.E1 - -Conversions: -e.i() -> $ -e.printStackTrace() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t131/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t131/after/test.java deleted file mode 100644 index 5c02bb8a41f2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t131/after/test.java +++ /dev/null @@ -1,18 +0,0 @@ -class Test { - static class E extends Exception { } - static interface I { void i(); } - static class E1 extends E implements I { public void i() { } } - static class E2 extends E implements I { public void i() { } } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E2 | E1 e) { - e.printStackTrace(); - e.i(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t131/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t131/before/test.java deleted file mode 100644 index 7ee7852db3d4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t131/before/test.java +++ /dev/null @@ -1,18 +0,0 @@ -class Test { - static class E extends Exception { } - static interface I { void i(); } - static class E1 extends E implements I { public void i() { } } - static class E2 extends E implements I { public void i() { } } - - void m(boolean f) { - try { - if (f) - throw new E1(); - else - throw new E2(); - } catch (E1 | E2 e) { - e.printStackTrace(); - e.i(); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t132/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t132/after/Test.items deleted file mode 100644 index e5b813b90288..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t132/after/Test.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiMethodCallExpression:i.f() : void -PsiMethodCallExpression:i.f() : void -PsiParameter:i : I -PsiParameter:i : I -PsiParameter:i : I -PsiReferenceExpression:i : I -PsiReferenceExpression:i : I - -Conversions: -i.f() -> $ -i.f() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t132/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t132/after/test.java deleted file mode 100644 index 6f53c98f5459..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t132/after/test.java +++ /dev/null @@ -1,25 +0,0 @@ -interface I { - void f(); -} - -interface J extends I { - void g(); -} - -public interface Test { - void h(I i); -} - -class B implements Test { - @Override - public void h(I i) { - i.f(); - } -} - -class C implements Test { - @Override - public void h(I i) { - i.f(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t132/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t132/before/test.java deleted file mode 100644 index 2e6ab23c21d6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t132/before/test.java +++ /dev/null @@ -1,25 +0,0 @@ -interface I { - void f(); -} - -interface J extends I { - void g(); -} - -public interface Test { - void h(J i); -} - -class B implements Test { - @Override - public void h(J i) { - i.f(); - } -} - -class C implements Test { - @Override - public void h(J i) { - i.f(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t133/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t133/after/Test.items deleted file mode 100644 index 777fddf90a83..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t133/after/Test.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiMethodCallExpression:i.f() : void -PsiMethodCallExpression:i.f() : void -PsiParameter:i : I -PsiParameter:i : I -PsiParameter:i : I -PsiParameter:i : I -PsiReferenceExpression:i : I -PsiReferenceExpression:i : I - -Conversions: -i.f() -> $ -i.f() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t133/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t133/after/test.java deleted file mode 100644 index 41db920f7120..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t133/after/test.java +++ /dev/null @@ -1,33 +0,0 @@ -interface I { - void f(); -} - -interface J extends I { - void g(); -} - -public interface Test { - void h(I i); -} - -class B implements Test { - @Override - public void h(I i) { - i.f(); - } -} - -class C extends B { - @Override - public void h(I i) { - i.f(); - } -} - -abstract class F implements Test {} - -class FF extends F { - @Override - public void h(I i) { - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t133/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t133/before/test.java deleted file mode 100644 index 5599c1a59b46..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t133/before/test.java +++ /dev/null @@ -1,33 +0,0 @@ -interface I { - void f(); -} - -interface J extends I { - void g(); -} - -public interface Test { - void h(J i); -} - -class B implements Test { - @Override - public void h(J i) { - i.f(); - } -} - -class C extends B { - @Override - public void h(J i) { - i.f(); - } -} - -abstract class F implements Test {} - -class FF extends F { - @Override - public void h(J i) { - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t134/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t134/after/Test.items deleted file mode 100644 index 2880fefdc224..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t134/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiLocalVariable:i : java.lang.String -PsiParameter:a : java.lang.String -PsiReferenceExpression:a : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t134/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t134/after/test.java deleted file mode 100644 index 26cb24f419d2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t134/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void buzz(final String a, final int b, final int c) { - String i = a + b + c; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t134/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t134/before/test.java deleted file mode 100644 index 7a7760404f36..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t134/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void buzz(final int a, final int b, final int c) { - int i = a + b + c; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t135/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t135/after/Test.items deleted file mode 100644 index 4e20b05def59..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t135/after/Test.items +++ /dev/null @@ -1,16 +0,0 @@ -Types: -PsiField:bar : int -PsiField:foo : int -PsiParameter:bar : int -PsiParameter:foo : int -PsiReferenceExpression:bar : int -PsiReferenceExpression:bar : int -PsiReferenceExpression:foo : int -PsiReferenceExpression:foo : int -PsiReferenceExpression:this.bar : int -PsiReferenceExpression:this.foo : int - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t135/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t135/after/test.java deleted file mode 100644 index c992fd8569bf..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t135/after/test.java +++ /dev/null @@ -1,19 +0,0 @@ -class Test { - private int foo, bar; - - public long getFoo() { - return foo; - } - - public void setFoo(int foo) { - this.foo = foo; - } - - public long getBar() { - return bar; - } - - public void setBar(int bar) { - this.bar = bar; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t135/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t135/before/test.java deleted file mode 100644 index 756e9380835d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t135/before/test.java +++ /dev/null @@ -1,19 +0,0 @@ -class Test { - private long foo, bar; - - public long getFoo() { - return foo; - } - - public void setFoo(long foo) { - this.foo = foo; - } - - public long getBar() { - return bar; - } - - public void setBar(long bar) { - this.bar = bar; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t136/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t136/after/Test.items deleted file mode 100644 index 617357a07275..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t136/after/Test.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiLocalVariable:ints : java.util.ArrayList<java.lang.String> -PsiMethodCallExpression:ints.add(i) : boolean -PsiNewExpression:new ArrayList<Integer>() : java.util.ArrayList<java.lang.String> -PsiParameter:i : java.lang.String -PsiReferenceExpression:i : java.lang.String -PsiReferenceExpression:i : java.lang.String -PsiReferenceExpression:ints : java.util.ArrayList<java.lang.String> -PsiReferenceExpression:ints : java.util.ArrayList<java.lang.String> - -Conversions: -i -> $ -ints.add(i) -> $ - -New expression type changes: -new ArrayList<Integer>() -> java.util.ArrayList<java.lang.String> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t136/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t136/after/test.java deleted file mode 100644 index 08185f4c079c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t136/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - private void foo(String i) { - ArrayList<String> ints = new ArrayList<>(); - ints.add(i); - Object j = constantaB == null ? ints : i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t136/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t136/before/test.java deleted file mode 100644 index e66f3a5f5bfa..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t136/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - private void foo(Integer i) { - ArrayList<Integer> ints = new ArrayList<Integer>(); - ints.add(i); - Object j = constantaB == null ? ints : i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t137/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t137/after/Test.items deleted file mode 100644 index 01da876f7e94..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t137/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:i : java.lang.String -PsiReferenceExpression:i : java.lang.String - -Conversions: - -New expression type changes: -Fails: -i[0]->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t137/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t137/after/test.java deleted file mode 100644 index b2d59c1303dc..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t137/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - private void foo(String i) { - int p = i[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t137/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t137/before/test.java deleted file mode 100644 index 832535bc9440..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t137/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - private void foo(int i) { - int p = i[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t138/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t138/after/Test.items deleted file mode 100644 index 176574ab1bc0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t138/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:set : java.util.Collection<java.lang.String> -PsiReferenceExpression:set : java.util.Collection<java.lang.String> - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t138/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t138/after/test.java deleted file mode 100644 index 141e122e2ccc..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t138/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - Set<String> mySet = new HashSet(); - void foo(Collection<String> set) { - mySet.retainAll(set); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t138/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t138/before/test.java deleted file mode 100644 index 28feb3c90d4a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t138/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - Set<String> mySet = new HashSet(); - void foo(Set<String> set) { - mySet.retainAll(set); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t139/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t139/after/Test.items deleted file mode 100644 index 2fbe632fa578..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t139/after/Test.items +++ /dev/null @@ -1,7 +0,0 @@ -Types: -PsiParameter:s : java.lang.Integer - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t139/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t139/after/test.java deleted file mode 100644 index d91661b68309..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t139/after/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; - -abstract class A implements Iterable<String> {} - -class Test { - void test(A it) { - for(Integer s : it) { - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t139/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t139/before/test.java deleted file mode 100644 index f937525f52e2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t139/before/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; - -abstract class A implements Iterable<String> {} - -class Test { - void test(A it) { - for(String s : it) { - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t14/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t14/after/Test.items deleted file mode 100644 index 21635daebc66..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t14/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:f : A -PsiMethodCallExpression:f.foo() : int -PsiReferenceExpression:f : A - -Conversions: -f.foo() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t14/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t14/after/test.java deleted file mode 100644 index de034ae20adf..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t14/after/test.java +++ /dev/null @@ -1,13 +0,0 @@ -public class Test { - A f; - int bar(){ - return f.foo(); - } -} -class A { - int foo(){ - return 0; - } -} - -class B extends A{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t14/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t14/before/test.java deleted file mode 100644 index 8f6feeba681d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t14/before/test.java +++ /dev/null @@ -1,13 +0,0 @@ -public class Test { - B f; - int bar(){ - return f.foo(); - } -} -class A { - int foo(){ - return 0; - } -} - -class B extends A{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t15/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t15/after/Test.items deleted file mode 100644 index 31ff4b94b421..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t15/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : A -PsiMethodCallExpression:f.foo(f) : int -PsiReferenceExpression:f : A -PsiReferenceExpression:f : A - -Conversions: -f.foo(f) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t15/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t15/after/test.java deleted file mode 100644 index dcc5808448d5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t15/after/test.java +++ /dev/null @@ -1,16 +0,0 @@ -public class Test { - A f; - int bar(){ - return f.foo(f); - } -} -class A { - /** - * @param a - */ - int foo(A a){ - return 0; - } -} - -class B extends A{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t15/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t15/before/test.java deleted file mode 100644 index b22cc32ea85b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t15/before/test.java +++ /dev/null @@ -1,16 +0,0 @@ -public class Test { - B f; - int bar(){ - return f.foo(f); - } -} -class A { - /** - * @param a - */ - int foo(A a){ - return 0; - } -} - -class B extends A{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t16/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t16/after/Test.items deleted file mode 100644 index c0038308e560..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t16/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:f : B -PsiMethodCallExpression:f.foo(f) : B -PsiReferenceExpression:f : B -PsiReferenceExpression:f : B - -Conversions: -f -> $ -f.foo(f) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t16/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t16/after/test.java deleted file mode 100644 index 8c87396bcb3d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t16/after/test.java +++ /dev/null @@ -1,15 +0,0 @@ -class Test { - B f; - - A bar() { - return f.foo(f); - } -} -class A { - <T> T foo(T t) { - return t; - } -} - -class B extends A { -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t16/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t16/before/test.java deleted file mode 100644 index c401bf03de20..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t16/before/test.java +++ /dev/null @@ -1,15 +0,0 @@ -class Test { - A f; - - A bar() { - return f.foo(f); - } -} -class A { - <T> T foo(T t) { - return t; - } -} - -class B extends A { -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t17/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t17/after/Test.items deleted file mode 100644 index aa0aa0551659..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t17/after/Test.items +++ /dev/null @@ -1,18 +0,0 @@ -Types: -PsiField:f : B -PsiMethodCallExpression:f.foo(s) : B -PsiMethodCallExpression:s.add(f) : boolean -PsiParameter:s : java.util.Set<B> -PsiReferenceExpression:f : B -PsiReferenceExpression:f : B -PsiReferenceExpression:s : java.util.Set<B> -PsiReferenceExpression:s : java.util.Set<B> - -Conversions: -f -> $ -f.foo(s) -> $ -s -> $ -s.add(f) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t17/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t17/after/test.java deleted file mode 100644 index 73530057f21b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t17/after/test.java +++ /dev/null @@ -1,17 +0,0 @@ -import java.util.*; -class Test { - B f; - - A bar(Set<B> s) { - s.add(f); - return f.foo(s); - } -} -class A { - <T> T foo(Set<T> t) { - return null; - } -} - -class B extends A { -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t17/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t17/before/test.java deleted file mode 100644 index a425495c6065..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t17/before/test.java +++ /dev/null @@ -1,17 +0,0 @@ -import java.util.*; -class Test { - A f; - - A bar(Set<A> s) { - s.add(f); - return f.foo(s); - } -} -class A { - <T> T foo(Set<T> t) { - return null; - } -} - -class B extends A { -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t18/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t18/after/Test.items deleted file mode 100644 index 2f426a4bb9b0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t18/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : B -PsiReferenceExpression:f : B - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t18/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t18/after/test.java deleted file mode 100644 index 35d9b61c1045..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t18/after/test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.*; -class Test { - B f; - void bar(Set<A> s) { - for (String s : f) {} - } -} - -class A<Y> extends List<String> {} - -class B extends A<Integer> {}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t18/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t18/before/test.java deleted file mode 100644 index 3113a46d5dc6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t18/before/test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.*; -class Test { - A f; - void bar(Set<A> s) { - for (String s : f) {} - } -} - -class A<Y> extends List<String> {} - -class B extends A<Integer> {}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t19/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t19/after/Test.items deleted file mode 100644 index a2ec06ad3634..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t19/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : java.util.HashMap<java.lang.Integer,java.lang.Integer> -PsiLocalVariable:s : java.util.Set<java.lang.Integer> -PsiMethodCallExpression:f.keySet() : java.util.Set<java.lang.Integer> -PsiReferenceExpression:f : java.util.HashMap<java.lang.Integer,java.lang.Integer> - -Conversions: -f.keySet() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t19/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t19/after/test.java deleted file mode 100644 index 9609791bb138..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t19/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - HashMap<Integer, Integer> f; - void foo() { - Set<Integer> s = f.keySet(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t19/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t19/before/test.java deleted file mode 100644 index 815f0ed1ab3a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t19/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - Map<String, String> f; - void foo() { - Set<String> s = f.keySet(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t20/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t20/after/Test.items deleted file mode 100644 index c97038d663ce..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t20/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : java.util.Map<java.lang.String,java.lang.String> -PsiLocalVariable:s : java.util.Set<java.lang.String> -PsiMethodCallExpression:f.keySet() : java.util.Set<java.lang.String> -PsiReferenceExpression:f : java.util.Map<java.lang.String,java.lang.String> - -Conversions: -f.keySet() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t20/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t20/after/test.java deleted file mode 100644 index 815f0ed1ab3a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t20/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - Map<String, String> f; - void foo() { - Set<String> s = f.keySet(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t20/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t20/before/test.java deleted file mode 100644 index 9609791bb138..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t20/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - HashMap<Integer, Integer> f; - void foo() { - Set<Integer> s = f.keySet(); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t21/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t21/after/Test.items deleted file mode 100644 index 53630275ac1c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t21/after/Test.items +++ /dev/null @@ -1,14 +0,0 @@ -Types: -PsiField:f : java.util.Map<java.lang.String,java.util.Set<java.lang.String>> -PsiLocalVariable:stringList : java.util.Set<java.lang.String> -PsiMethodCallExpression:f.get(s) : java.util.Set<java.lang.String> -PsiMethodCallExpression:stringList.add(s) : boolean -PsiReferenceExpression:f : java.util.Map<java.lang.String,java.util.Set<java.lang.String>> -PsiReferenceExpression:stringList : java.util.Set<java.lang.String> - -Conversions: -f.get(s) -> $ -stringList.add(s) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t21/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t21/after/test.java deleted file mode 100644 index 34e758cb64d6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t21/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - Map<String, Set<String>> f; - void foo(String s) { - Set<String> stringList = f.get(s); - stringList.add(s); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t21/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t21/before/test.java deleted file mode 100644 index 1f647aff2488..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t21/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -class Test { - Map<String, List<String>> f; - void foo(String s) { - List<String> stringList = f.get(s); - stringList.add(s); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t22/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t22/after/Test.items deleted file mode 100644 index e8b61ea780ac..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t22/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:f : java.lang.Integer -PsiParameter:s : java.lang.Integer -PsiReferenceExpression:f : java.lang.Integer - -Conversions: -f -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t22/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t22/after/test.java deleted file mode 100644 index affc2b3da86f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t22/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -class Test { - Integer f; - void foo(Integer s) {} - - void bar() { - foo(f); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t22/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t22/before/test.java deleted file mode 100644 index 24b0b43cb5a2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t22/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -class Test { - String f; - void foo(String... s) {} - - void bar() { - foo(f); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t23/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t23/after/Test.items deleted file mode 100644 index 99507129472e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t23/after/Test.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiField:f : HashMap<java.lang.String,java.util.List<java.lang.String>> -PsiLocalVariable:set : java.util.List<java.lang.String> -PsiMethodCallExpression:f.get(s) : java.util.List<java.lang.String> -PsiMethodCallExpression:f.put(s, set) : java.util.List<java.lang.String> -PsiMethodCallExpression:set.add(s1) : boolean -PsiReferenceExpression:f : HashMap<java.lang.String,java.util.List<java.lang.String>> -PsiReferenceExpression:f : HashMap<java.lang.String,java.util.List<java.lang.String>> -PsiReferenceExpression:set : java.util.List<java.lang.String> -PsiReferenceExpression:set : java.util.List<java.lang.String> -PsiReferenceExpression:set : java.util.List<java.lang.String> -PsiReferenceExpression:set : java.util.List<java.lang.String> - -Conversions: -f.get(s) -> $ -f.put(s, set) -> $ -set -> $ -set.add(s1) -> $ - -New expression type changes: -Fails: -new HashSet<String>()->java.util.List<java.lang.String> diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t23/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t23/after/test.java deleted file mode 100644 index df9ad40dc0e9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t23/after/test.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.*; -class Test { - HashMap<String, List<String>> f; - - void foo(String s, String s1) { - List<String> set = f.get(s); - if (set == null) { - set = new HashSet<String>(); - f.put(s, set); - } - set.add(s1); - } -} - -class HashMap<K, V> extends java.util.HashMap<K, V>{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t23/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t23/before/test.java deleted file mode 100644 index a99eafcc46dc..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t23/before/test.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.*; -class Test { - HashMap<String, Set<String>> f; - - void foo(String s, String s1) { - Set<String> set = f.get(s); - if (set == null) { - set = new HashSet<String>(); - f.put(s, set); - } - set.add(s1); - } -} - -class HashMap<K, V> extends java.util.HashMap<K, V>{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t24/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t24/after/Test.items deleted file mode 100644 index 21962d201ce2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t24/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : D -PsiReferenceExpression:f : D - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t24/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t24/after/test.java deleted file mode 100644 index 6e0abdb55348..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t24/after/test.java +++ /dev/null @@ -1,14 +0,0 @@ -public class Test { - D f; - C foo() { - return null; - } -} -class B extends Test { - C foo() { - return f; - } -} - -class C {} -class D extends C{} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t24/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t24/before/test.java deleted file mode 100644 index 536dfc3ebd30..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t24/before/test.java +++ /dev/null @@ -1,14 +0,0 @@ -public class Test { - C f; - C foo() { - return null; - } -} -class B extends Test { - C foo() { - return f; - } -} - -class C {} -class D extends C{} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t25/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t25/after/Test.items deleted file mode 100644 index 21962d201ce2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t25/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : D -PsiReferenceExpression:f : D - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t25/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t25/after/test.java deleted file mode 100644 index b06e456332d8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t25/after/test.java +++ /dev/null @@ -1,15 +0,0 @@ -public class Test { - D f; - C foo() { - return f; - } -} - -class B extends Test { - C foo() { - return null; - } -} - -class C {} -class D extends C{} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t25/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t25/before/test.java deleted file mode 100644 index 2994877fade8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t25/before/test.java +++ /dev/null @@ -1,15 +0,0 @@ -public class Test { - C f; - C foo() { - return f; - } -} - -class B extends Test { - C foo() { - return null; - } -} - -class C {} -class D extends C{} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t26/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t26/after/Test.items deleted file mode 100644 index eae7ba330dd9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t26/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : D -PsiParameter:c : D -PsiParameter:c : D -PsiReferenceExpression:c : D -PsiReferenceExpression:f : D - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t26/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t26/after/test.java deleted file mode 100644 index ee47caa11464..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t26/after/test.java +++ /dev/null @@ -1,15 +0,0 @@ -class Test { - D f; - void foo(D c) { - f = c; - } -} - -class B extends Test { - void foo(D c) { - - } -} - -class C {} -class D extends C{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t26/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t26/before/test.java deleted file mode 100644 index 581f5fa3bc83..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t26/before/test.java +++ /dev/null @@ -1,15 +0,0 @@ -class Test { - C f; - void foo(C c) { - f = c; - } -} - -class B extends Test { - void foo(C c) { - - } -} - -class C {} -class D extends C{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t27/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t27/after/Test.items deleted file mode 100644 index eae7ba330dd9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t27/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : D -PsiParameter:c : D -PsiParameter:c : D -PsiReferenceExpression:c : D -PsiReferenceExpression:f : D - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t27/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t27/after/test.java deleted file mode 100644 index 5eb0cb2d97b9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t27/after/test.java +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - D f; - void foo(D c) {} -} - -class B extends Test { - void foo(D c) { - f = c; - } -} - -class C {} -class D extends C{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t27/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t27/before/test.java deleted file mode 100644 index a18da122856d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t27/before/test.java +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - C f; - void foo(C c) {} -} - -class B extends Test { - void foo(C c) { - f = c; - } -} - -class C {} -class D extends C{}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t28/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t28/after/Test.items deleted file mode 100644 index 80d6c0c3bf37..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t28/after/Test.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiField:f : java.lang.String[] -PsiMethodCallExpression:f.size() : int -PsiMethodCallExpression:f.toArray(new String[f.size()]) : java.lang.String[] -PsiReferenceExpression:f : java.lang.String[] -PsiReferenceExpression:f : java.lang.String[] - -Conversions: -f.size() -> $qualifier$.length $qualifier$.size() -f.toArray(new String[f.size()]) -> $qualifier$ $qualifier$.toArray($expr$) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t28/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t28/after/test.java deleted file mode 100644 index 0b1e27daa0ee..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t28/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - String[] f; - String[] get() { - return f; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t28/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t28/before/test.java deleted file mode 100644 index 43c040a3baf4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t28/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List<String> f; - String[] get() { - return f.toArray(new String[f.size()]); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t29/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t29/after/Test.items deleted file mode 100644 index 5b040a6aaa19..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t29/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiMethod:get : java.util.List<java.lang.String> - -Conversions: -f.toArray(new String[f.size()]) -> $qualifier$ $qualifier$.toArray($expr$) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t29/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t29/after/test.java deleted file mode 100644 index 23a1f11f461e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t29/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List<String> f; - List<String> get() { - return f; - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t29/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t29/before/test.java deleted file mode 100644 index 43c040a3baf4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t29/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List<String> f; - String[] get() { - return f.toArray(new String[f.size()]); - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t30/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t30/after/Test.items deleted file mode 100644 index cfd748933e5d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t30/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:f : java.lang.String[] -PsiMethodCallExpression:f.size() : int -PsiReferenceExpression:f : java.lang.String[] - -Conversions: -f.size() -> $qualifier$.length $qualifier$.size() - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t30/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t30/after/test.java deleted file mode 100644 index 28f71fc98c82..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t30/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.*; -class Test { - String[] f; - void foo() { - for (int i = 0; i < f.length; i++) { - - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t30/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t30/before/test.java deleted file mode 100644 index 5317e2164e7b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t30/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.*; -class Test { - List<String> f; - void foo() { - for (int i = 0; i < f.size(); i++) { - - } - } -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t31/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t31/after/Test.items deleted file mode 100644 index 7459a22f27d0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t31/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.lang.Object -PsiReferenceExpression:f : java.lang.Object - -Conversions: - -New expression type changes: -Fails: -f->java.lang.Object diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t31/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t31/after/test.java deleted file mode 100644 index ec7fb8e9807d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t31/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -class Test { - Object f; - void foo(){} - - void bar() { - f.foo(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t31/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t31/before/test.java deleted file mode 100644 index b8c08fdfd786..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t31/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -class Test { - Test f; - void foo(){} - - void bar() { - f.foo(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t32/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t32/after/Test.items deleted file mode 100644 index 5638ea15f4a6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t32/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:i : int - -Conversions: -#bar(long) -> PsiMethod:bar - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t32/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t32/after/test.java deleted file mode 100644 index 27e7eeb25258..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t32/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -/** -* {@link #bar(int)} -*/ -class Test { - - void bar(int i) {} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t32/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t32/before/test.java deleted file mode 100644 index a98179d5054c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t32/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -/** -* {@link #bar(long)} -*/ -class Test { - - void bar(long i) {} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t33/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t33/after/Test.items deleted file mode 100644 index df8f4d2c09d4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t33/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:l : java.util.List<java.lang.Integer> -PsiNewExpression:new ArrayList<String>() : java.util.ArrayList<java.lang.Integer> -PsiReferenceExpression:l : java.util.List<java.lang.Integer> - -Conversions: - -New expression type changes: -new ArrayList<String>() -> java.util.ArrayList<java.lang.Integer> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t33/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t33/after/test.java deleted file mode 100644 index 126292ad9322..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t33/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List<Integer> l; - void foo() { - l = new ArrayList<>(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t33/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t33/before/test.java deleted file mode 100644 index f604f9185e2d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t33/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List<String> l; - void foo() { - l = new ArrayList<String>(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t34/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t34/after/Test.items deleted file mode 100644 index d9f0bafc62d7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t34/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:l : java.util.AbstractList<java.lang.String> -PsiNewExpression:new ArrayList<String>() : java.util.ArrayList<java.lang.String> -PsiReferenceExpression:l : java.util.AbstractList<java.lang.String> - -Conversions: - -New expression type changes: -new ArrayList<String>() -> java.util.ArrayList<java.lang.String> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t34/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t34/after/test.java deleted file mode 100644 index 954f507013c6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t34/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - AbstractList<String> l; - void foo() { - l = new ArrayList<>(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t34/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t34/before/test.java deleted file mode 100644 index f604f9185e2d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t34/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List<String> l; - void foo() { - l = new ArrayList<String>(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t35/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t35/after/Test.items deleted file mode 100644 index 2b28dc8c0984..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t35/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:myParent : TestImpl -PsiParameter:parent : TestImpl -PsiParameter:parent : TestImpl -PsiReferenceExpression:myParent : TestImpl -PsiReferenceExpression:parent : TestImpl -PsiReferenceExpression:parent : TestImpl - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t35/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t35/after/test.java deleted file mode 100644 index b575a53519c4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t35/after/test.java +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - TestImpl myParent; - - public Test(TestImpl parent) { - myParent = parent; - } - - class TestImpl extends Test { - public TestImpl(TestImpl parent) { - super(parent); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t35/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t35/before/test.java deleted file mode 100644 index 83f66b0bea7c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t35/before/test.java +++ /dev/null @@ -1,13 +0,0 @@ -class Test { - Test myParent; - - public Test(Test parent) { - myParent = parent; - } - - class TestImpl extends Test { - public TestImpl(Test parent) { - super(parent); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t36/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t36/after/Test.items deleted file mode 100644 index 521251a0dd37..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t36/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:i : byte -PsiReferenceExpression:i : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t36/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t36/after/test.java deleted file mode 100644 index 8fd62fdc775d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t36/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void foo(byte i) { - long j = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t36/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t36/before/test.java deleted file mode 100644 index 1cbff3a1272c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t36/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void foo(int i) { - long j = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t37/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t37/after/Test.items deleted file mode 100644 index 26c064a26ffa..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t37/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiParameter:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t37/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t37/after/test.java deleted file mode 100644 index 032dc398e040..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t37/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - void foo(int i) { - int i1 = i + 1; - int i2 = i - 1; - int i3 = i >> 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t37/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t37/before/test.java deleted file mode 100644 index 2cc80bd340ed..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t37/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - void foo(short i) { - int i1 = i + 1; - int i2 = i - 1; - int i3 = i >> 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t38/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t38/after/Test.items deleted file mode 100644 index ce5df8ea5fcb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t38/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiParameter:i : long -PsiReferenceExpression:i : long -PsiReferenceExpression:i : long -PsiReferenceExpression:i : long - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t38/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t38/after/test.java deleted file mode 100644 index 7ef08a9041c0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t38/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - void foo(long i) { - int i1 = i + 1; - int i2 = i - 1; - int i3 = i >> 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t38/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t38/before/test.java deleted file mode 100644 index 7ef08a9041c0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t38/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - void foo(long i) { - int i1 = i + 1; - int i2 = i - 1; - int i3 = i >> 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t39/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t39/after/Test.items deleted file mode 100644 index 3c746805c0f1..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t39/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiParameter:i : byte -PsiReferenceExpression:i : byte -PsiReferenceExpression:i : byte -PsiReferenceExpression:i : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t39/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t39/after/test.java deleted file mode 100644 index 0b59f99cc084..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t39/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - void foo(byte i) { - int i1 = i + 1; - int i2 = i - 1; - int i3 = i >> 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t39/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t39/before/test.java deleted file mode 100644 index 7ef08a9041c0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t39/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - void foo(long i) { - int i1 = i + 1; - int i2 = i - 1; - int i3 = i >> 1; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t40/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t40/after/Test.items deleted file mode 100644 index 2aff3bd8c623..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t40/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:l : java.util.ArrayList -PsiReferenceExpression:l : java.util.ArrayList - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t40/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t40/after/test.java deleted file mode 100644 index 83cae108fdd9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t40/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - ArrayList l; - void foo() { - l = new ArrayList(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t40/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t40/before/test.java deleted file mode 100644 index dd72766db414..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t40/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List l; - void foo() { - l = new ArrayList(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t41/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t41/after/Test.items deleted file mode 100644 index 583812d7778b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t41/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:l : java.util.ArrayList -PsiNewExpression:new ArrayList<String>() : java.util.ArrayList<java.lang.String> -PsiReferenceExpression:l : java.util.ArrayList - -Conversions: - -New expression type changes: -new ArrayList<String>() -> java.util.ArrayList<java.lang.String> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t41/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t41/after/test.java deleted file mode 100644 index 3ac0475a9e96..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t41/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - ArrayList l; - void foo() { - l = new ArrayList<String>(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t41/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t41/before/test.java deleted file mode 100644 index 8b8b5018717b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t41/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List l; - void foo() { - l = new ArrayList<String>(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t42/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t42/after/Test.items deleted file mode 100644 index d1417fa9ad32..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t42/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:l : java.util.ArrayList<java.lang.String> -PsiNewExpression:new ArrayList() : java.util.ArrayList -PsiReferenceExpression:l : java.util.ArrayList<java.lang.String> - -Conversions: - -New expression type changes: -new ArrayList() -> java.util.ArrayList -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t42/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t42/after/test.java deleted file mode 100644 index 0dd8c405b1d9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t42/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - ArrayList<String> l; - void foo() { - l = new ArrayList(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t42/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t42/before/test.java deleted file mode 100644 index dd72766db414..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t42/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; -class Test { - List l; - void foo() { - l = new ArrayList(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t43/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t43/after/Test.items deleted file mode 100644 index b1e94aa2143b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t43/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:o : java.lang.Long - -Conversions: -l -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t43/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t43/after/test.java deleted file mode 100644 index c386bc247acd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t43/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -class Test { - long l; - Long o = l; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t43/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t43/before/test.java deleted file mode 100644 index d7e1595d92bb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t43/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -class Test { - long l; - Object o = l; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t44/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t44/after/Test.items deleted file mode 100644 index 3cae6713c3b0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t44/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:i : byte -PsiReferenceExpression:i : byte - -Conversions: -l -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t44/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t44/after/test.java deleted file mode 100644 index 60a560399b71..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t44/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - long l; - byte i; - void foo() { - l = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t44/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t44/before/test.java deleted file mode 100644 index 4dee20b44e33..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t44/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - long l; - int i; - void foo() { - l = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t45/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t45/after/Test.items deleted file mode 100644 index c97169454693..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t45/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:i : byte -PsiField:l : byte -PsiReferenceExpression:i : byte -PsiReferenceExpression:l : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t45/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t45/after/test.java deleted file mode 100644 index 45fcb1f6eb1f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t45/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - byte l; - byte i; - void foo() { - l = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t45/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t45/before/test.java deleted file mode 100644 index 4dee20b44e33..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t45/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -class Test { - long l; - int i; - void foo() { - l = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t46/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t46/after/Test.items deleted file mode 100644 index 934d4a09ec3b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t46/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:j : int - -Conversions: -i -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t46/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t46/after/test.java deleted file mode 100644 index f77f19689836..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t46/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -class Test { - byte i; - int j = i; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t46/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t46/before/test.java deleted file mode 100644 index 5256726fdd95..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t46/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -class Test { - byte i; - long j = i; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t47/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t47/after/Test.items deleted file mode 100644 index d39a160ee9a7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t47/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:o : int - -Conversions: - -New expression type changes: -Fails: -null->int diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t47/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t47/after/test.java deleted file mode 100644 index 99f4d773fd24..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t47/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - int o = null; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t47/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t47/before/test.java deleted file mode 100644 index 308305e1cb41..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t47/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Object o = null; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t48/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t48/after/Test.items deleted file mode 100644 index fedb3311ad6b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t48/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiLocalVariable:set : java.util.Set<B> -PsiParameter:s : java.util.AbstractSet<B> -PsiReferenceExpression:s : java.util.AbstractSet<B> - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t48/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t48/after/test.java deleted file mode 100644 index 60e1a9ddd8c7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t48/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.*; -class Test { - void foo(AbstractSet<B> s) { - Set<B> set = s; - } - - class A {} - class B extends A{} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t48/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t48/before/test.java deleted file mode 100644 index e859716610c8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t48/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.*; -class Test { - void foo(AbstractSet<A> s) { - Set<A> set = s; - } - - class A {} - class B extends A{} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t49/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t49/after/Test.items deleted file mode 100644 index b65d6bce02d1..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t49/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:f : java.util.Set<B> -PsiParameter:s : java.util.AbstractSet<B> -PsiReferenceExpression:f : java.util.Set<B> -PsiReferenceExpression:s : java.util.AbstractSet<B> - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t49/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t49/after/test.java deleted file mode 100644 index 91c41afa26e2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t49/after/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; -class Test { - Set<B> f; - void foo(AbstractSet<B> s) { - f = s; - } - - class A {} - class B extends A{} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t49/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t49/before/test.java deleted file mode 100644 index 8a2a9a9054ce..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t49/before/test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.*; -class Test { - Set<A> f; - void foo(AbstractSet<A> s) { - f = s; - } - - class A {} - class B extends A{} -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t50/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t50/after/Test.items deleted file mode 100644 index 895bdd4d4118..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t50/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:c : java.util.Set<? extends JButton> -PsiField:c1 : java.util.Set<? extends JButton> -PsiReferenceExpression:c : java.util.Set<? extends JButton> - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t50/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t50/after/test.java deleted file mode 100644 index 50d5fb0229ca..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t50/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -import java.util.*; -class Test { - Set<? extends JButton> c; - Set<? extends JButton> c1 = c; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t50/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t50/before/test.java deleted file mode 100644 index 05b20ee8b1fe..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t50/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -import java.util.*; -class Test { - Set<? extends JComponent> c; - Set<? extends JComponent> c1 = c; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t51/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t51/after/Test.items deleted file mode 100644 index 81f430c2e8ab..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t51/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:f : java.lang.Object[] -PsiNewExpression:new String[] {"a"} : java.lang.Object[] - -Conversions: -"a" -> $ - -New expression type changes: -new String[] {"a"} -> java.lang.Object[] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t51/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t51/after/test.java deleted file mode 100644 index bbd211f73928..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t51/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Object[] f = new Object[] {"a"}; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t51/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t51/before/test.java deleted file mode 100644 index 7a9a090c342f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t51/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - String[] f = new String[] {"a"}; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t52/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t52/after/Test.items deleted file mode 100644 index fae3f5aa0b83..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t52/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : java.lang.Object[] -PsiNewExpression:new Set() : java.util.Set -PsiNewExpression:new Set[] { new Set() } : java.lang.Object[] - -Conversions: - -New expression type changes: -new Set() -> java.util.Set -new Set[] { new Set() } -> java.lang.Object[] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t52/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t52/after/test.java deleted file mode 100644 index 034f9e2a7285..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t52/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - Object[] f = new Object[] { new Set() }; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t52/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t52/before/test.java deleted file mode 100644 index abf3b7a12aff..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t52/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - Set[] f = new Set[] { new Set() }; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t53/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t53/after/Test.items deleted file mode 100644 index 6f10a470aef3..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t53/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : java.util.Set<java.lang.String>[] - -Conversions: - -New expression type changes: -Fails: -new double[0]->java.util.Set<java.lang.String>[] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t53/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t53/after/test.java deleted file mode 100644 index 52d1899803c8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t53/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - Set<String>[] f = new double[0]; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t53/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t53/before/test.java deleted file mode 100644 index 50be5aada106..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t53/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - double[] f = new double[0]; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t54/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t54/after/Test.items deleted file mode 100644 index 584021476055..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t54/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.util.Set<? extends java.lang.Integer> -PsiNewExpression:new Set<Object>() : java.util.Set<java.lang.Integer> - -Conversions: - -New expression type changes: -new Set<Object>() -> java.util.Set<java.lang.Integer> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t54/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t54/after/test.java deleted file mode 100644 index 11cbc3fe7520..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t54/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - Set<? extends Integer> f = new Set<>(); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t54/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t54/before/test.java deleted file mode 100644 index 96573db084dd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t54/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - Set<Object> f = new Set<Object>(); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t55/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t55/after/Test.items deleted file mode 100644 index 465e20e4a213..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t55/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.util.Set<?> -PsiNewExpression:new Set<Object>() : java.util.Set<java.lang.Object> - -Conversions: - -New expression type changes: -new Set<Object>() -> java.util.Set<java.lang.Object> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t55/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t55/after/test.java deleted file mode 100644 index c895ff398fa6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t55/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - Set<?> f = new Set<>(); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t55/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t55/before/test.java deleted file mode 100644 index 96573db084dd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t55/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -class Test { - Set<Object> f = new Set<Object>(); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t56/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t56/after/Test.items deleted file mode 100644 index 05ed851f0ce0..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t56/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiParameter:i : double -PsiReferenceExpression:i : double -PsiReferenceExpression:i : double - -Conversions: - -New expression type changes: -Fails: -i->double -i->double diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t56/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t56/after/test.java deleted file mode 100644 index 2f5cc73acbbb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t56/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - void foo(double i) { - int[] a = new int[i]; - System.out.println(a[i]); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t56/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t56/before/test.java deleted file mode 100644 index 0f9888806c18..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t56/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - void foo(int i) { - int[] a = new int[i]; - System.out.println(a[i]); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t57/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t57/after/Test.items deleted file mode 100644 index af2ecf9c114e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t57/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:i : byte -PsiReferenceExpression:i : byte -PsiReferenceExpression:i : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t57/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t57/after/test.java deleted file mode 100644 index ce9df2fbb45d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t57/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - void foo(byte i) { - int[] a = new int[i]; - System.out.println(a[i]); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t57/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t57/before/test.java deleted file mode 100644 index 0f9888806c18..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t57/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - void foo(int i) { - int[] a = new int[i]; - System.out.println(a[i]); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t58/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t58/after/Test.items deleted file mode 100644 index 19b07a44c139..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t58/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : java.lang.Object - -Conversions: -new String[1] -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t58/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t58/after/test.java deleted file mode 100644 index ff4055ac3129..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t58/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Object f = new String[1]; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t58/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t58/before/test.java deleted file mode 100644 index 8df4d62d721a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t58/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - String[] f = new String[1]; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t59/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t59/after/Test.items deleted file mode 100644 index ea0dda8061b2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t59/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : java.lang.Cloneable - -Conversions: -new String[1] -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t59/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t59/after/test.java deleted file mode 100644 index 78a09afee42b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t59/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Cloneable f = new String[1]; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t59/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t59/before/test.java deleted file mode 100644 index 8df4d62d721a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t59/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - String[] f = new String[1]; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t60/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t60/after/Test.items deleted file mode 100644 index 88822343977c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t60/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:p : java.lang.Object -PsiReferenceExpression:p : java.lang.Object - -Conversions: -i -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t60/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t60/after/test.java deleted file mode 100644 index 9ab940eaf425..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t60/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - Object p; - void foo(int... i) { - p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t60/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t60/before/test.java deleted file mode 100644 index 26172c13d2e7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t60/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - int[] p; - void foo(int... i) { - p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t61/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t61/after/Test.items deleted file mode 100644 index 830074d65d6b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t61/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiLocalVariable:p : int[] -PsiParameter:i : int... -PsiReferenceExpression:i : int[] - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t61/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t61/after/test.java deleted file mode 100644 index 1b05fce5b5b9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t61/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void foo(int... i) { - int[] p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t61/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t61/before/test.java deleted file mode 100644 index e9f49f1c3846..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t61/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void foo(int i) { - int p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t62/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t62/after/Test.items deleted file mode 100644 index 88822343977c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t62/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:p : java.lang.Object -PsiReferenceExpression:p : java.lang.Object - -Conversions: -i -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t62/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t62/after/test.java deleted file mode 100644 index 9ab940eaf425..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t62/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - Object p; - void foo(int... i) { - p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t62/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t62/before/test.java deleted file mode 100644 index 26172c13d2e7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t62/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - int[] p; - void foo(int... i) { - p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t63/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t63/after/Test.items deleted file mode 100644 index 69dcdaf945c5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t63/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiField:p : double[] -PsiParameter:i : double[] -PsiReferenceExpression:i : double[] -PsiReferenceExpression:p : double[] - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t63/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t63/after/test.java deleted file mode 100644 index 9602f0b3d59f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t63/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - double[] p; - void foo(double[] i) { - p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t63/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t63/before/test.java deleted file mode 100644 index 26172c13d2e7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t63/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - int[] p; - void foo(int... i) { - p = i; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t64/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t64/after/Test.items deleted file mode 100644 index 8ae72a21d857..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t64/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiLocalVariable:p : int -PsiParameter:i : int -PsiReferenceExpression:i : int - -Conversions: - -New expression type changes: -Fails: -foo(1, 2)->int diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t64/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t64/after/test.java deleted file mode 100644 index 29f4004383eb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t64/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - void foo(int i) { - int p = i; - } - - void bar() { - foo(1, 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t64/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t64/before/test.java deleted file mode 100644 index 5583e3c06a5d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t64/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - void foo(int... i) { - int[] p = i; - } - - void bar() { - foo(1, 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t65/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t65/after/Test.items deleted file mode 100644 index a1201587163f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t65/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiLocalVariable:p : java.lang.String -PsiParameter:i : java.lang.String -PsiReferenceExpression:i : java.lang.String - -Conversions: - -New expression type changes: -Fails: -1->java.lang.String -2->java.lang.String -foo(1, 2)->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t65/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t65/after/test.java deleted file mode 100644 index 3532ce557f8c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t65/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - void foo(String i) { - String p = i; - } - - void bar() { - foo(1, 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t65/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t65/before/test.java deleted file mode 100644 index 5583e3c06a5d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t65/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - void foo(int... i) { - int[] p = i; - } - - void bar() { - foo(1, 2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t66/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t66/after/Test.items deleted file mode 100644 index f8bf3a92ff7d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t66/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiLocalVariable:p : int -PsiParameter:i : int -PsiReferenceExpression:i : int - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t66/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t66/after/test.java deleted file mode 100644 index 56608039cf5e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t66/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - void foo(int i) { - int p = i; - } - - void bar() { - foo(1); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t66/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t66/before/test.java deleted file mode 100644 index 45ea51dddf11..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t66/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - void foo(int... i) { - int[] p = i; - } - - void bar() { - foo(1); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t67/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t67/after/Test.items deleted file mode 100644 index 0e5e72eb6f30..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t67/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:myForAccess : java.lang.String -PsiMethod:forAccess : java.lang.String -PsiMethodCallExpression:this.forAccess() : java.lang.String -PsiParameter:p : java.lang.String -PsiReferenceExpression:myForAccess : java.lang.String -PsiReferenceExpression:p : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t67/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t67/after/test.java deleted file mode 100644 index 8a4fda4a0fac..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t67/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - private String myForAccess; - private String forAccess() { - return myForAccess; - } - public void methMemAcc(String p) { - p = this.forAccess(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t67/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t67/before/test.java deleted file mode 100644 index 57a1c5db091b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t67/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - private Object myForAccess; - private Object forAccess() { - return myForAccess; - } - public void methMemAcc(Object p) { - p = this.forAccess(); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t68/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t68/after/Test.items deleted file mode 100644 index e31709e870fb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t68/after/Test.items +++ /dev/null @@ -1,17 +0,0 @@ -Types: -PsiArrayInitializerExpression:{p} : double[] -PsiArrayInitializerExpression:{p} : double[] -PsiArrayInitializerExpression:{{p},{p}} : double[][] -PsiLocalVariable:a : double[][] -PsiNewExpression:new int[][]{{p},{p}} : double[][] -PsiParameter:p : double -PsiReferenceExpression:p : double -PsiReferenceExpression:p : double - -Conversions: -p -> $ -p -> $ - -New expression type changes: -new int[][]{{p},{p}} -> double[][] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t68/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t68/after/test.java deleted file mode 100644 index f9d9a9257c5d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t68/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void foo(double p) { - double[][] a = new double[][]{{p},{p}}; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t68/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t68/before/test.java deleted file mode 100644 index 9f84d15cc993..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t68/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void foo(int p) { - int[][] a = new int[][]{{p},{p}}; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t69/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t69/after/Test.items deleted file mode 100644 index 6471629f221e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t69/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : byte -PsiReferenceExpression:p : byte -PsiReferenceExpression:p : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t69/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t69/after/test.java deleted file mode 100644 index bba00df7f5ed..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t69/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void foo(byte p) { - int[][] a = new int[][]{{p},{p}}; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t69/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t69/before/test.java deleted file mode 100644 index 9f84d15cc993..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t69/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void foo(int p) { - int[][] a = new int[][]{{p},{p}}; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t70/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t70/after/Test.items deleted file mode 100644 index 9811dea4870e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t70/after/Test.items +++ /dev/null @@ -1,18 +0,0 @@ -Types: -PsiArrayInitializerExpression:{p} : float[] -PsiArrayInitializerExpression:{p} : float[] -PsiArrayInitializerExpression:{{p}, {p}} : float[][] -PsiField:a : float[][] -PsiNewExpression:new int[][]{{p}, {p}} : float[][] -PsiParameter:p : float -PsiReferenceExpression:a : float[][] -PsiReferenceExpression:p : float -PsiReferenceExpression:p : float - -Conversions: -p -> $ -p -> $ - -New expression type changes: -new int[][]{{p}, {p}} -> float[][] -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t70/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t70/after/test.java deleted file mode 100644 index 7ef5f832a7d9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t70/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - float[][] a; - public void foo(float p) { - a = new float[][]{{p}, {p}}; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t70/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t70/before/test.java deleted file mode 100644 index d98804a2576f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t70/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -class Test { - int[][] a; - public void foo(int p) { - a = new int[][]{{p}, {p}}; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t71/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t71/after/Test.items deleted file mode 100644 index f65db392b622..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t71/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : java.lang.Class<? extends java.lang.Number> - -Conversions: -byte.class -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t71/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t71/after/test.java deleted file mode 100644 index be0143bbaafb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t71/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Class<? extends Number> f = byte.class; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t71/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t71/before/test.java deleted file mode 100644 index e3c0a3aecee2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t71/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Class f = byte.class; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t72/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t72/after/Test.items deleted file mode 100644 index cacd1729289d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t72/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f : java.lang.Class<java.lang.Integer> - -Conversions: - -New expression type changes: -Fails: -byte.class->java.lang.Class<java.lang.Integer> diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t72/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t72/after/test.java deleted file mode 100644 index ace9fbcc92a8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t72/after/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Class<Integer> f = byte.class; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t72/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t72/before/test.java deleted file mode 100644 index e3c0a3aecee2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t72/before/test.java +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - Class f = byte.class; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t73/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t73/after/Test.items deleted file mode 100644 index f46b39d67281..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t73/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiArrayInitializerExpression:{} : java.util.Set<java.awt.Component>[] -PsiField:f : java.util.Set<java.awt.Component>[][] - -Conversions: - -New expression type changes: -Fails: -new Set[][]{{}}->java.util.Set<java.awt.Component>[][] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t73/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t73/after/test.java deleted file mode 100644 index da9d9b2e6fe8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t73/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -import javax.swing.*; -import java.awt.*; -class Test { - Set<Component>[][] f = new Set[][]{{}}; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t73/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t73/before/test.java deleted file mode 100644 index b07764b2c29f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t73/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -import javax.swing.*; -import java.awt.*; -class Test { - Set<JComponent>[][] f = new Set[][]{{}}; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t74/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t74/after/Test.items deleted file mode 100644 index 236f769a7b98..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t74/after/Test.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiLocalVariable:v1 : float -PsiLocalVariable:v2 : float -PsiLocalVariable:v3 : float -PsiLocalVariable:v4 : float -PsiLocalVariable:vu1 : float -PsiLocalVariable:vu2 : float -PsiLocalVariable:vu3 : float -PsiParameter:pi : float -PsiReferenceExpression:pi : float -PsiReferenceExpression:pi : float -PsiReferenceExpression:pi : float -PsiReferenceExpression:pi : float -PsiReferenceExpression:pi : float -PsiReferenceExpression:pi : float -PsiReferenceExpression:pi : float - -Conversions: - -New expression type changes: -Fails: -~pi->float diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t74/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t74/after/test.java deleted file mode 100644 index 25d776d7d8c6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t74/after/test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - public void meth(float pi) { - float v1 = pi++; - float v2 = pi--; - float v3 = ++pi; - float v4 = --pi; - float vu1 = -pi; - float vu2 = +pi; - float vu3 = ~pi; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t74/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t74/before/test.java deleted file mode 100644 index c6e83eedc1bd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t74/before/test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - public void meth(int pi) { - int v1 = pi++; - int v2 = pi--; - int v3 = ++pi; - int v4 = --pi; - int vu1 = -pi; - int vu2 = +pi; - int vu3 = ~pi; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t75/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t75/after/Test.items deleted file mode 100644 index 9c3eb7b369e3..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t75/after/Test.items +++ /dev/null @@ -1,38 +0,0 @@ -Types: -PsiLocalVariable:vn4 : java.lang.String -PsiParameter:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String -PsiReferenceExpression:pn : java.lang.String - -Conversions: - -New expression type changes: -Fails: -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String -pn->java.lang.String diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t75/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t75/after/test.java deleted file mode 100644 index 750c3d1d51a4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t75/after/test.java +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - public void meth(String pn) { - int vn1 = pn * pn; - int vn2 = pn / pn; - int vn3 = pn % pn; - String vn4 = pn + pn; - int vn5 = pn - pn; - int vn6 = pn << pn; - int vn7 = pn >> pn; - int vn8 = pn >>> pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t75/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t75/before/test.java deleted file mode 100644 index fdde94165b43..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t75/before/test.java +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - public void meth(byte pn) { - int vn1 = pn * pn; - int vn2 = pn / pn; - int vn3 = pn % pn; - int vn4 = pn + pn; - int vn5 = pn - pn; - int vn6 = pn << pn; - int vn7 = pn >> pn; - int vn8 = pn >>> pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t76/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t76/after/Test.items deleted file mode 100644 index 7a2163c3200b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t76/after/Test.items +++ /dev/null @@ -1,37 +0,0 @@ -Types: -PsiLocalVariable:vn1 : float -PsiLocalVariable:vn2 : float -PsiLocalVariable:vn3 : float -PsiLocalVariable:vn4 : float -PsiLocalVariable:vn5 : float -PsiLocalVariable:vn6 : float -PsiLocalVariable:vn7 : float -PsiLocalVariable:vn8 : float -PsiParameter:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float -PsiReferenceExpression:pn : float - -Conversions: - -New expression type changes: -Fails: -pn->float -pn->float -pn->float -pn->float -pn->float -pn->float diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t76/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t76/after/test.java deleted file mode 100644 index 3e6b69cf7c94..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t76/after/test.java +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - public void meth(float pn) { - float vn1 = pn * pn; - float vn2 = pn / pn; - float vn3 = pn % pn; - float vn4 = pn + pn; - float vn5 = pn - pn; - float vn6 = pn << pn; - float vn7 = pn >> pn; - float vn8 = pn >>> pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t76/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t76/before/test.java deleted file mode 100644 index fdde94165b43..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t76/before/test.java +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - public void meth(byte pn) { - int vn1 = pn * pn; - int vn2 = pn / pn; - int vn3 = pn % pn; - int vn4 = pn + pn; - int vn5 = pn - pn; - int vn6 = pn << pn; - int vn7 = pn >> pn; - int vn8 = pn >>> pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t77/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t77/after/Test.items deleted file mode 100644 index dc0f44202f9b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t77/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:pn : java.lang.Object -PsiReferenceExpression:pn : java.lang.Object - -Conversions: - -New expression type changes: -Fails: -pn->java.lang.Object diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t77/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t77/after/test.java deleted file mode 100644 index 4e8733a49d43..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t77/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(Object pn, int p) { - p += pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t77/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t77/before/test.java deleted file mode 100644 index 252a45c4acc5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t77/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(int pn, int p) { - p += pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t78/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t78/after/Test.items deleted file mode 100644 index f935ec3be774..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t78/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiParameter:p : java.lang.String -PsiParameter:pn : java.lang.String -PsiReferenceExpression:p : java.lang.String -PsiReferenceExpression:pn : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t78/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t78/after/test.java deleted file mode 100644 index 573deb573d11..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t78/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(String pn, String p) { - p += pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t78/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t78/before/test.java deleted file mode 100644 index 252a45c4acc5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t78/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(int pn, int p) { - p += pn; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t79/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t79/after/Test.items deleted file mode 100644 index 9e7dba8b794e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t79/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:p : byte -PsiReferenceExpression:p : byte - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t79/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t79/after/test.java deleted file mode 100644 index 37ec2cb0f5fd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t79/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(byte p) { - float f = (float)p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t79/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t79/before/test.java deleted file mode 100644 index 30db2da5fa91..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t79/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(int p) { - float f = (float)p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t80/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t80/after/Test.items deleted file mode 100644 index 55661712f811..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t80/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:p : double -PsiReferenceExpression:p : double - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t80/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t80/after/test.java deleted file mode 100644 index 5fe4738b6a5e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t80/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(double p) { - float f = (float)p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t80/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t80/before/test.java deleted file mode 100644 index 30db2da5fa91..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t80/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(int p) { - float f = (float)p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t81/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t81/after/Test.items deleted file mode 100644 index f89012c7c140..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t81/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:o : A -PsiReferenceExpression:o : A - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t81/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t81/after/test.java deleted file mode 100644 index 55deae9424fa..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t81/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class A {} - -class B extends A {} - -class Test { - void foo(A o) { - if (o instanceof B){} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t81/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t81/before/test.java deleted file mode 100644 index 8bccf86ced7b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t81/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -class A {} - -class B extends A {} - -class Test { - void foo(Object o) { - if (o instanceof B){} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t82/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t82/after/Test.items deleted file mode 100644 index 5164a4b2f6d9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t82/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:o : C -PsiReferenceExpression:o : C - -Conversions: - -New expression type changes: -Fails: -o->C diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t82/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t82/after/test.java deleted file mode 100644 index 83b747a3cb27..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t82/after/test.java +++ /dev/null @@ -1,11 +0,0 @@ -class C{} - -class A {} - -class B extends A {} - -class Test { - void foo(C o) { - if (o instanceof B){} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t82/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t82/before/test.java deleted file mode 100644 index cb617f44766f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t82/before/test.java +++ /dev/null @@ -1,11 +0,0 @@ -class C{} - -class A {} - -class B extends A {} - -class Test { - void foo(Object o) { - if (o instanceof B){} - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t83/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t83/after/Test.items deleted file mode 100644 index 9f0dab259a44..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t83/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiParameter:p : java.lang.Object -PsiReferenceExpression:p : java.lang.Object - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t83/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t83/after/test.java deleted file mode 100644 index 2a6715c81d3f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t83/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(Object p) { - float f = (float)p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t83/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t83/before/test.java deleted file mode 100644 index 30db2da5fa91..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t83/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - public void meth(int p) { - float f = (float)p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t84/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t84/after/Test.items deleted file mode 100644 index 5f64399bef41..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t84/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiLocalVariable:f : java.util.Set<? extends java.util.Set> -PsiParameter:p : java.util.Set<? extends java.util.Set> -PsiReferenceExpression:p : java.util.Set<? extends java.util.Set> - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t84/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t84/after/test.java deleted file mode 100644 index b055ef3a4df9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t84/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -class Test { - public void meth(Set<? extends Set> p) { - Set<? extends Set> f = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t84/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t84/before/test.java deleted file mode 100644 index 7c85f93d7a57..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t84/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -class Test { - public void meth(Set p) { - Set<Set> f = p; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t85/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t85/after/Test.items deleted file mode 100644 index 76d7b14baa5d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t85/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:str : java.lang.Integer -PsiMethod:get : java.lang.Integer -PsiReferenceExpression:str : java.lang.Integer -PsiReferenceExpression:str : java.lang.Integer -PsiReferenceExpression:str : java.lang.Integer - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t85/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t85/after/test.java deleted file mode 100644 index c43a426e5277..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t85/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Test { - - Integer str; - Integer get(boolean f) { - return f ? str : str + str; - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t85/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t85/before/test.java deleted file mode 100644 index adde8623a884..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t85/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -public class Test { - - String str; - String get(boolean f) { - return f ? str : str + str; - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t86/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t86/after/Test.items deleted file mode 100644 index c2f8f1dd9fa6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t86/after/Test.items +++ /dev/null @@ -1,18 +0,0 @@ -Types: -PsiArrayAccessExpression:array[i] : java.lang.String -PsiArrayAccessExpression:array[i] : java.lang.String -PsiLocalVariable:array : java.util.List<java.lang.String> -PsiMethod:getArray : java.util.List<java.lang.String> -PsiMethodCallExpression:getArray() : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array.length : int - -Conversions: -array.length -> $qualifier$.size() $qualifier$.length -array[i] -> $qualifier$.get($idx$) $qualifier$[$idx$] -array[i] -> $qualifier$.set($idx$, $expr$) $qualifier$[$idx$] = $expr$ array[i] = "" - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t86/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t86/after/test.java deleted file mode 100644 index 25f8b851603d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t86/after/test.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.List; -public class Test { - - List<String> getArray(){ - return null; - } - - void foo() { - List<String> array = getArray(); - for (int i = 0; i < array.size(); i++) { - System.out.println(array.get(i)); - array.set(i, ""); - } - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t86/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t86/before/test.java deleted file mode 100644 index 880c69463055..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t86/before/test.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.List; -public class Test { - - String[] getArray(){ - return null; - } - - void foo() { - String[] array = getArray(); - for (int i = 0; i < array.length; i++) { - System.out.println(array[i]); - array[i] = ""; - } - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t87/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t87/after/Test.items deleted file mode 100644 index 45193ce9dcf4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t87/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiLocalVariable:array : java.lang.String[] -PsiMethod:getArray : java.lang.String[] -PsiMethodCallExpression:getArray() : java.lang.String[] -PsiReferenceExpression:array : java.lang.String[] - -Conversions: -array -> Arrays.sort($qualifier$) Collections.sort($qualifier$) Collections.sort(array) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t87/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t87/after/test.java deleted file mode 100644 index f0e5159bfcfd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t87/after/test.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.*; -public class Test { - - String[] getArray(){ - return null; - } - - void foo() { - String[] array = getArray(); - Arrays.sort(array); - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t87/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t87/before/test.java deleted file mode 100644 index 12a28fa3084c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t87/before/test.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.*; -public class Test { - - List<String> getArray(){ - return null; - } - - void foo() { - List<String> array = getArray(); - Collections.sort(array); - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t88/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t88/after/Test.items deleted file mode 100644 index 60ae50f9c699..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t88/after/Test.items +++ /dev/null @@ -1,15 +0,0 @@ -Types: -PsiLocalVariable:array : java.util.List<java.lang.String> -PsiMethod:getArray : java.util.List<java.lang.String> -PsiMethodCallExpression:getArray() : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> - -Conversions: -array -> Collections.sort($qualifier$, $expr$) Arrays.sort($qualifier$, $expr$) Arrays.sort(array, new Comparator<String>() { - public int compare(String s1, String s2) { - return 0; - } - }) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t88/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t88/after/test.java deleted file mode 100644 index 4be724c5d907..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t88/after/test.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.*; -public class Test { - - List<String> getArray(){ - return null; - } - - void foo() { - List<String> array = getArray(); - Collections.sort(array, new Comparator<String>() { - public int compare(String s1, String s2) { - return 0; - } - }); - - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t88/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t88/before/test.java deleted file mode 100644 index ce19bd33f20e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t88/before/test.java +++ /dev/null @@ -1,18 +0,0 @@ -import java.util.*; -public class Test { - - String[] getArray(){ - return null; - } - - void foo() { - String[] array = getArray(); - Arrays.sort(array, new Comparator<String>() { - public int compare(String s1, String s2) { - return 0; - } - }); - - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t89/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t89/after/Test.items deleted file mode 100644 index 069dfb76e5c3..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t89/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiLocalVariable:array : java.lang.String[] -PsiMethod:getArray : java.lang.String[] -PsiMethodCallExpression:getArray() : java.lang.String[] -PsiReferenceExpression:array : java.lang.String[] - -Conversions: - -New expression type changes: -Fails: -array->java.lang.String[] diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t89/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t89/after/test.java deleted file mode 100644 index 5a625c53c286..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t89/after/test.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.*; -public class Test { - - String[] getArray(){ - return null; - } - - void foo() { - String[] array = getArray(); - Collections.checkedList(array, String.class); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t89/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t89/before/test.java deleted file mode 100644 index c12161d8c76d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t89/before/test.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.*; -public class Test { - - List<String> getArray(){ - return null; - } - - void foo() { - List<String> array = getArray(); - Collections.checkedList(array, String.class); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t90/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t90/after/Test.items deleted file mode 100644 index 721469c186fa..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t90/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:l : java.util.List<A> -PsiMethodCallExpression:b.foo() : java.util.Map<java.lang.String,java.lang.String> -PsiParameter:b : A -PsiReferenceExpression:b : A -PsiReferenceExpression:l : java.util.List<A> - -Conversions: -b.foo() -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t90/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t90/after/test.java deleted file mode 100644 index 06c072088b02..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t90/after/test.java +++ /dev/null @@ -1,24 +0,0 @@ -import java.util.*; -public class Test { - List<A> l; - - @Override - Map<String, String> foo() { - HashMap<String, String> m = new HashMap<String, String>(); - for (A b : l) { - Map<String, String> map = b.foo(); - for (Map.Entry<String, String> entry : map.entrySet()) { - if (!m.containsKey(entry.getKey())) { - m.put(entry.getKey(), entry.getValue()); - } - } - } - return m; - } -} - -class A { - Map<String, String> foo(){return null;} -} - -class B extends A {}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t90/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t90/before/test.java deleted file mode 100644 index 80afdc6aa08b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t90/before/test.java +++ /dev/null @@ -1,24 +0,0 @@ -import java.util.*; -public class Test { - List<B> l; - - @Override - Map<String, String> foo() { - HashMap<String, String> m = new HashMap<String, String>(); - for (B b : l) { - Map<String, String> map = b.foo(); - for (Map.Entry<String, String> entry : map.entrySet()) { - if (!m.containsKey(entry.getKey())) { - m.put(entry.getKey(), entry.getValue()); - } - } - } - return m; - } -} - -class A { - Map<String, String> foo(){return null;} -} - -class B extends A {}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t91/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t91/after/Test.items deleted file mode 100644 index 9b53aeaf2084..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t91/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiMethod:foo : java.lang.String[] - -Conversions: -"" -> new java.lang.String[]{$qualifier$} $qualifier$ "" - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t91/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t91/after/test.java deleted file mode 100644 index 9575d720b844..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t91/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Test { - String[] foo(){ - return new String[]{""}; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t91/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t91/before/test.java deleted file mode 100644 index e916bd0a5dab..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t91/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Test { - String foo(){ - return ""; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t92/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t92/after/Test.items deleted file mode 100644 index bf241c7966a7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t92/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.util.List<java.lang.Integer> -PsiNewExpression:new ArrayList<String>(){} : java.util.ArrayList<java.lang.Integer> - -Conversions: - -New expression type changes: -new ArrayList<String>(){} -> java.util.ArrayList<java.lang.Integer> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t92/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t92/after/test.java deleted file mode 100644 index f70bc9515dea..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t92/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -public class Test { - List<Integer> f = new ArrayList<Integer>(){}; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t92/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t92/before/test.java deleted file mode 100644 index 89ae1f7d3101..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t92/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.*; -public class Test { - List<String> f = new ArrayList<String>(){}; -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t93/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t93/after/Test.items deleted file mode 100644 index ea2fc9440478..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t93/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:f : java.util.Map<java.lang.Boolean,java.lang.String> -PsiParameter:b : boolean -PsiReferenceExpression:b : boolean -PsiReferenceExpression:f : java.util.Map<java.lang.Boolean,java.lang.String> - -Conversions: -f -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t93/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t93/after/test.java deleted file mode 100644 index 6b714f8e8862..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t93/after/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - Map<Boolean, String> f; - - void foo(boolean b) { - f.put(b, null); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t93/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t93/before/test.java deleted file mode 100644 index 292b5f9f0361..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t93/before/test.java +++ /dev/null @@ -1,8 +0,0 @@ -import java.util.*; -public class Test { - Map<Boolean, String> f; - - void foo(Boolean b) { - f.put(b, null); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t94/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t94/after/Test.items deleted file mode 100644 index 76ae2a02000b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t94/after/Test.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiLocalVariable:array : java.lang.String[] -PsiMethod:getArray : java.lang.String[] -PsiMethodCallExpression:getArray() : java.lang.String[] -PsiReferenceExpression:array : java.lang.String[] -PsiReferenceExpression:array : java.lang.String[] - -Conversions: -array -> Arrays.binarySearch($qualifier$, $key$) Collections.binarySearch($qualifier$, $key$) Collections.binarySearch(array, "") -array -> Arrays.sort($qualifier$) Collections.sort($qualifier$) Collections.sort(array) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t94/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t94/after/test.java deleted file mode 100644 index d8df3e65dd43..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t94/after/test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; -public class Test { - - String[] getArray(){ - return null; - } - - void foo() { - String[] array = getArray(); - Arrays.binarySearch(array, ""); - Arrays.sort(array); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t94/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t94/before/test.java deleted file mode 100644 index 99bf050d6f00..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t94/before/test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; -public class Test { - - List<String> getArray(){ - return null; - } - - void foo() { - List<String> array = getArray(); - Collections.binarySearch(array, ""); - Collections.sort(array); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t95/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t95/after/Test.items deleted file mode 100644 index d3f8033938ea..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t95/after/Test.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiLocalVariable:array : java.util.List<java.lang.String> -PsiMethod:getArray : java.util.List<java.lang.String> -PsiMethodCallExpression:getArray() : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> - -Conversions: -array -> Collections.binarySearch($qualifier$, $key$) Arrays.binarySearch($qualifier$, $key$) Arrays.binarySearch(array, "") -array -> Collections.sort($qualifier$) Arrays.sort($qualifier$) Arrays.sort(array) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t95/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t95/after/test.java deleted file mode 100644 index 99bf050d6f00..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t95/after/test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; -public class Test { - - List<String> getArray(){ - return null; - } - - void foo() { - List<String> array = getArray(); - Collections.binarySearch(array, ""); - Collections.sort(array); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t95/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t95/before/test.java deleted file mode 100644 index d8df3e65dd43..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t95/before/test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.*; -public class Test { - - String[] getArray(){ - return null; - } - - void foo() { - String[] array = getArray(); - Arrays.binarySearch(array, ""); - Arrays.sort(array); - } - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t96/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t96/after/Test.items deleted file mode 100644 index d107b7626a41..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t96/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f1 : java.lang.String -PsiField:f2 : java.lang.String -PsiReferenceExpression:f1 : java.lang.String - -Conversions: - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t96/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t96/after/test.java deleted file mode 100644 index 25357fd46118..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t96/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Test { - String f1 = null; - String f2 = f1; - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t96/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t96/before/test.java deleted file mode 100644 index 55d7110ccb83..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t96/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -public class Test { - Integer f1 = null; - Integer f2 = f1; - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t97/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t97/after/Test.items deleted file mode 100644 index 1d376856a7ac..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t97/after/Test.items +++ /dev/null @@ -1,8 +0,0 @@ -Types: -PsiField:f1 : int - -Conversions: - -New expression type changes: -Fails: -{0}->int diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t97/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t97/after/test.java deleted file mode 100644 index 61687e78d725..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t97/after/test.java +++ /dev/null @@ -1,4 +0,0 @@ -public class Test { - int f1 = {0}; - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t97/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t97/before/test.java deleted file mode 100644 index f33899c2c3d7..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t97/before/test.java +++ /dev/null @@ -1,4 +0,0 @@ -public class Test { - Integer[] f1 = {0}; - -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t98/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t98/after/Test.items deleted file mode 100644 index 9b5e0b6b54e9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t98/after/Test.items +++ /dev/null @@ -1,21 +0,0 @@ -Types: -PsiArrayAccessExpression:array[i] : java.lang.String -PsiArrayAccessExpression:array[i] : java.lang.String -PsiArrayAccessExpression:array[i] : java.lang.String -PsiLocalVariable:array : java.util.List<java.lang.String> -PsiMethod:getArray : java.util.List<java.lang.String> -PsiMethodCallExpression:getArray() : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array : java.util.List<java.lang.String> -PsiReferenceExpression:array.length : int - -Conversions: -array.length -> $qualifier$.size() $qualifier$.length -array[i] -> $qualifier$.get($idx$) $qualifier$[$idx$] -array[i] -> $qualifier$.get($idx$) $qualifier$[$idx$] -array[i] -> $qualifier$.get($idx$) $qualifier$[$idx$] - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t98/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t98/after/test.java deleted file mode 100644 index 86e1e0b4f6c2..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t98/after/test.java +++ /dev/null @@ -1,17 +0,0 @@ -import java.util.List; -public class Test { - - List<String> getArray(){ - return null; - } - - void foo(String param) { - List<String> array = getArray(); - for (int i = 0; i < array.size(); i++) { - System.out.println(array.get(i)); - String str = array.get(i); - param = array.get(i); - } - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t98/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t98/before/test.java deleted file mode 100644 index b79f9495d4ac..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t98/before/test.java +++ /dev/null @@ -1,17 +0,0 @@ -import java.util.List; -public class Test { - - String[] getArray(){ - return null; - } - - void foo(String param) { - String[] array = getArray(); - for (int i = 0; i < array.length; i++) { - System.out.println(array[i]); - String str = array[i]; - param = array[i]; - } - } - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t99/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/t99/after/Test.items deleted file mode 100644 index 93ca5aa6a01e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t99/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:f : java.util.Set<java.util.List<int[]>> -PsiNewExpression:new Set<List<char[]>>() : java.util.Set<java.util.List<int[]>> - -Conversions: - -New expression type changes: -new Set<List<char[]>>() -> java.util.Set<java.util.List<int[]>> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t99/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t99/after/test.java deleted file mode 100644 index 1f7b49a490d9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t99/after/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -public class Test { - Set<List<int[]>> f = new Set<>(); - - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/t99/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/t99/before/test.java deleted file mode 100644 index 7ae6a2b492ba..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/t99/before/test.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.*; -public class Test { - Set<List<char[]>> f = new Set<List<char[]>>(); - - -} diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/after/Test.items deleted file mode 100644 index ab263cc2b7a6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:list : java.util.Collection<java.lang.Integer> -PsiNewExpression:new ArrayList<>(2) : java.util.ArrayList<java.lang.Integer> - -Conversions: - -New expression type changes: -new ArrayList<>(2) -> java.util.ArrayList<java.lang.Integer> -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/after/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/after/test.java deleted file mode 100644 index 7d25d562b91d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/after/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.annotation.*; -import java.util.*; - -@Target(value = ElementType.TYPE_USE) -public @interface TA { } - -class Test { - Collection<@TA Integer> list = new ArrayList<>(2); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/before/test.java b/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/before/test.java deleted file mode 100644 index 6cc51471d8d8..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigration/typeAnno/before/test.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.lang.annotation.*; -import java.util.*; - -@Target(value = ElementType.TYPE_USE) -public @interface TA { } - -class Test { - ArrayList<@TA Integer> list = new ArrayList<>(2); -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.items deleted file mode 100644 index 9d1b1894378f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.items +++ /dev/null @@ -1,25 +0,0 @@ -Types: -PsiAssignmentExpression:i += 2 : java.util.concurrent.atomic.AtomicInteger -PsiAssignmentExpression:i -= 5 : java.util.concurrent.atomic.AtomicInteger -PsiBinaryExpression:i + 9 : int -PsiBinaryExpression:i - 9 : int -PsiBinaryExpression:i == 0 : boolean -PsiField:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger - -Conversions: -0 -> new java.util.concurrent.atomic.AtomicInteger($val$) $val$ -9 -> $qualifier$.set($val$) $qualifier$ = $val$ i = 9 -i + 9 -> $qualifier$.get() + $val$ $qualifier$+$val$ -i += 2 -> $qualifier$.getAndAdd(($val$)) $qualifier$ += $val$ -i - 9 -> $qualifier$.get() - $val$ $qualifier$-$val$ -i -= 5 -> $qualifier$.getAndAdd(-($val$)) $qualifier$ -= $val$ -i == 0 -> $qualifier$.get() == $val$ $qualifier$==$val$ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.java deleted file mode 100644 index 5c16607a8b70..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/after/Test.java +++ /dev/null @@ -1,16 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -class Test { - AtomicInteger i = new AtomicInteger(0); - - void foo() { - i.getAndAdd((2)); - i.getAndAdd(-(5)); - if (i.get() == 0) { - i.set(9); - } - - System.out.println(i.get() + 9); - System.out.println(i.get() - 9); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/before/Test.java deleted file mode 100644 index b96f02057dfd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directAssignments/before/Test.java +++ /dev/null @@ -1,14 +0,0 @@ -class Test { - int i = 0; - - void foo() { - i += 2; - i -= 5; - if (i == 0) { - i = 9; - } - - System.out.println(i + 9); - System.out.println(i - 9); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/after/Test.items deleted file mode 100644 index e0e121ecf00d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/after/Test.items +++ /dev/null @@ -1,19 +0,0 @@ -Types: -PsiAssignmentExpression:b += 0 : java.util.concurrent.atomic.AtomicReference<java.lang.Byte> -PsiBinaryExpression:b == 0 : boolean -PsiField:b : java.util.concurrent.atomic.AtomicReference<java.lang.Byte> -PsiPostfixExpression:b++ : java.util.concurrent.atomic.AtomicReference<java.lang.Byte> -PsiReferenceExpression:b : java.util.concurrent.atomic.AtomicReference<java.lang.Byte> -PsiReferenceExpression:b : java.util.concurrent.atomic.AtomicReference<java.lang.Byte> -PsiReferenceExpression:b : java.util.concurrent.atomic.AtomicReference<java.lang.Byte> -PsiReferenceExpression:b : java.util.concurrent.atomic.AtomicReference<java.lang.Byte> - -Conversions: -0 -> new java.util.concurrent.atomic.AtomicReference<java.lang.Byte>((byte)$val$) $val$ -b += 0 -> $qualifier$.set(new Byte((byte)($qualifier$.get() + $val$))) $qualifier$+=$val$ -b -> $qualifier$.get() $qualifier$ b -b == 0 -> $qualifier$.get() == $val$ $qualifier$==$val$ -b++ -> $qualifier$.getAndSet(new Byte((byte)($qualifier$.get() + 1))) $qualifier$++ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/after/Test.java deleted file mode 100644 index a1dbfc714326..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/after/Test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.concurrent.atomic.AtomicReference; - -class Test { - AtomicReference<Byte> b = new AtomicReference<Byte>((byte) 0); - - void bar() { - if (b.get() == 0) { - b.getAndSet(new Byte((byte) (b.get() + 1))); - b.set(new Byte((byte) (b.get() + 0))); - //System.out.println(b + 10); - System.out.println(b.get()); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/before/Test.java deleted file mode 100644 index fa494c28a3c4..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directByte/before/Test.java +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - byte b = 0; - - void bar() { - if (b == 0) { - b++; - b += 0; - //System.out.println(b + 10); - System.out.println(b); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/after/Test.items deleted file mode 100644 index 95f366691485..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:b : java.util.concurrent.atomic.AtomicBoolean -PsiReferenceExpression:b : java.util.concurrent.atomic.AtomicBoolean -PsiReferenceExpression:b : java.util.concurrent.atomic.AtomicBoolean - -Conversions: -b -> $qualifier$.get() $qualifier$ b -true -> $qualifier$.set($val$) $qualifier$ = $val$ b = true - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/after/Test.java deleted file mode 100644 index 02fc40276a86..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicBoolean; - -class Test { - AtomicBoolean b; - - void foo() { - if (b.get()) { - b.set(true); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/before/Test.java deleted file mode 100644 index ef5413600c40..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directConditions/before/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - boolean b; - - void foo() { - if (b) { - b = true; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/after/Test.items deleted file mode 100644 index add3ea1f98e3..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiField:lst : java.util.concurrent.atomic.AtomicReference<java.util.List<java.lang.String>> -PsiReferenceExpression:lst : java.util.concurrent.atomic.AtomicReference<java.util.List<java.lang.String>> - -Conversions: -lst -> $qualifier$.get() $qualifier$ lst - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/after/Test.java deleted file mode 100644 index 4db9a5619849..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/after/Test.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.util.*; -import java.util.concurrent.atomic.AtomicReference; - -class Test { - AtomicReference<List<String>> lst; - - void foo() { - for (String s : lst.get()) { - System.out.println(s); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/before/Test.java deleted file mode 100644 index 1d40f4082444..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directForeach/before/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.*; - -class Test { - List<String> lst; - - void foo() { - for (String s : lst) { - System.out.println(s); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/after/Test.items deleted file mode 100644 index 852aa470a285..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/after/Test.items +++ /dev/null @@ -1,25 +0,0 @@ -Types: -PsiField:i : java.util.concurrent.atomic.AtomicInteger -PsiPostfixExpression:i++ : java.util.concurrent.atomic.AtomicInteger -PsiPostfixExpression:i++ : java.util.concurrent.atomic.AtomicInteger -PsiPostfixExpression:i-- : java.util.concurrent.atomic.AtomicInteger -PsiPrefixExpression:++i : java.util.concurrent.atomic.AtomicInteger -PsiPrefixExpression:--i : java.util.concurrent.atomic.AtomicInteger -PsiPrefixExpression:--i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger -PsiReferenceExpression:i : java.util.concurrent.atomic.AtomicInteger - -Conversions: -++i -> $qualifier$.incrementAndGet() ++$qualifier$ ---i -> $qualifier$.decrementAndGet() --$qualifier$ ---i -> $qualifier$.decrementAndGet() --$qualifier$ -i++ -> $qualifier$.getAndIncrement() $qualifier$++ -i++ -> $qualifier$.getAndIncrement() $qualifier$++ -i-- -> $qualifier$.getAndDecrement() $qualifier$-- - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/after/Test.java deleted file mode 100644 index bdcf7171016b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/after/Test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; - -class Test { - AtomicInteger i; - - void foo() { - i.getAndIncrement(); - i.incrementAndGet(); - i.getAndDecrement(); - i.decrementAndGet(); - System.out.println(i.getAndIncrement()); - System.out.println(i.decrementAndGet()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/before/Test.java deleted file mode 100644 index be6aa55d5f29..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIncrementDecrement/before/Test.java +++ /dev/null @@ -1,12 +0,0 @@ -class Test { - int i; - - void foo() { - i++; - ++i; - i--; - --i; - System.out.println(i++); - System.out.println(--i); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/after/Test.items deleted file mode 100644 index 69a66c34a6cb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/after/Test.items +++ /dev/null @@ -1,34 +0,0 @@ -Types: -PsiArrayAccessExpression:a[0] : int -PsiArrayAccessExpression:a[0] : int -PsiArrayAccessExpression:a[0] : int -PsiArrayAccessExpression:a[0] : int -PsiArrayAccessExpression:a[0] : int -PsiArrayAccessExpression:a[0] : int -PsiArrayAccessExpression:a[0] : int -PsiArrayAccessExpression:a[0] : int -PsiField:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray -PsiReferenceExpression:a : java.util.concurrent.atomic.AtomicIntegerArray - -Conversions: -a[0] -> $qualifier$.decrementAndGet($idx$) --$qualifier$[$idx$] --a[0] -a[0] -> $qualifier$.get($idx$) $qualifier$[$idx$] a[0] -a[0] -> $qualifier$.get($idx$) $qualifier$[$idx$] a[0] -a[0] -> $qualifier$.getAndAdd($idx$, ($val$)) $qualifier$[$idx$] += $val$ a[0] += (2) -a[0] -> $qualifier$.getAndDecrement($idx$) $qualifier$[$idx$]-- a[0]-- -a[0] -> $qualifier$.getAndIncrement($idx$) $qualifier$[$idx$]++ a[0]++ -a[0] -> $qualifier$.incrementAndGet($idx$) ++$qualifier$[$idx$] ++a[0] -a[0] -> $qualifier$.set($idx$, $qualifier$.get($idx$) * $val$) $qualifier$[$idx$]*=$val$ a[0] *= 2 -new int[0] -> new java.util.concurrent.atomic.AtomicIntegerArray($val$) $val$ new int[0] -new int[1] -> new java.util.concurrent.atomic.AtomicIntegerArray($val$) $val$ new int[1] - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/after/Test.java deleted file mode 100644 index 8dbba12048fe..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/after/Test.java +++ /dev/null @@ -1,20 +0,0 @@ -import java.util.concurrent.atomic.AtomicIntegerArray; - -class Test { - AtomicIntegerArray a = new AtomicIntegerArray(new int[1]); - - - void foo() { - a.getAndIncrement(0); - System.out.println(a.incrementAndGet(0)); - a.getAndDecrement(0); - if (a.decrementAndGet(0) == 0) { - a.getAndAdd(0, ((2))); - a.set(0, a.get(0) * 2); - if (a.get(0) == 0) { - System.out.println(a.get(0) + 7); - } - } - a = new AtomicIntegerArray(new int[0]); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/before/Test.java deleted file mode 100644 index 5d39cf2963c6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directIntArray/before/Test.java +++ /dev/null @@ -1,18 +0,0 @@ -class Test { - int[] a = new int[1]; - - - void foo() { - a[0]++; - System.out.println(++a[0]); - a[0]--; - if (--a[0] == 0) { - a[0] += (2); - a[0] *= 2; - if (a[0] == 0) { - System.out.println(a[0] + 7); - } - } - a = new int[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/after/Test.items deleted file mode 100644 index 0d306b0b4747..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:s : java.util.concurrent.atomic.AtomicReference<java.lang.String> -PsiReferenceExpression:s : java.util.concurrent.atomic.AtomicReference<java.lang.String> -PsiReferenceExpression:s : java.util.concurrent.atomic.AtomicReference<java.lang.String> - -Conversions: -"" -> new java.util.concurrent.atomic.AtomicReference<java.lang.String>($val$) $val$ -s -> $qualifier$.get() $qualifier$ s - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/after/Test.java deleted file mode 100644 index cb32e0ba130b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicReference; - -class Test { - AtomicReference<String> s = new AtomicReference<String>(""); - - void foo() { - if (s == null) { - System.out.println(s.get()); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/before/Test.java deleted file mode 100644 index 1770416a0295..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directString/before/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - String s = ""; - - void foo() { - if (s == null) { - System.out.println(s); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/after/Test.items deleted file mode 100644 index b90b4a347f40..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/after/Test.items +++ /dev/null @@ -1,14 +0,0 @@ -Types: -PsiArrayAccessExpression:s[0] : java.lang.String -PsiArrayAccessExpression:s[0] : java.lang.String -PsiField:s : java.util.concurrent.atomic.AtomicReferenceArray<java.lang.String> -PsiReferenceExpression:s : java.util.concurrent.atomic.AtomicReferenceArray<java.lang.String> -PsiReferenceExpression:s : java.util.concurrent.atomic.AtomicReferenceArray<java.lang.String> - -Conversions: -new String[2] -> new java.util.concurrent.atomic.AtomicReferenceArray<java.lang.String>($val$) $val$ new String[2] -s[0] -> $qualifier$.get($idx$) $qualifier$[$idx$] s[0] -s[0] -> $qualifier$.set($idx$, $val$) $qualifier$[$idx$] = $val$ s[0] = "" - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/after/Test.java deleted file mode 100644 index 42415d0c3141..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicReferenceArray; - -class Test { - AtomicReferenceArray<String> s = new AtomicReferenceArray<String>(new String[2]); - - void foo() { - s.set(0, ""); - System.out.println(s.get(0)); - - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/before/Test.java deleted file mode 100644 index 4f19feba6479..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/directStringArray/before/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - String[] s = new String[2]; - - void foo() { - s[0] = ""; - System.out.println(s[0]); - - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/after/Test.items deleted file mode 100644 index 767993764c48..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/after/Test.items +++ /dev/null @@ -1,26 +0,0 @@ -Types: -PsiField:i : int -PsiMethodCallExpression:i.addAndGet(-(9)) : int -PsiMethodCallExpression:i.addAndGet(9) : int -PsiMethodCallExpression:i.get() : int -PsiMethodCallExpression:i.getAndAdd(-5) : int -PsiMethodCallExpression:i.getAndAdd(2) : int -PsiMethodCallExpression:i.set(9) : void -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int - -Conversions: -i.addAndGet(-(9)) -> $qualifier$ + $delta$ $qualifier$.addAndGet($delta$) -i.addAndGet(9) -> $qualifier$ + $delta$ $qualifier$.addAndGet($delta$) -i.get() -> $qualifier$ $qualifier$.get() -i.getAndAdd(-5) -> $qualifier$ += $val$ $qualifier$.getAndAdd($val$) -i.getAndAdd(2) -> $qualifier$ += $val$ $qualifier$.getAndAdd($val$) -i.set(9) -> $qualifier$ = $val$ $qualifier$.set($val$) -new AtomicInteger(0) -> $qualifier$ new $type$($qualifier$) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/after/Test.java deleted file mode 100644 index 1372ccee2b27..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/after/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; -class Test { - int i = 0; - - void foo() { - i += 2; - i += -5; - if (i == 0) { - i = 9; - } - - System.out.println(i + 9); - System.out.println(i + -(9)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/before/Test.java deleted file mode 100644 index cfd312daa073..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseAssignments/before/Test.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; -class Test { - AtomicInteger i = new AtomicInteger(0); - - void foo() { - i.getAndAdd(2); - i.getAndAdd(-5); - if (i.get() == 0) { - i.set(9); - } - - System.out.println(i.addAndGet(9)); - System.out.println(i.addAndGet(-(9))); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/after/Test.items deleted file mode 100644 index 8585bda9e020..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/after/Test.items +++ /dev/null @@ -1,26 +0,0 @@ -Types: -PsiField:b : byte -PsiMethodCallExpression:b.get() : java.lang.Byte -PsiMethodCallExpression:b.get() : java.lang.Byte -PsiMethodCallExpression:b.get() : java.lang.Byte -PsiMethodCallExpression:b.get() : java.lang.Byte -PsiMethodCallExpression:b.getAndSet(new Byte((byte) (b.get() + 1))) : java.lang.Byte -PsiMethodCallExpression:b.set(new Byte((byte) (b.get() + 0))) : void -PsiReferenceExpression:b : byte -PsiReferenceExpression:b : byte -PsiReferenceExpression:b : byte -PsiReferenceExpression:b : byte -PsiReferenceExpression:b : byte -PsiReferenceExpression:b : byte - -Conversions: -b.get() -> $qualifier$ $qualifier$.get() -b.get() -> $qualifier$ $qualifier$.get() -b.get() -> $qualifier$ $qualifier$.get() -b.get() -> $qualifier$ $qualifier$.get() -b.getAndSet(new Byte((byte) (b.get() + 1))) -> $qualifier$ = $val$ $qualifier$.getAndSet($val$) -b.set(new Byte((byte) (b.get() + 0))) -> $qualifier$ = $val$ $qualifier$.set($val$) -new AtomicReference<Byte>((byte) 0) -> $qualifier$ new $type$($qualifier$) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/after/Test.java deleted file mode 100644 index 28445dd31728..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/after/Test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.concurrent.atomic.AtomicReference; - -class Test { - byte b = (byte) 0; - - void bar() { - if (b == 0) { - b = new Byte((byte) (b + 1)); - b = new Byte((byte) (b + 0)); - //System.out.println(b + 10); - System.out.println(b); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/before/Test.java deleted file mode 100644 index a1dbfc714326..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseByte/before/Test.java +++ /dev/null @@ -1,14 +0,0 @@ -import java.util.concurrent.atomic.AtomicReference; - -class Test { - AtomicReference<Byte> b = new AtomicReference<Byte>((byte) 0); - - void bar() { - if (b.get() == 0) { - b.getAndSet(new Byte((byte) (b.get() + 1))); - b.set(new Byte((byte) (b.get() + 0))); - //System.out.println(b + 10); - System.out.println(b.get()); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/after/Test.items deleted file mode 100644 index 3594508bebe5..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/after/Test.items +++ /dev/null @@ -1,13 +0,0 @@ -Types: -PsiField:b : boolean -PsiMethodCallExpression:b.get() : boolean -PsiMethodCallExpression:b.set(true) : void -PsiReferenceExpression:b : boolean -PsiReferenceExpression:b : boolean - -Conversions: -b.get() -> $qualifier$ $qualifier$.get() -b.set(true) -> $qualifier$ = $val$ $qualifier$.set($val$) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/after/Test.java deleted file mode 100644 index 92f515c35936..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/after/Test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.concurrent.atomic.AtomicBoolean; -class Test { - boolean b; - - void foo() { - if (b) { - b = true; - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/before/Test.java deleted file mode 100644 index 5464f705ddeb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseConditions/before/Test.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.util.concurrent.atomic.AtomicBoolean; -class Test { - AtomicBoolean b; - - void foo() { - if (b.get()) { - b.set(true); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/after/Test.items deleted file mode 100644 index cba5bc10f359..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/after/Test.items +++ /dev/null @@ -1,25 +0,0 @@ -Types: -PsiField:i : int -PsiMethodCallExpression:i.decrementAndGet() : int -PsiMethodCallExpression:i.decrementAndGet() : int -PsiMethodCallExpression:i.getAndDecrement() : int -PsiMethodCallExpression:i.getAndIncrement() : int -PsiMethodCallExpression:i.getAndIncrement() : int -PsiMethodCallExpression:i.incrementAndGet() : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int -PsiReferenceExpression:i : int - -Conversions: -i.decrementAndGet() -> --$qualifier$ $qualifier$.decrementAndGet() -i.decrementAndGet() -> --$qualifier$ $qualifier$.decrementAndGet() -i.getAndDecrement() -> $qualifier$-- $qualifier$.getAndDecrement() -i.getAndIncrement() -> $qualifier$++ $qualifier$.getAndIncrement() -i.getAndIncrement() -> $qualifier$++ $qualifier$.getAndIncrement() -i.incrementAndGet() -> ++$qualifier$ $qualifier$.incrementAndGet() - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/after/Test.java deleted file mode 100644 index dd70e550a751..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/after/Test.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; -class Test { - int i; - - void foo() { - i++; - ++i; - i--; - --i; - System.out.println(i++); - System.out.println(--i); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/before/Test.java deleted file mode 100644 index 853e5387aca9..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIncrementDecrement/before/Test.java +++ /dev/null @@ -1,13 +0,0 @@ -import java.util.concurrent.atomic.AtomicInteger; -class Test { - AtomicInteger i; - - void foo() { - i.getAndIncrement(); - i.incrementAndGet(); - i.getAndDecrement(); - i.decrementAndGet(); - System.out.println(i.getAndIncrement()); - System.out.println(i.decrementAndGet()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/after/Test.items deleted file mode 100644 index 55c1c7bc2574..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/after/Test.items +++ /dev/null @@ -1,35 +0,0 @@ -Types: -PsiField:a : int[] -PsiMethodCallExpression:a.addAndGet(0, 7) : int -PsiMethodCallExpression:a.decrementAndGet(0) : int -PsiMethodCallExpression:a.get(0) : int -PsiMethodCallExpression:a.get(0) : int -PsiMethodCallExpression:a.getAndAdd(0, ((2))) : int -PsiMethodCallExpression:a.getAndDecrement(0) : int -PsiMethodCallExpression:a.getAndIncrement(0) : int -PsiMethodCallExpression:a.incrementAndGet(0) : int -PsiMethodCallExpression:a.set(0, a.get(0) * 2) : void -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] -PsiReferenceExpression:a : int[] - -Conversions: -a.addAndGet(0, 7) -> $qualifier$[$idx$] + $delta$ $qualifier$.addAndGet($idx$, $delta$) -a.decrementAndGet(0) -> --$qualifier$[$idx$] $qualifier$.decrementAndGet($idx$) -a.get(0) -> $qualifier$[$idx$] $qualifier$.get($idx$) -a.get(0) -> $qualifier$[$idx$] $qualifier$.get($idx$) -a.getAndAdd(0, ((2))) -> $qualifier$[$idx$] += $val$ $qualifier$.getAndAdd($idx$, $val$) -a.getAndDecrement(0) -> $qualifier$[$idx$]-- $qualifier$.getAndDecrement($idx$) -a.getAndIncrement(0) -> $qualifier$[$idx$]++ $qualifier$.getAndIncrement($idx$) -a.incrementAndGet(0) -> ++$qualifier$[$idx$] $qualifier$.incrementAndGet($idx$) -a.set(0, a.get(0) * 2) -> $qualifier$[$idx$] = $val$ $qualifier$.set($idx$, $val$) -new AtomicIntegerArray(new int[1]) -> $qualifier$ new $type$($qualifier$) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/after/Test.java deleted file mode 100644 index 401714230d3c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/after/Test.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.util.concurrent.atomic.AtomicIntegerArray; - -class Test { - int[] a = new int[1]; - - - void foo() { - a[0]++; - System.out.println(++a[0]); - a[0]--; - if (--a[0] == 0) { - a[0] += ((2)); - a[0] = a[0] * 2; - if (a[0] == 0) { - System.out.println(a[0] + 7); - } - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/before/Test.java deleted file mode 100644 index df31528b9d7e..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseIntArray/before/Test.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.util.concurrent.atomic.AtomicIntegerArray; - -class Test { - AtomicIntegerArray a = new AtomicIntegerArray(new int[1]); - - - void foo() { - a.getAndIncrement(0); - System.out.println(a.incrementAndGet(0)); - a.getAndDecrement(0); - if (a.decrementAndGet(0) == 0) { - a.getAndAdd(0, ((2))); - a.set(0, a.get(0) * 2); - if (a.get(0) == 0) { - System.out.println(a.addAndGet(0, 7)); - } - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/after/Test.items deleted file mode 100644 index 7c23d49d8bfd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiField:s : java.lang.String -PsiMethodCallExpression:s.get() : java.lang.String -PsiReferenceExpression:s : java.lang.String -PsiReferenceExpression:s : java.lang.String - -Conversions: -new AtomicReference<String>("") -> $qualifier$ new $type$($qualifier$) -s.get() -> $qualifier$ $qualifier$.get() - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/after/Test.java deleted file mode 100644 index a0106ff8d66f..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicReference; - -class Test { - String s = ""; - - void foo() { - if (s == null) { - System.out.println(s); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/before/Test.java deleted file mode 100644 index cb32e0ba130b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseString/before/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicReference; - -class Test { - AtomicReference<String> s = new AtomicReference<String>(""); - - void foo() { - if (s == null) { - System.out.println(s.get()); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/after/Test.items deleted file mode 100644 index eaf82b5cc2e6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/after/Test.items +++ /dev/null @@ -1,14 +0,0 @@ -Types: -PsiField:s : java.lang.String[] -PsiMethodCallExpression:s.get(0) : java.lang.String -PsiMethodCallExpression:s.set(0, "") : void -PsiReferenceExpression:s : java.lang.String[] -PsiReferenceExpression:s : java.lang.String[] - -Conversions: -new AtomicReferenceArray<String>(new String[2]) -> $qualifier$ new $type$($qualifier$) -s.get(0) -> $qualifier$[$idx$] $qualifier$.get($idx$) -s.set(0, "") -> $qualifier$[$idx$] = $val$ $qualifier$.set($idx$, $val$) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/after/Test.java deleted file mode 100644 index 0c64ea445f01..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicReferenceArray; - -class Test { - String[] s = new String[2]; - - void foo() { - s[0] = ""; - System.out.println(s[0]); - - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/before/Test.java deleted file mode 100644 index fbc97bc2eb36..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByAtomic/reverseStringArray/before/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -import java.util.concurrent.atomic.AtomicReferenceArray; - -class Test { - AtomicReferenceArray<String> s = new AtomicReferenceArray<String>(new String[2]); - - void foo() { - s.set(0, ""); - System.out.println(s.get(0)); - - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/after/Test.items deleted file mode 100644 index e01b4b5e1f8b..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/after/Test.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiBinaryExpression:i == 0 : boolean -PsiField:i : java.lang.ThreadLocal<java.lang.Byte> -PsiPostfixExpression:i++ : java.lang.ThreadLocal<java.lang.Byte> -PsiPostfixExpression:i-- : java.lang.ThreadLocal<java.lang.Byte> -PsiPrefixExpression:++i : java.lang.ThreadLocal<java.lang.Byte> -PsiPrefixExpression:--i : java.lang.ThreadLocal<java.lang.Byte> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Byte> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Byte> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Byte> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Byte> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Byte> - -Conversions: -++i -> $qualifier$.set(new java.lang.Byte((byte)($qualifier$.get() + 1))) ++$qualifier$ ---i -> $qualifier$.set(new java.lang.Byte((byte)($qualifier$.get() - 1))) --$qualifier$ -i == 0 -> $qualifier$.get() == $val$ $qualifier$==$val$ -i++ -> $qualifier$.set(new java.lang.Byte((byte)($qualifier$.get() + 1))) $qualifier$++ -i-- -> $qualifier$.set(new java.lang.Byte((byte)($qualifier$.get() - 1))) $qualifier$-- - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/after/Test.java deleted file mode 100644 index 61b88dbefceb..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - ThreadLocal<Byte> i; - - void foo() { - i.set(new Byte((byte) (i.get() + 1))); - i.set(new Byte((byte) (i.get() + 1))); - i.set(new Byte((byte) (i.get() - 1))); - i.set(new Byte((byte) (i.get() - 1))); - if (i.get() == 0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/before/Test.java deleted file mode 100644 index dd3fb1bca60d..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directByte/before/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - byte i; - - void foo() { - i++; - ++i; - i--; - --i; - if (i == 0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/after/Test.items deleted file mode 100644 index 1bffd7037cb6..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/after/Test.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiBinaryExpression:i == 0 : boolean -PsiField:i : java.lang.ThreadLocal<java.lang.Integer> -PsiPostfixExpression:i++ : java.lang.ThreadLocal<java.lang.Integer> -PsiPostfixExpression:i-- : java.lang.ThreadLocal<java.lang.Integer> -PsiPrefixExpression:++i : java.lang.ThreadLocal<java.lang.Integer> -PsiPrefixExpression:--i : java.lang.ThreadLocal<java.lang.Integer> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Integer> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Integer> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Integer> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Integer> -PsiReferenceExpression:i : java.lang.ThreadLocal<java.lang.Integer> - -Conversions: -++i -> $qualifier$.set($qualifier$.get() + 1) ++$qualifier$ ---i -> $qualifier$.set($qualifier$.get() - 1) --$qualifier$ -i == 0 -> $qualifier$.get() == $val$ $qualifier$==$val$ -i++ -> $qualifier$.set($qualifier$.get() + 1) $qualifier$++ -i-- -> $qualifier$.set($qualifier$.get() - 1) $qualifier$-- - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/after/Test.java deleted file mode 100644 index 627739bc4b1c..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - ThreadLocal<Integer> i; - - void foo() { - i.set(i.get() + 1); - i.set(i.get() + 1); - i.set(i.get() - 1); - i.set(i.get() - 1); - if (i.get() == 0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/before/Test.java deleted file mode 100644 index 9039f28e9617..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directInt/before/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - int i; - - void foo() { - i++; - ++i; - i--; - --i; - if (i == 0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/after/Test.items deleted file mode 100644 index 29d4312a8580..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiField:myS : java.lang.ThreadLocal<java.lang.String> -PsiReferenceExpression:myS : java.lang.ThreadLocal<java.lang.String> -PsiReferenceExpression:myS : java.lang.ThreadLocal<java.lang.String> - -Conversions: -myS -> $qualifier$.get() $qualifier$ myS - -New expression type changes: -Fails: -""->java.lang.ThreadLocal<java.lang.String> diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/after/Test.java deleted file mode 100644 index 949869096327..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/after/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - ThreadLocal<String> myS = ""; - - void foo() { - if (myS == null) { - System.out.println(myS.get()); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/before/Test.java deleted file mode 100644 index 8ee02790f113..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/directString/before/Test.java +++ /dev/null @@ -1,9 +0,0 @@ -class Test { - String myS = ""; - - void foo() { - if (myS == null) { - System.out.println(myS); - } - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/after/Test.items b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/after/Test.items deleted file mode 100644 index 09a2a211ae6a..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/after/Test.items +++ /dev/null @@ -1,22 +0,0 @@ -Types: -PsiBinaryExpression:i == 0 : boolean -PsiField:i : java.lang.ThreadLocal -PsiPostfixExpression:i++ : java.lang.ThreadLocal -PsiPostfixExpression:i-- : java.lang.ThreadLocal -PsiPrefixExpression:++i : java.lang.ThreadLocal -PsiPrefixExpression:--i : java.lang.ThreadLocal -PsiReferenceExpression:i : java.lang.ThreadLocal -PsiReferenceExpression:i : java.lang.ThreadLocal -PsiReferenceExpression:i : java.lang.ThreadLocal -PsiReferenceExpression:i : java.lang.ThreadLocal -PsiReferenceExpression:i : java.lang.ThreadLocal - -Conversions: -++i -> $qualifier$.set(new java.lang.Integer(((java.lang.Integer)$qualifier$.get()).intValue() + 1)) ++$qualifier$ ---i -> $qualifier$.set(new java.lang.Integer(((java.lang.Integer)$qualifier$.get()).intValue() - 1)) --$qualifier$ -i == 0 -> ((java.lang.Integer)$qualifier$.get()).intValue() == $val$ $qualifier$==$val$ -i++ -> $qualifier$.set(new java.lang.Integer(((java.lang.Integer)$qualifier$.get()).intValue() + 1)) $qualifier$++ -i-- -> $qualifier$.set(new java.lang.Integer(((java.lang.Integer)$qualifier$.get()).intValue() - 1)) $qualifier$-- - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/after/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/after/Test.java deleted file mode 100644 index 81e5fe05d6dd..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/after/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - ThreadLocal i; - - void foo() { - i.set(new Integer(((Integer) i.get()).intValue() + 1)); - i.set(new Integer(((Integer) i.get()).intValue() + 1)); - i.set(new Integer(((Integer) i.get()).intValue() - 1)); - i.set(new Integer(((Integer) i.get()).intValue() - 1)); - if (((Integer) i.get()).intValue() == 0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/before/Test.java b/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/before/Test.java deleted file mode 100644 index 9039f28e9617..000000000000 --- a/plugins/typeMigration/testData/refactoring/typeMigrationByThreadLocal/languageLevel/before/Test.java +++ /dev/null @@ -1,11 +0,0 @@ -class Test { - int i; - - void foo() { - i++; - ++i; - i--; - --i; - if (i == 0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/after/Test.items deleted file mode 100644 index b39d716277ba..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.util.ArrayList<? extends java.lang.Integer> -PsiReferenceExpression:p : java.util.ArrayList<? extends java.lang.Integer> - -Conversions: - -New expression type changes: -Fails: -p[0]->java.util.ArrayList<? extends java.lang.Integer> diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/after/test.java deleted file mode 100644 index 16a620ef2e6d..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? extends Integer> p) { - p[0] = new Integer(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/before/test.java deleted file mode 100644 index 4a148c3bd6fe..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentExtends/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - p[0] = new Integer(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/after/Test.items deleted file mode 100644 index 8ee86c529545..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiArrayAccessExpression:p[0] : java.lang.Integer -PsiParameter:p : java.util.ArrayList<? super java.lang.Integer> -PsiReferenceExpression:p : java.util.ArrayList<? super java.lang.Integer> - -Conversions: -p[0] -> $qualifier$.set($idx$, $expr$) $qualifier$[$idx$] = $expr$ p[0] = new Integer(0) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/after/test.java deleted file mode 100644 index 25cab7a9d34c..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Integer> p) { - p.set(0, new Integer(0)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/before/test.java deleted file mode 100644 index 4a148c3bd6fe..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentSuper/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - p[0] = new Integer(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/after/Test.items deleted file mode 100644 index e2bbfc48b834..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.util.ArrayList<?> -PsiReferenceExpression:p : java.util.ArrayList<?> - -Conversions: - -New expression type changes: -Fails: -p[0]->java.util.ArrayList<?> diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/after/test.java deleted file mode 100644 index 4804293a696e..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<?> p) { - p[0] = new Integer(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/before/test.java deleted file mode 100644 index 4a148c3bd6fe..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/assignmentUnbounded/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - p[0] = new Integer(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/after/Test.items deleted file mode 100644 index 455ebca21125..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:p.get(0) : java.lang.Number -PsiParameter:p : java.util.ArrayList<? extends java.lang.Number> -PsiReferenceExpression:p : java.util.ArrayList<? extends java.lang.Number> - -Conversions: -p.get(0) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/after/test.java deleted file mode 100644 index b403162051ad..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? extends Number> p, Number p2) { - p2 = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/before/test.java deleted file mode 100644 index 649da301cc82..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerExtends/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<Number> p, Number p2) { - p2 = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/after/Test.items deleted file mode 100644 index e4f5c3fc2088..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiMethodCallExpression:p.get(0) : java.lang.Object -PsiParameter:p : java.util.ArrayList<? super java.lang.Number> -PsiParameter:p2 : java.lang.Object -PsiReferenceExpression:p : java.util.ArrayList<? super java.lang.Number> -PsiReferenceExpression:p2 : java.lang.Object - -Conversions: -p.get(0) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/after/test.java deleted file mode 100644 index 2c315ea3a723..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Number> p, Object p2) { - p2 = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/before/test.java deleted file mode 100644 index 649da301cc82..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerSuper/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<Number> p, Number p2) { - p2 = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/after/Test.items deleted file mode 100644 index a0b14b30985e..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/after/Test.items +++ /dev/null @@ -1,12 +0,0 @@ -Types: -PsiMethodCallExpression:p.get(0) : java.lang.Object -PsiParameter:p : java.util.ArrayList<?> -PsiParameter:p2 : java.lang.Object -PsiReferenceExpression:p : java.util.ArrayList<?> -PsiReferenceExpression:p2 : java.lang.Object - -Conversions: -p.get(0) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/after/test.java deleted file mode 100644 index f10b5e2ae860..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<?> p, Object p2) { - p2 = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/before/test.java deleted file mode 100644 index 649da301cc82..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/consumerUnbounded/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<Number> p, Number p2) { - p2 = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/after/Test.items deleted file mode 100644 index 1ac8dc86d9ca..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:p.get(0) : java.lang.Number -PsiParameter:p : java.lang.Integer[] -PsiReferenceExpression:p : java.lang.Integer[] - -Conversions: -p.get(0) -> $qualifier$[$i$] $qualifier$.get($i$) p.get(0) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/after/test.java deleted file mode 100644 index bfe5eb68baba..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - Number n = p[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/before/test.java deleted file mode 100644 index bbddcc1a4d79..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToChildType/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? extends Number> p) { - Number n = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/after/Test.items deleted file mode 100644 index a4ea13d41b29..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.lang.Object[] -PsiReferenceExpression:p : java.lang.Object[] - -Conversions: - -New expression type changes: -Fails: -p->java.lang.Object[] diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/after/test.java deleted file mode 100644 index 96208756fe87..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Object[] p) { - Number n = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/before/test.java deleted file mode 100644 index bbddcc1a4d79..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToSuperType/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? extends Number> p) { - Number n = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/after/Test.items deleted file mode 100644 index a0fd8df506c4..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:p.get(0) : java.lang.Number -PsiParameter:p : java.lang.Number[] -PsiReferenceExpression:p : java.lang.Number[] - -Conversions: -p.get(0) -> $qualifier$[$i$] $qualifier$.get($i$) p.get(0) - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/after/test.java deleted file mode 100644 index 33a962b96171..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Number[] p) { - Number n = p[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/before/test.java deleted file mode 100644 index bbddcc1a4d79..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getAssignmentExtendsToType/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? extends Number> p) { - Number n = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getExtends/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/getExtends/after/Test.items deleted file mode 100644 index d68b720f5d5b..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getExtends/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiArrayAccessExpression:p[0] : java.lang.Integer -PsiParameter:p : java.util.ArrayList<? extends java.lang.Integer> -PsiReferenceExpression:p : java.util.ArrayList<? extends java.lang.Integer> - -Conversions: -p[0] -> $qualifier$.get($idx$) $qualifier$[$idx$] - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getExtends/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getExtends/after/test.java deleted file mode 100644 index 529d4942a2ce..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getExtends/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? extends Integer> p) { - Integer p1 = p.get(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getExtends/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getExtends/before/test.java deleted file mode 100644 index 685d78f23f3d..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getExtends/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - Integer p1 = p[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getSuper/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/getSuper/after/Test.items deleted file mode 100644 index 5300a386dc23..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getSuper/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.util.ArrayList<? super java.lang.Integer> -PsiReferenceExpression:p : java.util.ArrayList<? super java.lang.Integer> - -Conversions: - -New expression type changes: -Fails: -p[0]->java.util.ArrayList<? super java.lang.Integer> diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getSuper/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getSuper/after/test.java deleted file mode 100644 index eebb4c1f2dbb..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getSuper/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Integer> p) { - Integer p1 = p[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getSuper/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getSuper/before/test.java deleted file mode 100644 index 685d78f23f3d..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getSuper/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - Integer p1 = p[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/after/Test.items deleted file mode 100644 index e2bbfc48b834..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:p : java.util.ArrayList<?> -PsiReferenceExpression:p : java.util.ArrayList<?> - -Conversions: - -New expression type changes: -Fails: -p[0]->java.util.ArrayList<?> diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/after/test.java deleted file mode 100644 index 9ab43aa01dbe..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<?> p) { - Integer p1 = p[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/before/test.java deleted file mode 100644 index 685d78f23f3d..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/getUnbounded/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - Integer p1 = p[0]; - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/after/Test.items deleted file mode 100644 index bf63b11ab5b2..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiParameter:p : java.util.ArrayList<?> -PsiReferenceExpression:p : java.util.ArrayList<?> -PsiReferenceExpression:p.length : int - -Conversions: -p.length -> $qualifier$.size() $qualifier$.length - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/after/test.java deleted file mode 100644 index 4f0770adbfb5..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<?> p) { - System.out.println(p.size()); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/before/test.java deleted file mode 100644 index e8758383dd0a..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/lengthSize/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Integer[] p) { - System.out.println(p.length); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/after/Test.items deleted file mode 100644 index fe9d55b37cda..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:p.add(new Integer(8)) : boolean -PsiParameter:p : java.util.Set<? super java.lang.Integer> -PsiReferenceExpression:p : java.util.Set<? super java.lang.Integer> - -Conversions: -p.add(new Integer(8)) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/after/test.java deleted file mode 100644 index 25825f1f78c0..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Set<? super Integer> p) { - p.add(new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/before/test.java deleted file mode 100644 index d8cf544f6fde..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerCollectionChanged/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Number> p) { - p.add(new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/after/Test.items deleted file mode 100644 index 8b996f4d00e1..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiMethodCallExpression:p.set(0, new Integer(8)) : java.lang.Number -PsiParameter:p : java.util.ArrayList<? extends java.lang.Number> -PsiReferenceExpression:p : java.util.ArrayList<? extends java.lang.Number> - -Conversions: -p.set(0, new Integer(8)) -> $ - -New expression type changes: -Fails: -new Integer(8)->? extends java.lang.Number diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/after/test.java deleted file mode 100644 index f8f4f761d73a..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? extends Number> p) { - p.set(0, new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/before/test.java deleted file mode 100644 index b5e9a24ad373..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtends/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Number> p) { - p.set(0, new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/after/Test.items deleted file mode 100644 index 88976428ea99..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiMethodCallExpression:p.add(new Integer(8)) : boolean -PsiParameter:p : java.util.Set<? extends java.lang.Object> -PsiReferenceExpression:p : java.util.Set<? extends java.lang.Object> - -Conversions: -p.add(new Integer(8)) -> $ - -New expression type changes: -Fails: -new Integer(8)->? extends java.lang.Object diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/after/test.java deleted file mode 100644 index 0c24d5791d14..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(Set<? extends Object> p) { - p.add(new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/before/test.java deleted file mode 100644 index d8cf544f6fde..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsCollectionChanged/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Number> p) { - p.add(new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/after/Test.items deleted file mode 100644 index f2f5bb75a60f..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiMethodCallExpression:p1.add(p2) : boolean -PsiParameter:p1 : java.util.List<? extends java.lang.Number> -PsiReferenceExpression:p1 : java.util.List<? extends java.lang.Number> - -Conversions: -p1.add(p2) -> $ - -New expression type changes: -Fails: -p2->? extends java.lang.Number diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/after/test.java deleted file mode 100644 index 5d4d6fda25a2..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<? extends Number> p1, Number p2){ - p1.add(p2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/before/test.java deleted file mode 100644 index a2e2cb2ae329..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerExtendsFailToStopAtWildcard/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<Number> p1, Number p2){ - p1.add(p2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/after/Test.items deleted file mode 100644 index 9d9b2e2a447f..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiMethodCallExpression:p1.add(p2) : boolean -PsiParameter:p1 : java.util.List<? super java.lang.Integer> -PsiReferenceExpression:p1 : java.util.List<? super java.lang.Integer> - -Conversions: -p1.add(p2) -> $ - -New expression type changes: -Fails: -p2->? super java.lang.Integer diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/after/test.java deleted file mode 100644 index bbc30114137e..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<? super Integer> p1, Number p2){ - p1.add(p2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/before/test.java deleted file mode 100644 index a2e2cb2ae329..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerFailToStopAtWildcard/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<Number> p1, Number p2){ - p1.add(p2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/after/Test.items deleted file mode 100644 index 2f3689b42ba5..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:p1.add(p2) : boolean -PsiParameter:p1 : java.util.List<? super java.lang.Number> -PsiReferenceExpression:p1 : java.util.List<? super java.lang.Number> - -Conversions: -p1.add(p2) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/after/test.java deleted file mode 100644 index 353f0432f59d..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<? super Number> p1, Number p2){ - p1.add(p2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/before/test.java deleted file mode 100644 index a2e2cb2ae329..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerStopAtWildcard/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<Number> p1, Number p2){ - p1.add(p2); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/after/Test.items deleted file mode 100644 index b0c91006b9d1..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:p.set(0, new Integer(8)) : java.lang.Object -PsiParameter:p : java.util.ArrayList<? super java.lang.Integer> -PsiReferenceExpression:p : java.util.ArrayList<? super java.lang.Integer> - -Conversions: -p.set(0, new Integer(8)) -> $ - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/after/test.java deleted file mode 100644 index 0769f09a7b7a..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Integer> p) { - p.set(0, new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/before/test.java deleted file mode 100644 index b5e9a24ad373..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerSuper/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Number> p) { - p.set(0, new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/after/Test.items deleted file mode 100644 index e2b8ee35fcd2..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/after/Test.items +++ /dev/null @@ -1,11 +0,0 @@ -Types: -PsiMethodCallExpression:p.set(0, new Integer(8)) : java.lang.Object -PsiParameter:p : java.util.ArrayList<?> -PsiReferenceExpression:p : java.util.ArrayList<?> - -Conversions: -p.set(0, new Integer(8)) -> $ - -New expression type changes: -Fails: -new Integer(8)->? diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/after/test.java deleted file mode 100644 index 37a2f8fcac83..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<?> p) { - p.set(0, new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/before/test.java deleted file mode 100644 index b5e9a24ad373..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/producerUnbounded/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ArrayList<? super Number> p) { - p.set(0, new Integer(8)); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/after/Test.items deleted file mode 100644 index 7ae170499472..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:l.substring(0) : java.lang.String -PsiParameter:l : java.lang.ThreadLocal<? extends java.lang.String> -PsiReferenceExpression:l : java.lang.ThreadLocal<? extends java.lang.String> - -Conversions: -l.substring(0) -> $qualifier$.get() $qualifier$ l - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/after/test.java deleted file mode 100644 index 5275db851a70..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void method(ThreadLocal<? extends String> l) { - l.get().substring(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/before/test.java deleted file mode 100644 index 8805129f7191..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerExtends/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void method(String l) { - l.substring(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/after/Test.items deleted file mode 100644 index d05d101463c7..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:l : java.lang.ThreadLocal<? super java.lang.String> -PsiReferenceExpression:l : java.lang.ThreadLocal<? super java.lang.String> - -Conversions: - -New expression type changes: -Fails: -l->java.lang.ThreadLocal<? super java.lang.String> diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/after/test.java deleted file mode 100644 index beb0d0ebef46..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/after/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void method(ThreadLocal<? super String> l) { - l.substring(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/before/test.java deleted file mode 100644 index 8805129f7191..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalConsumerSuper/before/test.java +++ /dev/null @@ -1,5 +0,0 @@ -class Test { - void method(String l) { - l.substring(0); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/after/Test.items deleted file mode 100644 index 47a89e441962..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/after/Test.items +++ /dev/null @@ -1,9 +0,0 @@ -Types: -PsiParameter:l : java.lang.ThreadLocal<java.util.List<? extends java.lang.String>> -PsiReferenceExpression:l : java.lang.ThreadLocal<java.util.List<? extends java.lang.String>> - -Conversions: - -New expression type changes: -Fails: -l->java.lang.ThreadLocal<java.util.List<? extends java.lang.String>> diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/after/test.java deleted file mode 100644 index 93724be5c0dd..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ThreadLocal<List<? extends String>> l) { - l.add(""); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/before/test.java deleted file mode 100644 index 8df669c77899..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerExtends/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<String> l) { - l.add(""); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/after/Test.items b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/after/Test.items deleted file mode 100644 index 736189db2585..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/after/Test.items +++ /dev/null @@ -1,10 +0,0 @@ -Types: -PsiMethodCallExpression:l.add("") : boolean -PsiParameter:l : java.lang.ThreadLocal<java.util.List<? super java.lang.String>> -PsiReferenceExpression:l : java.lang.ThreadLocal<java.util.List<? super java.lang.String>> - -Conversions: -l.add("") -> $qualifier$.get() $qualifier$ l - -New expression type changes: -Fails: diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/after/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/after/test.java deleted file mode 100644 index fb3b568ca1b0..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/after/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(ThreadLocal<List<? super String>> l) { - l.get().add(""); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/before/test.java b/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/before/test.java deleted file mode 100644 index 8df669c77899..000000000000 --- a/plugins/typeMigration/testData/refactoring/wildcard/threadLocalProducerSuper/before/test.java +++ /dev/null @@ -1,7 +0,0 @@ -import java.util.*; - -class Test { - void method(List<String> l) { - l.add(""); - } -}
\ No newline at end of file diff --git a/plugins/typeMigration/typeMigration.iml b/plugins/typeMigration/typeMigration.iml deleted file mode 100644 index ac3679760ed4..000000000000 --- a/plugins/typeMigration/typeMigration.iml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<module relativePaths="true" type="JAVA_MODULE" version="4"> - <component name="NewModuleRootManager" inherit-compiler-output="true"> - <exclude-output /> - <content url="file://$MODULE_DIR$"> - <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> - <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> - </content> - <orderEntry type="inheritedJdk" /> - <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="module" module-name="util" /> - <orderEntry type="module" module-name="lang-api" /> - <orderEntry type="module" module-name="lang-impl" /> - <orderEntry type="module" module-name="openapi" /> - <orderEntry type="module" module-name="structuralsearch" /> - <orderEntry type="module" module-name="java-impl" /> - <orderEntry type="module" module-name="testFramework-java" scope="TEST" /> - <orderEntry type="module" module-name="structuralsearch-java" /> - </component> -</module> - diff --git a/plugins/ui-designer/src/META-INF/plugin.xml b/plugins/ui-designer/src/META-INF/plugin.xml index 6724c40198dd..bca8934330a4 100644 --- a/plugins/ui-designer/src/META-INF/plugin.xml +++ b/plugins/ui-designer/src/META-INF/plugin.xml @@ -33,7 +33,7 @@ <i18nInspectionTool implementation="com.intellij.uiDesigner.i18n.I18nFormInspection"/> <java15InspectionTool implementation="com.intellij.uiDesigner.inspections.Java15FormInspection"/> - <projectConfigurable instance="com.intellij.uiDesigner.GuiDesignerConfigurable" id="project.propGUI" key="title.gui.designer" + <projectConfigurable groupId="editor" instance="com.intellij.uiDesigner.GuiDesignerConfigurable" id="project.propGUI" key="title.gui.designer" bundle="messages.UIDesignerBundle"/> <favoriteNodeProvider implementation="com.intellij.uiDesigner.projectView.UIDesignerFavoriteNodeProvider"/> diff --git a/plugins/xpath/xpath-view/src/META-INF/plugin.xml b/plugins/xpath/xpath-view/src/META-INF/plugin.xml index 65a942a56ba3..2030b75c8d0a 100644 --- a/plugins/xpath/xpath-view/src/META-INF/plugin.xml +++ b/plugins/xpath/xpath-view/src/META-INF/plugin.xml @@ -59,7 +59,7 @@ serviceInterface="org.intellij.lang.xpath.xslt.psi.XsltElementFactory" serviceImplementation="org.intellij.lang.xpath.xslt.psi.impl.XsltElementFactoryImpl" /> - <projectConfigurable instance="org.intellij.lang.xpath.xslt.associations.impl.FileAssociationsConfigurable" id="xslt.associations" displayName="XSLT File Associations" nonDefaultProject="true" /> + <projectConfigurable groupId="language" instance="org.intellij.lang.xpath.xslt.associations.impl.FileAssociationsConfigurable" id="xslt.associations" displayName="XSLT File Associations" nonDefaultProject="true" /> <projectService serviceInterface="org.intellij.lang.xpath.xslt.associations.impl.FileAssociationsConfigurable$UIState" @@ -137,8 +137,8 @@ <category>XSLT</category> </intentionAction> - <applicationConfigurable instance="org.intellij.plugins.xpathView.XPathConfigurable" id="xpath.settings" displayName="XPath Viewer" /> - <applicationConfigurable instance="org.intellij.lang.xpath.xslt.impl.XsltConfigImpl$UIImpl" id="settings.xslt" + <applicationConfigurable groupId="tools" instance="org.intellij.plugins.xpathView.XPathConfigurable" id="xpath.settings" displayName="XPath Viewer" /> + <applicationConfigurable groupId="language" instance="org.intellij.lang.xpath.xslt.impl.XsltConfigImpl$UIImpl" id="settings.xslt" displayName="XSLT"/> <fileIconPatcher implementation="org.intellij.lang.xpath.xslt.impl.XsltIconProvider"/> |