Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1977 from ProAdd-ons/Update-Variables-Reference
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a authored Oct 16, 2018
2 parents a9962eb + 8affa8d commit cb1869c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 31 deletions.
20 changes: 10 additions & 10 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@
// path to VSCode executable
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
"--extensionDevelopmentPath=${workspaceFolder}"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/**/*.js"
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm"
},
{
"name": "Launch as server",
"type": "node2",
"request": "launch",
"program": "${workspaceRoot}/out/src/debugAdapter/goDebug.js",
"program": "${workspaceFolder}/out/src/debugAdapter/goDebug.js",
"args": [
"--server=4712"
],
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/**/*.js"
"${workspaceFolder}/out/**/*.js"
]
},
{
Expand All @@ -37,28 +37,28 @@
"runtimeExecutable": "${execPath}",
// the workspace path should be GOPATH
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test"
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/**/*.js"
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "npm"
},
{
"type": "node",
"request": "launch",
"name": "Unit Tests",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"tdd",
"--timeout",
"5000",
"--colors",
"${workspaceRoot}/out/test/unit"
"${workspaceFolder}/out/test/unit"
],
"internalConsoleOptions": "openOnSessionStart"
}
Expand All @@ -72,4 +72,4 @@
]
}
]
}
}
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${workspaceFolder}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
Expand Down Expand Up @@ -28,4 +28,4 @@

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ An alternative of golint is [revive](https://github.com/mgechev/revive). It is e
To configure revive, use:

```javascript
"go.lintFlags": ["-exclude=vendor/...", "-config=${workspaceRoot}/config.toml"]
"go.lintFlags": ["-exclude=vendor/...", "-config=${workspaceFolder}/config.toml"]
```

Finally, the result of those linters will show right in the code (locations with suggestions will be underlined),
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
"type": "go",
"request": "launch",
"mode": "debug",
"program": "^\"\\${workspaceRoot}${1:}\""
"program": "^\"\\${workspaceFolder}${1:}\""
}
},
{
Expand All @@ -299,7 +299,7 @@
"type": "go",
"request": "launch",
"mode": "test",
"program": "^\"\\${workspaceRoot}${1:}\""
"program": "^\"\\${workspaceFolder}${1:}\""
}
},
{
Expand All @@ -310,7 +310,7 @@
"type": "go",
"request": "launch",
"mode": "test",
"program": "^\"\\${workspaceRoot}${1:}\"",
"program": "^\"\\${workspaceFolder}${1:}\"",
"args": [
"-test.run",
"${2:MyTestFunction}"
Expand All @@ -325,10 +325,10 @@
"type": "go",
"request": "launch",
"mode": "remote",
"remotePath": "^\"\\${workspaceRoot}${1:}\"",
"remotePath": "^\"\\${workspaceFolder}${1:}\"",
"port": 2345,
"host": "127.0.0.1",
"program": "^\"\\${workspaceRoot}${1:}\"",
"program": "^\"\\${workspaceFolder}${1:}\"",
"env": {},
"args": []
}
Expand All @@ -341,7 +341,7 @@
"program": {
"type": "string",
"description": "Path to the program folder (or any file within that folder) when in 'debug' or 'test' mode, and to the pre-built binary file to debug in 'exec' mode.",
"default": "${workspaceRoot}"
"default": "${workspaceFolder}"
},
"mode": {
"enum": [
Expand Down Expand Up @@ -422,7 +422,7 @@
"envFile": {
"type": "string",
"description": "Absolute path to a file containing environment variable definitions.",
"default": "${workspaceRoot}/.env"
"default": "${workspaceFolder}/.env"
},
"backend": {
"type": "string",
Expand Down
21 changes: 10 additions & 11 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,16 @@ function resolveToolsGopath(): string {

let toolsGopathForWorkspace = vscode.workspace.getConfiguration('go')['toolsGopath'] || '';

// In case of single root, use resolvePath to resolve ~ and ${workspaceRoot}
// In case of single root
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length <= 1) {
return resolvePath(toolsGopathForWorkspace);
}

// In case of multi-root, resolve ~ and ignore ${workspaceRoot}
// In case of multi-root, resolve ~ and ${workspaceFolder}
if (toolsGopathForWorkspace.startsWith('~')) {
toolsGopathForWorkspace = path.join(os.homedir(), toolsGopathForWorkspace.substr(1));
}
if (toolsGopathForWorkspace && toolsGopathForWorkspace.trim() && !/\${workspaceRoot}/.test(toolsGopathForWorkspace)) {
if (toolsGopathForWorkspace && toolsGopathForWorkspace.trim() && !/\${workspaceFolder}|\${workspaceRoot}/.test(toolsGopathForWorkspace)) {
return toolsGopathForWorkspace;
}

Expand Down Expand Up @@ -502,21 +502,21 @@ export function timeout(millis): Promise<void> {
}

/**
* Exapnds ~ to homedir in non-Windows platform and resolves ${workspaceRoot}
* Exapnds ~ to homedir in non-Windows platform and resolves ${workspaceFolder} or ${workspaceRoot}
*/
export function resolvePath(inputPath: string, workspaceRoot?: string): string {
export function resolvePath(inputPath: string, workspaceFolder?: string): string {
if (!inputPath || !inputPath.trim()) return inputPath;

if (!workspaceRoot && vscode.workspace.workspaceFolders) {
if (!workspaceFolder && vscode.workspace.workspaceFolders) {
if (vscode.workspace.workspaceFolders.length === 1) {
workspaceRoot = vscode.workspace.rootPath;
workspaceFolder = vscode.workspace.rootPath;
} else if (vscode.window.activeTextEditor && vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri)) {
workspaceRoot = vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath;
workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.window.activeTextEditor.document.uri).uri.fsPath;
}
}

if (workspaceRoot) {
inputPath = inputPath.replace(/\${workspaceRoot}/g, workspaceRoot).replace(/\${workspaceFolder}/g, workspaceRoot);
if (workspaceFolder) {
inputPath = inputPath.replace(/\${workspaceFolder}|\${workspaceRoot}/g, workspaceFolder);
}
return resolveHomeDir(inputPath);
}
Expand Down Expand Up @@ -890,4 +890,3 @@ export function cleanupTempDir() {
}
tmpDir = undefined;
}

0 comments on commit cb1869c

Please sign in to comment.