Search in sources :

Example 1 with DynamicElementSettings

use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.

the class QuickfixUtil method createSettings.

public static DynamicElementSettings createSettings(GrArgumentLabel label, PsiClass targetClass) {
    DynamicElementSettings settings = new DynamicElementSettings();
    assert targetClass != null;
    String className = targetClass.getQualifiedName();
    className = className == null ? targetClass.getContainingFile().getName() : className;
    settings.setContainingClassName(className);
    settings.setName(label.getName());
    return settings;
}
Also used : DynamicElementSettings(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings)

Example 2 with DynamicElementSettings

use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.

the class QuickfixUtil method createSettings.

public static DynamicElementSettings createSettings(GrReferenceExpression referenceExpression) {
    DynamicElementSettings settings = new DynamicElementSettings();
    final PsiClass containingClass = findTargetClass(referenceExpression, false);
    assert containingClass != null;
    String className = containingClass.getQualifiedName();
    className = className == null ? containingClass.getContainingFile().getName() : className;
    if (isStaticCall(referenceExpression)) {
        settings.setStatic(true);
    }
    settings.setContainingClassName(className);
    settings.setName(referenceExpression.getReferenceName());
    if (PsiUtil.isCall(referenceExpression)) {
        List<PsiType> unboxedTypes = new ArrayList<>();
        for (PsiType type : PsiUtil.getArgumentTypes(referenceExpression, false)) {
            unboxedTypes.add(TypesUtil.unboxPrimitiveTypeWrapperAndEraseGenerics(type));
        }
        final PsiType[] types = unboxedTypes.toArray(PsiType.createArray(unboxedTypes.size()));
        final String[] names = GroovyNamesUtil.getMethodArgumentsNames(referenceExpression.getProject(), types);
        final List<ParamInfo> infos = swapArgumentsAndTypes(names, types);
        settings.setMethod(true);
        settings.setParams(infos);
    } else {
        settings.setMethod(false);
    }
    return settings;
}
Also used : ArrayList(java.util.ArrayList) DynamicElementSettings(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings) ParamInfo(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ParamInfo)

Example 3 with DynamicElementSettings

use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.

the class DynamicMethodFix method invoke.

public void invoke(Project project) throws IncorrectOperationException {
    final DynamicElementSettings settings = QuickfixUtil.createSettings(myReferenceExpression);
    DynamicManager.getInstance(project).addMethod(settings);
}
Also used : DynamicElementSettings(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings)

Example 4 with DynamicElementSettings

use of org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings in project intellij-community by JetBrains.

the class DynamicPropertyFix method invoke.

/**
   * for tests
   */
public void invoke(Project project) throws IncorrectOperationException {
    final DynamicElementSettings settings;
    if (myReferenceExpression != null) {
        settings = QuickfixUtil.createSettings(myReferenceExpression);
    } else {
        settings = QuickfixUtil.createSettings(myArgumentLabel, myTargetClass);
    }
    DynamicManager.getInstance(project).addProperty(settings);
}
Also used : DynamicElementSettings(org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings)

Aggregations

DynamicElementSettings (org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ui.DynamicElementSettings)4 ArrayList (java.util.ArrayList)1 ParamInfo (org.jetbrains.plugins.groovy.annotator.intentions.dynamic.ParamInfo)1