mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix(lsp): invalid inferred file extensions in FileProvider
This commit is contained in:
@@ -93,7 +93,7 @@ class FileProvider {
|
||||
* @return The path to the file.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun sourceFile(name: String): Path {
|
||||
fun sourceFile(name: String, extension: String = ""): Path {
|
||||
return resources().resolve("${name}_template.$extension").normalize()
|
||||
}
|
||||
|
||||
|
||||
@@ -26,29 +26,15 @@ class FileProviderTest {
|
||||
|
||||
@Test
|
||||
fun testPath() {
|
||||
val path = FileProvider.sourceFile("SourceFileTest")
|
||||
val path = FileProvider.sourceFile("SourceFileTest", "java")
|
||||
assertThat(Files.exists(path)).isTrue()
|
||||
assertThat(path.fileName.toString()).isEqualTo("SourceFileTest_template.java")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNested() {
|
||||
val path = FileProvider.sourceFile("package/SourceFileTest")
|
||||
val path = FileProvider.sourceFile("package/SourceFileTest", "java")
|
||||
assertThat(Files.exists(path)).isTrue()
|
||||
assertThat(path.fileName.toString()).isEqualTo("SourceFileTest_template.java")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testExtension() {
|
||||
val folder = File(".").canonicalFile
|
||||
|
||||
assertThat(FileProvider.extension).isNotEmpty()
|
||||
assertThat(FileProvider.extension)
|
||||
.isEqualTo(
|
||||
when (folder.name) {
|
||||
"xml" -> "xml"
|
||||
else -> "java"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user