Stubs:
- Activate stub behaviour for named functions - Move information about stubs implementation to the suffix of class names
This commit is contained in:
@@ -37,7 +37,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class JetClass extends JetStubTypeParameterListOwner<PsiJetClassStub>
|
||||
public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub>
|
||||
implements JetClassOrObject, JetModifierListOwner {
|
||||
|
||||
public JetClass(@NotNull ASTNode node) {
|
||||
|
||||
+3
-3
@@ -30,12 +30,12 @@ import org.jetbrains.jet.lexer.JetToken;
|
||||
/**
|
||||
* @author Nikolay Krasko
|
||||
*/
|
||||
abstract class JetStubDeclaration<T extends StubElement> extends StubBasedPsiElementBase<T> implements JetDeclaration, StubBasedPsiElement<T> {
|
||||
public JetStubDeclaration(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
abstract class JetDeclarationStub<T extends StubElement> extends StubBasedPsiElementBase<T> implements JetDeclaration, StubBasedPsiElement<T> {
|
||||
public JetDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
|
||||
public JetStubDeclaration(@NotNull ASTNode node) {
|
||||
public JetDeclarationStub(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@@ -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<JetParameter> getValueParameters() {
|
||||
JetParameterList list = getValueParameterList();
|
||||
return list != null ? list.getParameters() : Collections.<JetParameter>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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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<JetParameter> getValueParameters() {
|
||||
JetParameterList list = getValueParameterList();
|
||||
return list != null ? list.getParameters() : Collections.<JetParameter>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);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -30,12 +30,12 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
/**
|
||||
* @author Nikolay Krasko
|
||||
*/
|
||||
abstract class JetStubNamedDeclaration<T extends StubElement> extends JetStubDeclaration<T> implements JetNamedDeclaration {
|
||||
public JetStubNamedDeclaration(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
abstract class JetNamedDeclarationStub<T extends StubElement> extends JetDeclarationStub<T> 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);
|
||||
}
|
||||
|
||||
@@ -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<PsiJetFunctionStub<?>>, JetNamed {
|
||||
public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFunctionStub> 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<JetParameter> getValueParameters() {
|
||||
JetParameterList list = getValueParameterList();
|
||||
return list != null ? list.getParameters() : Collections.<JetParameter>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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
+3
-3
@@ -29,12 +29,12 @@ import java.util.List;
|
||||
/**
|
||||
* @author Nikolay Krasko
|
||||
*/
|
||||
abstract class JetStubTypeParameterListOwner<T extends StubElement> extends JetStubNamedDeclaration<T> implements JetTypeParameterListOwner {
|
||||
public JetStubTypeParameterListOwner(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
abstract class JetTypeParameterListOwnerStub<T extends StubElement> extends JetNamedDeclarationStub<T> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 <T extends JetFunction> extends StubElement<T> {
|
||||
public interface PsiJetFunctionStub extends StubElement<JetNamedFunction> {
|
||||
@Nullable
|
||||
String getName();
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class JetFunctionElementType extends JetStubElementType<PsiJetFunctionStu
|
||||
|
||||
@Override
|
||||
public JetNamedFunction createPsi(@NotNull PsiJetFunctionStub stub) {
|
||||
return null;
|
||||
return new JetNamedFunction(stub);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -22,13 +22,13 @@ import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetFunctionStub;
|
||||
|
||||
/**
|
||||
* @author Nikolay Krasko
|
||||
*/
|
||||
public class PsiJetFunctionStubImpl extends StubBase<JetFunction> implements PsiJetFunctionStub<JetFunction> {
|
||||
public class PsiJetFunctionStubImpl extends StubBase<JetNamedFunction> implements PsiJetFunctionStub {
|
||||
|
||||
private final StringRef nameRef;
|
||||
private final boolean isTopLevel;
|
||||
|
||||
@@ -61,20 +61,22 @@ public class RemoveFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
||||
@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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user