Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d824e4b
update project build structure to prepare for adding webview
matthewbastien Oct 15, 2024
cc4551a
add preview documentation command
matthewbastien Oct 21, 2024
063d5a4
add docstrings to various functions and interfaces
matthewbastien Oct 21, 2024
34aa15a
rename several files in the webview
matthewbastien Oct 22, 2024
a3d340d
handle navigation events that happen while the webview is hidden
matthewbastien Oct 22, 2024
127b9cd
rename WebviewEvent to WebviewMessage
matthewbastien Oct 22, 2024
874c697
introduce a DocumentationManager to the WorkspaceContext
matthewbastien Oct 23, 2024
f5bb087
use document symbols for navigation
matthewbastien Oct 24, 2024
37984b2
fix build scripts
matthewbastien Oct 30, 2024
787f487
improve symbol lookup
matthewbastien Oct 30, 2024
b2f50c8
add more unit tests for document symbol search
matthewbastien Oct 31, 2024
ad0a42a
First draft of happy path integration test on markdown render
michael-weng Nov 4, 2024
4b44f7d
use textDocument/renderDocumentation request from SourceKit-LSP to fe…
matthewbastien Nov 12, 2024
cf9c7a8
remove .DS_Store file
matthewbastien Nov 12, 2024
eefa313
rename test fixture to SlothCreatorExample
matthewbastien Nov 12, 2024
3b847a4
fix unacceptable language in SlothCreatorExample
matthewbastien Nov 12, 2024
7682836
remove license headers from SlothCreatorExample
matthewbastien Nov 12, 2024
38ced26
only enable documentation preview if SourceKit-LSP supports it
matthewbastien Nov 12, 2024
d2822c7
fix context keys test in MockUtils.test.ts
matthewbastien Nov 12, 2024
13a7f01
skip documentation preview tests if SourceKit-LSP does not support them
matthewbastien Nov 12, 2024
d58c3a3
fix swift.isActivated context key
matthewbastien Nov 18, 2024
285b8b3
add activation events for markdown and tutorial files
matthewbastien Nov 22, 2024
ccb08b6
transform asset URLs into webview URIs
matthewbastien Nov 22, 2024
5520a4a
Added first set of integration tests
michael-weng Nov 19, 2024
03bdb44
Remove some local set up files
michael-weng Nov 22, 2024
d730330
Add edit test for all tests in the test suite
michael-weng Nov 25, 2024
46a55eb
Add focus switch tests
michael-weng Nov 25, 2024
8448769
remove commented code
matthewbastien Nov 27, 2024
dc1065b
remove console log statement
matthewbastien Nov 27, 2024
eb3b507
remove more console.log statements
matthewbastien Nov 27, 2024
7fdb217
remove even more console.log statements
matthewbastien Nov 27, 2024
283636c
fix test suite setup
matthewbastien Nov 27, 2024
243ecc6
change LSP request name to convertDocumentation
matthewbastien Dec 12, 2024
21820b2
remove tests until SourceKit-LSP supports documentation preview
matthewbastien Dec 13, 2024
d772d5b
address review comments
matthewbastien Dec 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
]
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
"ignorePatterns": ["assets", "out", "dist", "**/*.d.ts"]
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ default.profraw
*.vsix
.vscode-test
.build
.DS_Store
assets/documentation-webview
assets/test/**/Package.resolved
assets/swift-docc-render
assets/swift-docc-render
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"VSCODE_DEBUG": "1"
},
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "build"
"preLaunchTask": "Build Extension"
},
{
"name": "Extension Tests",
Expand Down
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
// Tell VS Code to use the same version of TypeScript as the build
"typescript.tsdk": "node_modules/typescript/lib",

// Configure Prettier
"editor.formatOnSave": true,
Expand Down
55 changes: 52 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@
"version": "2.0.0",
"tasks": [
{
"label": "build",
"label": "Build Extension",
"dependsOn": ["compile", "compile-documentation-webview"],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "compile",
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
Expand All @@ -13,8 +21,49 @@
},
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
"kind": "build"
}
},
{
"label": "compile-documentation-webview",
"type": "npm",
"script": "watch-documentation-webview",
"problemMatcher": [
{
"owner": "esbuild",
"severity": "error",
"source": "esbuild",
"fileLocation": "relative",
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "\\[watch\\] build started"
},
"endsPattern": {
"regexp": "\\[watch\\] build finished"
}
},
"pattern": [
{
"regexp": "^[✘▲] \\[([A-Z]+)\\] (.+)",
"severity": 1,
"message": 2
},
{
"regexp": "^(?:\\t| {4})(?!\\s)([^:]+)(?::([0-9]+))?(?::([0-9]+))?:$",
"file": 1,
"line": 2,
"column": 3
}
]
}
],
"presentation": {
"reveal": "never"
},
"isBackground": true,
"group": {
"kind": "build"
}
},
{
Expand Down
28 changes: 25 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
".swiftinterface",
".swift"
]
},
{
"id": "tutorial",
"aliases": [
"Tutorial"
],
"filenamePatterns": [
"*.tutorial"
]
}
],
"snippets": [
Expand All @@ -76,6 +85,11 @@
}
],
"commands": [
{
"command": "swift.previewDocumentation",
"title": "Preview Documentation",
"category": "Swift"
},
{
"command": "swift.createNewProject",
"title": "Create New Project...",
Expand Down Expand Up @@ -663,6 +677,10 @@
}
],
"commandPalette": [
{
"command": "swift.previewDocumentation",
"when": "swift.supportsDocumentationLivePreview"
},
{
"command": "swift.createNewProject",
"when": "!swift.isActivated || swift.createNewProjectAvailable"
Expand Down Expand Up @@ -1274,9 +1292,13 @@
],
"scripts": {
"vscode:prepublish": "npm run bundle",
"bundle": "del-cli ./dist && esbuild ./src/extension.ts --bundle --outfile=dist/src/extension.js --external:vscode --format=cjs --platform=node --target=node18 --minify --sourcemap",
"compile": "del-cli ./dist && tsc",
"watch": "del-cli ./dist && tsc --watch",
"bundle": "del-cli ./dist && npm run bundle-extension && npm run bundle-documentation-webview",
"bundle-extension": "del-cli ./dist && esbuild ./src/extension.ts --bundle --outfile=dist/src/extension.js --external:vscode --format=cjs --platform=node --target=node18 --minify --sourcemap",
"bundle-documentation-webview": "npm run compile-documentation-webview -- --minify",
"compile": "del-cli ./dist/ && tsc --build",
"watch": "npm run compile -- --watch",
"compile-documentation-webview": "del-cli ./assets/documentation-webview && esbuild ./src/documentation/webview/webview.ts --bundle --outfile=assets/documentation-webview/index.js --format=cjs --sourcemap",
"watch-documentation-webview": "npm run compile-documentation-webview -- --watch",
"lint": "eslint ./ --ext ts && tsc --noEmit",
"update-swift-docc-render": "tsx ./scripts/update_swift_docc_render.ts",
"format": "prettier --check .",
Expand Down
19 changes: 16 additions & 3 deletions src/WorkspaceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { DebugAdapter, LaunchConfigType } from "./debugger/debugAdapter";
import { SwiftBuildStatus } from "./ui/SwiftBuildStatus";
import { SwiftToolchain } from "./toolchain/toolchain";
import { DiagnosticsManager } from "./DiagnosticsManager";
import { DocumentationManager } from "./documentation/DocumentationManager";

/**
* Context for whole workspace. Holds array of contexts for each workspace folder
Expand All @@ -49,10 +50,12 @@ export class WorkspaceContext implements vscode.Disposable {
public diagnostics: DiagnosticsManager;
public subscriptions: vscode.Disposable[];
public commentCompletionProvider: CommentCompletionProviders;
public documentation: DocumentationManager;
private lastFocusUri: vscode.Uri | undefined;
private initialisationFinished = false;

private constructor(
extensionContext: vscode.ExtensionContext,
public tempFolder: TemporaryFolder,
public outputChannel: SwiftOutputChannel,
public toolchain: SwiftToolchain
Expand All @@ -62,6 +65,7 @@ export class WorkspaceContext implements vscode.Disposable {
this.languageClientManager = new LanguageClientManager(this);
this.tasks = new TaskManager(this);
this.diagnostics = new DiagnosticsManager(this);
this.documentation = new DocumentationManager(extensionContext, this);
this.currentDocument = null;
this.commentCompletionProvider = new CommentCompletionProviders();

Expand Down Expand Up @@ -163,6 +167,7 @@ export class WorkspaceContext implements vscode.Disposable {
onChangeConfig,
this.tasks,
this.diagnostics,
this.documentation,
this.languageClientManager,
this.outputChannel,
this.statusItem,
Expand Down Expand Up @@ -192,11 +197,12 @@ export class WorkspaceContext implements vscode.Disposable {

/** Get swift version and create WorkspaceContext */
static async create(
extensionContext: vscode.ExtensionContext,
outputChannel: SwiftOutputChannel,
toolchain: SwiftToolchain
): Promise<WorkspaceContext> {
const tempFolder = await TemporaryFolder.create();
return new WorkspaceContext(tempFolder, outputChannel, toolchain);
return new WorkspaceContext(extensionContext, tempFolder, outputChannel, toolchain);
}

/**
Expand Down Expand Up @@ -224,11 +230,18 @@ export class WorkspaceContext implements vscode.Disposable {
contextKeys.currentTargetType = undefined;
}

// LSP can be configured per workspace to support reindexing
// Set context keys that depend on features from SourceKit-LSP
this.languageClientManager.useLanguageClient(async client => {
const experimentalCaps = client.initializeResult?.capabilities.experimental;
if (!experimentalCaps) {
contextKeys.supportsReindexing = false;
contextKeys.supportsDocumentationLivePreview = false;
return;
}
contextKeys.supportsReindexing =
experimentalCaps && experimentalCaps["workspace/triggerReindex"] !== undefined;
experimentalCaps["workspace/triggerReindex"] !== undefined;
contextKeys.supportsDocumentationLivePreview =
experimentalCaps["textDocument/convertDocumentation"] !== undefined;
});

setSnippetContextKey(this);
Expand Down
5 changes: 5 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export enum Commands {
USE_LOCAL_DEPENDENCY = "swift.useLocalDependency",
UNEDIT_DEPENDENCY = "swift.uneditDependency",
RUN_PLUGIN_TASK = "swift.runPluginTask",
PREVIEW_DOCUMENTATION = "swift.previewDocumentation",
}

/**
Expand Down Expand Up @@ -155,5 +156,9 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
"swift.runAllTestsParallel",
async () => await runAllTestsParallel(ctx)
),
vscode.commands.registerCommand(
Commands.PREVIEW_DOCUMENTATION,
async () => await ctx.documentation.launchDocumentationPreview()
),
];
}
Loading
Loading