Search in sources :

Example 56 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class JavaElementFinder method getSubPackages.

@NotNull
@Override
public PsiPackage[] getSubPackages(@NotNull PsiPackage psiPackage, @NotNull final GlobalSearchScope scope) {
    FqName packageFQN = new FqName(psiPackage.getQualifiedName());
    Collection<FqName> subpackages = lightClassGenerationSupport.getSubPackages(packageFQN, scope);
    Collection<PsiPackage> answer = Collections2.transform(subpackages, new Function<FqName, PsiPackage>() {

        @Override
        public PsiPackage apply(@Nullable FqName input) {
            return new KtLightPackage(psiManager, input, scope);
        }
    });
    return answer.toArray(new PsiPackage[answer.size()]);
}
Also used : FqName(org.jetbrains.kotlin.name.FqName) NotNull(org.jetbrains.annotations.NotNull)

Example 57 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class AbstractResolveByStubTest method performTest.

private void performTest(@NotNull String path, boolean checkPrimaryConstructors, boolean checkPropertyAccessors) {
    KtFile file = (KtFile) getFile();
    ModuleDescriptor module = ResolutionUtils.findModuleDescriptor(file);
    PackageViewDescriptor packageViewDescriptor = module.getPackage(new FqName("test"));
    Assert.assertFalse(packageViewDescriptor.isEmpty());
    File fileToCompareTo = new File(FileUtil.getNameWithoutExtension(path) + ".txt");
    RecursiveDescriptorComparator.validateAndCompareDescriptorWithFile(packageViewDescriptor, RecursiveDescriptorComparator.DONT_INCLUDE_METHODS_OF_OBJECT.filterRecursion(RecursiveDescriptorComparator.SKIP_BUILT_INS_PACKAGES).checkPrimaryConstructors(checkPrimaryConstructors).checkPropertyAccessors(checkPropertyAccessors).withValidationStrategy(errorTypesForbidden()), fileToCompareTo);
}
Also used : ModuleDescriptor(org.jetbrains.kotlin.descriptors.ModuleDescriptor) FqName(org.jetbrains.kotlin.name.FqName) KtFile(org.jetbrains.kotlin.psi.KtFile) KtFile(org.jetbrains.kotlin.psi.KtFile) File(java.io.File) PackageViewDescriptor(org.jetbrains.kotlin.descriptors.PackageViewDescriptor)

Example 58 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class TranslationUtils method getCoroutineBaseClass.

@NotNull
public static ClassDescriptor getCoroutineBaseClass(@NotNull TranslationContext context) {
    FqName className = DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME.child(Name.identifier("CoroutineImpl"));
    ClassDescriptor descriptor = FindClassInModuleKt.findClassAcrossModuleDependencies(context.getCurrentModule(), ClassId.topLevel(className));
    assert descriptor != null;
    return descriptor;
}
Also used : FqName(org.jetbrains.kotlin.name.FqName) NotNull(org.jetbrains.annotations.NotNull)

Example 59 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class FunctionCodegen method getThrownExceptions.

@NotNull
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final KotlinTypeMapper mapper) {
    AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.throws"));
    if (annotation == null) {
        annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.jvm.Throws"));
    }
    if (annotation == null)
        return ArrayUtil.EMPTY_STRING_ARRAY;
    Collection<ConstantValue<?>> values = annotation.getAllValueArguments().values();
    if (values.isEmpty())
        return ArrayUtil.EMPTY_STRING_ARRAY;
    Object value = values.iterator().next();
    if (!(value instanceof ArrayValue))
        return ArrayUtil.EMPTY_STRING_ARRAY;
    ArrayValue arrayValue = (ArrayValue) value;
    List<String> strings = ContainerUtil.mapNotNull(arrayValue.getValue(), new Function<ConstantValue<?>, String>() {

        @Override
        public String fun(ConstantValue<?> constant) {
            if (constant instanceof KClassValue) {
                KClassValue classValue = (KClassValue) constant;
                ClassDescriptor classDescriptor = DescriptorUtils.getClassDescriptorForType(classValue.getValue());
                return mapper.mapClass(classDescriptor).getInternalName();
            }
            return null;
        }
    });
    return ArrayUtil.toStringArray(strings);
}
Also used : AnnotationDescriptor(org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor) JavaClassDescriptor(org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor) FqName(org.jetbrains.kotlin.name.FqName) KClassValue(org.jetbrains.kotlin.resolve.constants.KClassValue) ConstantValue(org.jetbrains.kotlin.resolve.constants.ConstantValue) ArrayValue(org.jetbrains.kotlin.resolve.constants.ArrayValue) NotNull(org.jetbrains.annotations.NotNull)

Example 60 with FqName

use of org.jetbrains.kotlin.name.FqName in project kotlin by JetBrains.

the class KtPsiUtilTest method testConvertToImportPath.

public void testConvertToImportPath() {
    Assert.assertEquals(null, getImportPathFromParsed("import "));
    Assert.assertEquals(new ImportPath(new FqName("some"), false), getImportPathFromParsed("import some."));
    Assert.assertEquals(null, getImportPathFromParsed("import *"));
    Assert.assertEquals(new ImportPath(new FqName("some.test"), true), getImportPathFromParsed("import some.test.* as SomeTest"));
    Assert.assertEquals(new ImportPath(new FqName("some"), false), getImportPathFromParsed("import some?.Test"));
    Assert.assertEquals(new ImportPath(new FqName("some"), false), getImportPathFromParsed("import some"));
    Assert.assertEquals(new ImportPath(new FqName("some"), true), getImportPathFromParsed("import some.*"));
    Assert.assertEquals(new ImportPath(new FqName("some.Test"), false), getImportPathFromParsed("import some.Test"));
    Assert.assertEquals(new ImportPath(new FqName("some.test"), true), getImportPathFromParsed("import some.test.*"));
    Assert.assertEquals(new ImportPath(new FqName("some.test"), false, Name.identifier("SomeTest")), getImportPathFromParsed("import some.test as SomeTest"));
    Assert.assertEquals(new ImportPath(new FqName("some.Test"), false), getImportPathFromParsed("import some./* hello world */Test"));
    Assert.assertEquals(new ImportPath(new FqName("some.Test"), false), getImportPathFromParsed("import some.    Test"));
    Assert.assertNotSame(new ImportPath(new FqName("some.test"), false), getImportPathFromParsed("import some.Test"));
}
Also used : ImportPath(org.jetbrains.kotlin.resolve.ImportPath) FqName(org.jetbrains.kotlin.name.FqName)

Aggregations

FqName (org.jetbrains.kotlin.name.FqName)74 NotNull (org.jetbrains.annotations.NotNull)25 Nullable (org.jetbrains.annotations.Nullable)15 KtFile (org.jetbrains.kotlin.psi.KtFile)10 StringRef (com.intellij.util.io.StringRef)6 File (java.io.File)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)4 ModuleDescriptor (org.jetbrains.kotlin.descriptors.ModuleDescriptor)4 Name (org.jetbrains.kotlin.name.Name)4 PsiClass (com.intellij.psi.PsiClass)3 ClassId (org.jetbrains.kotlin.name.ClassId)3 Disposable (com.intellij.openapi.Disposable)2 ConfigurationException (com.intellij.openapi.options.ConfigurationException)2 SmartList (com.intellij.util.SmartList)2 Function1 (kotlin.jvm.functions.Function1)2 KotlinCoreEnvironment (org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment)2 CompilerConfiguration (org.jetbrains.kotlin.config.CompilerConfiguration)2 JavaClassDescriptor (org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor)2 KtClassOrObject (org.jetbrains.kotlin.psi.KtClassOrObject)2