This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 646
Use -imports-only option from go-outline #550
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ encountered. | |
vscode.workspace.openTextDocument(uri).then((textDocument) => { | ||
return vscode.window.showTextDocument(textDocument).then(editor => { | ||
let promises = testCases.map(([position, expected]) => | ||
provider.provideCompletionItems(textDocument, position, null).then(items => { | ||
provider.provideCompletionItems(editor.document, position, null).then(items => { | ||
let labels = items.map(x => x.label); | ||
for (let entry of expected) { | ||
if (labels.indexOf(entry) < 0) { | ||
|
@@ -97,6 +97,9 @@ encountered. | |
}) | ||
); | ||
return Promise.all(promises); | ||
}).then(() => { | ||
vscode.commands.executeCommand('workbench.action.closeActiveEditor'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. executeCommand returns a promise - don't know if it matters though |
||
return Promise.resolve(); | ||
}); | ||
}, (err) => { | ||
assert.ok(false, `error in OpenTextDocument ${err}`); | ||
|
@@ -115,13 +118,13 @@ encountered. | |
let uri = vscode.Uri.file(path.join(fixturePath, 'test.go')); | ||
|
||
vscode.workspace.openTextDocument(uri).then((textDocument) => { | ||
return vscode.window.showTextDocument(textDocument).then((editor => { | ||
return vscode.window.showTextDocument(textDocument).then(editor => { | ||
return editor.edit(editbuilder => { | ||
editbuilder.insert(new vscode.Position(12, 0), 'by\n'); | ||
editbuilder.insert(new vscode.Position(13, 0), 'math.\n'); | ||
}).then(() => { | ||
let promises = testCases.map(([position, expected]) => | ||
provider.provideCompletionItemsInternal(textDocument, position, null, config).then(items => { | ||
provider.provideCompletionItemsInternal(editor.document, position, null, config).then(items => { | ||
let labels = items.map(x => x.label); | ||
for (let entry of expected) { | ||
assert.equal(labels.indexOf(entry) > -1, true, `missing expected item in competion list: ${entry} Actual: ${labels}`); | ||
|
@@ -130,7 +133,7 @@ encountered. | |
); | ||
return Promise.all(promises); | ||
}); | ||
})).then(() => { | ||
}).then(() => { | ||
vscode.commands.executeCommand('workbench.action.closeActiveEditor'); | ||
return Promise.resolve(); | ||
}); | ||
|
@@ -181,45 +184,49 @@ encountered. | |
} | ||
assert.equal(sortedDiagnostics.length, expected.length, `too many errors ${JSON.stringify(sortedDiagnostics)}`); | ||
}); | ||
|
||
}).then(() => done(), done); | ||
|
||
}); | ||
|
||
test('Test Generate unit tests squeleton for file', (done) => { | ||
getGoVersion().then(version => { | ||
if (version.major === 1 && version.minor === 5) { | ||
if (version.major === 1 && version.minor < 6) { | ||
// gotests is not supported in Go 1.5, so skip the test | ||
return Promise.resolve(); | ||
} | ||
|
||
let uri = vscode.Uri.file(path.join(fixturePath, 'test.go')); | ||
vscode.workspace.openTextDocument(uri).then(document => { | ||
return vscode.workspace.openTextDocument(uri).then(document => { | ||
return vscode.window.showTextDocument(document).then(editor => { | ||
return generateTestCurrentFile().then((result: boolean) => { | ||
assert.equal(result, true); | ||
return Promise.resolve(); | ||
}); | ||
}); | ||
}).then(() => { | ||
vscode.commands.executeCommand('workbench.action.closeActiveEditor'); | ||
return Promise.resolve(); | ||
}); | ||
}).then(() => done(), done); | ||
}); | ||
|
||
test('Test Generate unit tests squeleton for package', (done) => { | ||
getGoVersion().then(version => { | ||
if (version.major === 1 && version.minor === 5) { | ||
if (version.major === 1 && version.minor < 6) { | ||
// gotests is not supported in Go 1.5, so skip the test | ||
return Promise.resolve(); | ||
} | ||
|
||
let uri = vscode.Uri.file(path.join(fixturePath, 'test.go')); | ||
vscode.workspace.openTextDocument(uri).then(document => { | ||
return vscode.workspace.openTextDocument(uri).then(document => { | ||
return vscode.window.showTextDocument(document).then(editor => { | ||
return generateTestCurrentPackage().then((result: boolean) => { | ||
assert.equal(result, true); | ||
return Promise.resolve(); | ||
}); | ||
}); | ||
}).then(() => { | ||
vscode.commands.executeCommand('workbench.action.closeActiveEditor'); | ||
return Promise.resolve(); | ||
}); | ||
}).then(() => done(), done); | ||
}); | ||
|
@@ -362,7 +369,8 @@ encountered. | |
|
||
test('Test Outline', (done) => { | ||
let filePath = path.join(fixturePath, 'test.go'); | ||
documentSymbols(filePath).then(outlines => { | ||
let options = { fileName: filePath }; | ||
documentSymbols(options).then(outlines => { | ||
let packageOutline = outlines[0]; | ||
let symbols = packageOutline.children; | ||
let imports = symbols.filter(x => x.type === 'import'); | ||
|
@@ -377,6 +385,24 @@ encountered. | |
}, done); | ||
}); | ||
|
||
test('Test Outline imports only', (done) => { | ||
let filePath = path.join(fixturePath, 'test.go'); | ||
let options = { fileName: filePath, importsOnly: true }; | ||
documentSymbols(options).then(outlines => { | ||
let packageOutline = outlines[0]; | ||
let symbols = packageOutline.children; | ||
let imports = symbols.filter(x => x.type === 'import'); | ||
let functions = symbols.filter(x => x.type === 'function'); | ||
|
||
assert.equal(packageOutline.type, 'package'); | ||
assert.equal(packageOutline.label, 'main'); | ||
assert.equal(imports[0].label, '"fmt"'); | ||
assert.equal(functions.length, 0); | ||
assert.equal(imports.length, 1); | ||
done(); | ||
}, done); | ||
}); | ||
|
||
test('Test listPackages', (done) => { | ||
let uri = vscode.Uri.file(path.join(fixturePath, 'test.go')); | ||
vscode.workspace.openTextDocument(uri).then(document => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
camelCase?