Search in sources :

Example 6 with JSParameterInfo

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

the class FlexChangeSignatureTest method testIncompatibleImplementation.

public void testIncompatibleImplementation() throws Exception {
    myIgnoreConflicts = true;
    doTest("foo2", JSAttributeList.AccessType.PUBLIC, "", null, new JSParameterInfo("j", "int", "", "", 0));
}
Also used : JSParameterInfo(com.intellij.lang.javascript.refactoring.changeSignature.JSParameterInfo)

Example 7 with JSParameterInfo

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

the class JSCreateMethodActionBase method prepare.

@Override
public Runnable prepare(Object element, DiagramBuilder builder) {
    final JSClass clazz = (JSClass) element;
    if (!JSRefactoringUtil.checkReadOnlyStatus(clazz, null, getTemplatePresentation().getText()))
        return null;
    final JSFunction fakeMethod = JSCreateMethodDialog.createFakeMethod(clazz, createFakeMethodText(clazz), false);
    final JSCreateMethodDialog dialog = new JSCreateMethodDialog(clazz, fakeMethod, isForceConstructor());
    if (!dialog.showAndGet()) {
        return null;
    }
    return () -> {
        final JSFunction method = dialog.createMethod();
        importType(clazz, dialog.getReturnTypeText());
        for (JSParameterInfo param : dialog.getParameters()) {
            importType(clazz, param.getTypeText());
        }
        final PsiElement added = JSRefactoringUtil.addMemberToTargetClass(clazz, method);
        final List<FormatFixer> formatters = new ArrayList<>();
        formatters.add(FormatFixer.create(added, FormatFixer.Mode.Reformat));
        formatters.addAll(ECMAScriptImportOptimizer.executeNoFormat(clazz.getContainingFile()));
        FormatFixer.fixAll(FormatFixer.merge(formatters));
    };
}
Also used : JSFunction(com.intellij.lang.javascript.psi.JSFunction) JSAttributeList(com.intellij.lang.javascript.psi.ecmal4.JSAttributeList) ArrayList(java.util.ArrayList) List(java.util.List) JSClass(com.intellij.lang.javascript.psi.ecmal4.JSClass) PsiElement(com.intellij.psi.PsiElement) 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