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()]);
}
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);
}
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;
}
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);
}
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"));
}
Aggregations