IJ file type optimizations based on extension

#KTIJ-21668

Merge-request: KT-MR-6288
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
This commit is contained in:
Vladimir Dolzhenko
2022-05-17 14:46:00 +00:00
committed by Space
parent 4a6466e290
commit efd5beb49b
10 changed files with 13 additions and 12 deletions
@@ -55,7 +55,7 @@ internal fun VirtualFile.getAnnotationEntries(project: Project): Iterable<KtAnno
val psiFile: PsiFile = PsiManager.getInstance(project).findFile(this)
?: throw IllegalArgumentException("Unable to load PSI from $canonicalPath")
return (psiFile as? KtFile)?.annotationEntries
?: throw IllegalArgumentException("Unable to extract kotlin annotations from $name ($fileType)")
?: throw IllegalArgumentException("Unable to extract kotlin annotations from $name (${fileType.name})")
}
/**
@@ -335,7 +335,7 @@ fun SourceCode.getKtFile(definition: ScriptDefinition, project: Project): KtFile
val psiFile: PsiFile = PsiManager.getInstance(project).findFile(file)
?: throw IllegalArgumentException("Unable to load PSI from ${file.path}")
(psiFile as? KtFile)
?: throw IllegalArgumentException("Not a kotlin file ${file.path} (${file.fileType})")
?: throw IllegalArgumentException("Not a kotlin file ${file.path} (${file.fileType.name})")
}
}