Skip to content

Commit

Permalink
feat: added FunctionSymbol
Browse files Browse the repository at this point in the history
Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

add function symbol kind to lsp

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update function symbol def

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fix ci

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fix ci

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

add tests to sema_token

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

add get_function_symbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

highlight for func call

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

modify walk_call_expr

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update namer for func_name

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: distinguish highlight for func symbol and normal var symbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update alloc_function_symbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

function symbol for builtin functions

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update function symbol def

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

delete test.log

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

remove func symbol from walk_call_expr

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update walk_call_expr for namer

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update sema test

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

add function symbol kind in global state

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update hover to handle func symbolkind

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

add condition for symbolkind in hover

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

remove print statements

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update loader snapshots

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fix advanced resolver

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update assign stmt for lambda expr

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update resolve_names for identifier_expr

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

update semantic tokens with function type

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: api list_variables supports get variables from multi-files (#1389)

* feat: api list_variables supports get variables from multi-files

Signed-off-by: zongz <zongzhe1024@163.com>

* fix: fix CR comments

Signed-off-by: zongz <zongzhe1024@163.com>

* fix: fix test cases

Signed-off-by: zongz <zongzhe1024@163.com>

---------

Signed-off-by: zongz <zongzhe1024@163.com>

feat: advance resolver incremental compile (#1209)

feat: advanced resolver incremental compile. 1. Namer and Advanced Resolver support incremental compilation, clear cache by pkg and only update new pkg
2. Add gs cache in lsp state
3. Namer and Advanced Resolver modify gs in place(&mut) to reduce clone

Signed-off-by: he1pa <18012015693@163.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

resolve conflicts

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

resolve conflicts

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

resolve conflicts

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

remove duplicate code

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

remove repititions

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

fmt check

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>

feat: added FunctionSymbol

Signed-off-by: shruti2522 <shruti.apc01@gmail.com>
  • Loading branch information
shruti2522 committed Jun 3, 2024
1 parent c07925f commit 5ae3432
Show file tree
Hide file tree
Showing 46 changed files with 1,173 additions and 468 deletions.
8 changes: 4 additions & 4 deletions kclvm/api/src/service/service_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl KclvmServiceImpl {
},
module_cache,
scope_cache,
GlobalState::default(),
&mut GlobalState::default(),
)?;
if args.with_ast_index {
// Thread local options
Expand Down Expand Up @@ -351,18 +351,18 @@ impl KclvmServiceImpl {
///
/// let serv = KclvmServiceImpl::default();
/// let args = &ListVariablesArgs {
/// file: Path::new(".").join("src").join("testdata").join("variables").join("main.k").canonicalize().unwrap().display().to_string(),
/// files: vec![Path::new(".").join("src").join("testdata").join("variables").join("main.k").canonicalize().unwrap().display().to_string()],
/// specs: vec!["a".to_string()]
/// };
/// let result = serv.list_variables(args).unwrap();
/// assert_eq!(result.variables.len(), 1);
/// assert_eq!(result.variables.get("a").unwrap().value, "1");
/// ```
pub fn list_variables(&self, args: &ListVariablesArgs) -> anyhow::Result<ListVariablesResult> {
let k_file = args.file.to_string();
let k_files = args.files.clone();
let specs = args.specs.clone();

let select_res = list_variables(k_file, specs)?;
let select_res = list_variables(k_files, specs)?;

let variables: HashMap<String, Variable> = select_res
.variables
Expand Down
2 changes: 1 addition & 1 deletion kclvm/api/src/testdata/list-variables.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"file": "./src/testdata/variables/main.k",
"files": ["./src/testdata/variables/main.k"],
"specs": ["a", "b", "c"]
}
Empty file.
8 changes: 4 additions & 4 deletions kclvm/loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn load_packages(opts: &LoadPackageOptions) -> Result<Packages> {
opts,
KCLModuleCache::default(),
KCLScopeCache::default(),
GlobalState::default(),
&mut GlobalState::default(),
)
}

Expand All @@ -126,7 +126,7 @@ pub fn load_packages_with_cache(
opts: &LoadPackageOptions,
module_cache: KCLModuleCache,
scope_cache: KCLScopeCache,
gs: GlobalState,
gs: &mut GlobalState,
) -> Result<Packages> {
let sess = ParseSessionRef::default();
let paths: Vec<&str> = opts.paths.iter().map(|s| s.as_str()).collect();
Expand All @@ -149,8 +149,8 @@ pub fn load_packages_with_cache(
Some(scope_cache),
);
let node_ty_map = prog_scope.node_ty_map;
let gs = Namer::find_symbols(&program, gs);
let gs = AdvancedResolver::resolve_program(&program, gs, node_ty_map.clone())?;
Namer::find_symbols(&program, gs);
AdvancedResolver::resolve_program(&program, gs, node_ty_map.clone())?;
(program, prog_scope.handler.diagnostics.clone(), gs)
} else {
(parse_result.program, IndexSet::default(), gs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 165,
index: 0,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 165,
index: 0,
generation: 0,
},
kind: Value,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: loader/src/tests.rs
assertion_line: 27
expression: "format!(\"{:#?}\", p.symbols.values())"
---
[
Expand Down Expand Up @@ -38,7 +39,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
def: Some(
SymbolRef {
id: Index {
index: 165,
index: 0,
generation: 0,
},
kind: Value,
Expand Down
61 changes: 31 additions & 30 deletions kclvm/loader/src/snapshots/kclvm_loader__tests__builtin_call_0.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
source: loader/src/tests.rs
assertion_line: 37
expression: "format!(\"{:#?}\", p.symbols.values())"
---
[
Expand Down Expand Up @@ -46,7 +47,7 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
index: 1,
generation: 0,
},
kind: Value,
kind: Function,
},
),
attrs: [],
Expand Down Expand Up @@ -93,203 +94,203 @@ expression: "format!(\"{:#?}\", p.symbols.values())"
index: 136,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 137,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 138,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 139,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 140,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 141,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 142,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 143,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 144,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 145,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 146,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 147,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 148,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 149,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 150,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 151,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 152,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 153,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 154,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 155,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 156,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 157,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 158,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 159,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 160,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 161,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 162,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 163,
generation: 0,
},
kind: Value,
kind: Function,
},
SymbolRef {
id: Index {
index: 164,
generation: 0,
},
kind: Value,
kind: Function,
},
],
is_global: false,
Expand Down
Loading

0 comments on commit 5ae3432

Please sign in to comment.