Search in sources :

Example 1 with JSMethodDescriptor

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

the class ActionScriptCompletionInTextFieldTest method testChangeSignatureReturnType.

@JSTestOptions({ JSTestOption.WithFlexSdk })
public void testChangeSignatureReturnType() throws Exception {
    configureByFiles(null, BASE_PATH + getTestName(false) + "_2.js2");
    JSFunction function = createFakeFunction();
    JSExpressionCodeFragment fragment = JSChangeSignatureDialog.createReturnTypeCodeFragment(new JSMethodDescriptor(function, false).getReturnType(), function, JavaScriptSupportLoader.ECMA_SCRIPT_L4);
    String[] included = new String[] { "Z111", "Z222", "int", "String", "uint", "Number", "EventDispatcher", "void", "*" };
    String[] excluded = ArrayUtil.mergeArrays(DEFALUT_VALUES, "public", "function", "while");
    checkTextFieldCompletion(fragment, included, excluded, "Z111", BASE_PATH + getTestName(false) + ".txt");
}
Also used : JSFunction(com.intellij.lang.javascript.psi.JSFunction) JSMethodDescriptor(com.intellij.lang.javascript.refactoring.changeSignature.JSMethodDescriptor) JSExpressionCodeFragment(com.intellij.lang.javascript.psi.JSExpressionCodeFragment) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 2 with JSMethodDescriptor

use of com.intellij.lang.javascript.refactoring.changeSignature.JSMethodDescriptor 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)

Aggregations

JSMethodDescriptor (com.intellij.lang.javascript.refactoring.changeSignature.JSMethodDescriptor)2 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)1 JSExpressionCodeFragment (com.intellij.lang.javascript.psi.JSExpressionCodeFragment)1 JSFunction (com.intellij.lang.javascript.psi.JSFunction)1 JSChangeSignatureDialog (com.intellij.lang.javascript.refactoring.changeSignature.JSChangeSignatureDialog)1 JSParameterInfo (com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)1 BaseRefactoringProcessor (com.intellij.refactoring.BaseRefactoringProcessor)1