Sphinx 8.1.2__py3-none-any.whl → 8.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of Sphinx might be problematic. Click here for more details.
- sphinx/__init__.py +8 -4
- sphinx/__main__.py +2 -0
- sphinx/_cli/__init__.py +2 -5
- sphinx/_cli/util/colour.py +34 -11
- sphinx/_cli/util/errors.py +128 -61
- sphinx/addnodes.py +51 -35
- sphinx/application.py +362 -230
- sphinx/builders/__init__.py +87 -64
- sphinx/builders/_epub_base.py +65 -56
- sphinx/builders/changes.py +17 -23
- sphinx/builders/dirhtml.py +8 -13
- sphinx/builders/epub3.py +70 -38
- sphinx/builders/gettext.py +93 -73
- sphinx/builders/html/__init__.py +240 -186
- sphinx/builders/html/_assets.py +9 -2
- sphinx/builders/html/_build_info.py +3 -0
- sphinx/builders/latex/__init__.py +64 -54
- sphinx/builders/latex/constants.py +14 -11
- sphinx/builders/latex/nodes.py +2 -0
- sphinx/builders/latex/theming.py +8 -9
- sphinx/builders/latex/transforms.py +7 -5
- sphinx/builders/linkcheck.py +193 -149
- sphinx/builders/manpage.py +17 -17
- sphinx/builders/singlehtml.py +28 -16
- sphinx/builders/texinfo.py +28 -21
- sphinx/builders/text.py +10 -15
- sphinx/builders/xml.py +10 -19
- sphinx/cmd/build.py +49 -119
- sphinx/cmd/make_mode.py +35 -31
- sphinx/cmd/quickstart.py +78 -62
- sphinx/config.py +265 -163
- sphinx/directives/__init__.py +51 -54
- sphinx/directives/admonitions.py +107 -0
- sphinx/directives/code.py +24 -19
- sphinx/directives/other.py +21 -42
- sphinx/directives/patches.py +28 -16
- sphinx/domains/__init__.py +54 -31
- sphinx/domains/_domains_container.py +22 -17
- sphinx/domains/_index.py +5 -8
- sphinx/domains/c/__init__.py +366 -245
- sphinx/domains/c/_ast.py +378 -256
- sphinx/domains/c/_ids.py +89 -31
- sphinx/domains/c/_parser.py +283 -214
- sphinx/domains/c/_symbol.py +269 -198
- sphinx/domains/changeset.py +39 -24
- sphinx/domains/citation.py +54 -24
- sphinx/domains/cpp/__init__.py +517 -362
- sphinx/domains/cpp/_ast.py +999 -682
- sphinx/domains/cpp/_ids.py +133 -65
- sphinx/domains/cpp/_parser.py +746 -588
- sphinx/domains/cpp/_symbol.py +692 -489
- sphinx/domains/index.py +10 -8
- sphinx/domains/javascript.py +152 -74
- sphinx/domains/math.py +50 -40
- sphinx/domains/python/__init__.py +402 -211
- sphinx/domains/python/_annotations.py +134 -61
- sphinx/domains/python/_object.py +155 -68
- sphinx/domains/rst.py +94 -49
- sphinx/domains/std/__init__.py +510 -249
- sphinx/environment/__init__.py +345 -61
- sphinx/environment/adapters/asset.py +7 -1
- sphinx/environment/adapters/indexentries.py +15 -20
- sphinx/environment/adapters/toctree.py +19 -9
- sphinx/environment/collectors/__init__.py +3 -1
- sphinx/environment/collectors/asset.py +18 -15
- sphinx/environment/collectors/dependencies.py +8 -10
- sphinx/environment/collectors/metadata.py +6 -4
- sphinx/environment/collectors/title.py +3 -1
- sphinx/environment/collectors/toctree.py +4 -4
- sphinx/errors.py +1 -3
- sphinx/events.py +4 -4
- sphinx/ext/apidoc/__init__.py +66 -0
- sphinx/ext/apidoc/__main__.py +9 -0
- sphinx/ext/apidoc/_cli.py +356 -0
- sphinx/ext/apidoc/_extension.py +262 -0
- sphinx/ext/apidoc/_generate.py +356 -0
- sphinx/ext/apidoc/_shared.py +99 -0
- sphinx/ext/autodoc/__init__.py +837 -483
- sphinx/ext/autodoc/directive.py +57 -21
- sphinx/ext/autodoc/importer.py +184 -67
- sphinx/ext/autodoc/mock.py +25 -10
- sphinx/ext/autodoc/preserve_defaults.py +17 -9
- sphinx/ext/autodoc/type_comment.py +56 -29
- sphinx/ext/autodoc/typehints.py +49 -26
- sphinx/ext/autosectionlabel.py +28 -11
- sphinx/ext/autosummary/__init__.py +281 -142
- sphinx/ext/autosummary/generate.py +121 -51
- sphinx/ext/coverage.py +152 -91
- sphinx/ext/doctest.py +169 -101
- sphinx/ext/duration.py +12 -6
- sphinx/ext/extlinks.py +33 -21
- sphinx/ext/githubpages.py +8 -8
- sphinx/ext/graphviz.py +175 -109
- sphinx/ext/ifconfig.py +11 -6
- sphinx/ext/imgconverter.py +48 -25
- sphinx/ext/imgmath.py +127 -97
- sphinx/ext/inheritance_diagram.py +177 -103
- sphinx/ext/intersphinx/__init__.py +22 -13
- sphinx/ext/intersphinx/__main__.py +3 -1
- sphinx/ext/intersphinx/_cli.py +18 -14
- sphinx/ext/intersphinx/_load.py +91 -82
- sphinx/ext/intersphinx/_resolve.py +108 -74
- sphinx/ext/intersphinx/_shared.py +2 -2
- sphinx/ext/linkcode.py +28 -12
- sphinx/ext/mathjax.py +60 -29
- sphinx/ext/napoleon/__init__.py +19 -7
- sphinx/ext/napoleon/docstring.py +229 -231
- sphinx/ext/todo.py +44 -49
- sphinx/ext/viewcode.py +105 -57
- sphinx/extension.py +3 -1
- sphinx/highlighting.py +13 -7
- sphinx/io.py +9 -13
- sphinx/jinja2glue.py +29 -26
- sphinx/locale/__init__.py +8 -9
- sphinx/locale/ar/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ar/LC_MESSAGES/sphinx.po +2155 -2050
- sphinx/locale/bg/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bg/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/bn/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/bn/LC_MESSAGES/sphinx.po +2175 -2070
- sphinx/locale/ca/LC_MESSAGES/sphinx.js +3 -3
- sphinx/locale/ca/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ca/LC_MESSAGES/sphinx.po +2690 -2585
- sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.js +63 -0
- sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ca@valencia/LC_MESSAGES/sphinx.po +4216 -0
- sphinx/locale/cak/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cak/LC_MESSAGES/sphinx.po +2096 -1991
- sphinx/locale/cs/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cs/LC_MESSAGES/sphinx.po +2248 -2143
- sphinx/locale/cy/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/cy/LC_MESSAGES/sphinx.po +2201 -2096
- sphinx/locale/da/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/da/LC_MESSAGES/sphinx.po +2282 -2177
- sphinx/locale/de/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de/LC_MESSAGES/sphinx.po +2261 -2156
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/de_DE/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/el/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/el/LC_MESSAGES/sphinx.po +2604 -2499
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_DE/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_FR/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_GB/LC_MESSAGES/sphinx.po +2631 -2526
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/en_HK/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/eo/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eo/LC_MESSAGES/sphinx.po +2078 -1973
- sphinx/locale/es/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es/LC_MESSAGES/sphinx.po +2633 -2528
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/es_CO/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/et/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/et/LC_MESSAGES/sphinx.po +2449 -2344
- sphinx/locale/eu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/eu/LC_MESSAGES/sphinx.po +2241 -2136
- sphinx/locale/fa/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fa/LC_MESSAGES/sphinx.po +504 -500
- sphinx/locale/fi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fi/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/fr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr/LC_MESSAGES/sphinx.po +513 -509
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/fr_FR/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/gl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/gl/LC_MESSAGES/sphinx.po +2644 -2539
- sphinx/locale/he/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/he/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/hi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi/LC_MESSAGES/sphinx.po +504 -500
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hi_IN/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/hr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hr/LC_MESSAGES/sphinx.po +501 -497
- sphinx/locale/hu/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/hu/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/id/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/id/LC_MESSAGES/sphinx.po +2609 -2504
- sphinx/locale/is/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/is/LC_MESSAGES/sphinx.po +499 -495
- sphinx/locale/it/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/it/LC_MESSAGES/sphinx.po +2265 -2160
- sphinx/locale/ja/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ja/LC_MESSAGES/sphinx.po +2621 -2516
- sphinx/locale/ka/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ka/LC_MESSAGES/sphinx.po +2567 -2462
- sphinx/locale/ko/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ko/LC_MESSAGES/sphinx.po +2631 -2526
- sphinx/locale/lt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lt/LC_MESSAGES/sphinx.po +2214 -2109
- sphinx/locale/lv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/lv/LC_MESSAGES/sphinx.po +2218 -2113
- sphinx/locale/mk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/mk/LC_MESSAGES/sphinx.po +2088 -1983
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nb_NO/LC_MESSAGES/sphinx.po +2247 -2142
- sphinx/locale/ne/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ne/LC_MESSAGES/sphinx.po +2227 -2122
- sphinx/locale/nl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/nl/LC_MESSAGES/sphinx.po +2316 -2211
- sphinx/locale/pl/LC_MESSAGES/sphinx.js +2 -2
- sphinx/locale/pl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pl/LC_MESSAGES/sphinx.po +2442 -2336
- sphinx/locale/pt/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_BR/LC_MESSAGES/sphinx.po +2657 -2552
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/pt_PT/LC_MESSAGES/sphinx.po +2243 -2138
- sphinx/locale/ro/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ro/LC_MESSAGES/sphinx.po +2244 -2139
- sphinx/locale/ru/LC_MESSAGES/sphinx.js +1 -1
- sphinx/locale/ru/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ru/LC_MESSAGES/sphinx.po +2660 -2555
- sphinx/locale/si/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/si/LC_MESSAGES/sphinx.po +2134 -2029
- sphinx/locale/sk/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sk/LC_MESSAGES/sphinx.po +2614 -2509
- sphinx/locale/sl/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sl/LC_MESSAGES/sphinx.po +2167 -2062
- sphinx/locale/sphinx.pot +2069 -1964
- sphinx/locale/sq/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sq/LC_MESSAGES/sphinx.po +2661 -2556
- sphinx/locale/sr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sr/LC_MESSAGES/sphinx.po +2213 -2108
- sphinx/locale/sv/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/sv/LC_MESSAGES/sphinx.po +2229 -2124
- sphinx/locale/te/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/te/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/tr/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/tr/LC_MESSAGES/sphinx.po +2608 -2503
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/uk_UA/LC_MESSAGES/sphinx.po +2167 -2062
- sphinx/locale/ur/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/ur/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/vi/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/vi/LC_MESSAGES/sphinx.po +2204 -2099
- sphinx/locale/yue/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/yue/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_HK/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW/LC_MESSAGES/sphinx.po +2659 -2554
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.mo +0 -0
- sphinx/locale/zh_TW.Big5/LC_MESSAGES/sphinx.po +2045 -1940
- sphinx/parsers.py +8 -7
- sphinx/project.py +2 -2
- sphinx/pycode/__init__.py +31 -21
- sphinx/pycode/ast.py +6 -3
- sphinx/pycode/parser.py +14 -8
- sphinx/pygments_styles.py +4 -5
- sphinx/registry.py +192 -92
- sphinx/roles.py +58 -7
- sphinx/search/__init__.py +75 -54
- sphinx/search/en.py +11 -13
- sphinx/search/fi.py +1 -1
- sphinx/search/ja.py +8 -6
- sphinx/search/nl.py +1 -1
- sphinx/search/zh.py +19 -21
- sphinx/testing/fixtures.py +26 -29
- sphinx/testing/path.py +26 -62
- sphinx/testing/restructuredtext.py +14 -8
- sphinx/testing/util.py +21 -19
- sphinx/texinputs/make.bat.jinja +50 -50
- sphinx/texinputs/sphinx.sty +4 -3
- sphinx/texinputs/sphinxlatexadmonitions.sty +1 -1
- sphinx/texinputs/sphinxlatexobjects.sty +29 -10
- sphinx/themes/basic/static/searchtools.js +8 -5
- sphinx/theming.py +49 -61
- sphinx/transforms/__init__.py +17 -38
- sphinx/transforms/compact_bullet_list.py +5 -3
- sphinx/transforms/i18n.py +8 -21
- sphinx/transforms/post_transforms/__init__.py +142 -93
- sphinx/transforms/post_transforms/code.py +5 -5
- sphinx/transforms/post_transforms/images.py +28 -24
- sphinx/transforms/references.py +3 -1
- sphinx/util/__init__.py +109 -60
- sphinx/util/_files.py +39 -23
- sphinx/util/_importer.py +4 -1
- sphinx/util/_inventory_file_reader.py +76 -0
- sphinx/util/_io.py +2 -2
- sphinx/util/_lines.py +6 -3
- sphinx/util/_pathlib.py +40 -2
- sphinx/util/build_phase.py +2 -0
- sphinx/util/cfamily.py +19 -14
- sphinx/util/console.py +44 -179
- sphinx/util/display.py +9 -10
- sphinx/util/docfields.py +140 -122
- sphinx/util/docstrings.py +1 -1
- sphinx/util/docutils.py +118 -77
- sphinx/util/fileutil.py +25 -26
- sphinx/util/http_date.py +2 -0
- sphinx/util/i18n.py +77 -64
- sphinx/util/images.py +8 -6
- sphinx/util/inspect.py +147 -38
- sphinx/util/inventory.py +215 -116
- sphinx/util/logging.py +33 -33
- sphinx/util/matching.py +12 -4
- sphinx/util/nodes.py +18 -13
- sphinx/util/osutil.py +38 -39
- sphinx/util/parallel.py +22 -13
- sphinx/util/parsing.py +2 -1
- sphinx/util/png.py +6 -2
- sphinx/util/requests.py +33 -2
- sphinx/util/rst.py +3 -2
- sphinx/util/tags.py +1 -1
- sphinx/util/template.py +18 -10
- sphinx/util/texescape.py +8 -6
- sphinx/util/typing.py +148 -122
- sphinx/versioning.py +3 -3
- sphinx/writers/html.py +3 -1
- sphinx/writers/html5.py +63 -52
- sphinx/writers/latex.py +83 -67
- sphinx/writers/manpage.py +19 -38
- sphinx/writers/texinfo.py +47 -47
- sphinx/writers/text.py +50 -32
- sphinx/writers/xml.py +11 -8
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/LICENSE.rst +1 -1
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/METADATA +25 -15
- sphinx-8.2.0.dist-info/RECORD +606 -0
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/WHEEL +1 -1
- sphinx/builders/html/transforms.py +0 -90
- sphinx/ext/apidoc.py +0 -721
- sphinx/util/exceptions.py +0 -74
- sphinx-8.1.2.dist-info/RECORD +0 -598
- {sphinx-8.1.2.dist-info → sphinx-8.2.0.dist-info}/entry_points.txt +0 -0
sphinx/domains/c/_symbol.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
4
|
|
|
5
5
|
from sphinx.domains.c._ast import (
|
|
6
6
|
ASTDeclaration,
|
|
7
|
-
ASTIdentifier,
|
|
8
7
|
ASTNestedName,
|
|
9
8
|
)
|
|
10
9
|
from sphinx.locale import __
|
|
@@ -12,9 +11,11 @@ from sphinx.util import logging
|
|
|
12
11
|
|
|
13
12
|
if TYPE_CHECKING:
|
|
14
13
|
from collections.abc import Callable, Iterable, Iterator, Sequence
|
|
14
|
+
from typing import Any, Self
|
|
15
15
|
|
|
16
|
-
from
|
|
17
|
-
|
|
16
|
+
from sphinx.domains.c._ast import (
|
|
17
|
+
ASTIdentifier,
|
|
18
|
+
)
|
|
18
19
|
from sphinx.environment import BuildEnvironment
|
|
19
20
|
|
|
20
21
|
logger = logging.getLogger(__name__)
|
|
@@ -28,29 +29,47 @@ class _DuplicateSymbolError(Exception):
|
|
|
28
29
|
self.declaration = declaration
|
|
29
30
|
|
|
30
31
|
def __str__(self) -> str:
|
|
31
|
-
return
|
|
32
|
+
return 'Internal C duplicate symbol error:\n%s' % self.symbol.dump(0)
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
class SymbolLookupResult:
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
__slots__ = 'symbols', 'parent_symbol', 'ident'
|
|
37
|
+
|
|
38
|
+
symbols: Iterable[Symbol]
|
|
39
|
+
parent_symbol: Symbol
|
|
40
|
+
ident_or_op: ASTIdentifier
|
|
41
|
+
|
|
42
|
+
def __init__(
|
|
43
|
+
self, symbols: Iterable[Symbol], parent_symbol: Symbol, ident: ASTIdentifier
|
|
44
|
+
) -> None:
|
|
37
45
|
self.symbols = symbols
|
|
38
|
-
self.
|
|
46
|
+
self.parent_symbol = parent_symbol
|
|
39
47
|
self.ident = ident
|
|
40
48
|
|
|
49
|
+
@property
|
|
50
|
+
def parentSymbol(self) -> Symbol:
|
|
51
|
+
return self.parent_symbol
|
|
52
|
+
|
|
41
53
|
|
|
42
54
|
class LookupKey:
|
|
43
|
-
|
|
55
|
+
__slots__ = ('data',)
|
|
56
|
+
|
|
57
|
+
data: Sequence[tuple[ASTIdentifier, str]]
|
|
58
|
+
|
|
59
|
+
def __init__(self, data: Sequence[tuple[ASTIdentifier, str]], /) -> None:
|
|
44
60
|
self.data = data
|
|
45
61
|
|
|
62
|
+
def __repr__(self) -> str:
|
|
63
|
+
return f'LookupKey({self.data!r})'
|
|
64
|
+
|
|
46
65
|
def __str__(self) -> str:
|
|
47
|
-
inner = ', '.join(f
|
|
66
|
+
inner = ', '.join(f'({ident}, {id_})' for ident, id_ in self.data)
|
|
48
67
|
return f'[{inner}]'
|
|
49
68
|
|
|
50
69
|
|
|
51
70
|
class Symbol:
|
|
52
71
|
debug_indent = 0
|
|
53
|
-
debug_indent_string =
|
|
72
|
+
debug_indent_string = ' '
|
|
54
73
|
debug_lookup = False
|
|
55
74
|
debug_show_tree = False
|
|
56
75
|
|
|
@@ -66,7 +85,7 @@ class Symbol:
|
|
|
66
85
|
@staticmethod
|
|
67
86
|
def debug_print(*args: Any) -> None:
|
|
68
87
|
msg = Symbol.debug_indent_string * Symbol.debug_indent
|
|
69
|
-
msg +=
|
|
88
|
+
msg += ''.join(str(e) for e in args)
|
|
70
89
|
logger.debug(msg)
|
|
71
90
|
|
|
72
91
|
def _assert_invariants(self) -> None:
|
|
@@ -79,7 +98,7 @@ class Symbol:
|
|
|
79
98
|
assert self.docname
|
|
80
99
|
|
|
81
100
|
def __setattr__(self, key: str, value: Any) -> None:
|
|
82
|
-
if key ==
|
|
101
|
+
if key == 'children':
|
|
83
102
|
raise AssertionError
|
|
84
103
|
return super().__setattr__(key, value)
|
|
85
104
|
|
|
@@ -136,7 +155,8 @@ class Symbol:
|
|
|
136
155
|
def _remove_child(self, child: Symbol) -> None:
|
|
137
156
|
name = child.ident.name
|
|
138
157
|
self._children_by_name.pop(name, None)
|
|
139
|
-
self._children_by_docname.get(child.docname
|
|
158
|
+
if children := self._children_by_docname.get(child.docname):
|
|
159
|
+
children.pop(name, None)
|
|
140
160
|
if child.ident.is_anonymous:
|
|
141
161
|
self._anon_children.discard(child)
|
|
142
162
|
|
|
@@ -159,12 +179,15 @@ class Symbol:
|
|
|
159
179
|
def _add_function_params(self) -> None:
|
|
160
180
|
if Symbol.debug_lookup:
|
|
161
181
|
Symbol.debug_indent += 1
|
|
162
|
-
Symbol.debug_print(
|
|
182
|
+
Symbol.debug_print('_add_function_params:')
|
|
163
183
|
# Note: we may be called from _fill_empty, so the symbols we want
|
|
164
184
|
# to add may actually already be present (as empty symbols).
|
|
165
185
|
|
|
166
186
|
# add symbols for function parameters, if any
|
|
167
|
-
if
|
|
187
|
+
if (
|
|
188
|
+
self.declaration is not None
|
|
189
|
+
and self.declaration.function_params is not None
|
|
190
|
+
):
|
|
168
191
|
for p in self.declaration.function_params:
|
|
169
192
|
if p.arg is None:
|
|
170
193
|
continue
|
|
@@ -205,8 +228,8 @@ class Symbol:
|
|
|
205
228
|
|
|
206
229
|
def get_all_symbols(self) -> Iterator[Symbol]:
|
|
207
230
|
yield self
|
|
208
|
-
for
|
|
209
|
-
yield from
|
|
231
|
+
for s_child in self._children:
|
|
232
|
+
yield from s_child.get_all_symbols()
|
|
210
233
|
|
|
211
234
|
@property
|
|
212
235
|
def children(self) -> Iterator[Symbol]:
|
|
@@ -222,14 +245,11 @@ class Symbol:
|
|
|
222
245
|
while s.parent:
|
|
223
246
|
symbols.append(s)
|
|
224
247
|
s = s.parent
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
key.append((s.ident, s.declaration.get_newest_id()))
|
|
231
|
-
else:
|
|
232
|
-
key.append((s.ident, None))
|
|
248
|
+
key = [
|
|
249
|
+
# TODO: do we need the ID?
|
|
250
|
+
(s.ident, None if s.declaration is None else s.declaration.get_newest_id())
|
|
251
|
+
for s in reversed(symbols)
|
|
252
|
+
]
|
|
233
253
|
return LookupKey(key)
|
|
234
254
|
|
|
235
255
|
def get_full_nested_name(self) -> ASTNestedName:
|
|
@@ -244,70 +264,74 @@ class Symbol:
|
|
|
244
264
|
|
|
245
265
|
def _symbol_lookup(
|
|
246
266
|
self,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
267
|
+
nested_name: ASTNestedName,
|
|
268
|
+
on_missing_qualified_symbol: Callable[[Symbol, ASTIdentifier], Symbol | None],
|
|
269
|
+
ancestor_lookup_type: str | None,
|
|
270
|
+
match_self: bool,
|
|
271
|
+
recurse_in_anon: bool,
|
|
272
|
+
search_in_siblings: bool,
|
|
253
273
|
) -> SymbolLookupResult | None:
|
|
254
274
|
# TODO: further simplification from C++ to C
|
|
255
|
-
#
|
|
275
|
+
# ancestor_lookup_type: if not None, specifies the target type of the lookup
|
|
256
276
|
if Symbol.debug_lookup:
|
|
257
277
|
Symbol.debug_indent += 1
|
|
258
|
-
Symbol.debug_print(
|
|
278
|
+
Symbol.debug_print('_symbol_lookup:')
|
|
259
279
|
Symbol.debug_indent += 1
|
|
260
|
-
Symbol.debug_print(
|
|
280
|
+
Symbol.debug_print('self:')
|
|
261
281
|
logger.debug(self.to_string(Symbol.debug_indent + 1, addEndNewline=False))
|
|
262
|
-
Symbol.debug_print(
|
|
263
|
-
Symbol.debug_print(
|
|
264
|
-
Symbol.debug_print(
|
|
265
|
-
Symbol.debug_print(
|
|
266
|
-
Symbol.debug_print(
|
|
282
|
+
Symbol.debug_print('nested_name: ', nested_name)
|
|
283
|
+
Symbol.debug_print('ancestor_lookup_type:', ancestor_lookup_type)
|
|
284
|
+
Symbol.debug_print('match_self: ', match_self)
|
|
285
|
+
Symbol.debug_print('recurse_in_anon: ', recurse_in_anon)
|
|
286
|
+
Symbol.debug_print('search_in_siblings: ', search_in_siblings)
|
|
267
287
|
|
|
268
|
-
names =
|
|
288
|
+
names = nested_name.names
|
|
269
289
|
|
|
270
290
|
# find the right starting point for lookup
|
|
271
|
-
|
|
272
|
-
if
|
|
273
|
-
while
|
|
274
|
-
|
|
291
|
+
parent_symbol = self
|
|
292
|
+
if nested_name.rooted:
|
|
293
|
+
while parent_symbol.parent is not None:
|
|
294
|
+
parent_symbol = parent_symbol.parent
|
|
275
295
|
|
|
276
|
-
if
|
|
296
|
+
if ancestor_lookup_type is not None:
|
|
277
297
|
# walk up until we find the first identifier
|
|
278
|
-
|
|
279
|
-
while
|
|
280
|
-
if
|
|
298
|
+
first_name = names[0]
|
|
299
|
+
while parent_symbol.parent:
|
|
300
|
+
if first_name.name in parent_symbol._children_by_name:
|
|
281
301
|
break
|
|
282
|
-
|
|
302
|
+
parent_symbol = parent_symbol.parent
|
|
283
303
|
|
|
284
304
|
if Symbol.debug_lookup:
|
|
285
|
-
Symbol.debug_print(
|
|
286
|
-
logger.debug(
|
|
305
|
+
Symbol.debug_print('starting point:')
|
|
306
|
+
logger.debug(
|
|
307
|
+
parent_symbol.to_string(Symbol.debug_indent + 1, addEndNewline=False)
|
|
308
|
+
)
|
|
287
309
|
|
|
288
310
|
# and now the actual lookup
|
|
289
311
|
for ident in names[:-1]:
|
|
290
312
|
name = ident.name
|
|
291
|
-
if name in
|
|
292
|
-
symbol =
|
|
313
|
+
if name in parent_symbol._children_by_name:
|
|
314
|
+
symbol = parent_symbol._children_by_name[name]
|
|
293
315
|
else:
|
|
294
|
-
symbol =
|
|
316
|
+
symbol = on_missing_qualified_symbol(parent_symbol, ident)
|
|
295
317
|
if symbol is None:
|
|
296
318
|
if Symbol.debug_lookup:
|
|
297
319
|
Symbol.debug_indent -= 2
|
|
298
320
|
return None
|
|
299
|
-
|
|
321
|
+
parent_symbol = symbol
|
|
300
322
|
|
|
301
323
|
if Symbol.debug_lookup:
|
|
302
|
-
Symbol.debug_print(
|
|
303
|
-
logger.debug(
|
|
324
|
+
Symbol.debug_print('handle last name from:')
|
|
325
|
+
logger.debug(
|
|
326
|
+
parent_symbol.to_string(Symbol.debug_indent + 1, addEndNewline=False)
|
|
327
|
+
)
|
|
304
328
|
|
|
305
329
|
# handle the last name
|
|
306
330
|
ident = names[-1]
|
|
307
331
|
name = ident.name
|
|
308
|
-
symbol =
|
|
309
|
-
if not symbol and
|
|
310
|
-
for child in
|
|
332
|
+
symbol = parent_symbol._children_by_name.get(name)
|
|
333
|
+
if not symbol and recurse_in_anon:
|
|
334
|
+
for child in parent_symbol._anon_children:
|
|
311
335
|
if name in child._children_by_name:
|
|
312
336
|
symbol = child._children_by_name[name]
|
|
313
337
|
break
|
|
@@ -316,11 +340,11 @@ class Symbol:
|
|
|
316
340
|
Symbol.debug_indent -= 2
|
|
317
341
|
|
|
318
342
|
result = [symbol] if symbol else []
|
|
319
|
-
return SymbolLookupResult(result,
|
|
343
|
+
return SymbolLookupResult(result, parent_symbol, ident)
|
|
320
344
|
|
|
321
345
|
def _add_symbols(
|
|
322
346
|
self,
|
|
323
|
-
|
|
347
|
+
nested_name: ASTNestedName,
|
|
324
348
|
declaration: ASTDeclaration | None,
|
|
325
349
|
docname: str | None,
|
|
326
350
|
line: int | None,
|
|
@@ -331,152 +355,172 @@ class Symbol:
|
|
|
331
355
|
|
|
332
356
|
if Symbol.debug_lookup:
|
|
333
357
|
Symbol.debug_indent += 1
|
|
334
|
-
Symbol.debug_print(
|
|
358
|
+
Symbol.debug_print('_add_symbols:')
|
|
335
359
|
Symbol.debug_indent += 1
|
|
336
|
-
Symbol.debug_print(
|
|
337
|
-
Symbol.debug_print(
|
|
338
|
-
Symbol.debug_print(f
|
|
360
|
+
Symbol.debug_print('nn: ', nested_name)
|
|
361
|
+
Symbol.debug_print('decl: ', declaration)
|
|
362
|
+
Symbol.debug_print(f'location: {docname}:{line}')
|
|
339
363
|
|
|
340
|
-
def
|
|
364
|
+
def on_missing_qualified_symbol(
|
|
365
|
+
parent_symbol: Symbol, ident: ASTIdentifier
|
|
366
|
+
) -> Symbol:
|
|
341
367
|
if Symbol.debug_lookup:
|
|
342
368
|
Symbol.debug_indent += 1
|
|
343
|
-
Symbol.debug_print(
|
|
369
|
+
Symbol.debug_print('_add_symbols, on_missing_qualified_symbol:')
|
|
344
370
|
Symbol.debug_indent += 1
|
|
345
|
-
Symbol.debug_print(
|
|
371
|
+
Symbol.debug_print('ident: ', ident)
|
|
346
372
|
Symbol.debug_indent -= 2
|
|
347
|
-
return Symbol(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
373
|
+
return Symbol(
|
|
374
|
+
parent=parent_symbol,
|
|
375
|
+
ident=ident,
|
|
376
|
+
declaration=None,
|
|
377
|
+
docname=None,
|
|
378
|
+
line=None,
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
lookup_result = self._symbol_lookup(
|
|
382
|
+
nested_name,
|
|
383
|
+
on_missing_qualified_symbol,
|
|
384
|
+
ancestor_lookup_type=None,
|
|
385
|
+
match_self=False,
|
|
386
|
+
recurse_in_anon=False,
|
|
387
|
+
search_in_siblings=False,
|
|
388
|
+
)
|
|
389
|
+
# we create symbols all the way, so that can't happen
|
|
390
|
+
assert lookup_result is not None
|
|
391
|
+
symbols = list(lookup_result.symbols)
|
|
358
392
|
if len(symbols) == 0:
|
|
359
393
|
if Symbol.debug_lookup:
|
|
360
|
-
Symbol.debug_print(
|
|
394
|
+
Symbol.debug_print('_add_symbols, result, no symbol:')
|
|
361
395
|
Symbol.debug_indent += 1
|
|
362
|
-
Symbol.debug_print(
|
|
363
|
-
Symbol.debug_print(
|
|
364
|
-
Symbol.debug_print(f
|
|
396
|
+
Symbol.debug_print('ident: ', lookup_result.ident)
|
|
397
|
+
Symbol.debug_print('declaration: ', declaration)
|
|
398
|
+
Symbol.debug_print(f'location: {docname}:{line}')
|
|
365
399
|
Symbol.debug_indent -= 1
|
|
366
|
-
symbol = Symbol(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
400
|
+
symbol = Symbol(
|
|
401
|
+
parent=lookup_result.parent_symbol,
|
|
402
|
+
ident=lookup_result.ident,
|
|
403
|
+
declaration=declaration,
|
|
404
|
+
docname=docname,
|
|
405
|
+
line=line,
|
|
406
|
+
)
|
|
370
407
|
if Symbol.debug_lookup:
|
|
371
408
|
Symbol.debug_indent -= 2
|
|
372
409
|
return symbol
|
|
373
410
|
|
|
374
411
|
if Symbol.debug_lookup:
|
|
375
|
-
Symbol.debug_print(
|
|
412
|
+
Symbol.debug_print('_add_symbols, result, symbols:')
|
|
376
413
|
Symbol.debug_indent += 1
|
|
377
|
-
Symbol.debug_print(
|
|
414
|
+
Symbol.debug_print('number symbols:', len(symbols))
|
|
378
415
|
Symbol.debug_indent -= 1
|
|
379
416
|
|
|
380
417
|
if not declaration:
|
|
381
418
|
if Symbol.debug_lookup:
|
|
382
|
-
Symbol.debug_print(
|
|
419
|
+
Symbol.debug_print('no declaration')
|
|
383
420
|
Symbol.debug_indent -= 2
|
|
384
421
|
# good, just a scope creation
|
|
385
422
|
# TODO: what if we have more than one symbol?
|
|
386
423
|
return symbols[0]
|
|
387
424
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
425
|
+
no_decl = []
|
|
426
|
+
with_decl = []
|
|
427
|
+
dup_decl = []
|
|
391
428
|
for s in symbols:
|
|
392
429
|
if s.declaration is None:
|
|
393
|
-
|
|
430
|
+
no_decl.append(s)
|
|
394
431
|
elif s.isRedeclaration:
|
|
395
|
-
|
|
432
|
+
dup_decl.append(s)
|
|
396
433
|
else:
|
|
397
|
-
|
|
434
|
+
with_decl.append(s)
|
|
398
435
|
if Symbol.debug_lookup:
|
|
399
|
-
Symbol.debug_print(
|
|
400
|
-
Symbol.debug_print(
|
|
401
|
-
Symbol.debug_print(
|
|
436
|
+
Symbol.debug_print('#no_decl: ', len(no_decl))
|
|
437
|
+
Symbol.debug_print('#with_decl:', len(with_decl))
|
|
438
|
+
Symbol.debug_print('#dup_decl: ', len(dup_decl))
|
|
402
439
|
|
|
403
440
|
# With partial builds we may start with a large symbol tree stripped of declarations.
|
|
404
|
-
# Essentially any combination of
|
|
441
|
+
# Essentially any combination of no_decl, with_decl, and dup_decls seems possible.
|
|
405
442
|
# TODO: make partial builds fully work. What should happen when the primary symbol gets
|
|
406
443
|
# deleted, and other duplicates exist? The full document should probably be rebuild.
|
|
407
444
|
|
|
408
445
|
# First check if one of those with a declaration matches.
|
|
409
446
|
# If it's a function, we need to compare IDs,
|
|
410
447
|
# otherwise there should be only one symbol with a declaration.
|
|
411
|
-
def
|
|
448
|
+
def make_cand_symbol() -> Symbol:
|
|
412
449
|
if Symbol.debug_lookup:
|
|
413
|
-
Symbol.debug_print(
|
|
414
|
-
symbol = Symbol(
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
450
|
+
Symbol.debug_print('begin: creating candidate symbol')
|
|
451
|
+
symbol = Symbol(
|
|
452
|
+
parent=lookup_result.parent_symbol,
|
|
453
|
+
ident=lookup_result.ident,
|
|
454
|
+
declaration=declaration,
|
|
455
|
+
docname=docname,
|
|
456
|
+
line=line,
|
|
457
|
+
)
|
|
418
458
|
if Symbol.debug_lookup:
|
|
419
|
-
Symbol.debug_print(
|
|
459
|
+
Symbol.debug_print('end: creating candidate symbol')
|
|
420
460
|
return symbol
|
|
421
461
|
|
|
422
|
-
if len(
|
|
423
|
-
|
|
462
|
+
if len(with_decl) == 0:
|
|
463
|
+
cand_symbol = None
|
|
424
464
|
else:
|
|
425
|
-
|
|
465
|
+
cand_symbol = make_cand_symbol()
|
|
426
466
|
|
|
427
|
-
def
|
|
467
|
+
def handle_duplicate_declaration(
|
|
468
|
+
symbol: Symbol, cand_symbol: Symbol
|
|
469
|
+
) -> None:
|
|
428
470
|
if Symbol.debug_lookup:
|
|
429
471
|
Symbol.debug_indent += 1
|
|
430
|
-
Symbol.debug_print(
|
|
472
|
+
Symbol.debug_print('redeclaration')
|
|
431
473
|
Symbol.debug_indent -= 1
|
|
432
474
|
Symbol.debug_indent -= 2
|
|
433
475
|
# Redeclaration of the same symbol.
|
|
434
476
|
# Let the new one be there, but raise an error to the client
|
|
435
477
|
# so it can use the real symbol as subscope.
|
|
436
478
|
# This will probably result in a duplicate id warning.
|
|
437
|
-
|
|
479
|
+
cand_symbol.isRedeclaration = True
|
|
438
480
|
raise _DuplicateSymbolError(symbol, declaration)
|
|
439
481
|
|
|
440
|
-
if declaration.objectType !=
|
|
441
|
-
assert len(
|
|
442
|
-
|
|
482
|
+
if declaration.objectType != 'function':
|
|
483
|
+
assert len(with_decl) <= 1
|
|
484
|
+
handle_duplicate_declaration(with_decl[0], cand_symbol)
|
|
443
485
|
# (not reachable)
|
|
444
486
|
|
|
445
487
|
# a function, so compare IDs
|
|
446
|
-
|
|
488
|
+
cand_id = declaration.get_newest_id()
|
|
447
489
|
if Symbol.debug_lookup:
|
|
448
|
-
Symbol.debug_print(
|
|
449
|
-
for symbol in
|
|
450
|
-
|
|
490
|
+
Symbol.debug_print('cand_id:', cand_id)
|
|
491
|
+
for symbol in with_decl:
|
|
492
|
+
old_id = symbol.declaration.get_newest_id()
|
|
451
493
|
if Symbol.debug_lookup:
|
|
452
|
-
Symbol.debug_print(
|
|
453
|
-
if
|
|
454
|
-
|
|
494
|
+
Symbol.debug_print('old_id: ', old_id)
|
|
495
|
+
if cand_id == old_id:
|
|
496
|
+
handle_duplicate_declaration(symbol, cand_symbol)
|
|
455
497
|
# (not reachable)
|
|
456
498
|
# no candidate symbol found with matching ID
|
|
457
499
|
# if there is an empty symbol, fill that one
|
|
458
|
-
if len(
|
|
500
|
+
if len(no_decl) == 0:
|
|
459
501
|
if Symbol.debug_lookup:
|
|
460
502
|
Symbol.debug_print(
|
|
461
|
-
|
|
503
|
+
'no match, no empty, cand_sybmol is not None?:',
|
|
504
|
+
cand_symbol is not None,
|
|
462
505
|
)
|
|
463
506
|
Symbol.debug_indent -= 2
|
|
464
|
-
if
|
|
465
|
-
return
|
|
507
|
+
if cand_symbol is not None:
|
|
508
|
+
return cand_symbol
|
|
466
509
|
else:
|
|
467
|
-
return
|
|
510
|
+
return make_cand_symbol()
|
|
468
511
|
else:
|
|
469
512
|
if Symbol.debug_lookup:
|
|
470
513
|
Symbol.debug_print(
|
|
471
|
-
|
|
472
|
-
|
|
514
|
+
'no match, but fill an empty declaration, cand_sybmol is not None?:',
|
|
515
|
+
cand_symbol is not None,
|
|
516
|
+
)
|
|
473
517
|
Symbol.debug_indent -= 2
|
|
474
|
-
if
|
|
475
|
-
|
|
476
|
-
# assert len(
|
|
518
|
+
if cand_symbol is not None:
|
|
519
|
+
cand_symbol.remove()
|
|
520
|
+
# assert len(no_decl) == 1
|
|
477
521
|
# TODO: enable assertion when we at some point find out how to do cleanup
|
|
478
522
|
# for now, just take the first one, it should work fine ... right?
|
|
479
|
-
symbol =
|
|
523
|
+
symbol = no_decl[0]
|
|
480
524
|
# If someone first opened the scope, and then later
|
|
481
525
|
# declares it, e.g,
|
|
482
526
|
# .. namespace:: Test
|
|
@@ -485,39 +529,50 @@ class Symbol:
|
|
|
485
529
|
symbol._fill_empty(declaration, docname, line)
|
|
486
530
|
return symbol
|
|
487
531
|
|
|
488
|
-
def merge_with(
|
|
489
|
-
|
|
532
|
+
def merge_with(
|
|
533
|
+
self, other: Symbol, docnames: list[str], env: BuildEnvironment
|
|
534
|
+
) -> None:
|
|
490
535
|
if Symbol.debug_lookup:
|
|
491
536
|
Symbol.debug_indent += 1
|
|
492
|
-
Symbol.debug_print(
|
|
537
|
+
Symbol.debug_print('merge_with:')
|
|
493
538
|
|
|
494
539
|
assert other is not None
|
|
495
|
-
for
|
|
496
|
-
|
|
497
|
-
if
|
|
540
|
+
for other_child in other._children:
|
|
541
|
+
other_name = other_child.ident.name
|
|
542
|
+
if other_name not in self._children_by_name:
|
|
498
543
|
# TODO: hmm, should we prune by docnames?
|
|
499
|
-
|
|
500
|
-
self._add_child(
|
|
501
|
-
|
|
544
|
+
other_child.parent = self
|
|
545
|
+
self._add_child(other_child)
|
|
546
|
+
other_child._assert_invariants()
|
|
502
547
|
continue
|
|
503
|
-
|
|
504
|
-
if
|
|
505
|
-
if not
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
548
|
+
our_child = self._children_by_name[other_name]
|
|
549
|
+
if other_child.declaration and other_child.docname in docnames:
|
|
550
|
+
if not our_child.declaration:
|
|
551
|
+
our_child._fill_empty(
|
|
552
|
+
other_child.declaration, other_child.docname, other_child.line
|
|
553
|
+
)
|
|
554
|
+
elif our_child.docname != other_child.docname:
|
|
555
|
+
name = str(our_child.declaration)
|
|
556
|
+
msg = __(
|
|
557
|
+
'Duplicate C declaration, also defined at %s:%s.\n'
|
|
558
|
+
"Declaration is '.. c:%s:: %s'."
|
|
559
|
+
)
|
|
560
|
+
logger.warning(
|
|
561
|
+
msg,
|
|
562
|
+
our_child.docname,
|
|
563
|
+
our_child.line,
|
|
564
|
+
our_child.declaration.directiveType,
|
|
565
|
+
name,
|
|
566
|
+
location=(other_child.docname, other_child.line),
|
|
567
|
+
type='duplicate_declaration',
|
|
568
|
+
subtype='c',
|
|
569
|
+
)
|
|
515
570
|
else:
|
|
516
571
|
# Both have declarations, and in the same docname.
|
|
517
572
|
# This can apparently happen, it should be safe to
|
|
518
573
|
# just ignore it, right?
|
|
519
574
|
pass
|
|
520
|
-
|
|
575
|
+
our_child.merge_with(other_child, docnames, env)
|
|
521
576
|
|
|
522
577
|
if Symbol.debug_lookup:
|
|
523
578
|
Symbol.debug_indent -= 1
|
|
@@ -525,45 +580,52 @@ class Symbol:
|
|
|
525
580
|
def add_name(self, nestedName: ASTNestedName) -> Symbol:
|
|
526
581
|
if Symbol.debug_lookup:
|
|
527
582
|
Symbol.debug_indent += 1
|
|
528
|
-
Symbol.debug_print(
|
|
583
|
+
Symbol.debug_print('add_name:')
|
|
529
584
|
res = self._add_symbols(nestedName, declaration=None, docname=None, line=None)
|
|
530
585
|
if Symbol.debug_lookup:
|
|
531
586
|
Symbol.debug_indent -= 1
|
|
532
587
|
return res
|
|
533
588
|
|
|
534
|
-
def add_declaration(
|
|
535
|
-
|
|
589
|
+
def add_declaration(
|
|
590
|
+
self, declaration: ASTDeclaration, docname: str, line: int
|
|
591
|
+
) -> Symbol:
|
|
536
592
|
if Symbol.debug_lookup:
|
|
537
593
|
Symbol.debug_indent += 1
|
|
538
|
-
Symbol.debug_print(
|
|
594
|
+
Symbol.debug_print('add_declaration:')
|
|
539
595
|
assert declaration is not None
|
|
540
596
|
assert docname is not None
|
|
541
597
|
assert line is not None
|
|
542
|
-
|
|
543
|
-
res = self._add_symbols(
|
|
598
|
+
nested_name = declaration.name
|
|
599
|
+
res = self._add_symbols(nested_name, declaration, docname, line)
|
|
544
600
|
if Symbol.debug_lookup:
|
|
545
601
|
Symbol.debug_indent -= 1
|
|
546
602
|
return res
|
|
547
603
|
|
|
548
|
-
def find_identifier(
|
|
549
|
-
|
|
550
|
-
|
|
604
|
+
def find_identifier(
|
|
605
|
+
self,
|
|
606
|
+
ident: ASTIdentifier,
|
|
607
|
+
matchSelf: bool,
|
|
608
|
+
recurseInAnon: bool,
|
|
609
|
+
searchInSiblings: bool,
|
|
610
|
+
) -> Symbol | None:
|
|
551
611
|
if Symbol.debug_lookup:
|
|
552
612
|
Symbol.debug_indent += 1
|
|
553
|
-
Symbol.debug_print(
|
|
613
|
+
Symbol.debug_print('find_identifier:')
|
|
554
614
|
Symbol.debug_indent += 1
|
|
555
|
-
Symbol.debug_print(
|
|
556
|
-
Symbol.debug_print(
|
|
557
|
-
Symbol.debug_print(
|
|
558
|
-
Symbol.debug_print(
|
|
615
|
+
Symbol.debug_print('ident: ', ident)
|
|
616
|
+
Symbol.debug_print('matchSelf: ', matchSelf)
|
|
617
|
+
Symbol.debug_print('recurseInAnon: ', recurseInAnon)
|
|
618
|
+
Symbol.debug_print('searchInSiblings:', searchInSiblings)
|
|
559
619
|
logger.debug(self.to_string(Symbol.debug_indent + 1, addEndNewline=False))
|
|
560
620
|
Symbol.debug_indent -= 2
|
|
561
621
|
current = self
|
|
562
622
|
while current is not None:
|
|
563
623
|
if Symbol.debug_lookup:
|
|
564
624
|
Symbol.debug_indent += 2
|
|
565
|
-
Symbol.debug_print(
|
|
566
|
-
logger.debug(
|
|
625
|
+
Symbol.debug_print('trying:')
|
|
626
|
+
logger.debug(
|
|
627
|
+
current.to_string(Symbol.debug_indent + 1, addEndNewline=False)
|
|
628
|
+
)
|
|
567
629
|
Symbol.debug_indent -= 2
|
|
568
630
|
if matchSelf and current.ident == ident:
|
|
569
631
|
return current
|
|
@@ -582,49 +644,53 @@ class Symbol:
|
|
|
582
644
|
def direct_lookup(self, key: LookupKey) -> Symbol | None:
|
|
583
645
|
if Symbol.debug_lookup:
|
|
584
646
|
Symbol.debug_indent += 1
|
|
585
|
-
Symbol.debug_print(
|
|
647
|
+
Symbol.debug_print('direct_lookup:')
|
|
586
648
|
Symbol.debug_indent += 1
|
|
587
649
|
s = self
|
|
588
650
|
for ident, id_ in key.data:
|
|
589
651
|
s = s._children_by_name.get(ident.name)
|
|
590
652
|
if Symbol.debug_lookup:
|
|
591
|
-
Symbol.debug_print(
|
|
592
|
-
Symbol.debug_print(
|
|
653
|
+
Symbol.debug_print('name: ', ident.name)
|
|
654
|
+
Symbol.debug_print('id: ', id_)
|
|
593
655
|
if s is not None:
|
|
594
|
-
logger.debug(
|
|
656
|
+
logger.debug(
|
|
657
|
+
s.to_string(Symbol.debug_indent + 1, addEndNewline=False)
|
|
658
|
+
)
|
|
595
659
|
else:
|
|
596
|
-
Symbol.debug_print(
|
|
660
|
+
Symbol.debug_print('not found')
|
|
597
661
|
if s is None:
|
|
598
662
|
break
|
|
599
663
|
if Symbol.debug_lookup:
|
|
600
664
|
Symbol.debug_indent -= 2
|
|
601
665
|
return s
|
|
602
666
|
|
|
603
|
-
def find_declaration(
|
|
604
|
-
|
|
667
|
+
def find_declaration(
|
|
668
|
+
self, nestedName: ASTNestedName, typ: str, matchSelf: bool, recurseInAnon: bool
|
|
669
|
+
) -> Symbol | None:
|
|
605
670
|
# templateShorthand: missing template parameter lists for templates is ok
|
|
606
671
|
if Symbol.debug_lookup:
|
|
607
672
|
Symbol.debug_indent += 1
|
|
608
|
-
Symbol.debug_print(
|
|
673
|
+
Symbol.debug_print('find_declaration:')
|
|
609
674
|
|
|
610
|
-
def
|
|
611
|
-
|
|
612
|
-
ident: ASTIdentifier,
|
|
675
|
+
def on_missing_qualified_symbol(
|
|
676
|
+
parent_symbol: Symbol, ident: ASTIdentifier
|
|
613
677
|
) -> Symbol | None:
|
|
614
678
|
return None
|
|
615
679
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
680
|
+
lookup_result = self._symbol_lookup(
|
|
681
|
+
nestedName,
|
|
682
|
+
on_missing_qualified_symbol,
|
|
683
|
+
ancestor_lookup_type=typ,
|
|
684
|
+
match_self=matchSelf,
|
|
685
|
+
recurse_in_anon=recurseInAnon,
|
|
686
|
+
search_in_siblings=False,
|
|
687
|
+
)
|
|
622
688
|
if Symbol.debug_lookup:
|
|
623
689
|
Symbol.debug_indent -= 1
|
|
624
|
-
if
|
|
690
|
+
if lookup_result is None:
|
|
625
691
|
return None
|
|
626
692
|
|
|
627
|
-
symbols = list(
|
|
693
|
+
symbols = list(lookup_result.symbols)
|
|
628
694
|
if len(symbols) == 0:
|
|
629
695
|
return None
|
|
630
696
|
return symbols[0]
|
|
@@ -639,17 +705,22 @@ class Symbol:
|
|
|
639
705
|
else:
|
|
640
706
|
res.append(str(self.declaration))
|
|
641
707
|
if self.declaration:
|
|
642
|
-
res.append(
|
|
708
|
+
res.append(': ')
|
|
643
709
|
if self.isRedeclaration:
|
|
644
710
|
res.append('!!duplicate!! ')
|
|
645
711
|
res.append(str(self.declaration))
|
|
646
712
|
if self.docname:
|
|
647
|
-
res.
|
|
648
|
-
|
|
649
|
-
|
|
713
|
+
res.extend((
|
|
714
|
+
'\t(',
|
|
715
|
+
self.docname,
|
|
716
|
+
')',
|
|
717
|
+
))
|
|
650
718
|
if addEndNewline:
|
|
651
719
|
res.append('\n')
|
|
652
720
|
return ''.join(res)
|
|
653
721
|
|
|
654
722
|
def dump(self, indent: int) -> str:
|
|
655
|
-
return ''.join([
|
|
723
|
+
return ''.join([
|
|
724
|
+
self.to_string(indent),
|
|
725
|
+
*(c.dump(indent + 1) for c in self._children),
|
|
726
|
+
])
|