use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl in project intellij-community by JetBrains.
the class ClosureGenerator method generateClosureMethod.
@NotNull
private GrMethod generateClosureMethod(@NotNull GrClosableBlock block) {
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(context.project);
final GrMethod method = factory.createMethodFromText("def doCall(){}", block);
GrReferenceAdjuster.shortenAllReferencesIn(method.setReturnType(context.typeProvider.getReturnType(block)));
if (block.hasParametersSection()) {
method.getParameterList().replace(block.getParameterList());
} else {
final GrParameter[] allParameters = block.getAllParameters();
LOG.assertTrue(allParameters.length == 1);
final GrParameter itParameter = allParameters[0];
final GrParameter parameter = factory.createParameter("it", itParameter.getType().getCanonicalText(), "null", block);
method.getParameterList().add(parameter);
}
((GroovyFileImpl) method.getContainingFile()).setContextNullable(null);
return method;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl in project intellij-community by JetBrains.
the class GroovyShellRunnerImpl method createConsoleView.
@Override
protected LanguageConsoleView createConsoleView() {
final LanguageConsoleView res = new GroovyShellLanguageConsoleView(getProject(), getConsoleTitle());
final GroovyFileImpl file = (GroovyFileImpl) res.getFile();
assert file.getContext() == null;
file.putUserData(GROOVY_SHELL_FILE, Boolean.TRUE);
file.setContext(myShellRunner.getContext(myModule));
return res;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl in project intellij-community by JetBrains.
the class GrTypeDefinitionImpl method delete.
@Override
public void delete() throws IncorrectOperationException {
PsiElement parent = getParent();
if (parent instanceof GroovyFileImpl) {
GroovyFileImpl file = (GroovyFileImpl) parent;
if (file.getTypeDefinitions().length == 1 && !file.isScript()) {
file.delete();
return;
}
}
super.delete();
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl in project intellij-community by JetBrains.
the class GrAssignmentExpressionImpl method processDeclarations.
@Override
public boolean processDeclarations(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, PsiElement lastParent, @NotNull PsiElement place) {
final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
if (!ResolveUtil.shouldProcessProperties(classHint))
return true;
final DynamicMembersHint dynamicMembersHint = processor.getHint(DynamicMembersHint.KEY);
if (dynamicMembersHint != null && !dynamicMembersHint.shouldProcessProperties())
return true;
if (!(getParent() instanceof GroovyFileImpl))
return true;
final GroovyFileImpl file = (GroovyFileImpl) getParent();
if (!file.isInScriptBody(lastParent, place))
return true;
final GrExpression lValue = getLValue();
if (!processLValue(processor, state, place, file, lValue))
return false;
if (lValue instanceof GrTupleExpression) {
for (GrExpression expression : ((GrTupleExpression) lValue).getExpressions()) {
if (!processLValue(processor, state, place, file, expression))
return false;
}
}
return true;
}
Aggregations