Skip to content

Commit 8fe455d

Browse files
authored
small tweak to the qualified reference resolution code (#1309)
* small tweak to the qualified reference resolution code * typo
1 parent 08da7d6 commit 8fe455d

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

lib/src/markdown_processor.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,12 @@ MatchingLinkResult _findRefElementInLibrary(String codeRef, ModelElement element
123123
}
124124
}
125125

126-
for (final modelElement in library.allModelElements) {
127-
if (codeRef == modelElement.fullyQualifiedNameWithoutLibrary) {
128-
result[modelElement.fullyQualifiedName] = modelElement;
126+
// Only look for partially qualified matches if we didn't find a fully qualified one.
127+
if (result.isEmpty) {
128+
for (final modelElement in library.allModelElements) {
129+
if (codeRef == modelElement.fullyQualifiedNameWithoutLibrary) {
130+
result[modelElement.fullyQualifiedName] = modelElement;
131+
}
129132
}
130133
}
131134

lib/src/model.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,8 +1235,8 @@ class Library extends ModelElement {
12351235
List<ModelElement> _allModelElements;
12361236
List<ModelElement> get allModelElements {
12371237
if (_allModelElements == null) {
1238-
final List<ModelElement> result = [];
1239-
result
1238+
final List<ModelElement> results = [];
1239+
results
12401240
..addAll(library.allClasses)
12411241
..addAll(library.constants)
12421242
..addAll(library.enums)
@@ -1245,14 +1245,16 @@ class Library extends ModelElement {
12451245
..addAll(library.typedefs);
12461246

12471247
library.allClasses.forEach((c) {
1248-
result.addAll(c.allInstanceMethods);
1249-
result.addAll(c.allInstanceProperties);
1250-
result.addAll(c.allOperators);
1251-
result.addAll(c.staticMethods);
1252-
result.addAll(c.staticProperties);
1248+
results.addAll(c.allInstanceMethods);
1249+
results.addAll(c.allInstanceProperties);
1250+
results.addAll(c.allOperators);
1251+
results.addAll(c.staticMethods);
1252+
results.addAll(c.staticProperties);
12531253
});
1254-
_allModelElements = result;
1254+
1255+
_allModelElements = results;
12551256
}
1257+
12561258
return _allModelElements;
12571259
}
12581260
}
@@ -1815,7 +1817,7 @@ abstract class ModelElement implements Comparable, Nameable, Documentable {
18151817
RegExp exampleRE = new RegExp(r'{@example\s+([^}]+)}');
18161818
return rawdocs.replaceAllMapped(exampleRE, (match) {
18171819
var args = _getExampleArgs(match[1]);
1818-
var lang = args['lang'] ?? p.extension(args['src']).replaceFirst('.','');
1820+
var lang = args['lang'] ?? p.extension(args['src']).replaceFirst('.', '');
18191821

18201822
var replacement = match[0]; // default to fully matched string.
18211823

0 commit comments

Comments
 (0)