Use special index to record files corresponding to static facade classes.
This commit is contained in:
committed by
Michael Bogdanov
parent
ab8b5d05ed
commit
83336553df
+3
-2
@@ -214,8 +214,7 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PsiClass> getFacadeClasses(@NotNull FqName facadeFqName, @NotNull GlobalSearchScope scope) {
|
||||
Collection<JetFile> filesInPackage = findFilesForPackage(facadeFqName.parent(), scope);
|
||||
List<JetFile> filesForFacade = PackagePartClassUtils.getFilesForFacade(facadeFqName, filesInPackage);
|
||||
Collection<JetFile> filesForFacade = findFilesForFacade(facadeFqName, scope);
|
||||
if (filesForFacade.isEmpty()) return Collections.emptyList();
|
||||
|
||||
//noinspection RedundantTypeArguments
|
||||
@@ -226,6 +225,8 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<JetFile> findFilesForFacade(@NotNull FqName facadeFqName, @NotNull GlobalSearchScope scope) {
|
||||
// TODO We need a way to plug some platform-dependent stuff into LazyTopDownAnalyzer.
|
||||
// It already performs some ad hoc stuff for packages->files mapping, anyway.
|
||||
Collection<JetFile> filesInPackage = findFilesForPackage(facadeFqName.parent(), scope);
|
||||
return PackagePartClassUtils.getFilesForFacade(facadeFqName, filesInPackage);
|
||||
}
|
||||
|
||||
+9
-3
@@ -77,8 +77,14 @@ public class PackagePartClassUtils {
|
||||
|
||||
@NotNull
|
||||
public static FqName getPackagePartFqName(@NotNull FqName facadeFqName, @NotNull VirtualFile file, @Nullable JetFile jetFile) {
|
||||
String fileName = FileUtil.getNameWithoutExtension(PathUtil.getFileName(file.getName()));
|
||||
return facadeFqName.parent().child(Name.identifier(getSanitizedClassNameBase(fileName) + FACADE_CLASS_NAME_SUFFIX));
|
||||
String fileName = file.getName();
|
||||
return getStaticFacadeClassFqNameForFile(facadeFqName.parent(), fileName);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static FqName getStaticFacadeClassFqNameForFile(@NotNull FqName packageFqName, String fileName) {
|
||||
String nameWithoutExtension = FileUtil.getNameWithoutExtension(PathUtil.getFileName(fileName));
|
||||
return packageFqName.child(Name.identifier(getSanitizedClassNameBase(nameWithoutExtension) + FACADE_CLASS_NAME_SUFFIX));
|
||||
}
|
||||
|
||||
public static boolean isFacadeClassFqName(@NotNull FqName classFqName) {
|
||||
@@ -98,7 +104,7 @@ public class PackagePartClassUtils {
|
||||
|
||||
@NotNull
|
||||
public static FqName getPackagePartFqName(@NotNull JetFile file) {
|
||||
return getPackagePartFqName(getPackageClassFqName(file.getPackageFqName()), file.getVirtualFile(), file);
|
||||
return getStaticFacadeClassFqNameForFile(file.getPackageFqName(), file.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user