@@ -24,30 +24,22 @@ Document indexPubspec({
2424}) {
2525 final pubspecLineInfo = LineInfo .fromContent (pubspecStr);
2626
27- final fileSymbol = [
28- 'scip-dart' ,
29- 'pub' ,
30- pubspec.name,
31- pubspec.version! ,
32- '`pubspec.yaml`/' ,
33- ].join (' ' );
27+ final symbols = < SymbolInformation > [];
28+ final occurrences = < Occurrence > [];
3429
35- final symbols = < SymbolInformation > [
36- SymbolInformation (
37- symbol: fileSymbol,
38- kind: SymbolInformation_Kind
39- .UnspecifiedKind , // TODO: Add SymbolInformation_Kind.Dependency
40- signatureDocumentation: Document (
41- language: Language .YAML .name,
42- text: ['name: ${pubspec .name }' , 'version: ${pubspec .version }' ]
43- .join ('\n ' )))
44- ];
45- final occurrences = < Occurrence > [
46- Occurrence (
47- symbol: fileSymbol,
30+ // a 'none' publishTo implies that the pubspec.yaml file (and project) are not
31+ // actually published to a pub server, and only used for testing. We still want
32+ // to index the dependencies in this case, but avoid creating the file symbol
33+ // to reduce duplicate packages names
34+ if (pubspec.publishTo != 'none' ) {
35+ final info = _buildFileSymbol (pubspec);
36+ symbols.add (info);
37+ occurrences.add (Occurrence (
38+ symbol: info.symbol,
39+ symbolRoles: SymbolRole .Definition .value,
4840 range: [0 , 0 , 0 ],
49- )
50- ];
41+ ));
42+ }
5143
5244 final deps = {
5345 DependencyKind .regular: pubspec.dependencies,
@@ -73,30 +65,57 @@ Document indexPubspec({
7365 );
7466}
7567
68+ SymbolInformation _buildFileSymbol (Pubspec pubspec) {
69+ final symbol = [
70+ 'scip-dart' ,
71+ 'pub' ,
72+ pubspec.name,
73+ pubspec.version ?? '*' ,
74+ '`pubspec.yaml`/' ,
75+ ].join (' ' );
76+
77+ return SymbolInformation (
78+ symbol: symbol,
79+ kind: SymbolInformation_Kind
80+ .UnspecifiedKind , // TODO: Add SymbolInformation_Kind.Dependency
81+ signatureDocumentation: Document (
82+ language: Language .YAML .name,
83+ text: [
84+ 'name: ${pubspec .name }' ,
85+ 'version: ${pubspec .version }' ,
86+ ].join ('\n ' ),
87+ ),
88+ );
89+ }
90+
7691SymbolInformation _buildSymbol (String depName, PubspecLock lock) {
7792 final depVersion = lock.packages[depName]? .version.toString ();
7893 if (depVersion == null ) {
7994 throw Exception (
8095 'Unable to find ${depName } in pubspec.lock. Have you ran pub get?' );
8196 }
8297
98+ final symbol = [
99+ 'scip-dart' ,
100+ 'pub' ,
101+ depName,
102+ depVersion,
103+ '`pubspec.yaml`/' ,
104+ ].join (' ' );
105+
83106 return SymbolInformation (
84- displayName: depName,
85- symbol: [
86- 'scip-dart' ,
87- 'pub' ,
88- depName,
89- depVersion,
90- '`pubspec.yaml`/' ,
91- ].join (' ' ),
92- kind: SymbolInformation_Kind
93- .UnspecifiedKind , // TODO: Add SymbolInformation_Kind.Dependency and SymbolInformation_Kind.DevDependency
94- signatureDocumentation: Document (
95- language: Language .YAML .name,
96- text: [
97- 'name: $depName ' ,
98- 'version: $depVersion ' ,
99- ].join ('\n ' )));
107+ displayName: depName,
108+ symbol: symbol,
109+ kind: SymbolInformation_Kind
110+ .UnspecifiedKind , // TODO: Add SymbolInformation_Kind.Dependency and SymbolInformation_Kind.DevDependency
111+ signatureDocumentation: Document (
112+ language: Language .YAML .name,
113+ text: [
114+ 'name: $depName ' ,
115+ 'version: $depVersion ' ,
116+ ].join ('\n ' ),
117+ ),
118+ );
100119}
101120
102121enum DependencyKind {
0 commit comments