Skip to content

Commit e2e049f

Browse files
Some Modules Intellisense Fixes (#4249)
* update some modules docs * update module logic, likely should update for capitilization * update method stub
1 parent 9bc94e8 commit e2e049f

2 files changed

Lines changed: 107 additions & 35 deletions

File tree

assets/modules.json

Lines changed: 89 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
},
170170
"CMakeFindDependencyMacro": {
171171
"name": "CMakeFindDependencyMacro",
172-
"description": "TODO: Document me."
172+
"description": "The ``find_dependency()`` macro wraps a :command:`find_package` call for a package dependency."
173173
},
174174
"CMakeFindFrameworks": {
175175
"name": "CMakeFindFrameworks",
@@ -309,15 +309,15 @@
309309
},
310310
"ExternalProject": {
311311
"name": "ExternalProject",
312-
"description": "TODO: Document me."
312+
"description": "The ExternalProject_Add() function creates a custom target to drive download, update/patch, configure, build, install and test steps of an external project"
313313
},
314314
"FeatureSummary": {
315315
"name": "FeatureSummary",
316316
"description": "Functions for generating a summary of enabled/disabled features."
317317
},
318318
"FetchContent": {
319319
"name": "FetchContent",
320-
"description": "TODO: Document me."
320+
"description": "This module enables populating content at configure time via any method supported by the ExternalProject module. Whereas ExternalProject_Add() downloads at build time, the FetchContent module makes content available immediately, allowing the configure step to use the content in commands like add_subdirectory(), include() or file() operations."
321321
},
322322
"FindALSA": {
323323
"name": "FindALSA",
@@ -327,7 +327,10 @@
327327
"name": "FindArmadillo",
328328
"description": "Find the Armadillo C++ library. Armadillo is a library for linear algebra & scientific computing."
329329
},
330-
"FindASPELL": { "name": "FindASPELL", "description": "Try to find ASPELL" },
330+
"FindASPELL": {
331+
"name": "FindASPELL",
332+
"description": "Try to find ASPELL"
333+
},
331334
"FindAVIFile": {
332335
"name": "FindAVIFile",
333336
"description": "Locate AVIFILE library and include paths"
@@ -352,8 +355,14 @@
352355
"name": "FindBullet",
353356
"description": "Try to find the Bullet physics engine"
354357
},
355-
"FindBZip2": { "name": "FindBZip2", "description": "Try to find BZip2" },
356-
"FindCABLE": { "name": "FindCABLE", "description": "Find CABLE" },
358+
"FindBZip2": {
359+
"name": "FindBZip2",
360+
"description": "Try to find BZip2"
361+
},
362+
"FindCABLE": {
363+
"name": "FindCABLE",
364+
"description": "Find CABLE"
365+
},
357366
"FindCoin3D": {
358367
"name": "FindCoin3D",
359368
"description": "Find Coin3D (Open Inventor)"
@@ -390,7 +399,10 @@
390399
"name": "FindCygwin",
391400
"description": "Find Cygwin, a POSIX-compatible environment that runs natively on Microsoft Windows"
392401
},
393-
"FindDart": { "name": "FindDart", "description": "Find DART" },
402+
"FindDart": {
403+
"name": "FindDart",
404+
"description": "Find DART"
405+
},
394406
"FindDCMTK": {
395407
"name": "FindDCMTK",
396408
"description": "Find DICOM ToolKit (DCMTK) libraries and applications"
@@ -507,7 +519,10 @@
507519
"name": "FindIconv",
508520
"description": "This module finds the iconv() POSIX.1 functions on the system. These functions might be provided in the regular C library or externally in the form of an additional library."
509521
},
510-
"FindIcotool": { "name": "FindIcotool", "description": "Find icotool" },
522+
"FindIcotool": {
523+
"name": "FindIcotool",
524+
"description": "Find icotool"
525+
},
511526
"FindICU": {
512527
"name": "FindICU",
513528
"description": "Find the International Components for Unicode (ICU) libraries and programs."
@@ -528,7 +543,10 @@
528543
"name": "FindJasper",
529544
"description": "Find the Jasper JPEG2000 library."
530545
},
531-
"FindJava": { "name": "FindJava", "description": "Find Java" },
546+
"FindJava": {
547+
"name": "FindJava",
548+
"description": "Find Java"
549+
},
532550
"FindJNI": {
533551
"name": "FindJNI",
534552
"description": "Find Java Native Interface (JNI) headers and libraries."
@@ -549,7 +567,10 @@
549567
"name": "FindLAPACK",
550568
"description": "Find Linear Algebra PACKage (LAPACK) library"
551569
},
552-
"FindLATEX": { "name": "FindLATEX", "description": "Find LaTeX" },
570+
"FindLATEX": {
571+
"name": "FindLATEX",
572+
"description": "Find LaTeX"
573+
},
553574
"FindLibArchive": {
554575
"name": "FindLibArchive",
555576
"description": "Find libarchive library and headers. Libarchive is multi-format archive and compression library."
@@ -574,8 +595,14 @@
574595
"name": "FindLTTngUST",
575596
"description": "Find Linux Trace Toolkit Next Generation (LTTng-UST) library."
576597
},
577-
"FindLua": { "name": "FindLua", "description": "Locate Lua library." },
578-
"FindLua50": { "name": "FindLua50", "description": "Locate Lua library." },
598+
"FindLua": {
599+
"name": "FindLua",
600+
"description": "Locate Lua library."
601+
},
602+
"FindLua50": {
603+
"name": "FindLua50",
604+
"description": "Locate Lua library."
605+
},
579606
"FindLua51": {
580607
"name": "FindLua51",
581608
"description": "Locate Lua library. This module defines:"
@@ -748,12 +775,18 @@
748775
"name": "FindPerlLibs",
749776
"description": "Find Perl libraries"
750777
},
751-
"FindPHP4": { "name": "FindPHP4", "description": "Find PHP4" },
778+
"FindPHP4": {
779+
"name": "FindPHP4",
780+
"description": "Find PHP4"
781+
},
752782
"FindPhysFS": {
753783
"name": "FindPhysFS",
754784
"description": "Locate PhysFS library This module defines:"
755785
},
756-
"FindPike": { "name": "FindPike", "description": "Find Pike" },
786+
"FindPike": {
787+
"name": "FindPike",
788+
"description": "Find Pike"
789+
},
757790
"FindPkgConfig": {
758791
"name": "FindPkgConfig",
759792
"description": "A pkg-config module for CMake."
@@ -802,7 +835,10 @@
802835
"name": "FindQt3",
803836
"description": "Locate Qt include paths and libraries"
804837
},
805-
"FindQt4": { "name": "FindQt4", "description": "TODO: Document me." },
838+
"FindQt4": {
839+
"name": "FindQt4",
840+
"description": "This module can be used to find Qt4. The most important issue is that the Qt4 qmake is available via the system path. This qmake is then used to detect basically everything else. This module defines a number of IMPORTED targets, macros and variables."
841+
},
806842
"FindQuickTime": {
807843
"name": "FindQuickTime",
808844
"description": "Locate QuickTime This module defines:"
@@ -811,8 +847,14 @@
811847
"name": "FindRTI",
812848
"description": "Try to find M&S HLA RTI libraries"
813849
},
814-
"FindRuby": { "name": "FindRuby", "description": "Find Ruby" },
815-
"FindSDL": { "name": "FindSDL", "description": "Locate the SDL library" },
850+
"FindRuby": {
851+
"name": "FindRuby",
852+
"description": "Find Ruby"
853+
},
854+
"FindSDL": {
855+
"name": "FindSDL",
856+
"description": "Locate the SDL library"
857+
},
816858
"FindSDL_gfx": {
817859
"name": "FindSDL_gfx",
818860
"description": "Locate SDL_gfx library"
@@ -837,12 +879,18 @@
837879
"name": "FindSDL_ttf",
838880
"description": "Locate SDL_ttf library"
839881
},
840-
"FindSelfPackers": { "name": "FindSelfPackers", "description": "Find upx" },
882+
"FindSelfPackers": {
883+
"name": "FindSelfPackers",
884+
"description": "Find upx"
885+
},
841886
"FindSQLite3": {
842887
"name": "FindSQLite3",
843888
"description": "Find the SQLite libraries, v3"
844889
},
845-
"FindSquish": { "name": "FindSquish", "description": "-- Typical Use" },
890+
"FindSquish": {
891+
"name": "FindSquish",
892+
"description": "-- Typical Use"
893+
},
846894
"FindSubversion": {
847895
"name": "FindSubversion",
848896
"description": "Extract information from a subversion working copy"
@@ -855,7 +903,10 @@
855903
"name": "FindTCL",
856904
"description": "TK_INTERNAL_PATH was removed."
857905
},
858-
"FindTclsh": { "name": "FindTclsh", "description": "Find tclsh" },
906+
"FindTclsh": {
907+
"name": "FindTclsh",
908+
"description": "Find tclsh"
909+
},
859910
"FindTclStub": {
860911
"name": "FindTclStub",
861912
"description": "TCL_STUB_LIBRARY_DEBUG and TK_STUB_LIBRARY_DEBUG were removed."
@@ -880,8 +931,14 @@
880931
"name": "FindVulkan",
881932
"description": "Find Vulkan, which is a low-overhead, cross-platform 3D graphics and computing API."
882933
},
883-
"FindWget": { "name": "FindWget", "description": "Find wget" },
884-
"FindWish": { "name": "FindWish", "description": "Find wish installation" },
934+
"FindWget": {
935+
"name": "FindWget",
936+
"description": "Find wget"
937+
},
938+
"FindWish": {
939+
"name": "FindWish",
940+
"description": "Find wish installation"
941+
},
885942
"FindwxWidgets": {
886943
"name": "FindwxWidgets",
887944
"description": "Find a wxWidgets (a.k.a., wxWindows) installation."
@@ -890,7 +947,10 @@
890947
"name": "FindwxWindows",
891948
"description": "Find wxWindows (wxWidgets) installation"
892949
},
893-
"FindX11": { "name": "FindX11", "description": "Find X11 installation" },
950+
"FindX11": {
951+
"name": "FindX11",
952+
"description": "Find X11 installation"
953+
},
894954
"FindXalanC": {
895955
"name": "FindXalanC",
896956
"description": "Find the Apache Xalan-C++ XSL transform processor headers and libraries."
@@ -903,7 +963,10 @@
903963
"name": "FindXercesC",
904964
"description": "Find the Apache Xerces-C++ validating XML parser headers and libraries."
905965
},
906-
"FindXMLRPC": { "name": "FindXMLRPC", "description": "Find xmlrpc" },
966+
"FindXMLRPC": {
967+
"name": "FindXMLRPC",
968+
"description": "Find xmlrpc"
969+
},
907970
"FindZLIB": {
908971
"name": "FindZLIB",
909972
"description": "Find the native ZLIB includes and library."
@@ -1006,10 +1069,10 @@
10061069
},
10071070
"WriteBasicConfigVersionFile": {
10081071
"name": "WriteBasicConfigVersionFile",
1009-
"description": "TODO: Document me."
1072+
"description": "Deprecated since version 3.0: Use the identical command write_basic_package_version_file() from module CMakePackageConfigHelpers."
10101073
},
10111074
"WriteCompilerDetectionHeader": {
10121075
"name": "WriteCompilerDetectionHeader",
10131076
"description": "This module provides the function write_compiler_detection_header()."
10141077
}
1015-
}
1078+
}

src/languageServices/languageServiceData.ts

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,16 @@ export class LanguageServiceData implements vscode.HoverProvider, vscode.Complet
5858
this.modules = JSON.parse(await this.getFile("modules.json", locale));
5959
}
6060

61-
private getCompletionSuggestionsHelper(currentWord: string, data: Commands | Modules | Variables, type: LanguageType): vscode.CompletionItem[] {
62-
function moduleInsertText(module: string): vscode.SnippetString {
61+
private getCompletionSuggestionsHelper(currentWord: string, data: Commands | Modules | Variables, type: LanguageType, beforeCurrentWord?: string): vscode.CompletionItem[] {
62+
function moduleInsertText(module: string, beforeCurrentWord?: string): vscode.SnippetString {
63+
if (beforeCurrentWord) {
64+
if (beforeCurrentWord.startsWith("include")) {
65+
return new vscode.SnippetString(module);
66+
} else if (beforeCurrentWord.startsWith("find_package")) {
67+
return new vscode.SnippetString(`${module.replace("Find", "")}\${1: REQUIRED}`);
68+
}
69+
}
70+
6371
if (module.indexOf("Find") === 0) {
6472
return new vscode.SnippetString(`find_package(${module.replace("Find", "")}\${1: REQUIRED})`);
6573
} else {
@@ -84,18 +92,18 @@ export class LanguageServiceData implements vscode.HoverProvider, vscode.Complet
8492
return Object.keys(data).map((key) => {
8593
if (data[key].name.includes(currentWord)) {
8694
const completionItem = new vscode.CompletionItem(data[key].name);
87-
completionItem.insertText = type === LanguageType.Command ? commandInsertText(data[key].name) : type === LanguageType.Variable ? variableInsertText(data[key].name) : moduleInsertText(data[key].name);
95+
completionItem.insertText = type === LanguageType.Command ? commandInsertText(data[key].name) : type === LanguageType.Variable ? variableInsertText(data[key].name) : moduleInsertText(data[key].name, beforeCurrentWord);
8896
completionItem.kind = type === LanguageType.Command ? vscode.CompletionItemKind.Function : type === LanguageType.Variable ? vscode.CompletionItemKind.Variable : vscode.CompletionItemKind.Module;
8997
return completionItem;
9098
}
9199
return null;
92100
}).filter((value) => value !== null) as vscode.CompletionItem[];
93101
}
94102

95-
private getCompletionSuggestions(currentWord: string): vscode.CompletionItem[] {
96-
return this.getCompletionSuggestionsHelper(currentWord, this.commands, LanguageType.Command)
97-
.concat(this.getCompletionSuggestionsHelper(currentWord, this.variables, LanguageType.Variable))
98-
.concat(this.getCompletionSuggestionsHelper(currentWord, this.modules, LanguageType.Module));
103+
private getCompletionSuggestions(currentWord: string, beforeCurrentWord?: string): vscode.CompletionItem[] {
104+
return this.getCompletionSuggestionsHelper(currentWord, this.commands, LanguageType.Command, beforeCurrentWord)
105+
.concat(this.getCompletionSuggestionsHelper(currentWord, this.variables, LanguageType.Variable, beforeCurrentWord))
106+
.concat(this.getCompletionSuggestionsHelper(currentWord, this.modules, LanguageType.Module, beforeCurrentWord));
99107
}
100108

101109
public static async create(): Promise<LanguageServiceData> {
@@ -106,6 +114,7 @@ export class LanguageServiceData implements vscode.HoverProvider, vscode.Complet
106114

107115
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, _context: vscode.CompletionContext): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {
108116
const wordAtPosition = document.getWordRangeAtPosition(position);
117+
const beforeWordAtPosition = wordAtPosition ? document.getText(new vscode.Range(new vscode.Position(position.line, 0), new vscode.Position(position.line, wordAtPosition.start.character))) : undefined;
109118

110119
let currentWord = "";
111120
if (wordAtPosition && wordAtPosition.start.character < position.character) {
@@ -117,7 +126,7 @@ export class LanguageServiceData implements vscode.HoverProvider, vscode.Complet
117126
return null;
118127
}
119128

120-
return this.getCompletionSuggestions(currentWord);
129+
return this.getCompletionSuggestions(currentWord, beforeWordAtPosition);
121130
}
122131

123132
resolveCompletionItem?(item: vscode.CompletionItem, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem> {
@@ -132,7 +141,7 @@ export class LanguageServiceData implements vscode.HoverProvider, vscode.Complet
132141
return null;
133142
}
134143

135-
const hoverSuggestions = this.commands[value] || this.variables[value] || this.modules[value];
144+
const hoverSuggestions = this.commands[value] || this.variables[value] || this.modules[value] || this.modules[`Find${value}`];
136145

137146
const markdown: vscode.MarkdownString = new vscode.MarkdownString();
138147
markdown.appendMarkdown(hoverSuggestions.description);

0 commit comments

Comments
 (0)