Search in sources :

Example 1 with JSParameterInfo

use of com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo in project intellij-plugins by JetBrains.

the class JSChangeSignatureDetector method performChange.

@Override
public void performChange(JSChangeInfo changeInfo, Editor editor, @NotNull final String oldText) {
    final JSChangeInfo jsChangeInfo = changeInfo;
    JSMethodDescriptor descriptor = new JSMethodDescriptor(jsChangeInfo.getMethod(), false) {

        @Override
        public String getName() {
            return jsChangeInfo.getNewName();
        }

        @Override
        public List<JSParameterInfo> getParameters() {
            return Arrays.asList(jsChangeInfo.getNewParameters());
        }

        @Override
        public int getParametersCount() {
            return getParameters().size();
        }

        @Override
        public String getVisibility() {
            return jsChangeInfo.getNewVisibility().name();
        }

        @Override
        public JSFunction getMethod() {
            return jsChangeInfo.getMethod();
        }
    };
    JSChangeSignatureDialog d = new JSChangeSignatureDialog(descriptor, changeInfo.getMethod()) {

        @Override
        protected void invokeRefactoring(BaseRefactoringProcessor processor) {
            revertChanges(jsChangeInfo.getMethod(), oldText);
            super.invokeRefactoring(processor);
        }
    };
    d.showAndGet();
}
Also used : BaseRefactoringProcessor(com.intellij.refactoring.BaseRefactoringProcessor) JSChangeSignatureDialog(com.intellij.lang.javascript.refactoring.changeSignature.JSChangeSignatureDialog) JSMethodDescriptor(com.intellij.lang.javascript.refactoring.changeSignature.JSMethodDescriptor) JSParameterInfo(com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)

Example 2 with JSParameterInfo

use of com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo in project intellij-plugins by JetBrains.

the class FlexChangeSignatureTest method testConflicts2.

public void testConflicts2() throws Exception {
    String[] conflicts = new String[] { "There is already a variable value2 in the property From.prop. It will conflict with the renamed parameter.", "Property From.prop with private visibility won't be accessible from function ttt()", "Class From already contains a field _prop2" };
    doTestConflicts("prop2", JSAttributeList.AccessType.PRIVATE, "*", conflicts, ArrayUtil.EMPTY_STRING_ARRAY, new JSParameterInfo("value2", "", "", "foo", 0));
}
Also used : JSParameterInfo(com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)

Example 3 with JSParameterInfo

use of com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo in project intellij-plugins by JetBrains.

the class FlexChangeSignatureTest method testIncompatibleImplementationConflict.

public void testIncompatibleImplementationConflict() throws Exception {
    String[] conflicts = new String[] { "Implementing method B.foo() has different number of parameters than refactored method A.foo(int). Method B.foo() will be ignored during refactoring." };
    doTestConflicts("foo", JSAttributeList.AccessType.PUBLIC, "", conflicts, null, new JSParameterInfo("j", "int", "", "", 0));
}
Also used : JSParameterInfo(com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)

Example 4 with JSParameterInfo

use of com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo in project intellij-plugins by JetBrains.

the class FlexChangeSignatureTest method testConflicts1.

public void testConflicts1() throws Exception {
    String[] conflicts = new String[] { "There is already a parameter p1 in method From.foo(String, String). It will conflict with the new parameter.", "There is already a parameter p1 in the method From.foo(String, String). It will conflict with the renamed parameter.", "There is already a variable p2 in method From.foo(String, String). It will conflict with the new parameter.", "There is already a variable p3 in method FromEx.foo(String, String). It will conflict with the new parameter.", "There is already a variable p1 in method From.pp(). It will conflict with the new parameter.", "There is already a variable p2 in method From.pp(). It will conflict with the new parameter.", "There is already a variable p3 in method From.pp(). It will conflict with the new parameter.", "There is already a variable p1 in function pp2(). It will conflict with the new parameter.", "Class From already contains a method bar()", "Method FromEx.foo(String, String) with internal visibility won't be accessible from function zz()", "Method From.foo(String, String) with internal visibility won't be able to participate in hierarchy" };
    doTestConflicts("bar", JSAttributeList.AccessType.PACKAGE_LOCAL, "String", conflicts, new String[] { "pp", "zz" }, // p1
    new JSParameterInfo("p1", "String", "", "", 0), // p2->p1
    new JSParameterInfo("p1", "String", "", "", 1), new JSParameterInfo("p1", "String", "", "a", -1), new JSParameterInfo("p2", "String", "", "b", -1), new JSParameterInfo("p3", "String", "", "c", -1));
}
Also used : JSParameterInfo(com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)

Example 5 with JSParameterInfo

use of com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo in project intellij-plugins by JetBrains.

the class FlexChangeSignatureTest method testIncompatibleOverrideConflict.

public void testIncompatibleOverrideConflict() throws Exception {
    String[] conflicts = new String[] { "Overriding method B.foo() has different number of parameters than refactored method A.foo(int). Method B.foo() will be ignored during refactoring." };
    doTestConflicts("foo2", JSAttributeList.AccessType.PUBLIC, "", conflicts, null, new JSParameterInfo("j", "int", "", "", 0));
}
Also used : JSParameterInfo(com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)

Aggregations

JSParameterInfo (com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)7 JSFunction (com.intellij.lang.javascript.psi.JSFunction)1 JSAttributeList (com.intellij.lang.javascript.psi.ecmal4.JSAttributeList)1 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)1 JSChangeSignatureDialog (com.intellij.lang.javascript.refactoring.changeSignature.JSChangeSignatureDialog)1 JSMethodDescriptor (com.intellij.lang.javascript.refactoring.changeSignature.JSMethodDescriptor)1 PsiElement (com.intellij.psi.PsiElement)1 BaseRefactoringProcessor (com.intellij.refactoring.BaseRefactoringProcessor)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1