Skip to content
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

Merged
merged 10 commits into from
Jun 27, 2018
Merged

Conversation

rchande
Copy link

@rchande rchande commented Jun 1, 2018

import { blockStructure } from "../omnisharp/utils";
import { Request } from "../omnisharp/protocol";

export class structureProvider extends AbstractSupport implements FoldingRangeProvider
Copy link
Contributor

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 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Copy link
Author

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?

import { blockStructure } from "../omnisharp/utils";
import { Request } from "../omnisharp/protocol";

export class structureProvider extends AbstractSupport implements FoldingRangeProvider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

HintSpan: Range;
BannerText: string;
Type: string;
}
Copy link
Member

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.

Copy link
Member

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

Copy link
Author

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
Copy link

codecov bot commented Jun 6, 2018

Codecov Report

Merging #2360 into master will increase coverage by 0.3%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#integration 51.71% <85.71%> (+0.36%) ⬆️
#unit 84.26% <100%> (+0.01%) ⬆️
Impacted Files Coverage Δ
src/omnisharp/extension.ts 80.18% <100%> (+0.38%) ⬆️
src/omnisharp/utils.ts 70.17% <100%> (+1.08%) ⬆️
src/omnisharp/protocol.ts 78.88% <100%> (+0.23%) ⬆️
src/features/structureProvider.ts 81.25% <81.25%> (ø)
src/omnisharp/delayTracker.ts 68.42% <0%> (ø) ⬆️
src/assets.ts 50% <0%> (+2.91%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2bed4f...078ed96. Read the comment docs.

Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests?

@@ -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')
Copy link
Member

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.

export interface BlockSpan {
Range: Range;
Type: string;
}
Copy link
Member

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.

@@ -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) {
Copy link
Member

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.

else if (type == "Region")
{
return FoldingRangeKind.Region
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch?

}

let response = await blockStructure(this._server, request, token)
let ranges : FoldingRange[] = [];
Copy link
Member

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.

return ranges;
}

GetType(type: string) : FoldingRangeKind
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetKind?

@rchande rchande merged commit 6d115ca into dotnet:master Jun 27, 2018
@rchande rchande deleted the folding branch June 27, 2018 20:16
@DustinCampbell
Copy link
Member

DustinCampbell commented Jul 9, 2018

When will we update OmniSharp in C# for VS Code so that this works without specifying "omnisharp.path": "latest"? Technically, master is broken (at least for this feature) with the default OmniSharp that is specified in master.

@rchande
Copy link
Author

rchande commented Jul 10, 2018

@DustinCampbell let's try to do it this week--I've requested opinions in the o# slack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants