Tree-sitter: Emit empty_location relation to avoid scan

This commit is contained in:
Tom Hvitved
2024-05-27 09:44:56 +02:00
parent 44f666c90a
commit 94d2e9591d
6 changed files with 23 additions and 3 deletions

View File

@@ -28,6 +28,7 @@
"/*- Yaml dbscheme -*/", "/*- Yaml dbscheme -*/",
"/*- Blame dbscheme -*/", "/*- Blame dbscheme -*/",
"/*- JSON dbscheme -*/", "/*- JSON dbscheme -*/",
"/*- Python dbscheme -*/" "/*- Python dbscheme -*/",
"/*- Empty location -*/"
] ]
} }

View File

@@ -36,6 +36,12 @@ containerparent(
unique int child: @container ref unique int child: @container ref
); );
/*- Empty location -*/
empty_location(
int location: @location_default ref
);
/*- Source location prefix -*/ /*- Source location prefix -*/
/** /**

View File

@@ -64,5 +64,5 @@ class Location extends @location_default {
/** An entity representing an empty location. */ /** An entity representing an empty location. */
class EmptyLocation extends Location { class EmptyLocation extends Location {
EmptyLocation() { this.hasLocationInfo("", 0, 0, 0, 0) } EmptyLocation() { empty_location(this) }
} }

View File

@@ -36,6 +36,12 @@ containerparent(
unique int child: @container ref unique int child: @container ref
); );
/*- Empty location -*/
empty_location(
int location: @location_default ref
);
/*- Source location prefix -*/ /*- Source location prefix -*/
/** /**

View File

@@ -75,7 +75,7 @@ fn populate_empty_file(writer: &mut trap::Writer) -> trap::Label {
pub fn populate_empty_location(writer: &mut trap::Writer) { pub fn populate_empty_location(writer: &mut trap::Writer) {
let file_label = populate_empty_file(writer); let file_label = populate_empty_file(writer);
global_location( let loc_label = global_location(
writer, writer,
file_label, file_label,
trap::Location { trap::Location {
@@ -85,6 +85,7 @@ pub fn populate_empty_location(writer: &mut trap::Writer) {
end_column: 0, end_column: 0,
}, },
); );
writer.add_tuple("empty_location", vec![trap::Arg::Label(loc_label)]);
} }
pub fn populate_parent_folders( pub fn populate_parent_folders(

View File

@@ -33,6 +33,12 @@ containerparent(
unique int child: @container ref unique int child: @container ref
); );
/*- Empty location -*/
empty_location(
int location: @location_default ref
);
/*- Source location prefix -*/ /*- Source location prefix -*/
/** /**