Add getFqName() to JetNamedDeclaration interface
Use stubs to get fq name in stubbed implementations
This commit is contained in:
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
public class JetFunctionLiteral extends JetFunctionNotStubbed {
|
||||
@@ -66,4 +67,10 @@ public class JetFunctionLiteral extends JetFunctionNotStubbed {
|
||||
public ASTNode getArrowNode() {
|
||||
return getNode().findChildByType(JetTokens.ARROW);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getFqName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import static org.jetbrains.jet.lexer.JetTokens.VAL_KEYWORD;
|
||||
@@ -63,4 +64,10 @@ public class JetMultiDeclarationEntry extends JetNamedDeclarationNotStubbed impl
|
||||
public ASTNode getValOrVarNode() {
|
||||
return getParentNode().findChildByType(TokenSet.create(VAL_KEYWORD, VAR_KEYWORD));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getFqName() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,12 @@ package org.jetbrains.jet.lang.psi;
|
||||
import com.intellij.psi.PsiNameIdentifierOwner;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public interface JetNamedDeclaration extends JetDeclaration, PsiNameIdentifierOwner, JetStatementExpression, JetNamed {
|
||||
@NotNull
|
||||
Name getNameAsSafeName();
|
||||
@Nullable
|
||||
FqName getFqName();
|
||||
}
|
||||
|
||||
@@ -21,14 +21,16 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.SearchScope;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetStubWithFqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
abstract class JetNamedDeclarationStub<T extends NamedStub> extends JetDeclarationStub<T> implements JetNamedDeclaration {
|
||||
abstract class JetNamedDeclarationStub<T extends PsiJetStubWithFqName> extends JetDeclarationStub<T> implements JetNamedDeclaration {
|
||||
public JetNamedDeclarationStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
@@ -92,4 +94,14 @@ abstract class JetNamedDeclarationStub<T extends NamedStub> extends JetDeclarati
|
||||
|
||||
return super.getUseScope();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getFqName() {
|
||||
T stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getFqName();
|
||||
}
|
||||
return JetPsiUtil.getFQName(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ 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.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -76,35 +74,6 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
|
||||
return PsiTreeUtil.getNextSiblingOfType(getEqualsToken(), JetExpression.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns full qualified name for function "package_fqn.function_name"
|
||||
* Not null for top level functions unless syntax errors are present.
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public FqName getFqName() {
|
||||
PsiJetFunctionStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getTopFQName();
|
||||
}
|
||||
|
||||
PsiElement parent = getParent();
|
||||
if (parent instanceof JetFile) {
|
||||
// fqname is different in scripts
|
||||
if (((JetFile) parent).getPackageDirective() == null) {
|
||||
return null;
|
||||
}
|
||||
JetFile jetFile = (JetFile) parent;
|
||||
FqName fileFQN = JetPsiUtil.getFQName(jetFile);
|
||||
Name nameAsName = getNameAsName();
|
||||
if (nameAsName != null) {
|
||||
return fileFQN.child(nameAsName);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
return ItemPresentationProviders.getItemPresentation(this);
|
||||
|
||||
@@ -54,19 +54,6 @@ public class JetObjectDeclaration extends JetNamedDeclarationStub<PsiJetObjectSt
|
||||
return nameAsDeclaration == null ? null : nameAsDeclaration.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Could be null for anonymous objects and object declared inside functions
|
||||
* @return
|
||||
*/
|
||||
public FqName getFqName() {
|
||||
PsiJetObjectStub stub = getStub();
|
||||
if (stub != null) {
|
||||
return stub.getFqName();
|
||||
}
|
||||
|
||||
return JetPsiUtil.getFQName(this);
|
||||
}
|
||||
|
||||
public boolean isTopLevel() {
|
||||
PsiJetObjectStub stub = getStub();
|
||||
if (stub != null) {
|
||||
|
||||
@@ -18,15 +18,15 @@ package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.stubs.IStubElementType;
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetStubWithFqName;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
abstract class JetTypeParameterListOwnerStub<T extends NamedStub> extends JetNamedDeclarationStub<T> implements JetTypeParameterListOwner {
|
||||
abstract class JetTypeParameterListOwnerStub<T extends PsiJetStubWithFqName> extends JetNamedDeclarationStub<T> implements JetTypeParameterListOwner {
|
||||
public JetTypeParameterListOwnerStub(@NotNull T stub, @NotNull IStubElementType nodeType) {
|
||||
super(stub, nodeType);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.lang.ASTNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
public class JetTypedef extends JetTypeParameterListOwnerNotStubbed {
|
||||
public JetTypedef(@NotNull ASTNode node) {
|
||||
@@ -35,4 +36,11 @@ public class JetTypedef extends JetTypeParameterListOwnerNotStubbed {
|
||||
public JetTypeReference getTypeReference() {
|
||||
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getFqName() {
|
||||
//TODO: typedefs are unsupported
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,16 +16,10 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
public interface PsiJetFunctionStub extends NamedStub<JetNamedFunction> {
|
||||
@Nullable
|
||||
FqName getTopFQName();
|
||||
|
||||
public interface PsiJetFunctionStub extends PsiJetStubWithFqName<JetNamedFunction> {
|
||||
/**
|
||||
* Is function defined in directly in package.
|
||||
* @return
|
||||
|
||||
@@ -16,17 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
|
||||
public interface PsiJetParameterStub extends NamedStub<JetParameter> {
|
||||
public interface PsiJetParameterStub extends PsiJetStubWithFqName<JetParameter> {
|
||||
boolean isMutable();
|
||||
boolean isVarArg();
|
||||
|
||||
@Nullable
|
||||
String getTypeText();
|
||||
|
||||
@Nullable
|
||||
String getDefaultValueText();
|
||||
}
|
||||
|
||||
@@ -16,19 +16,11 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
public interface PsiJetPropertyStub extends NamedStub<JetProperty> {
|
||||
public interface PsiJetPropertyStub extends PsiJetStubWithFqName<JetProperty> {
|
||||
boolean isVar();
|
||||
|
||||
boolean isTopLevel();
|
||||
|
||||
@Nullable
|
||||
FqName getTopFQName();
|
||||
|
||||
String getTypeText();
|
||||
String getInferenceBodyText();
|
||||
}
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi.stubs;
|
||||
|
||||
import com.intellij.psi.stubs.NamedStub;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeParameter;
|
||||
|
||||
public interface PsiJetTypeParameterStub extends NamedStub<JetTypeParameter> {
|
||||
public interface PsiJetTypeParameterStub extends PsiJetStubWithFqName<JetTypeParameter> {
|
||||
String getExtendBoundTypeText();
|
||||
boolean isInVariance();
|
||||
boolean isOutVariance();
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class JetClassElementType extends JetStubElementType<PsiJetClassStub, Jet
|
||||
|
||||
@Override
|
||||
public PsiJetClassStub createStub(@NotNull JetClass psi, StubElement parentStub) {
|
||||
FqName fqName = JetPsiUtil.getFQName(psi);
|
||||
FqName fqName = psi.getFqName();
|
||||
boolean isEnumEntry = psi instanceof JetEnumEntry;
|
||||
List<String> superNames = PsiUtilPackage.getSuperNames(psi);
|
||||
return new PsiJetClassStubImpl(
|
||||
|
||||
+4
-4
@@ -77,8 +77,8 @@ public class JetFunctionElementType extends JetStubElementType<PsiJetFunctionStu
|
||||
dataStream.writeName(stub.getName());
|
||||
dataStream.writeBoolean(stub.isTopLevel());
|
||||
|
||||
FqName topFQName = stub.getTopFQName();
|
||||
dataStream.writeName(topFQName != null ? topFQName.toString() : null);
|
||||
FqName fqName = stub.getFqName();
|
||||
dataStream.writeName(fqName != null ? fqName.asString() : null);
|
||||
|
||||
dataStream.writeBoolean(stub.isExtension());
|
||||
}
|
||||
@@ -89,8 +89,8 @@ public class JetFunctionElementType extends JetStubElementType<PsiJetFunctionStu
|
||||
StringRef name = dataStream.readName();
|
||||
boolean isTopLevel = dataStream.readBoolean();
|
||||
|
||||
StringRef topFQNameStr = dataStream.readName();
|
||||
FqName fqName = topFQNameStr != null ? new FqName(topFQNameStr.toString()) : null;
|
||||
StringRef fqNameAsString = dataStream.readName();
|
||||
FqName fqName = fqNameAsString != null ? new FqName(fqNameAsString.toString()) : null;
|
||||
|
||||
boolean isExtension = dataStream.readBoolean();
|
||||
|
||||
|
||||
+7
-2
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeReference;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetParameterStub;
|
||||
import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetParameterStubImpl;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -53,7 +54,7 @@ public class JetParameterElementType extends JetStubElementType<PsiJetParameterS
|
||||
JetTypeReference typeReference = psi.getTypeReference();
|
||||
JetExpression defaultValue = psi.getDefaultValue();
|
||||
|
||||
return new PsiJetParameterStubImpl(JetStubElementTypes.VALUE_PARAMETER, parentStub,
|
||||
return new PsiJetParameterStubImpl(JetStubElementTypes.VALUE_PARAMETER, parentStub, psi.getFqName(),
|
||||
psi.getName(), psi.isMutable(), psi.isVarArg(),
|
||||
typeReference != null ? typeReference.getText() : null,
|
||||
defaultValue != null ? defaultValue.getText() : null);
|
||||
@@ -75,6 +76,8 @@ public class JetParameterElementType extends JetStubElementType<PsiJetParameterS
|
||||
dataStream.writeBoolean(stub.isVarArg());
|
||||
dataStream.writeName(stub.getTypeText());
|
||||
dataStream.writeName(stub.getDefaultValueText());
|
||||
FqName name = stub.getFqName();
|
||||
dataStream.writeName(name != null ? name.asString() : null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -85,8 +88,10 @@ public class JetParameterElementType extends JetStubElementType<PsiJetParameterS
|
||||
boolean isVarArg = dataStream.readBoolean();
|
||||
StringRef typeText = dataStream.readName();
|
||||
StringRef defaultValueText = dataStream.readName();
|
||||
StringRef fqNameAsString = dataStream.readName();
|
||||
FqName fqName = fqNameAsString != null ? new FqName(fqNameAsString.toString()) : null;
|
||||
|
||||
return new PsiJetParameterStubImpl(JetStubElementTypes.VALUE_PARAMETER, parentStub, name, isMutable, isVarArg,
|
||||
return new PsiJetParameterStubImpl(JetStubElementTypes.VALUE_PARAMETER, parentStub, fqName, name, isMutable, isVarArg,
|
||||
typeText, defaultValueText);
|
||||
}
|
||||
|
||||
|
||||
+5
-6
@@ -27,7 +27,6 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeReference;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetPropertyStub;
|
||||
import org.jetbrains.jet.lang.psi.stubs.impl.PsiJetPropertyStubImpl;
|
||||
@@ -73,7 +72,7 @@ public class JetPropertyElementType extends JetStubElementType<PsiJetPropertyStu
|
||||
psi.getText(), psi.getParent() != null ? psi.getParent().getText() : "<no parent>");
|
||||
|
||||
return new PsiJetPropertyStubImpl(JetStubElementTypes.PROPERTY, parentStub,
|
||||
psi.getName(), psi.isVar(), psi.isTopLevel(), JetPsiUtil.getFQName(psi),
|
||||
psi.getName(), psi.isVar(), psi.isTopLevel(), psi.getFqName(),
|
||||
typeRef != null ? typeRef.getText() : null,
|
||||
expression != null ? expression.getText() : null);
|
||||
}
|
||||
@@ -84,8 +83,8 @@ public class JetPropertyElementType extends JetStubElementType<PsiJetPropertyStu
|
||||
dataStream.writeBoolean(stub.isVar());
|
||||
dataStream.writeBoolean(stub.isTopLevel());
|
||||
|
||||
FqName topFQName = stub.getTopFQName();
|
||||
dataStream.writeName(topFQName != null ? topFQName.toString() : null);
|
||||
FqName fqName = stub.getFqName();
|
||||
dataStream.writeName(fqName != null ? fqName.asString() : null);
|
||||
|
||||
dataStream.writeName(stub.getTypeText());
|
||||
dataStream.writeName(stub.getInferenceBodyText());
|
||||
@@ -98,8 +97,8 @@ public class JetPropertyElementType extends JetStubElementType<PsiJetPropertyStu
|
||||
boolean isVar = dataStream.readBoolean();
|
||||
boolean isTopLevel = dataStream.readBoolean();
|
||||
|
||||
StringRef topFQNameStr = dataStream.readName();
|
||||
FqName fqName = topFQNameStr != null ? new FqName(topFQNameStr.toString()) : null;
|
||||
StringRef fqNameAsString = dataStream.readName();
|
||||
FqName fqName = fqNameAsString != null ? new FqName(fqNameAsString.toString()) : null;
|
||||
|
||||
StringRef typeText = dataStream.readName();
|
||||
StringRef inferenceBodyText = dataStream.readName();
|
||||
|
||||
+15
-15
@@ -32,16 +32,16 @@ public class PsiJetFunctionStubImpl extends StubBase<JetNamedFunction> implement
|
||||
private final StringRef nameRef;
|
||||
private final boolean isTopLevel;
|
||||
private final boolean isExtension;
|
||||
private final FqName topFQName;
|
||||
private final FqName fqName;
|
||||
|
||||
public PsiJetFunctionStubImpl(
|
||||
@NotNull IStubElementType elementType,
|
||||
@NotNull StubElement parent,
|
||||
@Nullable String name,
|
||||
boolean isTopLevel,
|
||||
@Nullable FqName topFQName,
|
||||
@Nullable FqName fqName,
|
||||
boolean isExtension) {
|
||||
this(elementType, parent, StringRef.fromString(name), isTopLevel, topFQName, isExtension);
|
||||
this(elementType, parent, StringRef.fromString(name), isTopLevel, fqName, isExtension);
|
||||
}
|
||||
|
||||
public PsiJetFunctionStubImpl(
|
||||
@@ -49,16 +49,16 @@ public class PsiJetFunctionStubImpl extends StubBase<JetNamedFunction> implement
|
||||
@NotNull StubElement parent,
|
||||
@Nullable StringRef nameRef,
|
||||
boolean isTopLevel,
|
||||
@Nullable FqName topFQName,
|
||||
@Nullable FqName fqName,
|
||||
boolean isExtension) {
|
||||
super(parent, elementType);
|
||||
|
||||
if (isTopLevel && topFQName == null) {
|
||||
throw new IllegalArgumentException("topFQName shouldn't be null for top level functions");
|
||||
if (isTopLevel && fqName == null) {
|
||||
throw new IllegalArgumentException("fqName shouldn't be null for top level functions");
|
||||
}
|
||||
|
||||
this.nameRef = nameRef;
|
||||
this.topFQName = topFQName;
|
||||
this.fqName = fqName;
|
||||
this.isTopLevel = isTopLevel;
|
||||
this.isExtension = isExtension;
|
||||
}
|
||||
@@ -68,12 +68,6 @@ public class PsiJetFunctionStubImpl extends StubBase<JetNamedFunction> implement
|
||||
return StringRef.toString(nameRef);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getTopFQName() {
|
||||
return topFQName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTopLevel() {
|
||||
return isTopLevel;
|
||||
@@ -97,8 +91,8 @@ public class PsiJetFunctionStubImpl extends StubBase<JetNamedFunction> implement
|
||||
builder.append("PsiJetFunctionStubImpl[");
|
||||
|
||||
if (isTopLevel()) {
|
||||
assert topFQName != null;
|
||||
builder.append("top ").append("topFQName=").append(topFQName.toString()).append(" ");
|
||||
assert fqName != null;
|
||||
builder.append("top ").append("fqName=").append(fqName.toString()).append(" ");
|
||||
}
|
||||
|
||||
if (isExtension()) {
|
||||
@@ -111,4 +105,10 @@ public class PsiJetFunctionStubImpl extends StubBase<JetNamedFunction> implement
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getFqName() {
|
||||
return fqName;
|
||||
}
|
||||
}
|
||||
|
||||
+24
-7
@@ -23,6 +23,7 @@ import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetParameter;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetParameterStub;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
public class PsiJetParameterStubImpl extends StubBase<JetParameter> implements PsiJetParameterStub {
|
||||
private final StringRef name;
|
||||
@@ -30,26 +31,33 @@ public class PsiJetParameterStubImpl extends StubBase<JetParameter> implements P
|
||||
private final boolean isVarArg;
|
||||
private final StringRef typeText;
|
||||
private final StringRef defaultValueText;
|
||||
private final FqName fqName;
|
||||
|
||||
public PsiJetParameterStubImpl(IStubElementType elementType, StubElement parent,
|
||||
StringRef name,
|
||||
public PsiJetParameterStubImpl(
|
||||
IStubElementType elementType, StubElement parent,
|
||||
FqName fqName, StringRef name,
|
||||
boolean isMutable,
|
||||
boolean isVarArg,
|
||||
StringRef typeText, StringRef defaultValueText) {
|
||||
StringRef typeText, StringRef defaultValueText
|
||||
) {
|
||||
super(parent, elementType);
|
||||
this.name = name;
|
||||
this.isMutable = isMutable;
|
||||
this.isVarArg = isVarArg;
|
||||
this.typeText = typeText;
|
||||
this.defaultValueText = defaultValueText;
|
||||
this.fqName = fqName;
|
||||
}
|
||||
|
||||
public PsiJetParameterStubImpl(IStubElementType elementType, StubElement parent,
|
||||
String name,
|
||||
public PsiJetParameterStubImpl(
|
||||
IStubElementType elementType, StubElement parent,
|
||||
FqName fqName, String name,
|
||||
boolean isMutable,
|
||||
boolean isVarArg,
|
||||
String typeText, String defaultValueText) {
|
||||
this(elementType, parent, StringRef.fromString(name), isMutable, isVarArg,
|
||||
String typeText,
|
||||
String defaultValueText
|
||||
) {
|
||||
this(elementType, parent, fqName, StringRef.fromString(name), isMutable, isVarArg,
|
||||
StringRef.fromString(typeText), StringRef.fromString(defaultValueText));
|
||||
}
|
||||
|
||||
@@ -91,6 +99,9 @@ public class PsiJetParameterStubImpl extends StubBase<JetParameter> implements P
|
||||
}
|
||||
|
||||
builder.append("name=").append(getName());
|
||||
if (fqName != null) {
|
||||
builder.append(" fqName=").append(fqName.toString()).append(" ");
|
||||
}
|
||||
builder.append(" typeText=").append(getTypeText());
|
||||
builder.append(" defaultValue=").append(getDefaultValueText());
|
||||
|
||||
@@ -98,4 +109,10 @@ public class PsiJetParameterStubImpl extends StubBase<JetParameter> implements P
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getFqName() {
|
||||
return fqName;
|
||||
}
|
||||
}
|
||||
|
||||
+9
-9
@@ -29,22 +29,22 @@ public class PsiJetPropertyStubImpl extends StubBase<JetProperty> implements Psi
|
||||
private final StringRef name;
|
||||
private final boolean isVar;
|
||||
private final boolean isTopLevel;
|
||||
private final FqName topFQName;
|
||||
private final FqName fqName;
|
||||
private final StringRef typeText;
|
||||
private final StringRef inferenceBodyText;
|
||||
|
||||
public PsiJetPropertyStubImpl(IStubElementType elementType, StubElement parent, StringRef name,
|
||||
boolean isVar, boolean isTopLevel, @Nullable FqName topFQName, StringRef typeText, StringRef inferenceBodyText) {
|
||||
boolean isVar, boolean isTopLevel, @Nullable FqName fqName, StringRef typeText, StringRef inferenceBodyText) {
|
||||
super(parent, elementType);
|
||||
|
||||
if (isTopLevel && topFQName == null) {
|
||||
throw new IllegalArgumentException("topFQName shouldn't be null for top level properties");
|
||||
if (isTopLevel && fqName == null) {
|
||||
throw new IllegalArgumentException("fqName shouldn't be null for top level properties");
|
||||
}
|
||||
|
||||
this.name = name;
|
||||
this.isVar = isVar;
|
||||
this.isTopLevel = isTopLevel;
|
||||
this.topFQName = topFQName;
|
||||
this.fqName = fqName;
|
||||
this.typeText = typeText;
|
||||
this.inferenceBodyText = inferenceBodyText;
|
||||
}
|
||||
@@ -69,8 +69,8 @@ public class PsiJetPropertyStubImpl extends StubBase<JetProperty> implements Psi
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getTopFQName() {
|
||||
return topFQName;
|
||||
public FqName getFqName() {
|
||||
return fqName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,8 +97,8 @@ public class PsiJetPropertyStubImpl extends StubBase<JetProperty> implements Psi
|
||||
builder.append(isVar() ? "var " : "val ");
|
||||
|
||||
if (isTopLevel()) {
|
||||
assert topFQName != null;
|
||||
builder.append("top ").append("topFQName=").append(topFQName.toString()).append(" ");
|
||||
assert fqName != null;
|
||||
builder.append("top ").append("fqName=").append(fqName.toString()).append(" ");
|
||||
}
|
||||
|
||||
builder.append("name=").append(getName());
|
||||
|
||||
+9
@@ -19,9 +19,11 @@ package org.jetbrains.jet.lang.psi.stubs.impl;
|
||||
import com.intellij.psi.stubs.StubBase;
|
||||
import com.intellij.psi.stubs.StubElement;
|
||||
import com.intellij.util.io.StringRef;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeParameter;
|
||||
import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterStub;
|
||||
import org.jetbrains.jet.lang.psi.stubs.elements.JetTypeParameterElementType;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
public class PsiJetTypeParameterStubImpl extends StubBase<JetTypeParameter> implements PsiJetTypeParameterStub {
|
||||
private final StringRef name;
|
||||
@@ -84,4 +86,11 @@ public class PsiJetTypeParameterStubImpl extends StubBase<JetTypeParameter> impl
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FqName getFqName() {
|
||||
// type parameters doesn't have FqNames
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class StubIndexServiceImpl implements StubIndexService {
|
||||
sink.occurrence(JetTopLevelExtensionFunctionShortNameIndex.getInstance().getKey(), name);
|
||||
}
|
||||
|
||||
FqName topFQName = stub.getTopFQName();
|
||||
FqName topFQName = stub.getFqName();
|
||||
if (topFQName != null) {
|
||||
sink.occurrence(JetTopLevelFunctionsFqnNameIndex.getInstance().getKey(), topFQName.asString());
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class StubIndexServiceImpl implements StubIndexService {
|
||||
String propertyName = stub.getName();
|
||||
if (propertyName != null) {
|
||||
if (stub.isTopLevel()) {
|
||||
FqName topFQName = stub.getTopFQName();
|
||||
FqName topFQName = stub.getFqName();
|
||||
if (topFQName != null) {
|
||||
sink.occurrence(JetTopLevelPropertiesFqnNameIndex.getInstance().getKey(), topFQName.asString());
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testFunctionParameters() {
|
||||
doBuildTest("fun some(t: Int, other: String = \"hello\") { }",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=some name=some]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=some name=some]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" +
|
||||
" VALUE_PARAMETER:PsiJetParameterStubImpl[val name=t typeText=Int defaultValue=null]\n" +
|
||||
" VALUE_PARAMETER:PsiJetParameterStubImpl[val name=other typeText=String defaultValue=\"hello\"]\n");
|
||||
@@ -102,7 +102,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
doBuildTest("package test.testing\n" +
|
||||
"val some = 12",
|
||||
"PsiJetFileStubImpl[package=test.testing]\n" +
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val top topFQName=test.testing.some name=some typeText=null bodyText=12]\n");
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val top fqName=test.testing.some name=some typeText=null bodyText=12]\n");
|
||||
}
|
||||
|
||||
public void testClassProperty() {
|
||||
@@ -117,14 +117,14 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testNotStorePropertyFromInitializer() {
|
||||
doBuildTest("fun DoubleArray.some() = for (element in this) println(element)",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=some ext name=some]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=some ext name=some]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
|
||||
public void testNotStorePropertyFromDelegate() {
|
||||
doBuildTest("val a by kotlin.\n val b = 1",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val top topFQName=a name=a typeText=null bodyText=null]\n");
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val top fqName=a name=a typeText=null bodyText=null]\n");
|
||||
}
|
||||
|
||||
public void testNotStorePropertiesFrom() {
|
||||
@@ -172,7 +172,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" +
|
||||
" CLASS:PsiJetClassStubImpl[local name=Test fqn=null superNames=[AT]]\n");
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" +
|
||||
" CLASS:PsiJetClassStubImpl[local name=Test fqn=null superNames=[AT]]\n");
|
||||
}
|
||||
@@ -200,7 +200,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n" +
|
||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[local name=O fqName=null superNames=[AT]]\n");
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[name=A fqn=A superNames=[]]\n" +
|
||||
" CLASS:PsiJetClassStubImpl[trait name=T fqn=T superNames=[]]\n" +
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val top topFQName=obj name=obj typeText=null bodyText=object : A(), T]\n" +
|
||||
" PROPERTY:PsiJetPropertyStubImpl[val top fqName=obj name=obj typeText=null bodyText=object : A(), T]\n" +
|
||||
" OBJECT_DECLARATION:PsiJetObjectStubImpl[local name=null fqName=null superNames=[AT]]\n");
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testAnnotationOnFunction() {
|
||||
doBuildTest("Deprecated fun foo() {}",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" +
|
||||
" ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
@@ -232,7 +232,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testQualifiedAnnotationOnFunction() {
|
||||
doBuildTest("java.lang.Deprecated fun foo() {}",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" +
|
||||
" ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testManyAnnotationsOnFunction() {
|
||||
doBuildTest("[Deprecated Override] fun foo() {}",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" +
|
||||
" ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Deprecated]\n" +
|
||||
" ANNOTATION_ENTRY:PsiJetAnnotationStubImpl[shortName=Override]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
@@ -249,7 +249,7 @@ public class JetStubsTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testAnnotationOnLocalFunction() {
|
||||
doBuildTest("fun foo() { [Deprecated] fun innerFoo() {} }",
|
||||
"PsiJetFileStubImpl[package=]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top topFQName=foo name=foo]\n" +
|
||||
" FUN:PsiJetFunctionStubImpl[top fqName=foo name=foo]\n" +
|
||||
" VALUE_PARAMETER_LIST:PsiJetParameterListStubImpl\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user