lsp: Show docs on hover

Also:
- Install the script to <prefix>/bin
- Fix a bug in XmlReader that would cause "uninteresting" tags to not be
  fully ignored
- Other minor improvements
This commit is contained in:
James Westman 2021-10-24 17:10:05 -05:00
parent 8fc0efb642
commit 55a117a5b7
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
7 changed files with 85 additions and 31 deletions

View file

@ -24,9 +24,10 @@ from xml import sax
from .utils import lazy_prop
# To speed up parsing, we ignore all tags except these
PARSE_GIR = set([
"repository", "namespace", "class", "interface", "property", "glib:signal",
"include", "implements",
"include", "implements"
])
@ -52,10 +53,13 @@ class Handler(sax.handler.ContentHandler):
def __init__(self, parse_type):
self.root = None
self.stack = []
self.skipping = 0
self._interesting_elements = parse_type
def startElement(self, name, attrs):
if name not in self._interesting_elements:
self.skipping += 1
if self.skipping > 0:
return
element = Element(name, attrs.copy())
@ -70,11 +74,14 @@ class Handler(sax.handler.ContentHandler):
def endElement(self, name):
if name in self._interesting_elements:
if self.skipping == 0:
self.stack.pop()
if name not in self._interesting_elements:
self.skipping -= 1
def characters(self, content):
self.stack[-1].cdata_chunks.append(content)
if not self.skipping:
self.stack[-1].cdata_chunks.append(content)
def parse(filename, parse_type):