-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support reading source files from jars
- Loading branch information
Showing
13 changed files
with
139 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import com.alecstrong.sql.psi.sample.core.SampleFileType | ||
import java.net.URI | ||
import java.nio.file.FileSystemNotFoundException | ||
import java.nio.file.FileSystems | ||
import java.nio.file.Path | ||
import kotlin.io.path.toPath | ||
import kotlin.properties.ReadOnlyProperty | ||
import kotlin.reflect.KProperty | ||
|
||
object SqliteTestFixtures : ReadOnlyProperty<Nothing?, Path> { | ||
val jarFile: Path get() = SqliteTestFixtures::class.java.getResource("/SqliteTestFixtures.class")!!.toURI().toJarPath().parent | ||
|
||
override operator fun getValue(thisRef: Nothing?, property: KProperty<*>): Path { | ||
val uri = | ||
SqliteTestFixtures::class.java.getResource("/${property.name}.${SampleFileType.defaultExtension}")!!.toURI() | ||
return uri.toJarPath() | ||
} | ||
|
||
private fun URI.toJarPath(): Path { | ||
try { | ||
FileSystems.getFileSystem(this) | ||
} catch (ignored: FileSystemNotFoundException) { | ||
val env = mapOf("create" to "true") | ||
FileSystems.newFileSystem(this, env) | ||
} | ||
return toPath() | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE test2 ( | ||
sample_column 42 TEXT AS "java.util.List" NOT NULL | ||
); | ||
|
||
SELECT * | ||
FROM test, test2 | ||
WHERE test.sample_column = "foo"; | ||
|
||
SELECT * FROM test2 WHERE (1 = 1) FOO 13; | ||
SELECT * FROM test2 WHERE (1 = 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
sample-headless/src/main/kotlin/com/alecstrong/sql/psi/sample/headless/testing.samplesql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CREATE TABLE test ( | ||
sample_column 42 TEXT AS "java.util.List" NOT NULL | ||
); | ||
|
||
SELECT * | ||
FROM test | ||
WHERE sample_column = "foo"; | ||
|
||
SELECT * FROM test WHERE (1 = 1) FOO 13; | ||
SELECT * FROM test WHERE (1 = 1); |
41 changes: 37 additions & 4 deletions
41
...adless/src/test/kotlin/com/alecstrong/sql/psi/sample/headless/SampleHeadlessParserTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters