utility methods moved out of psi hierarchy
This commit is contained in:
committed by
Andrey Breslav
parent
689dbdf6b6
commit
9e17069546
@@ -773,7 +773,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
public StackValue visitNamedFunction(JetNamedFunction function, StackValue data) {
|
||||
assert data == StackValue.none();
|
||||
|
||||
if (function.isScriptDeclaration()) {
|
||||
if (JetPsiUtil.isScriptDeclaration(function)) {
|
||||
return StackValue.none();
|
||||
}
|
||||
|
||||
@@ -889,7 +889,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
for (JetElement statement : statements) {
|
||||
if (statement instanceof JetNamedDeclaration) {
|
||||
JetNamedDeclaration declaration = (JetNamedDeclaration) statement;
|
||||
if (declaration.isScriptDeclaration()) {
|
||||
if (JetPsiUtil.isScriptDeclaration(declaration)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -928,7 +928,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
for (JetElement statement : Lists.reverse(statements)) {
|
||||
if (statement instanceof JetNamedDeclaration) {
|
||||
JetNamedDeclaration declaration = (JetNamedDeclaration) statement;
|
||||
if (declaration.isScriptDeclaration()) {
|
||||
if (JetPsiUtil.isScriptDeclaration(declaration)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -1538,7 +1538,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
if (fd.getContainingDeclaration() instanceof ScriptDescriptor) {
|
||||
JetNamedFunction psi = (JetNamedFunction) BindingContextUtils.descriptorToDeclaration(bindingContext, fd);
|
||||
assert psi != null;
|
||||
return !psi.isScriptDeclaration();
|
||||
return !JetPsiUtil.isScriptDeclaration(psi);
|
||||
}
|
||||
else if (fd instanceof ExpressionAsFunctionDescriptor) {
|
||||
return true;
|
||||
@@ -2562,7 +2562,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
Type sharedVarType;
|
||||
int index;
|
||||
|
||||
if (property.isScriptDeclaration()) {
|
||||
if (JetPsiUtil.isScriptDeclaration(property)) {
|
||||
return StackValue.none();
|
||||
}
|
||||
else {
|
||||
@@ -2586,9 +2586,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
|
||||
JetExpression initializer = property.getInitializer();
|
||||
if (initializer != null) {
|
||||
if (property.isScriptDeclaration()) {
|
||||
if (JetPsiUtil.isScriptDeclaration(property)) {
|
||||
gen(initializer, varType);
|
||||
JetScript scriptPsi = property.getScript();
|
||||
JetScript scriptPsi = JetPsiUtil.getScript(property);
|
||||
assert scriptPsi != null;
|
||||
JvmClassName scriptClassName = state.getInjector().getClosureAnnotator().classNameForScriptPsi(scriptPsi);
|
||||
v.putfield(scriptClassName.getInternalName(), property.getName(), varType.getDescriptor());
|
||||
|
||||
@@ -11,9 +11,4 @@ import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
public interface JetNamedDeclaration extends JetDeclaration, PsiNameIdentifierOwner, JetStatementExpression, JetNamed {
|
||||
@NotNull
|
||||
Name getNameAsSafeName();
|
||||
|
||||
boolean isScriptDeclaration();
|
||||
|
||||
@Nullable
|
||||
JetScript getScript();
|
||||
}
|
||||
|
||||
@@ -74,20 +74,4 @@ abstract class JetNamedDeclarationNotStubbed extends JetDeclarationImpl implemen
|
||||
PsiElement identifier = getNameIdentifier();
|
||||
return identifier != null ? identifier.getTextRange().getStartOffset() : getTextRange().getStartOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScriptDeclaration() {
|
||||
return getScript() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetScript getScript() {
|
||||
if (getParent() != null && getParent().getParent() instanceof JetScript) {
|
||||
return (JetScript) getParent().getParent();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,20 +83,4 @@ abstract class JetNamedDeclarationStub<T extends NamedStub> extends JetDeclarati
|
||||
PsiElement identifier = getNameIdentifier();
|
||||
return identifier != null ? identifier.getTextRange().getStartOffset() : getTextRange().getStartOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScriptDeclaration() {
|
||||
return getScript() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetScript getScript() {
|
||||
if (getParent() != null && getParent().getParent() instanceof JetScript) {
|
||||
return (JetScript) getParent().getParent();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,4 +321,19 @@ public class JetPsiUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isScriptDeclaration(@NotNull JetDeclaration namedDeclaration) {
|
||||
return getScript(namedDeclaration) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static JetScript getScript(@NotNull JetDeclaration namedDeclaration) {
|
||||
PsiElement parent = namedDeclaration.getParent();
|
||||
if (parent != null && parent.getParent() instanceof JetScript) {
|
||||
return (JetScript) parent.getParent();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ public class DescriptorResolver {
|
||||
DataFlowInfo dataFlowInfo,
|
||||
BindingTrace trace
|
||||
) {
|
||||
if (property.isScriptDeclaration()) {
|
||||
if (JetPsiUtil.isScriptDeclaration(property)) {
|
||||
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(
|
||||
containingDeclaration,
|
||||
annotationResolver.createAnnotationStubs(property.getModifierList(), trace),
|
||||
|
||||
Reference in New Issue
Block a user