Introduced getFqNameSafe method.

This commit is contained in:
Evgeny Gerashchenko
2013-12-04 18:51:06 +04:00
parent 3352d8a954
commit a49551dd35
22 changed files with 50 additions and 37 deletions
@@ -71,7 +71,7 @@ public class ReferenceToClassesShortening {
compactReferenceToClass(userType, targetClass);
}
else if (classifier == null) {
ImportInsertHelper.addImportDirectiveIfNeeded(DescriptorUtils.getFqName(targetTopLevelClass).toSafe(), file);
ImportInsertHelper.addImportDirectiveIfNeeded(DescriptorUtils.getFqNameSafe(targetTopLevelClass), file);
compactReferenceToClass(userType, targetClass);
}
else {
@@ -54,7 +54,7 @@ public class JetClassInsertHandler implements InsertHandler<LookupElement> {
DeclarationDescriptor descriptor = lookupObject.getDescriptor();
PsiElement targetElement = lookupObject.getPsiElement();
if (descriptor != null) {
FqName fqn = DescriptorUtils.getFqName(descriptor).toSafe();
FqName fqn = DescriptorUtils.getFqNameSafe(descriptor);
// TODO: Find out the way for getting psi element for JS libs
if (targetElement != null) {
@@ -177,7 +177,7 @@ public class JetFunctionInsertHandler(val caretPosition : CaretPosition, val bra
if (DescriptorUtils.isTopLevelDeclaration(functionDescriptor)) {
ApplicationManager.getApplication()?.runWriteAction {
val fqn = DescriptorUtils.getFqName(functionDescriptor).toSafe()
val fqn = DescriptorUtils.getFqNameSafe(functionDescriptor)
ImportInsertHelper.addImportDirectiveIfNeeded(fqn, file)
}
}
@@ -183,9 +183,7 @@ public class JetImportOptimizer implements ImportOptimizer {
private void addResolvedCallFqName(@Nullable ResolvedCall resolvedCall) {
if (resolvedCall != null) {
CallableDescriptor resultingDescriptor = resolvedCall.getResultingDescriptor();
FqNameUnsafe name = DescriptorUtils.getFqName(resultingDescriptor);
assert name.isSafe(): "FqName for resulting descriptor should be safe " + resultingDescriptor.getName();
usedQualifiedNames.add(name.toSafe());
usedQualifiedNames.add(DescriptorUtils.getFqNameSafe(resultingDescriptor));
}
}
});
@@ -163,10 +163,8 @@ public class IdeRenderers {
stringBuilder.append(parametersToHighlight.contains(null) ? String.format(RED_TEMPLATE, ")") : ")");
stringBuilder.append(" <i>defined in</i> ");
DeclarationDescriptor containingDeclaration = funDescriptor.getContainingDeclaration();
if (containingDeclaration != null) {
FqNameUnsafe fqName = DescriptorUtils.getFqName(containingDeclaration);
stringBuilder.append(FqName.ROOT.equalsTo(fqName) ? "root package" : fqName.asString());
}
FqNameUnsafe fqName = DescriptorUtils.getFqName(containingDeclaration);
stringBuilder.append(FqName.ROOT.equalsTo(fqName) ? "root package" : fqName.asString());
stringBuilder.append("</li>");
}
return stringBuilder.toString();
@@ -32,6 +32,7 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
import java.util.Set;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFqName;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFqNameSafe;
public final class DecompiledNavigationUtils {
@@ -120,7 +121,7 @@ public final class DecompiledNavigationUtils {
if (classKind == ClassKind.CLASS_OBJECT || classKind == ClassKind.ENUM_ENTRY) {
return getContainerFqName(containerDescriptor.getContainingDeclaration());
}
return getFqName(containerDescriptor).toSafe();
return getFqNameSafe(containerDescriptor);
}
return null;
}
@@ -125,7 +125,7 @@ public class AutoImportFix extends JetHintAction<JetSimpleNameExpression> implem
@Override
public FqName apply(@Nullable DeclarationDescriptor declarationDescriptor) {
assert declarationDescriptor != null;
return DescriptorUtils.getFqName(declarationDescriptor).toSafe();
return DescriptorUtils.getFqNameSafe(declarationDescriptor);
}
}));
}
@@ -152,7 +152,7 @@ public class AutoImportFix extends JetHintAction<JetSimpleNameExpression> implem
@Override
public FqName apply(@Nullable DeclarationDescriptor declarationDescriptor) {
assert declarationDescriptor != null;
return DescriptorUtils.getFqName(declarationDescriptor).toSafe();
return DescriptorUtils.getFqNameSafe(declarationDescriptor);
}
}));
}
@@ -219,7 +219,7 @@ public class AutoImportFix extends JetHintAction<JetSimpleNameExpression> implem
return Collections2.transform(descriptors, new Function<ClassDescriptor, FqName>() {
@Override
public FqName apply(ClassDescriptor descriptor) {
return DescriptorUtils.getFqName(descriptor).toSafe();
return DescriptorUtils.getFqNameSafe(descriptor);
}
});
}
@@ -138,7 +138,7 @@ public class BuiltInsReferenceResolver extends AbstractProjectComponent {
return ((ClassDescriptor) currentParent).getClassObjectDescriptor();
}
else {
return bindingContext.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFqName(originalDescriptor).toSafe());
return bindingContext.get(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFqNameSafe(originalDescriptor));
}
}