Supporting FqNames with spaces/comments inside them for deprecated
This commit is contained in:
@@ -17,12 +17,14 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.CheckUtil;
|
||||
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetNodeTypes;
|
||||
@@ -207,6 +209,23 @@ public class JetPsiUtil {
|
||||
return firstPart.child(name);
|
||||
}
|
||||
|
||||
/** @return <code>null</code> iff the tye has syntactic errors */
|
||||
@Nullable
|
||||
public static FqName toQualifiedName(@NotNull JetUserType userType) {
|
||||
List<String> reversedNames = Lists.newArrayList();
|
||||
|
||||
JetUserType current = userType;
|
||||
while (current != null) {
|
||||
String name = current.getReferencedName();
|
||||
if (name == null) return null;
|
||||
|
||||
reversedNames.add(name);
|
||||
current = current.getQualifier();
|
||||
}
|
||||
|
||||
return FqName.fromSegments(ContainerUtil.reverse(reversedNames));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Name getShortName(JetAnnotationEntry annotation) {
|
||||
JetTypeReference typeReference = annotation.getTypeReference();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.jet.lang.resolve.name;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -24,6 +25,12 @@ import java.util.List;
|
||||
|
||||
public class FqName extends FqNameBase {
|
||||
|
||||
@NotNull
|
||||
public static FqName fromSegments(@NotNull List<String> names) {
|
||||
String fqName = StringUtil.join(names, ".");
|
||||
return new FqName(fqName);
|
||||
}
|
||||
|
||||
public static final FqName ROOT = new FqName("");
|
||||
|
||||
@NotNull
|
||||
@@ -32,7 +39,6 @@ public class FqName extends FqNameBase {
|
||||
// cache
|
||||
private transient FqName parent;
|
||||
|
||||
|
||||
public FqName(@NotNull String fqName) {
|
||||
this.fqName = new FqNameUnsafe(fqName, this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user