Skip to content
This repository was archived by the owner on Jun 22, 2024. It is now read-only.

Commit 47884aa

Browse files
committed
Index all swift files initially when no Package.swift defined #14
1 parent f5bff29 commit 47884aa

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Removed unused config `editor.quickSuggestions`
66
* Will no longer write `sde.buildOnSave` or `editor.quickSuggestions` to workspace settings
77
* `#` will now trigger completions
8-
* `-target` will now be detected for `UIKit`, `AppKit`, `WatchKit` and `Foundation` on macOS and linux
8+
* `-target` will now be detected for `UIKit`, `AppKit`, `WatchKit` and `Foundation` on macOS and linux #15
99
* Index all swift files together when no `Package.swift` defined #14
1010

1111
## 2.3.0

src/server/server.ts

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,12 @@ export function initializeModuleMeta() {
5656
}
5757
})
5858
sp.stderr.on('data', (data) => {
59-
if (isTracingOn) {
60-
trace('***swift package describe stderr*** ', '' + data)
61-
}
59+
trace('***swift package describe stderr*** ', '' + data)
60+
const globalSources = allModuleSources.get(null)
61+
gatherAllSwiftFilesInPath(workspaceRoot)
62+
.forEach(globalSources.add.bind(globalSources));
6263
})
63-
// sp.on('exit', function (code, signal) {
64-
// trace('***swift package describe***', `code: ${code}, signal: ${signal}`)
65-
// })
64+
6665
sp.on('error', function (err) {
6766
trace('***swift package describe error*** ', (<Error>err).message)
6867
if ((<Error>err).message.indexOf("ENOENT") > 0) {
@@ -75,6 +74,23 @@ export function initializeModuleMeta() {
7574
});
7675
}
7776

77+
function gatherAllSwiftFilesInPath(root: string): string[] {
78+
const result = new Array<string>();
79+
try {
80+
const dir = fs.readdirSync(root).filter(sub => !sub.startsWith('.') && sub !== 'Carthage');
81+
for (const sub of dir) {
82+
if (path.extname(sub) === '.swift') {
83+
result.push(path.join(root, sub));
84+
} else {
85+
result.push(...gatherAllSwiftFilesInPath(path.join(root, sub)));
86+
}
87+
}
88+
return result;
89+
} catch (error) {
90+
return result;
91+
}
92+
}
93+
7894
export function getAllSourcePaths(srcPath: string): string[] {
7995
const sp = path.dirname(srcPath)
8096
for (let [m, p] of allModulePaths) {

0 commit comments

Comments
 (0)