diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java index 014e784d444..7e9bf8f4e20 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetClass.java @@ -37,7 +37,7 @@ import java.util.List; /** * @author max */ -public class JetClass extends JetStubTypeParameterListOwner +public class JetClass extends JetTypeParameterListOwnerStub implements JetClassOrObject, JetModifierListOwner { public JetClass(@NotNull ASTNode node) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubDeclaration.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java similarity index 93% rename from compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubDeclaration.java rename to compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java index 9ab6c132711..3d47257e1b9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetDeclarationStub.java @@ -30,12 +30,12 @@ import org.jetbrains.jet.lexer.JetToken; /** * @author Nikolay Krasko */ -abstract class JetStubDeclaration extends StubBasedPsiElementBase implements JetDeclaration, StubBasedPsiElement { - public JetStubDeclaration(@NotNull T stub, @NotNull IStubElementType nodeType) { +abstract class JetDeclarationStub extends StubBasedPsiElementBase implements JetDeclaration, StubBasedPsiElement { + public JetDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) { super(stub, nodeType); } - public JetStubDeclaration(@NotNull ASTNode node) { + public JetDeclarationStub(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java index 5720b803cfa..0ced9c4f227 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunction.java @@ -1,106 +1,19 @@ -/* - * Copyright 2010-2012 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package org.jetbrains.jet.lang.psi; -import com.intellij.lang.ASTNode; -import com.intellij.psi.PsiElement; -import com.intellij.psi.tree.IElementType; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.JetNodeTypes; -import org.jetbrains.jet.lexer.JetTokens; - -import java.util.Collections; -import java.util.List; /** - * @author abreslav + * @author Nikolay Krasko */ -abstract public class JetFunction extends JetNotStubbedTypeParameterListOwner - implements JetDeclarationWithBody, JetModifierListOwner { - - public JetFunction(@NotNull ASTNode node) { - super(node); - } +public interface JetFunction extends JetTypeParameterListOwner, JetDeclarationWithBody, JetModifierListOwner { + @Nullable + JetParameterList getValueParameterList(); @Nullable - public JetParameterList getValueParameterList() { - return (JetParameterList) findChildByType(JetNodeTypes.VALUE_PARAMETER_LIST); - } - - @Override - @NotNull - public List getValueParameters() { - JetParameterList list = getValueParameterList(); - return list != null ? list.getParameters() : Collections.emptyList(); - } - - @Override - @Nullable - public JetExpression getBodyExpression() { - return findChildByClass(JetExpression.class); - } - - @Override - public boolean hasDeclaredReturnType() { - return getReturnTypeRef() != null; - } + JetTypeReference getReceiverTypeRef(); @Nullable - public JetTypeReference getReceiverTypeRef() { - PsiElement child = getFirstChild(); - while (child != null) { - IElementType tt = child.getNode().getElementType(); - if (tt == JetTokens.LPAR || tt == JetTokens.COLON) break; - if (child instanceof JetTypeReference) { - return (JetTypeReference) child; - } - child = child.getNextSibling(); - } + JetTypeReference getReturnTypeRef(); - return null; - } - - @Nullable - public JetTypeReference getReturnTypeRef() { - boolean colonPassed = false; - PsiElement child = getFirstChild(); - while (child != null) { - IElementType tt = child.getNode().getElementType(); - if (tt == JetTokens.COLON) { - colonPassed = true; - } - if (colonPassed && child instanceof JetTypeReference) { - return (JetTypeReference) child; - } - child = child.getNextSibling(); - } - - return null; - } - - @NotNull - @Override - public JetElement asElement() { - return this; - } - - public boolean isLocal() { - PsiElement parent = getParent(); - return !(parent instanceof JetFile || parent instanceof JetClassBody || parent instanceof JetNamespaceBody); - } + boolean isLocal(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java index f977e848a4a..6be7dfffee7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java @@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetTokens; /** * @author abreslav */ -public class JetFunctionLiteral extends JetFunction { +public class JetFunctionLiteral extends JetFunctionNotStubbed { public JetFunctionLiteral(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionNotStubbed.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionNotStubbed.java new file mode 100644 index 00000000000..42333525b60 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionNotStubbed.java @@ -0,0 +1,110 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.tree.IElementType; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lexer.JetTokens; + +import java.util.Collections; +import java.util.List; + +/** + * @author abreslav + */ +abstract public class JetFunctionNotStubbed extends JetTypeParameterListOwnerNotStubbed + implements JetFunction { + + public JetFunctionNotStubbed(@NotNull ASTNode node) { + super(node); + } + + @Override + @Nullable + public JetParameterList getValueParameterList() { + return (JetParameterList) findChildByType(JetNodeTypes.VALUE_PARAMETER_LIST); + } + + @Override + @NotNull + public List getValueParameters() { + JetParameterList list = getValueParameterList(); + return list != null ? list.getParameters() : Collections.emptyList(); + } + + @Override + @Nullable + public JetExpression getBodyExpression() { + return findChildByClass(JetExpression.class); + } + + @Override + public boolean hasDeclaredReturnType() { + return getReturnTypeRef() != null; + } + + @Override + @Nullable + public JetTypeReference getReceiverTypeRef() { + PsiElement child = getFirstChild(); + while (child != null) { + IElementType tt = child.getNode().getElementType(); + if (tt == JetTokens.LPAR || tt == JetTokens.COLON) break; + if (child instanceof JetTypeReference) { + return (JetTypeReference) child; + } + child = child.getNextSibling(); + } + + return null; + } + + @Override + @Nullable + public JetTypeReference getReturnTypeRef() { + boolean colonPassed = false; + PsiElement child = getFirstChild(); + while (child != null) { + IElementType tt = child.getNode().getElementType(); + if (tt == JetTokens.COLON) { + colonPassed = true; + } + if (colonPassed && child instanceof JetTypeReference) { + return (JetTypeReference) child; + } + child = child.getNextSibling(); + } + + return null; + } + + @NotNull + @Override + public JetElement asElement() { + return this; + } + + @Override + public boolean isLocal() { + PsiElement parent = getParent(); + return !(parent instanceof JetFile || parent instanceof JetClassBody || parent instanceof JetNamespaceBody); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedNamedDeclaration.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclarationNotStubbed.java similarity index 95% rename from compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedNamedDeclaration.java rename to compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclarationNotStubbed.java index 2f969bbdcb3..eb808b0275b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedNamedDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclarationNotStubbed.java @@ -30,8 +30,8 @@ import org.jetbrains.jet.lexer.JetTokens; */ // TODO: Remove when all named declarations get stubs @Deprecated -abstract class JetNotStubbedNamedDeclaration extends JetDeclarationImpl implements JetNamedDeclaration { - public JetNotStubbedNamedDeclaration(@NotNull ASTNode node) { +abstract class JetNamedDeclarationNotStubbed extends JetDeclarationImpl implements JetNamedDeclaration { + public JetNamedDeclarationNotStubbed(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubNamedDeclaration.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclarationStub.java similarity index 91% rename from compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubNamedDeclaration.java rename to compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclarationStub.java index 0205643c025..4f983d74561 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubNamedDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedDeclarationStub.java @@ -30,12 +30,12 @@ import org.jetbrains.jet.lexer.JetTokens; /** * @author Nikolay Krasko */ -abstract class JetStubNamedDeclaration extends JetStubDeclaration implements JetNamedDeclaration { - public JetStubNamedDeclaration(@NotNull T stub, @NotNull IStubElementType nodeType) { +abstract class JetNamedDeclarationStub extends JetDeclarationStub implements JetNamedDeclaration { + public JetNamedDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) { super(stub, nodeType); } - public JetStubNamedDeclaration(@NotNull ASTNode node) { + public JetNamedDeclarationStub(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java index 98981725c84..68749d7c63b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamedFunction.java @@ -20,23 +20,31 @@ import com.intellij.lang.ASTNode; import com.intellij.navigation.ItemPresentation; import com.intellij.navigation.ItemPresentationProviders; import com.intellij.psi.PsiElement; -import com.intellij.psi.StubBasedPsiElement; import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.lang.psi.stubs.PsiJetFunctionStub; import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lexer.JetTokens; +import java.util.Collections; +import java.util.List; + /** * @author max */ -public class JetNamedFunction extends JetFunction implements StubBasedPsiElement>, JetNamed { +public class JetNamedFunction extends JetTypeParameterListOwnerStub implements JetNamed, JetDeclarationWithBody, JetModifierListOwner, JetFunction { public JetNamedFunction(@NotNull ASTNode node) { super(node); } + public JetNamedFunction(@NotNull PsiJetFunctionStub stub) { + super(stub, JetStubElementTypes.FUNCTION); + } + @Override public void accept(@NotNull JetVisitorVoid visitor) { visitor.visitNamedFunction(this); @@ -100,14 +108,85 @@ public class JetNamedFunction extends JetFunction implements StubBasedPsiElement return JetStubElementTypes.FUNCTION; } - @Override - public PsiJetFunctionStub getStub() { - // TODO (stubs) - return null; - } - @Override public ItemPresentation getPresentation() { return ItemPresentationProviders.getItemPresentation(this); } + + @Nullable + public JetParameterList getValueParameterList() { + return (JetParameterList) findChildByType(JetNodeTypes.VALUE_PARAMETER_LIST); + } + + @Override + @NotNull + public List getValueParameters() { + JetParameterList list = getValueParameterList(); + return list != null ? list.getParameters() : Collections.emptyList(); + } + + @Override + @Nullable + public JetExpression getBodyExpression() { + return findChildByClass(JetExpression.class); + } + + @Override + public boolean hasDeclaredReturnType() { + return getReturnTypeRef() != null; + } + + @Nullable + public JetTypeReference getReceiverTypeRef() { + PsiElement child = getFirstChild(); + while (child != null) { + IElementType tt = child.getNode().getElementType(); + if (tt == JetTokens.LPAR || tt == JetTokens.COLON) break; + if (child instanceof JetTypeReference) { + return (JetTypeReference) child; + } + child = child.getNextSibling(); + } + + return null; + } + + @Nullable + public JetTypeReference getReturnTypeRef() { + boolean colonPassed = false; + PsiElement child = getFirstChild(); + while (child != null) { + IElementType tt = child.getNode().getElementType(); + if (tt == JetTokens.COLON) { + colonPassed = true; + } + if (colonPassed && child instanceof JetTypeReference) { + return (JetTypeReference) child; + } + child = child.getNextSibling(); + } + + return null; + } + + @NotNull + @Override + public JetElement asElement() { + return this; + } + + public boolean isLocal() { + PsiElement parent = getParent(); + return !(parent instanceof JetFile || parent instanceof JetClassBody || parent instanceof JetNamespaceBody); + } + + @Override + public String getName() { + PsiJetFunctionStub stub = getStub(); + if (stub != null) { + return stub.getName(); + } + + return super.getName(); + } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclaration.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclaration.java index 3d5d53dd805..c93da5d62c3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclaration.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclaration.java @@ -31,7 +31,7 @@ import java.util.List; /** * @author abreslav */ -public class JetObjectDeclaration extends JetNotStubbedNamedDeclaration implements JetClassOrObject { +public class JetObjectDeclaration extends JetNamedDeclarationNotStubbed implements JetClassOrObject { public JetObjectDeclaration(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclarationName.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclarationName.java index 7de233bcd86..5fcc76e2588 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclarationName.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetObjectDeclarationName.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull; /** * @author abreslav */ -public class JetObjectDeclarationName extends JetNotStubbedNamedDeclaration { +public class JetObjectDeclarationName extends JetNamedDeclarationNotStubbed { public JetObjectDeclarationName(@NotNull ASTNode node) { super(node); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java index 7cb50083c6c..21020e1c25c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetParameter.java @@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetTokens; /** * @author max */ -public class JetParameter extends JetNotStubbedNamedDeclaration { +public class JetParameter extends JetNamedDeclarationNotStubbed { public JetParameter(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java index 2edf63e88dc..4edec5aeb9d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetProperty.java @@ -36,7 +36,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*; /** * @author max */ -public class JetProperty extends JetNotStubbedTypeParameterListOwner implements JetModifierListOwner { +public class JetProperty extends JetTypeParameterListOwnerNotStubbed implements JetModifierListOwner { public JetProperty(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameter.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameter.java index 93b1f351c01..bbf44880fb5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameter.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameter.java @@ -26,7 +26,7 @@ import org.jetbrains.jet.lexer.JetTokens; /** * @author max */ -public class JetTypeParameter extends JetNotStubbedNamedDeclaration { +public class JetTypeParameter extends JetNamedDeclarationNotStubbed { public JetTypeParameter(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedTypeParameterListOwner.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwnerNotStubbed.java similarity index 90% rename from compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedTypeParameterListOwner.java rename to compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwnerNotStubbed.java index e1e84180a54..52164e0b8f1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNotStubbedTypeParameterListOwner.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwnerNotStubbed.java @@ -29,8 +29,8 @@ import java.util.List; */ // TODO: Remove when all implementations of JetTypeParameterListOwner get stubs @Deprecated -abstract class JetNotStubbedTypeParameterListOwner extends JetNotStubbedNamedDeclaration implements JetTypeParameterListOwner { - public JetNotStubbedTypeParameterListOwner(@NotNull ASTNode node) { +abstract class JetTypeParameterListOwnerNotStubbed extends JetNamedDeclarationNotStubbed implements JetTypeParameterListOwner { + public JetTypeParameterListOwnerNotStubbed(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubTypeParameterListOwner.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwnerStub.java similarity index 88% rename from compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubTypeParameterListOwner.java rename to compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwnerStub.java index c384ace349a..9ef112122e1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetStubTypeParameterListOwner.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypeParameterListOwnerStub.java @@ -29,12 +29,12 @@ import java.util.List; /** * @author Nikolay Krasko */ -abstract class JetStubTypeParameterListOwner extends JetStubNamedDeclaration implements JetTypeParameterListOwner { - public JetStubTypeParameterListOwner(@NotNull T stub, @NotNull IStubElementType nodeType) { +abstract class JetTypeParameterListOwnerStub extends JetNamedDeclarationStub implements JetTypeParameterListOwner { + public JetTypeParameterListOwnerStub(@NotNull T stub, @NotNull IStubElementType nodeType) { super(stub, nodeType); } - public JetStubTypeParameterListOwner(@NotNull ASTNode node) { + public JetTypeParameterListOwnerStub(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java index 823d36de1e5..a7bdb7ff548 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetTypedef.java @@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes; /** * @author max */ -public class JetTypedef extends JetNotStubbedTypeParameterListOwner { +public class JetTypedef extends JetTypeParameterListOwnerNotStubbed { public JetTypedef(@NotNull ASTNode node) { super(node); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetFunctionStub.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetFunctionStub.java index 946aed174b4..200ccea30b0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetFunctionStub.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/PsiJetFunctionStub.java @@ -19,12 +19,12 @@ package org.jetbrains.jet.lang.psi.stubs; import com.intellij.psi.stubs.StubElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lang.psi.JetFunction; +import org.jetbrains.jet.lang.psi.JetNamedFunction; /** * @author Nikolay Krasko */ -public interface PsiJetFunctionStub extends StubElement { +public interface PsiJetFunctionStub extends StubElement { @Nullable String getName(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java index ee10753c9cf..479ec26e0f1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/stubs/elements/JetFunctionElementType.java @@ -54,7 +54,7 @@ public class JetFunctionElementType extends JetStubElementType implements PsiJetFunctionStub { +public class PsiJetFunctionStubImpl extends StubBase implements PsiJetFunctionStub { private final StringRef nameRef; private final boolean isTopLevel; diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/RemoveFunctionBodyFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/RemoveFunctionBodyFix.java index 93370305876..dcd2af23e6c 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/RemoveFunctionBodyFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/RemoveFunctionBodyFix.java @@ -61,20 +61,22 @@ public class RemoveFunctionBodyFix extends JetIntentionAction { @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { JetFunction function = (JetFunction) element.copy(); + assert function instanceof ASTDelegatePsiElement; + ASTDelegatePsiElement functionElementWithAst = (ASTDelegatePsiElement) function; JetExpression bodyExpression = function.getBodyExpression(); assert bodyExpression != null; if (function.hasBlockBody()) { PsiElement prevElement = bodyExpression.getPrevSibling(); - QuickFixUtil.removePossiblyWhiteSpace(function, prevElement); - function.deleteChildInternal(bodyExpression.getNode()); + QuickFixUtil.removePossiblyWhiteSpace(functionElementWithAst, prevElement); + functionElementWithAst.deleteChildInternal(bodyExpression.getNode()); } else { PsiElement prevElement = bodyExpression.getPrevSibling(); PsiElement prevPrevElement = prevElement.getPrevSibling(); - QuickFixUtil.removePossiblyWhiteSpace(function, prevElement); - removePossiblyEquationSign(function, prevElement); - removePossiblyEquationSign(function, prevPrevElement); - function.deleteChildInternal(bodyExpression.getNode()); + QuickFixUtil.removePossiblyWhiteSpace(functionElementWithAst, prevElement); + removePossiblyEquationSign(functionElementWithAst, prevElement); + removePossiblyEquationSign(functionElementWithAst, prevPrevElement); + functionElementWithAst.deleteChildInternal(bodyExpression.getNode()); } element.replace(function); }