Skip to content

Commit 79c2f09

Browse files
authored
Merge pull request #302 from github/rm_tokeninfo_idx
Remove unused columns from tokeninfo tables
2 parents b2c4dae + 3201f30 commit 79c2f09

File tree

9 files changed

+10430
-9785
lines changed

9 files changed

+10430
-9785
lines changed

extractor/src/extractor.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ pub fn extract(
190190
// TODO: should we handle path strings that are not valid UTF8 better?
191191
path: format!("{}", path.display()),
192192
file_label: *file_label,
193-
token_counter: 0,
194193
toplevel_child_counter: 0,
195194
stack: Vec::new(),
196195
language_prefix,
@@ -300,8 +299,6 @@ struct Visitor<'a> {
300299
source: &'a Vec<u8>,
301300
/// A TrapWriter to accumulate trap entries
302301
trap_writer: &'a mut TrapWriter,
303-
/// A counter for tokens
304-
token_counter: usize,
305302
/// A counter for top-level child nodes
306303
toplevel_child_counter: usize,
307304
/// Language prefix
@@ -425,13 +422,10 @@ impl Visitor<'_> {
425422
vec![
426423
Arg::Label(id),
427424
Arg::Int(*kind_id),
428-
Arg::Label(self.file_label),
429-
Arg::Int(self.token_counter),
430425
sliced_source_arg(self.source, node),
431426
Arg::Label(loc),
432427
],
433428
);
434-
self.token_counter += 1;
435429
}
436430
EntryKind::Table {
437431
fields,

generator/src/main.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,6 @@ fn create_tokeninfo<'a>(name: &'a str, type_name: &'a str) -> dbscheme::Table<'a
305305
ql_type: ql::Type::Int,
306306
ql_type_is_ref: true,
307307
},
308-
dbscheme::Column {
309-
unique: false,
310-
db_type: dbscheme::DbColumnType::Int,
311-
name: "file",
312-
ql_type: ql::Type::AtType("file"),
313-
ql_type_is_ref: true,
314-
},
315-
dbscheme::Column {
316-
unique: false,
317-
db_type: dbscheme::DbColumnType::Int,
318-
name: "idx",
319-
ql_type: ql::Type::Int,
320-
ql_type_is_ref: true,
321-
},
322308
dbscheme::Column {
323309
unique: false,
324310
db_type: dbscheme::DbColumnType::String,

generator/src/ql_gen.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,22 +119,22 @@ pub fn create_ast_node_class<'a>(ast_node: &'a str, ast_node_parent: &'a str) ->
119119
}
120120

121121
pub fn create_token_class<'a>(token_type: &'a str, tokeninfo: &'a str) -> ql::Class<'a> {
122-
let tokeninfo_arity = 6;
122+
let tokeninfo_arity = 4;
123123
let get_value = ql::Predicate {
124124
qldoc: Some(String::from("Gets the value of this token.")),
125125
name: "getValue",
126126
overridden: false,
127127
return_type: Some(ql::Type::String),
128128
formal_parameters: vec![],
129-
body: create_get_field_expr_for_column_storage("result", tokeninfo, 3, tokeninfo_arity),
129+
body: create_get_field_expr_for_column_storage("result", tokeninfo, 1, tokeninfo_arity),
130130
};
131131
let get_location = ql::Predicate {
132132
qldoc: Some(String::from("Gets the location of this token.")),
133133
name: "getLocation",
134134
overridden: true,
135135
return_type: Some(ql::Type::Normal("Location")),
136136
formal_parameters: vec![],
137-
body: create_get_field_expr_for_column_storage("result", tokeninfo, 4, tokeninfo_arity),
137+
body: create_get_field_expr_for_column_storage("result", tokeninfo, 2, tokeninfo_arity),
138138
};
139139
let to_string = ql::Predicate {
140140
qldoc: Some(String::from(

ql/lib/codeql/ruby/ast/internal/TreeSitter.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ module Ruby {
3434
/** A token. */
3535
class Token extends @ruby_token, AstNode {
3636
/** Gets the value of this token. */
37-
string getValue() { ruby_tokeninfo(this, _, _, _, result, _) }
37+
string getValue() { ruby_tokeninfo(this, _, result, _) }
3838

3939
/** Gets the location of this token. */
40-
override Location getLocation() { ruby_tokeninfo(this, _, _, _, _, result) }
40+
override Location getLocation() { ruby_tokeninfo(this, _, _, result) }
4141

4242
/** Gets a string representation of this element. */
4343
override string toString() { result = getValue() }
@@ -1875,10 +1875,10 @@ module Erb {
18751875
/** A token. */
18761876
class Token extends @erb_token, AstNode {
18771877
/** Gets the value of this token. */
1878-
string getValue() { erb_tokeninfo(this, _, _, _, result, _) }
1878+
string getValue() { erb_tokeninfo(this, _, result, _) }
18791879

18801880
/** Gets the location of this token. */
1881-
override Location getLocation() { erb_tokeninfo(this, _, _, _, _, result) }
1881+
override Location getLocation() { erb_tokeninfo(this, _, _, result) }
18821882

18831883
/** Gets a string representation of this element. */
18841884
override string toString() { result = getValue() }

ql/lib/ruby.dbscheme

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,6 @@ ruby_yield_def(
12051205
ruby_tokeninfo(
12061206
unique int id: @ruby_token,
12071207
int kind: int ref,
1208-
int file: @file ref,
1209-
int idx: int ref,
12101208
string value: string ref,
12111209
int loc: @location ref
12121210
);
@@ -1293,8 +1291,6 @@ erb_template_def(
12931291
erb_tokeninfo(
12941292
unique int id: @erb_token,
12951293
int kind: int ref,
1296-
int file: @file ref,
1297-
int idx: int ref,
12981294
string value: string ref,
12991295
int loc: @location ref
13001296
);

0 commit comments

Comments
 (0)