MCPcopy
hub / github.com/h2oai/wave / FileMetadata

Class FileMetadata

tools/vscode-extension/server/parser.py:11–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11class FileMetadata():
12 files_to_parse: Dict[str, str] = {}
13
14 def __init__(self) -> None:
15 # TODO: Consider using Set instead of List.
16 self.args: List[str] = []
17 self.events: Dict[str, List[str]] = {}
18 self.zones: List[str] = []
19 self.client: List[str] = []
20 self.app: List[str] = []
21 self.user: List[str] = []
22 self.deps: Set[str] = set()
23
24 def add_completion(self, node: Any, completion_type: str) -> None:
25 if (node.type == 'string' or node.type == 'name'):
26 val = strip_quotes(node.value)
27 if val and (completion_type != 'args' or not val.startswith('#')):
28 getattr(self, completion_type).append(val)
29
30 def __get_event_names(self, nodes: List[Any]) -> List[str]:
31 return [strip_quotes(node.value) for node in nodes if node.type == 'string']
32
33 def add_event_completion(self, name_arg: Any, events_arg: Any):
34 if name_arg.type == 'string':
35 # Seems like args in events=['event'] and events=['event', 'event2'] are different AST-wise.
36 if events_arg.children[-1].children[1].type == 'testlist_comp':
37 event_nodes = events_arg.children[-1].children[1].children
38 else:
39 event_nodes = events_arg.children[-1].children
40 event_element_name = strip_quotes(name_arg.value)
41 self.events[event_element_name] = self.__get_event_names(event_nodes)
42
43 @staticmethod
44 def set_files_to_parse(files: List[str]) -> None:
45 for f in files:
46 FileMetadata.files_to_parse[os.path.basename(f)[:-3]] = f
47
48 def add_dep(self, dep_name: str) -> None:
49 dep_file = FileMetadata.files_to_parse.get(dep_name)
50 if dep_file:
51 self.deps.add(dep_file)
52
53
54def read_file(file: str) -> str:

Callers 3

fill_completionFunction · 0.85
get_initial_completionsFunction · 0.85
completionsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…