Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactoring: rename TEXT to FQNAMES_IN_TYPES
  • Loading branch information
goodwinnk committed Apr 18, 2014
1 parent 962044f commit 068c963
Show file tree
Hide file tree
Showing 39 changed files with 64 additions and 65 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/Nikolay_Krasko.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -3555,9 +3555,9 @@ public StackValue visitBinaryWithTypeRHSExpression(@NotNull JetBinaryExpressionW
v.ifnonnull(nonnull);
JetType leftType = bindingContext.get(BindingContext.EXPRESSION_TYPE, left);
assert leftType != null;
throwNewException("kotlin/TypeCastException", DescriptorRenderer.TEXT.renderType(leftType) +
throwNewException("kotlin/TypeCastException", DescriptorRenderer.FQNAMES_IN_TYPES.renderType(leftType) +
" cannot be cast to " +
DescriptorRenderer.TEXT.renderType(rightType));
DescriptorRenderer.FQNAMES_IN_TYPES.renderType(rightType));
v.mark(nonnull);
}
}
Expand Down
Expand Up @@ -97,7 +97,7 @@ protected static JetType computeReturnType(
else {
throw new AlternativeSignatureMismatchException(
"Return type in alternative signature is missing, while in real signature it is '%s'",
DescriptorRenderer.TEXT.renderType(originalType));
DescriptorRenderer.FQNAMES_IN_TYPES.renderType(originalType));
}
}

Expand Down
Expand Up @@ -74,7 +74,7 @@ public static JetType computeType(
public JetType visitNullableType(@NotNull JetNullableType nullableType, Void aVoid) {
if (!originalType.isNullable() && typeUsage != TYPE_ARGUMENT) {
throw new AlternativeSignatureMismatchException("Auto type '%s' is not-null, while type in alternative signature is nullable: '%s'",
DescriptorRenderer.TEXT.renderType(originalType), nullableType.getText());
DescriptorRenderer.FQNAMES_IN_TYPES.renderType(originalType), nullableType.getText());
}
JetTypeElement innerType = nullableType.getInnerType();
assert innerType != null : "Syntax error: " + nullableType.getText();
Expand Down Expand Up @@ -134,7 +134,7 @@ private JetType visitCommonType(@NotNull String qualifiedName, @NotNull JetTypeE

if (arguments.size() != type.getTypeArgumentsAsTypes().size()) {
throw new AlternativeSignatureMismatchException("'%s' type in method signature has %d type arguments, while '%s' in alternative signature has %d of them",
DescriptorRenderer.TEXT.renderType(originalType), arguments.size(), type.getText(),
DescriptorRenderer.FQNAMES_IN_TYPES.renderType(originalType), arguments.size(), type.getText(),
type.getTypeArgumentsAsTypes().size());
}

Expand Down
Expand Up @@ -158,7 +158,7 @@ public String render(@NotNull Collection<JetModifierKeywordToken> tokens) {

MAP.put(DATA_CLASS_OVERRIDE_CONFLICT, "Function ''{0}'' generated for the data class conflicts with member of supertype ''{1}''", NAME, NAME);

MAP.put(CANNOT_OVERRIDE_INVISIBLE_MEMBER, "''{0}'' has no access to ''{1}'', so it cannot override it", TEXT, TEXT);
MAP.put(CANNOT_OVERRIDE_INVISIBLE_MEMBER, "''{0}'' has no access to ''{1}'', so it cannot override it", FQNAMES_IN_TYPES, FQNAMES_IN_TYPES);
MAP.put(CANNOT_INFER_VISIBILITY, "Cannot infer visibility. Please specify it explicitly");

MAP.put(ENUM_ENTRY_SHOULD_BE_INITIALIZED, "Missing delegation specifier ''{0}''", NAME);
Expand All @@ -170,7 +170,7 @@ public String render(@NotNull Collection<JetModifierKeywordToken> tokens) {
MAP.put(UNUSED_PARAMETER, "Parameter ''{0}'' is never used", NAME);
MAP.put(ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE, "Variable ''{0}'' is assigned but never accessed", NAME);
MAP.put(VARIABLE_WITH_REDUNDANT_INITIALIZER, "Variable ''{0}'' initializer is redundant", NAME);
MAP.put(UNUSED_VALUE, "The value ''{0}'' assigned to ''{1}'' is never used", ELEMENT_TEXT, TEXT);
MAP.put(UNUSED_VALUE, "The value ''{0}'' assigned to ''{1}'' is never used", ELEMENT_TEXT, FQNAMES_IN_TYPES);
MAP.put(UNUSED_CHANGED_VALUE, "The value changed at ''{0}'' is never used", ELEMENT_TEXT);
MAP.put(UNUSED_EXPRESSION, "The expression is unused");
MAP.put(UNUSED_FUNCTION_LITERAL, "The function literal is unused. If you mean block, you can use 'run { ... }'");
Expand Down Expand Up @@ -292,7 +292,7 @@ public String render(@NotNull JetExpression expression) {
MAP.put(CONFLICTING_UPPER_BOUNDS, "Upper bounds of {0} have empty intersection", NAME);
MAP.put(CONFLICTING_CLASS_OBJECT_UPPER_BOUNDS, "Class object upper bounds of {0} have empty intersection", NAME);

MAP.put(TOO_MANY_ARGUMENTS, "Too many arguments for {0}", TEXT);
MAP.put(TOO_MANY_ARGUMENTS, "Too many arguments for {0}", FQNAMES_IN_TYPES);

MAP.put(CONSTANT_EXPECTED_TYPE_MISMATCH, "An {0} literal does not conform to the expected type {1}", STRING, RENDER_TYPE);
MAP.put(INTEGER_OVERFLOW, "This operation has led to an overflow");
Expand Down Expand Up @@ -383,17 +383,18 @@ public String render(@NotNull JetSimpleNameExpression nameExpression) {
MAP.put(CANNOT_CHANGE_ACCESS_PRIVILEGE, "Cannot change access privilege ''{0}'' for ''{1}'' in ''{2}''", TO_STRING, NAME, NAME);

MAP.put(RETURN_TYPE_MISMATCH_ON_OVERRIDE, "Return type of ''{0}'' is not a subtype of the return type of overridden member {1}",
NAME, TEXT);
NAME, FQNAMES_IN_TYPES);

MAP.put(PROPERTY_TYPE_MISMATCH_ON_OVERRIDE, "Type of ''{0}'' doesn't match to the type of overridden var-property {1}", NAME, TEXT);
MAP.put(PROPERTY_TYPE_MISMATCH_ON_OVERRIDE, "Type of ''{0}'' doesn't match to the type of overridden var-property {1}",
NAME, FQNAMES_IN_TYPES);

MAP.put(VAR_OVERRIDDEN_BY_VAL, "Var-property {0} cannot be overridden by val-property {1}", TEXT, TEXT);
MAP.put(VAR_OVERRIDDEN_BY_VAL, "Var-property {0} cannot be overridden by val-property {1}", FQNAMES_IN_TYPES, FQNAMES_IN_TYPES);

MAP.put(ABSTRACT_MEMBER_NOT_IMPLEMENTED, "{0} must be declared abstract or implement abstract member {1}", RENDER_CLASS_OR_OBJECT,
TEXT);
FQNAMES_IN_TYPES);

MAP.put(MANY_IMPL_MEMBER_NOT_IMPLEMENTED, "{0} must override {1} because it inherits many implementations of it",
RENDER_CLASS_OR_OBJECT, TEXT);
RENDER_CLASS_OR_OBJECT, FQNAMES_IN_TYPES);

MAP.put(CONFLICTING_OVERLOADS, "''{0}'' is already defined in {1}", COMPACT_WITH_MODIFIERS, STRING);

Expand Down Expand Up @@ -465,15 +466,15 @@ public String render(@NotNull Boolean hasValueParameters) {

String multipleDefaultsMessage = "More than one overridden descriptor declares a default value for ''{0}''. " +
"As the compiler can not make sure these values agree, this is not allowed.";
MAP.put(MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES, multipleDefaultsMessage, TEXT);
MAP.put(MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE, multipleDefaultsMessage, TEXT);
MAP.put(MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES, multipleDefaultsMessage, FQNAMES_IN_TYPES);
MAP.put(MULTIPLE_DEFAULTS_INHERITED_FROM_SUPERTYPES_WHEN_NO_EXPLICIT_OVERRIDE, multipleDefaultsMessage, FQNAMES_IN_TYPES);

MAP.put(PARAMETER_NAME_CHANGED_ON_OVERRIDE, "The corresponding parameter in the supertype ''{0}'' is named ''{1}''. " +
"This may cause problems when calling this function with named arguments.", NAME, NAME);

MAP.put(DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES,
"Names of the parameter #{1} conflict in the following members of supertypes: ''{0}''. " +
"This may cause problems when calling this function with named arguments.", commaSeparated(TEXT), TO_STRING);
"This may cause problems when calling this function with named arguments.", commaSeparated(FQNAMES_IN_TYPES), TO_STRING);

MAP.put(AMBIGUOUS_ANONYMOUS_TYPE_INFERRED, "Right-hand side has anonymous type. Please specify type explicitly", TO_STRING);

Expand Down
Expand Up @@ -120,7 +120,7 @@ public String render(@NotNull JetClassOrObject classOrObject) {
@NotNull
@Override
public String render(@NotNull JetType type) {
return DescriptorRenderer.TEXT.renderType(type);
return DescriptorRenderer.FQNAMES_IN_TYPES.renderType(type);
}
};

Expand All @@ -131,7 +131,7 @@ public String render(@NotNull JetType type) {
public String render(@NotNull Collection<? extends ResolvedCall<?>> argument) {
StringBuilder stringBuilder = new StringBuilder("\n");
for (ResolvedCall<?> call : argument) {
stringBuilder.append(DescriptorRenderer.TEXT.render(call.getResultingDescriptor())).append("\n");
stringBuilder.append(DescriptorRenderer.FQNAMES_IN_TYPES.render(call.getResultingDescriptor())).append("\n");
}
return stringBuilder.toString();
}
Expand Down
Expand Up @@ -302,7 +302,7 @@ public boolean apply(@Nullable DeclarationDescriptor descriptor) {
for (DeclarationDescriptor declarationDescriptor : descriptors) {
for (PsiElement declaration : getDeclarationsByDescriptor(declarationDescriptor)) {
assert declaration != null : "Null declaration for descriptor: " + declarationDescriptor + " " +
(declarationDescriptor != null ? DescriptorRenderer.TEXT.render(declarationDescriptor) : "");
(declarationDescriptor != null ? DescriptorRenderer.FQNAMES_IN_TYPES.render(declarationDescriptor) : "");
trace.report(REDECLARATION.on(declaration, declarationDescriptor.getName().asString()));
}
}
Expand Down
Expand Up @@ -111,7 +111,7 @@ public boolean isVariableIterable(@NotNull VariableDescriptor variableDescriptor
if (iteratorResolutionResults.isAmbiguity()) {
// StringBuffer stringBuffer = new StringBuffer("Method 'iterator()' is ambiguous for this expression: ");
// for (FunctionDescriptor functionDescriptor : iteratorResolutionResults.getResultingCalls()) {
// stringBuffer.append(DescriptorRendererImpl.TEXT.render(functionDescriptor)).append(" ");
// stringBuffer.append(DescriptorRendererImpl.FQNAMES_IN_TYPES.render(functionDescriptor)).append(" ");
// }
// errorMessage = stringBuffer.toString();
context.trace.report(ITERATOR_AMBIGUITY.on(loopRangeExpression, iteratorResolutionResults.getResultingCalls()));
Expand Down
Expand Up @@ -149,7 +149,7 @@ public Void visitPropertyDescriptor(PropertyDescriptor descriptor, Void data) {
private Void visitDeclaration(@NotNull DeclarationDescriptor descriptor) {
List<String> errors = bindingContext.get(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor);
if (errors != null) {
this.errors.put(DescriptorRenderer.TEXT.render(descriptor), errors);
this.errors.put(DescriptorRenderer.FQNAMES_IN_TYPES.render(descriptor), errors);
}
return null;
}
Expand Down
Expand Up @@ -47,7 +47,7 @@ public static void checkForLoadErrors(
for (DeclarationDescriptor descriptor : ContainerUtil.union(expectedErrors.keySet(), actualErrors.keySet())) {
List<String> actual = actualErrors.get(descriptor);
List<String> expected = expectedErrors.get(descriptor);
String rendered = DescriptorRenderer.TEXT.render(descriptor);
String rendered = DescriptorRenderer.FQNAMES_IN_TYPES.render(descriptor);

assertNotNull("Unexpected load error(s):\n" + actual + "\ncontainer:" + rendered, expected);
assertNotNull("Missing load error(s):\n" + expected + "\ncontainer:" + rendered, actual);
Expand Down
Expand Up @@ -154,7 +154,7 @@ public void visitJetElement(@NotNull JetElement element) {
if (renderedDescriptors.length() != 0) {
renderedDescriptors.append("\n");
}
renderedDescriptors.append(DescriptorRenderer.TEXT.render(descriptor));
renderedDescriptors.append(DescriptorRenderer.FQNAMES_IN_TYPES.render(descriptor));
}

Document document = new DocumentImpl(psiFile.getText());
Expand Down
Expand Up @@ -120,7 +120,7 @@ public void visitJetElement(@NotNull JetElement element) {
if (renderedDescriptors.length() != 0) {
renderedDescriptors.append("\n");
}
renderedDescriptors.append(DescriptorRenderer.TEXT.render(descriptor));
renderedDescriptors.append(DescriptorRenderer.FQNAMES_IN_TYPES.render(descriptor));
}

Document document = new DocumentImpl(psiFile.getText());
Expand Down
Expand Up @@ -367,6 +367,6 @@ private static <T> T getAncestorOfType(Class<T> type, PsiElement element) {

@NotNull
private static String renderNullableDescriptor(@Nullable DeclarationDescriptor d) {
return d == null ? "<null>" : DescriptorRenderer.TEXT.render(d);
return d == null ? "<null>" : DescriptorRenderer.FQNAMES_IN_TYPES.render(d);
}
}
Expand Up @@ -176,6 +176,6 @@ class LazyJavaAnnotationDescriptor(


override fun toString(): String {
return DescriptorRenderer.TEXT.renderAnnotation(this)
return DescriptorRenderer.FQNAMES_IN_TYPES.renderAnnotation(this)
}
}
Expand Up @@ -71,6 +71,6 @@ public boolean areValueArgumentsResolved() {

@Override
public String toString() {
return DescriptorRenderer.TEXT.renderAnnotation(this);
return DescriptorRenderer.FQNAMES_IN_TYPES.renderAnnotation(this);
}
}
Expand Up @@ -194,7 +194,7 @@ public TypeConstructor getTypeConstructor() {
@Override
public String toString() {
try {
return DescriptorRenderer.TEXT.render(this);
return DescriptorRenderer.FQNAMES_IN_TYPES.render(this);
} catch (Exception e) {
return this.getClass().getName() + "@" + System.identityHashCode(this);
}
Expand Down
Expand Up @@ -54,7 +54,7 @@ public interface DescriptorRenderer extends Renderer<DeclarationDescriptor> {
.setModifiers()
.setStartFromName(true).build();

DescriptorRenderer TEXT = new DescriptorRendererBuilder().build();
DescriptorRenderer FQNAMES_IN_TYPES = new DescriptorRendererBuilder().build();

DescriptorRenderer SHORT_NAMES_IN_TYPES = new DescriptorRendererBuilder().setShortNames(true).build();

Expand Down
Expand Up @@ -37,7 +37,7 @@ public String getElementText(PsiElement element) {
SimpleFunctionDescriptor fd =
bindingContext.get(BindingContext.FUNCTION, function);
assert fd != null;
return DescriptorRenderer.TEXT.render(fd);
return DescriptorRenderer.FQNAMES_IN_TYPES.render(fd);
}
return super.getElementText(element);
}
Expand Down
Expand Up @@ -240,7 +240,7 @@ public object ShortenReferences {
}
}

private fun DeclarationDescriptor.asString() = DescriptorRenderer.TEXT.render(this)
private fun DeclarationDescriptor.asString() = DescriptorRenderer.FQNAMES_IN_TYPES.render(this)

//TODO: do we need this "IfNeeded" check?
private fun addImportIfNeeded(descriptor: DeclarationDescriptor, file: JetFile) {
Expand Down
Expand Up @@ -131,7 +131,7 @@ private static JetProperty createProperty(@NotNull JetProperty property, @NotNul
typeString = typeRef.getText();
}
else if (!propertyType.isError()) {
typeString = DescriptorRenderer.TEXT.renderType(propertyType);
typeString = DescriptorRenderer.FQNAMES_IN_TYPES.renderType(propertyType);
}

return JetPsiFactory.createProperty(property.getProject(), property.getName(), typeString, property.isVar(), initializer);
Expand Down
Expand Up @@ -139,7 +139,7 @@ private static LookupElement createJavaLookupElementIfPossible(@NotNull PsiEleme
InsertHandler<LookupElement> handler = getInsertHandler(descriptor);
assert handler != null:
"Special kotlin handler is expected for function: " + declaration.getText() +
" and descriptor: " + DescriptorRenderer.TEXT.render(descriptor);
" and descriptor: " + DescriptorRenderer.FQNAMES_IN_TYPES.render(descriptor);

return new JavaMethodCallElementWithCustomHandler(declaration).setInsertHandler(handler);
}
Expand Down
Expand Up @@ -104,7 +104,7 @@ class StaticMembers(val bindingContext: BindingContext, val resolveSession: Reso
}

if (presentation.getTypeText().isNullOrEmpty()) {
presentation.setTypeText(DescriptorRenderer.TEXT.renderType(classDescriptor.getDefaultType()))
presentation.setTypeText(DescriptorRenderer.FQNAMES_IN_TYPES.renderType(classDescriptor.getDefaultType()))
}
}

Expand Down
Expand Up @@ -33,7 +33,7 @@ class ThisItems(val bindingContext: BindingContext) {
//val expressionText = if (i == 0) "this" else "this@" + (thisQualifierName(receiver, bindingContext) ?: continue)
val qualifier = if (i == 0) null else thisQualifierName(receiver) ?: continue
val expressionText = if (qualifier == null) "this" else "this@" + qualifier
val lookupElement = LookupElementBuilder.create(expressionText).withTypeText(DescriptorRenderer.TEXT.renderType(thisType))
val lookupElement = LookupElementBuilder.create(expressionText).withTypeText(DescriptorRenderer.FQNAMES_IN_TYPES.renderType(thisType))
collection.add(addTailToLookupElement(lookupElement, matchedExpectedInfos))
}
}
Expand Down
Expand Up @@ -42,7 +42,7 @@ class TypeInstantiationItems(val bindingContext: BindingContext, val resolveSess
var lookupString = lookupElement.getLookupString()

val typeArgs = jetType.getArguments()
var itemText = lookupString + DescriptorRenderer.TEXT.renderTypeArguments(typeArgs)
var itemText = lookupString + DescriptorRenderer.FQNAMES_IN_TYPES.renderTypeArguments(typeArgs)

val insertHandler: InsertHandler<LookupElement>
val typeText = DescriptorUtils.getFqName(classifier).toString() + DescriptorRenderer.SOURCE_CODE.renderTypeArguments(typeArgs)
Expand Down
Expand Up @@ -75,7 +75,7 @@ else if (target instanceof JetNamedFunction) {
if (functionDescriptor != null) {
JetType type = functionDescriptor.getReturnType();
if (type != null) {
String returnTypeText = DescriptorRenderer.TEXT.renderType(type);
String returnTypeText = DescriptorRenderer.FQNAMES_IN_TYPES.renderType(type);
if (returnTypeText.equals(functionName)) {
Collection<JetClassOrObject> classOrObjects =
JetClassShortNameIndex.getInstance().get(functionName, project, GlobalSearchScope.allScope(project));
Expand Down
Expand Up @@ -262,8 +262,8 @@ else if (descriptor instanceof PropertyDescriptor) {
return "val " + descriptor.getName();
}
else if (descriptor instanceof FunctionDescriptor) {
return "fun " + descriptor.getName() + DescriptorRenderer.TEXT.renderFunctionParameters((FunctionDescriptor) descriptor);
return "fun " + descriptor.getName() + DescriptorRenderer.FQNAMES_IN_TYPES.renderFunctionParameters((FunctionDescriptor) descriptor);
}
return DescriptorRenderer.TEXT.render(descriptor);
return DescriptorRenderer.FQNAMES_IN_TYPES.render(descriptor);
}
}

0 comments on commit 068c963

Please sign in to comment.