Search in sources :

Example 1 with NameSuggestion

use of org.jetbrains.kotlin.js.naming.NameSuggestion in project kotlin by JetBrains.

the class Namer method getStableMangledNameForDescriptor.

// TODO: get rid of this function
@NotNull
public static String getStableMangledNameForDescriptor(@NotNull ClassDescriptor descriptor, @NotNull String functionName) {
    Collection<SimpleFunctionDescriptor> functions = descriptor.getDefaultType().getMemberScope().getContributedFunctions(Name.identifier(functionName), NoLookupLocation.FROM_BACKEND);
    assert functions.size() == 1 : "Can't select a single function: " + functionName + " in " + descriptor;
    SuggestedName suggested = new NameSuggestion().suggest(functions.iterator().next());
    assert suggested != null : "Suggested name for class members is always non-null: " + functions.iterator().next();
    return suggested.getNames().get(0);
}
Also used : NameSuggestion(org.jetbrains.kotlin.js.naming.NameSuggestion) SimpleFunctionDescriptor(org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor) SuggestedName(org.jetbrains.kotlin.js.naming.SuggestedName) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with NameSuggestion

use of org.jetbrains.kotlin.js.naming.NameSuggestion in project kotlin by JetBrains.

the class Namer method getFunctionTag.

@NotNull
public static String getFunctionTag(@NotNull CallableDescriptor functionDescriptor) {
    functionDescriptor = (CallableDescriptor) JsDescriptorUtils.findRealInlineDeclaration(functionDescriptor);
    String moduleName = getModuleName(functionDescriptor);
    FqNameUnsafe fqNameParent = DescriptorUtils.getFqName(functionDescriptor).parent();
    String qualifier = null;
    if (!fqNameParent.isRoot()) {
        qualifier = fqNameParent.asString();
    }
    SuggestedName suggestedName = new NameSuggestion().suggest(functionDescriptor);
    assert suggestedName != null : "Suggested name can be null only for module descriptors: " + functionDescriptor;
    String mangledName = suggestedName.getNames().get(0);
    return StringUtil.join(Arrays.asList(moduleName, qualifier, mangledName), ".");
}
Also used : NameSuggestion(org.jetbrains.kotlin.js.naming.NameSuggestion) FqNameUnsafe(org.jetbrains.kotlin.name.FqNameUnsafe) SuggestedName(org.jetbrains.kotlin.js.naming.SuggestedName) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)2 NameSuggestion (org.jetbrains.kotlin.js.naming.NameSuggestion)2 SuggestedName (org.jetbrains.kotlin.js.naming.SuggestedName)2 SimpleFunctionDescriptor (org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor)1 FqNameUnsafe (org.jetbrains.kotlin.name.FqNameUnsafe)1