masaori335 commented on code in PR #14038:
URL: https://github.com/apache/trafficserver/pull/14038#discussion_r4534168847


##########
tools/hrw4u/scripts/hrw4u-lsp:
##########
@@ -127,16 +129,16 @@ class DocumentManager:
             if hasattr(parser, '_syntax_errors'):
                 parser_errors = list(parser._syntax_errors)
 
-            if tree is not None:
-                visitor = HRW4UVisitor(
-                    filename=filename,
-                    error_collector=error_collector,
-                    proc_search_paths=self.proc_search_paths or None,
-                    sandbox=self.sandbox,
-                )
+            # An error-recovered tree has no AST; hover and definition keep 
the last analysis's procedures.
+            if tree is not None and not error_collector.has_errors():
                 try:
-                    visitor.visit(tree)
-                    self.proc_registries[uri] = dict(visitor._proc_registry)
+                    ast = ASTVisitor(filename=filename).visit(tree)
+                    sema = Sema(
+                        error_collector=error_collector, 
proc_search_paths=self.proc_search_paths or None, sandbox=self.sandbox
+                    )
+                    sema.source_map.add(filename, text)
+                    sema.analyze(ast)
+                    self.proc_registries[uri] = sema.procs

Review Comment:
   Keeping this as is. Updating the cache only after an error-free run would 
freeze hover and definition at the last clean state whenever the document has 
any semantic error: a procedure just added with use would not hover until an 
unrelated typo is fixed. The registry from the latest run that produced an AST 
is the better source, and a procedure that fails to register, as in your 
example, is not a valid procedure to offer. The PR description overstated this; 
it now says "the last analysis that could build an AST".



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to