Fixed unnecessary FQ name bug.
#KT-1954 fixed
This commit is contained in:
@@ -17,8 +17,12 @@
|
|||||||
package org.jetbrains.jet.lang.psi;
|
package org.jetbrains.jet.lang.psi;
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.PsiFile;
|
||||||
import com.intellij.psi.StubBasedPsiElement;
|
import com.intellij.psi.StubBasedPsiElement;
|
||||||
import com.intellij.psi.stubs.IStubElementType;
|
import com.intellij.psi.stubs.IStubElementType;
|
||||||
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
import com.intellij.util.IncorrectOperationException;
|
import com.intellij.util.IncorrectOperationException;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -27,6 +31,7 @@ import org.jetbrains.jet.lang.psi.stubs.PsiJetClassStub;
|
|||||||
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
import org.jetbrains.jet.lang.psi.stubs.elements.JetStubElementTypes;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -41,11 +46,10 @@ public class JetClass extends JetTypeParameterListOwner
|
|||||||
public JetClass(@NotNull ASTNode node) {
|
public JetClass(@NotNull ASTNode node) {
|
||||||
super(node);
|
super(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (stubs)
|
// TODO (stubs)
|
||||||
// public JetClass(final PsiJetClassStub stub) {
|
// public JetClass(final PsiJetClassStub stub) {
|
||||||
// this.stub = stub;
|
// this.stub = stub;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<JetDeclaration> getDeclarations() {
|
public List<JetDeclaration> getDeclarations() {
|
||||||
@@ -163,4 +167,35 @@ public class JetClass extends JetTypeParameterListOwner
|
|||||||
public void delete() throws IncorrectOperationException {
|
public void delete() throws IncorrectOperationException {
|
||||||
JetPsiUtil.deleteClass(this);
|
JetPsiUtil.deleteClass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEquivalentTo(PsiElement another) {
|
||||||
|
if (super.isEquivalentTo(another)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (another instanceof JetClass) {
|
||||||
|
String fq1 = getQualifiedName();
|
||||||
|
String fq2 = ((JetClass) another).getQualifiedName();
|
||||||
|
return fq1 != null && fq2 != null && fq1.equals(fq2);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String getQualifiedName() {
|
||||||
|
List<String> parts = new ArrayList<String>();
|
||||||
|
JetClassOrObject current = this;
|
||||||
|
while (current != null) {
|
||||||
|
parts.add(current.getName());
|
||||||
|
current = PsiTreeUtil.getParentOfType(current, JetClassOrObject.class);
|
||||||
|
}
|
||||||
|
PsiFile file = getContainingFile();
|
||||||
|
if (!(file instanceof JetFile)) return null;
|
||||||
|
String fileQualifiedName = ((JetFile) file).getNamespaceHeader().getQualifiedName();
|
||||||
|
if (!fileQualifiedName.isEmpty()) {
|
||||||
|
parts.add(fileQualifiedName);
|
||||||
|
}
|
||||||
|
Collections.reverse(parts);
|
||||||
|
return StringUtil.join(parts, ".");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,5 +81,16 @@ public class JetNamespaceHeader extends JetReferenceExpression {
|
|||||||
public boolean isRoot() {
|
public boolean isRoot() {
|
||||||
return getName().length() == 0;
|
return getName().length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getQualifiedName() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (JetSimpleNameExpression e : findChildrenByClass(JetSimpleNameExpression.class)) {
|
||||||
|
if (builder.length() > 0) {
|
||||||
|
builder.append(".");
|
||||||
|
}
|
||||||
|
builder.append(e.getName());
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
public class JetParsingTest extends ParsingTestCase {
|
public class JetParsingTest extends ParsingTestCase {
|
||||||
static {
|
static {
|
||||||
@@ -88,6 +89,7 @@ public class JetParsingTest extends ParsingTestCase {
|
|||||||
String methodName = method.getName();
|
String methodName = method.getName();
|
||||||
if (!methodName.startsWith("get") && !methodName.startsWith("find") || methodName.equals("getReference") ||
|
if (!methodName.startsWith("get") && !methodName.startsWith("find") || methodName.equals("getReference") ||
|
||||||
methodName.equals("getReferences") || methodName.equals("getUseScope")) continue;
|
methodName.equals("getReferences") || methodName.equals("getUseScope")) continue;
|
||||||
|
if (!Modifier.isPublic(method.getModifiers())) continue;
|
||||||
if (method.getParameterTypes().length > 0) continue;
|
if (method.getParameterTypes().length > 0) continue;
|
||||||
Class<?> declaringClass = method.getDeclaringClass();
|
Class<?> declaringClass = method.getDeclaringClass();
|
||||||
if (!declaringClass.getName().startsWith("org.jetbrains.jet")) continue;
|
if (!declaringClass.getName().startsWith("org.jetbrains.jet")) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user