Search in sources :

Example 11 with LightMethodBuilder

use of com.intellij.psi.impl.light.LightMethodBuilder in project intellij-community by JetBrains.

the class AntTasksProvider method getAntTasks.

public static Set<LightMethodBuilder> getAntTasks(PsiElement place) {
    final PsiFile file = place.getContainingFile();
    if (!(file instanceof GroovyFile)) {
        return Collections.emptySet();
    }
    return CachedValuesManager.getManager(file.getProject()).getCachedValue(file, GANT_METHODS, () -> {
        Map<String, Class> antObjects = getAntObjects((GroovyFile) file);
        final Set<LightMethodBuilder> methods = new HashSet<>();
        final Project project = file.getProject();
        final PsiType closureType = TypesUtil.createType(GroovyCommonClassNames.GROOVY_LANG_CLOSURE, file);
        final PsiClassType stringType = TypesUtil.createType(CommonClassNames.JAVA_LANG_STRING, file);
        for (String name : antObjects.keySet()) {
            methods.add(new AntBuilderMethod(file, name, closureType, antObjects.get(name), stringType));
        }
        return CachedValueProvider.Result.create(methods, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT, ProjectRootManager.getInstance(project));
    }, false);
}
Also used : Project(com.intellij.openapi.project.Project) ReflectedProject(com.intellij.lang.ant.ReflectedProject) LightMethodBuilder(com.intellij.psi.impl.light.LightMethodBuilder) GroovyFile(org.jetbrains.plugins.groovy.lang.psi.GroovyFile)

Example 12 with LightMethodBuilder

use of com.intellij.psi.impl.light.LightMethodBuilder in project intellij-community by JetBrains.

the class SimpleBuilderStrategySupport method createFieldSetter.

@NotNull
public static LightMethodBuilder createFieldSetter(@NotNull PsiClass builderClass, @NotNull GrVariable field, @NotNull PsiAnnotation annotation) {
    final String name = field.getName();
    final LightMethodBuilder fieldSetter = new LightMethodBuilder(builderClass.getManager(), getFieldMethodName(annotation, name));
    fieldSetter.addModifier(PsiModifier.PUBLIC);
    fieldSetter.addParameter(name, field.getType(), false);
    fieldSetter.setMethodReturnType(createType(builderClass));
    fieldSetter.setNavigationElement(field);
    fieldSetter.setOriginInfo(ORIGIN_INFO);
    return fieldSetter;
}
Also used : LightMethodBuilder(com.intellij.psi.impl.light.LightMethodBuilder) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LightMethodBuilder (com.intellij.psi.impl.light.LightMethodBuilder)12 NotNull (org.jetbrains.annotations.NotNull)3 GrTypeDefinition (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition)2 GroovyScriptClass (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass)2 ReflectedProject (com.intellij.lang.ant.ReflectedProject)1 Project (com.intellij.openapi.project.Project)1 PsiArrayType (com.intellij.psi.PsiArrayType)1 PsiClass (com.intellij.psi.PsiClass)1 PsiType (com.intellij.psi.PsiType)1 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 MethodSignature (com.intellij.psi.util.MethodSignature)1 IOException (java.io.IOException)1 ObjectInput (java.io.ObjectInput)1 ObjectOutput (java.io.ObjectOutput)1 Nullable (org.jetbrains.annotations.Nullable)1 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)1 GroovyPsiElement (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement)1 GrAnnotationMemberValue (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue)1 GrLightMethodBuilder (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder)1