-
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
Implement VS Code syntax-based folding API #2360
Conversation
src/features/structureProvider.ts
Outdated
import { blockStructure } from "../omnisharp/utils"; | ||
import { Request } from "../omnisharp/protocol"; | ||
|
||
export class structureProvider extends AbstractSupport implements FoldingRangeProvider |
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.
Should this be in capital ?
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.
I agree
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.
Will fix. Also--it looks like many other classes start with Capital letters but have filenames that start with lowercase letters. Should we try to make this consistent or is this some typescriptism?
src/features/structureProvider.ts
Outdated
import { blockStructure } from "../omnisharp/utils"; | ||
import { Request } from "../omnisharp/protocol"; | ||
|
||
export class structureProvider extends AbstractSupport implements FoldingRangeProvider |
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.
I agree
src/omnisharp/protocol.ts
Outdated
HintSpan: Range; | ||
BannerText: string; | ||
Type: string; | ||
} |
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.
This protocol should match other OmniSharp endpoints better. It'd probably better to have just a single Range
property rather than all of the other properties that are ultimately unused.
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.
BlockStructureRequest
appears to be missing
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.
@DustinCampbell This is something the extension codebase is inconsistent about: for request types that derive Request but don't add any properties, we haven't been adding corresponding entries in protocol.ts (instead just preferring to use Request directly) (case in point: there's no FileMembersAsTree request type in the extension). I was following that pattern here. We could also switch to adding request-deriving types that don't add properties. What do you think?
Codecov Report
@@ Coverage Diff @@
## master #2360 +/- ##
=========================================
+ Coverage 62.25% 62.56% +0.3%
=========================================
Files 86 87 +1
Lines 3855 3876 +21
Branches 551 552 +1
=========================================
+ Hits 2400 2425 +25
+ Misses 1293 1287 -6
- Partials 162 164 +2
Continue to review full report at Codecov.
|
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.
tests?
src/omnisharp/launcher.ts
Outdated
@@ -228,6 +228,7 @@ async function launch(cwd: string, args: string[], launchInfo: LaunchInfo, platf | |||
args.push(`formattingOptions:useTabs=${!getConfigurationValue(globalConfig, csharpConfig, 'editor.insertSpaces', true)}`); | |||
args.push(`formattingOptions:tabSize=${getConfigurationValue(globalConfig, csharpConfig, 'editor.tabSize', 4)}`); | |||
args.push(`formattingOptions:indentationSize=${getConfigurationValue(globalConfig, csharpConfig, 'editor.tabSize', 4)}`); | |||
args.push('-z') |
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.
I don't think you want this. If you launch OmniSharp with --zero-based-indeces
, you'll need to update all of the places in C# for VS Code that expect 1-based indeces today.
src/omnisharp/protocol.ts
Outdated
export interface BlockSpan { | ||
Range: Range; | ||
Type: string; | ||
} |
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.
I think you're missing your BlockStructureRequest
type.
src/omnisharp/utils.ts
Outdated
@@ -19,6 +19,10 @@ export async function currentFileMembersAsTree(server: OmniSharpServer, request: | |||
return server.makeRequest<protocol.CurrentFileMembersAsTreeResponse>(protocol.Requests.CurrentFileMembersAsTree, request, token); | |||
} | |||
|
|||
export async function blockStructure(server: OmniSharpServer, request: protocol.Request, token: vscode.CancellationToken) { |
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.
In the protocol you defined on the OmniSharp side, this takes a BlockStructureRequest
, which inherits from SimpleFileRequest
rather than Request
.
src/features/structureProvider.ts
Outdated
else if (type == "Region") | ||
{ | ||
return FoldingRangeKind.Region | ||
} |
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.
switch?
src/features/structureProvider.ts
Outdated
} | ||
|
||
let response = await blockStructure(this._server, request, token) | ||
let ranges : FoldingRange[] = []; |
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.
nit: format this file? This colon is in a different spot than it is above.
src/features/structureProvider.ts
Outdated
return ranges; | ||
} | ||
|
||
GetType(type: string) : FoldingRangeKind |
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.
GetKind
?
When will we update OmniSharp in C# for VS Code so that this works without specifying |
@DustinCampbell let's try to do it this week--I've requested opinions in the o# slack. |
Uses OmniSharp/omnisharp-roslyn#1209