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

[WIP] Cake support #1681

Merged
merged 2 commits into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@
"workspaceContains:*.csproj",
"workspaceContains:*.sln",
"workspaceContains:*.csx",
"workspaceContains:*.cake",
"workspaceContains:**/*.csproj",
"workspaceContains:**/*.sln",
"workspaceContains:**/*.csx"
"workspaceContains:**/*.csx",
"workspaceContains:**/*.cake"
],
"contributes": {
"configuration": {
Expand Down
3 changes: 2 additions & 1 deletion src/features/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ let defaultSelector: vscode.DocumentSelector = [
{ pattern: '**/project.json' }, // project.json-files OR
{ pattern: '**/*.sln' }, // any solution file OR
{ pattern: '**/*.csproj' }, // an csproj file
{ pattern: '**/*.csx' } // C# script
{ pattern: '**/*.csx' }, // C# script
{ pattern: '**/*.cake' } // Cake script
];

class Status {
Expand Down
28 changes: 25 additions & 3 deletions src/omnisharp/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export enum LaunchTargetKind {
Solution,
ProjectJson,
Folder,
Csx
Csx,
Cake
}

/**
Expand Down Expand Up @@ -45,7 +46,7 @@ export function findLaunchTargets(): Thenable<LaunchTarget[]> {
const options = Options.Read();

return vscode.workspace.findFiles(
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx}',
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
/*exclude*/ '{**/node_modules/**,**/.git/**,**/bower_components/**}',
/*maxResults*/ options.maxProjectResults)
.then(resources => {
Expand Down Expand Up @@ -74,7 +75,8 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] {
hasSlnFile = false,
hasProjectJson = false,
hasProjectJsonAtRoot = false,
hasCSX = false;
hasCSX = false,
hasCake = false;

hasCsProjFiles = resources.some(isCSharpProject);

Expand Down Expand Up @@ -111,6 +113,11 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] {
if (!hasCSX && isCsx(resource)) {
hasCSX = true;
}

// Discover if there is any Cake file
if (!hasCake && isCake(resource)) {
hasCake = true;
}
});

// Add the root folder under the following circumstances:
Expand All @@ -137,6 +144,17 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] {
});
}

// if we noticed any Cake file(s), add a single Cake-specific target pointing at the root folder
if (hasCake) {
targets.push({
label: "Cake",
description: path.basename(rootPath),
target: rootPath,
directory: rootPath,
kind: LaunchTargetKind.Cake
});
}

return targets.sort((a, b) => a.directory.localeCompare(b.directory));
}

Expand All @@ -156,6 +174,10 @@ function isCsx(resource: vscode.Uri): boolean {
return /\.csx$/i.test(resource.fsPath);
}

function isCake(resource: vscode.Uri): boolean {
return /\.cake$/i.test(resource.fsPath);
}

export interface LaunchResult {
process: ChildProcess;
command: string;
Expand Down
5 changes: 5 additions & 0 deletions src/omnisharp/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export interface WorkspaceInformationResponse {
MsBuild?: MsBuildWorkspaceInformation;
DotNet?: DotNetWorkspaceInformation;
ScriptCs?: ScriptCsContext;
Cake?: CakeContext;
}

export interface MsBuildWorkspaceInformation {
Expand All @@ -294,6 +295,10 @@ export interface ScriptCsContext {
Path: string;
}

export interface CakeContext {
Path: string;
}

export interface MSBuildProject {
ProjectGuid: string;
Path: string;
Expand Down
4 changes: 2 additions & 2 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,11 @@ export class OmniSharpServer {
public autoStart(preferredPath: string): Thenable<void> {
return findLaunchTargets().then(launchTargets => {
// If there aren't any potential launch targets, we create file watcher and try to
// start the server again once a *.sln, *.csproj, project.json or CSX file is created.
// start the server again once a *.sln, *.csproj, project.json, CSX or Cake file is created.
if (launchTargets.length === 0) {
return new Promise<void>((resolve, reject) => {
// 1st watch for files
let watcher = vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.csproj,**/project.json,**/*.csx}',
let watcher = vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
/*ignoreCreateEvents*/ false,
/*ignoreChangeEvents*/ true,
/*ignoreDeleteEvents*/ true);
Expand Down