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
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetClass extends JetStubTypeParameterListOwner<PsiJetClassStub>
|
public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub>
|
||||||
implements JetClassOrObject, JetModifierListOwner {
|
implements JetClassOrObject, JetModifierListOwner {
|
||||||
|
|
||||||
public JetClass(@NotNull ASTNode node) {
|
public JetClass(@NotNull ASTNode node) {
|
||||||
|
|||||||
+3
-3
@@ -30,12 +30,12 @@ import org.jetbrains.jet.lexer.JetToken;
|
|||||||
/**
|
/**
|
||||||
* @author Nikolay Krasko
|
* @author Nikolay Krasko
|
||||||
*/
|
*/
|
||||||
abstract class JetStubDeclaration<T extends StubElement> extends StubBasedPsiElementBase<T> implements JetDeclaration, StubBasedPsiElement<T> {
|
abstract class JetDeclarationStub<T extends StubElement> extends StubBasedPsiElementBase<T> implements JetDeclaration, StubBasedPsiElement<T> {
|
||||||
public JetStubDeclaration(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
public JetDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||||
super(stub, nodeType);
|
super(stub, nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetStubDeclaration(@NotNull ASTNode node) {
|
public JetDeclarationStub(@NotNull ASTNode node) {
|
||||||
super(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;
|
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.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
|
public interface JetFunction extends JetTypeParameterListOwner, JetDeclarationWithBody, JetModifierListOwner {
|
||||||
implements JetDeclarationWithBody, JetModifierListOwner {
|
@Nullable
|
||||||
|
JetParameterList getValueParameterList();
|
||||||
public JetFunction(@NotNull ASTNode node) {
|
|
||||||
super(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public JetParameterList getValueParameterList() {
|
JetTypeReference getReceiverTypeRef();
|
||||||
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
|
@Nullable
|
||||||
public JetTypeReference getReceiverTypeRef() {
|
JetTypeReference getReturnTypeRef();
|
||||||
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;
|
boolean isLocal();
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetFunctionLiteral extends JetFunction {
|
public class JetFunctionLiteral extends JetFunctionNotStubbed {
|
||||||
public JetFunctionLiteral(@NotNull ASTNode node) {
|
public JetFunctionLiteral(@NotNull ASTNode node) {
|
||||||
super(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
|
// TODO: Remove when all named declarations get stubs
|
||||||
@Deprecated
|
@Deprecated
|
||||||
abstract class JetNotStubbedNamedDeclaration extends JetDeclarationImpl implements JetNamedDeclaration {
|
abstract class JetNamedDeclarationNotStubbed extends JetDeclarationImpl implements JetNamedDeclaration {
|
||||||
public JetNotStubbedNamedDeclaration(@NotNull ASTNode node) {
|
public JetNamedDeclarationNotStubbed(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-3
@@ -30,12 +30,12 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author Nikolay Krasko
|
* @author Nikolay Krasko
|
||||||
*/
|
*/
|
||||||
abstract class JetStubNamedDeclaration<T extends StubElement> extends JetStubDeclaration<T> implements JetNamedDeclaration {
|
abstract class JetNamedDeclarationStub<T extends StubElement> extends JetDeclarationStub<T> implements JetNamedDeclaration {
|
||||||
public JetStubNamedDeclaration(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
public JetNamedDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||||
super(stub, nodeType);
|
super(stub, nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetStubNamedDeclaration(@NotNull ASTNode node) {
|
public JetNamedDeclarationStub(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,23 +20,31 @@ import com.intellij.lang.ASTNode;
|
|||||||
import com.intellij.navigation.ItemPresentation;
|
import com.intellij.navigation.ItemPresentation;
|
||||||
import com.intellij.navigation.ItemPresentationProviders;
|
import com.intellij.navigation.ItemPresentationProviders;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.StubBasedPsiElement;
|
|
||||||
import com.intellij.psi.stubs.IStubElementType;
|
import com.intellij.psi.stubs.IStubElementType;
|
||||||
|
import com.intellij.psi.tree.IElementType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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.PsiJetFunctionStub;
|
||||||
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author max
|
* @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) {
|
public JetNamedFunction(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JetNamedFunction(@NotNull PsiJetFunctionStub stub) {
|
||||||
|
super(stub, JetStubElementTypes.FUNCTION);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(@NotNull JetVisitorVoid visitor) {
|
public void accept(@NotNull JetVisitorVoid visitor) {
|
||||||
visitor.visitNamedFunction(this);
|
visitor.visitNamedFunction(this);
|
||||||
@@ -100,14 +108,85 @@ public class JetNamedFunction extends JetFunction implements StubBasedPsiElement
|
|||||||
return JetStubElementTypes.FUNCTION;
|
return JetStubElementTypes.FUNCTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public PsiJetFunctionStub<?> getStub() {
|
|
||||||
// TODO (stubs)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemPresentation getPresentation() {
|
public ItemPresentation getPresentation() {
|
||||||
return ItemPresentationProviders.getItemPresentation(this);
|
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
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetObjectDeclaration extends JetNotStubbedNamedDeclaration implements JetClassOrObject {
|
public class JetObjectDeclaration extends JetNamedDeclarationNotStubbed implements JetClassOrObject {
|
||||||
public JetObjectDeclaration(@NotNull ASTNode node) {
|
public JetObjectDeclaration(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* @author abreslav
|
* @author abreslav
|
||||||
*/
|
*/
|
||||||
public class JetObjectDeclarationName extends JetNotStubbedNamedDeclaration {
|
public class JetObjectDeclarationName extends JetNamedDeclarationNotStubbed {
|
||||||
|
|
||||||
public JetObjectDeclarationName(@NotNull ASTNode node) {
|
public JetObjectDeclarationName(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetParameter extends JetNotStubbedNamedDeclaration {
|
public class JetParameter extends JetNamedDeclarationNotStubbed {
|
||||||
public JetParameter(@NotNull ASTNode node) {
|
public JetParameter(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetProperty extends JetNotStubbedTypeParameterListOwner implements JetModifierListOwner {
|
public class JetProperty extends JetTypeParameterListOwnerNotStubbed implements JetModifierListOwner {
|
||||||
public JetProperty(@NotNull ASTNode node) {
|
public JetProperty(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTypeParameter extends JetNotStubbedNamedDeclaration {
|
public class JetTypeParameter extends JetNamedDeclarationNotStubbed {
|
||||||
public JetTypeParameter(@NotNull ASTNode node) {
|
public JetTypeParameter(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -29,8 +29,8 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
// TODO: Remove when all implementations of JetTypeParameterListOwner get stubs
|
// TODO: Remove when all implementations of JetTypeParameterListOwner get stubs
|
||||||
@Deprecated
|
@Deprecated
|
||||||
abstract class JetNotStubbedTypeParameterListOwner extends JetNotStubbedNamedDeclaration implements JetTypeParameterListOwner {
|
abstract class JetTypeParameterListOwnerNotStubbed extends JetNamedDeclarationNotStubbed implements JetTypeParameterListOwner {
|
||||||
public JetNotStubbedTypeParameterListOwner(@NotNull ASTNode node) {
|
public JetTypeParameterListOwnerNotStubbed(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-3
@@ -29,12 +29,12 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* @author Nikolay Krasko
|
* @author Nikolay Krasko
|
||||||
*/
|
*/
|
||||||
abstract class JetStubTypeParameterListOwner<T extends StubElement> extends JetStubNamedDeclaration<T> implements JetTypeParameterListOwner {
|
abstract class JetTypeParameterListOwnerStub<T extends StubElement> extends JetNamedDeclarationStub<T> implements JetTypeParameterListOwner {
|
||||||
public JetStubTypeParameterListOwner(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
public JetTypeParameterListOwnerStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||||
super(stub, nodeType);
|
super(stub, nodeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetStubTypeParameterListOwner(@NotNull ASTNode node) {
|
public JetTypeParameterListOwnerStub(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.JetNodeTypes;
|
|||||||
/**
|
/**
|
||||||
* @author max
|
* @author max
|
||||||
*/
|
*/
|
||||||
public class JetTypedef extends JetNotStubbedTypeParameterListOwner {
|
public class JetTypedef extends JetTypeParameterListOwnerNotStubbed {
|
||||||
public JetTypedef(@NotNull ASTNode node) {
|
public JetTypedef(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ package org.jetbrains.jet.lang.psi.stubs;
|
|||||||
import com.intellij.psi.stubs.StubElement;
|
import com.intellij.psi.stubs.StubElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nikolay Krasko
|
* @author Nikolay Krasko
|
||||||
*/
|
*/
|
||||||
public interface PsiJetFunctionStub <T extends JetFunction> extends StubElement<T> {
|
public interface PsiJetFunctionStub extends StubElement<JetNamedFunction> {
|
||||||
@Nullable
|
@Nullable
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ public class JetFunctionElementType extends JetStubElementType<PsiJetFunctionStu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetNamedFunction createPsi(@NotNull PsiJetFunctionStub stub) {
|
public JetNamedFunction createPsi(@NotNull PsiJetFunctionStub stub) {
|
||||||
return null;
|
return new JetNamedFunction(stub);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+2
-2
@@ -22,13 +22,13 @@ import com.intellij.psi.stubs.StubElement;
|
|||||||
import com.intellij.util.io.StringRef;
|
import com.intellij.util.io.StringRef;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
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;
|
import org.jetbrains.jet.lang.psi.stubs.PsiJetFunctionStub;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Nikolay Krasko
|
* @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 StringRef nameRef;
|
||||||
private final boolean isTopLevel;
|
private final boolean isTopLevel;
|
||||||
|
|||||||
@@ -61,20 +61,22 @@ public class RemoveFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
|||||||
@Override
|
@Override
|
||||||
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
|
||||||
JetFunction function = (JetFunction) element.copy();
|
JetFunction function = (JetFunction) element.copy();
|
||||||
|
assert function instanceof ASTDelegatePsiElement;
|
||||||
|
ASTDelegatePsiElement functionElementWithAst = (ASTDelegatePsiElement) function;
|
||||||
JetExpression bodyExpression = function.getBodyExpression();
|
JetExpression bodyExpression = function.getBodyExpression();
|
||||||
assert bodyExpression != null;
|
assert bodyExpression != null;
|
||||||
if (function.hasBlockBody()) {
|
if (function.hasBlockBody()) {
|
||||||
PsiElement prevElement = bodyExpression.getPrevSibling();
|
PsiElement prevElement = bodyExpression.getPrevSibling();
|
||||||
QuickFixUtil.removePossiblyWhiteSpace(function, prevElement);
|
QuickFixUtil.removePossiblyWhiteSpace(functionElementWithAst, prevElement);
|
||||||
function.deleteChildInternal(bodyExpression.getNode());
|
functionElementWithAst.deleteChildInternal(bodyExpression.getNode());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PsiElement prevElement = bodyExpression.getPrevSibling();
|
PsiElement prevElement = bodyExpression.getPrevSibling();
|
||||||
PsiElement prevPrevElement = prevElement.getPrevSibling();
|
PsiElement prevPrevElement = prevElement.getPrevSibling();
|
||||||
QuickFixUtil.removePossiblyWhiteSpace(function, prevElement);
|
QuickFixUtil.removePossiblyWhiteSpace(functionElementWithAst, prevElement);
|
||||||
removePossiblyEquationSign(function, prevElement);
|
removePossiblyEquationSign(functionElementWithAst, prevElement);
|
||||||
removePossiblyEquationSign(function, prevPrevElement);
|
removePossiblyEquationSign(functionElementWithAst, prevPrevElement);
|
||||||
function.deleteChildInternal(bodyExpression.getNode());
|
functionElementWithAst.deleteChildInternal(bodyExpression.getNode());
|
||||||
}
|
}
|
||||||
element.replace(function);
|
element.replace(function);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user