-
Notifications
You must be signed in to change notification settings - Fork 676
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Structured Documentation for Signature Help and improving Parameter Documentation #1958
Merged
+158
−7
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4e6162b
Structured Documentation in Signature Help
akshita31 29ee957
Code clean up
akshita31 20be756
Using only summary of the documentation
akshita31 d102d1f
Code clean up
akshita31 59746e4
Documentation for parameters showing in signature help
akshita31 2f5d90e
Merge remote-tracking branch 'upstream/master' into sig_help_doc
akshita31 4a222a1
Removing unnecesaary import
akshita31 a94398b
Using interploated string and fixed spacing
akshita31 15e80b2
Parameter Documentation using interpolated text
akshita31 e0bd7ab
Merge branch 'master' into sig_help_doc
akshita31 29b360a
Merge branch 'master' into sig_help_doc
73fcf55
Merge branch 'master' into sig_help_doc
13b034c
Merge branch 'master' into sig_help_doc
ff98b23
Merge branch 'master' into sig_help_doc
akshita31 bd99cb2
Merge branch 'master' into sig_help_doc
akshita31 995ada4
Added tests
akshita31 088bee9
Merge branch 'master' into sig_help_doc
akshita31 1818a23
Added different function for signature help
akshita31 12e5099
Merge remote-tracking branch 'origin/sig_help_doc' into sig_help_doc
akshita31 694cc72
Changed duplicate class name
akshita31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import * as vscode from 'vscode'; | ||
import * as path from 'path'; | ||
|
||
import poll from './poll'; | ||
import { should, expect } from 'chai'; | ||
import testAssetWorkspace from './testAssets/testAssetWorkspace'; | ||
import { omnisharp } from '../../src/omnisharp/extension'; | ||
|
||
const chai = require('chai'); | ||
chai.use(require('chai-arrays')); | ||
chai.use(require('chai-fs')); | ||
|
||
suite(`SignatureHelp: ${testAssetWorkspace.description}`, function () { | ||
let fileUri: vscode.Uri; | ||
suiteSetup(async function () { | ||
should(); | ||
|
||
let csharpExtension = vscode.extensions.getExtension("ms-vscode.csharp"); | ||
if (!csharpExtension.isActive) { | ||
await csharpExtension.activate(); | ||
} | ||
|
||
await csharpExtension.exports.initializationFinished; | ||
|
||
let fileName = 'sigHelp.cs'; | ||
let dir = path.dirname(testAssetWorkspace.projects[0].projectDirectoryPath); | ||
let loc = path.join(dir, fileName); | ||
fileUri = vscode.Uri.file(loc); | ||
await omnisharp.waitForEmptyEventQueue(); | ||
await vscode.commands.executeCommand("vscode.open", fileUri); | ||
}); | ||
|
||
|
||
test("Returns response with documentation as undefined when method does not have documentation", async function () { | ||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(20, 23)); | ||
expect(c.signatures[0].documentation).to.be.undefined; | ||
}); | ||
|
||
test("Returns label when method does not have documentation", async function () { | ||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(20, 23)); | ||
let answer = `void testissue.noDocMethod()`; | ||
expect(c.signatures[0].label).to.equal(answer); | ||
}); | ||
|
||
test("Returns summary as documentation for the method", async function () { | ||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 19)); | ||
let answer = `Checks if object is tagged with the tag.`; | ||
expect(c.signatures[0].documentation).to.equal(answer); | ||
}); | ||
|
||
test("Returns label for the method", async function () { | ||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 19)); | ||
let answer = `void testissue.Compare(int gameObject, string tagName)`; | ||
expect(c.signatures[0].label).to.equal(answer); | ||
}); | ||
|
||
test("Returns label for the parameters", async function () { | ||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 19)); | ||
let param1 = `int gameObject`; | ||
let param2 = `string tagName`; | ||
expect(c.signatures[0].parameters[0].label).to.equal(param1); | ||
expect(c.signatures[0].parameters[1].label).to.equal(param2); | ||
}); | ||
|
||
test("Returns documentation for the parameters", async function () { | ||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 19)); | ||
let param1 = `**gameObject**: The game object.`; | ||
let param2 = `**tagName**: Name of the tag.`; | ||
expect((<vscode.MarkdownString> c.signatures[0].parameters[0].documentation).value).to.equal(param1); | ||
expect((<vscode.MarkdownString> c.signatures[0].parameters[1].documentation).value).to.equal(param2); | ||
}); | ||
|
||
test("Signature Help identifies active parameter if there is no comma", async function () { | ||
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. Nice! BTW, where did these tests come from? 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. I wrote them myself. |
||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 19)); | ||
let answer = `int gameObject`; | ||
expect(c.signatures[0].parameters[c.activeParameter].label).to.equal(answer); | ||
}); | ||
|
||
test("Signature Help identifies active parameter based on comma", async function () { | ||
let c = <vscode.SignatureHelp>await vscode.commands.executeCommand("vscode.executeSignatureHelpProvider", fileUri, new vscode.Position(19, 21)); | ||
let answer = `string tagName`; | ||
expect(c.signatures[0].parameters[c.activeParameter].label).to.equal(answer); | ||
}); | ||
|
||
suiteTeardown(async () => { | ||
await testAssetWorkspace.cleanupWorkspace(); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...stAssets/singleCsproj/obj/Debug/netcoreapp2.0/singleCsproj.csproj.CoreCompileInputs.cache
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 |
---|---|---|
@@ -1 +1 @@ | ||
fe2f654e9c48e6a308b6a264aa38a2b3defe5730 | ||
a42255fc669f86623d73c2e9ad48ccb8310c65c0 |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
namespace Test | ||
{ | ||
class testissue | ||
{ | ||
///<summary>Checks if object is tagged with the tag.</summary> | ||
/// <param name="gameObject">The game object.</param> | ||
/// <param name="tagName">Name of the tag.</param> | ||
/// <returns>Returns <c>true</c> if object is tagged with tag.</returns> | ||
public static void Compare(int gameObject,string tagName) | ||
{ | ||
} | ||
|
||
public static void noDocMethod() | ||
{ | ||
} | ||
|
||
public static void main() | ||
{ | ||
Compare(4, "four"); | ||
noDocMethod(); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
test/integrationTests/testAssets/slnWithCsproj/src/app/sigHelp.cs
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
namespace Test | ||
{ | ||
class testissue | ||
{ | ||
///<summary>Checks if object is tagged with the tag.</summary> | ||
/// <param name="gameObject">The game object.</param> | ||
/// <param name="tagName">Name of the tag.</param> | ||
/// <returns>Returns <c>true</c> if object is tagged with tag.</returns> | ||
public static void Compare(int gameObject,string tagName) | ||
{ | ||
} | ||
|
||
public static void noDocMethod() | ||
{ | ||
} | ||
|
||
public static void main() | ||
{ | ||
Compare(4, "four"); | ||
noDocMethod(); | ||
} | ||
} | ||
} |
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.
There are two types of tests we should be thinking about:
Today, we can only test features by writing "integration" tests. At some point, we should think about what we'll need to do to write "unit" tests to test these kinds of implementation details. Not blocking your PR on this, but something to consider (cc @TheRealPiotrP ).