Skip to content

Commit 1af9733

Browse files
Merge pull request #1681 from cake-build/feature/cake
[WIP] Cake support
2 parents e22749e + 9f5495d commit 1af9733

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@
206206
"workspaceContains:*.csproj",
207207
"workspaceContains:*.sln",
208208
"workspaceContains:*.csx",
209+
"workspaceContains:*.cake",
209210
"workspaceContains:**/*.csproj",
210211
"workspaceContains:**/*.sln",
211-
"workspaceContains:**/*.csx"
212+
"workspaceContains:**/*.csx",
213+
"workspaceContains:**/*.cake"
212214
],
213215
"contributes": {
214216
"configuration": {

src/features/status.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ let defaultSelector: vscode.DocumentSelector = [
2727
{ pattern: '**/project.json' }, // project.json-files OR
2828
{ pattern: '**/*.sln' }, // any solution file OR
2929
{ pattern: '**/*.csproj' }, // an csproj file
30-
{ pattern: '**/*.csx' } // C# script
30+
{ pattern: '**/*.csx' }, // C# script
31+
{ pattern: '**/*.cake' } // Cake script
3132
];
3233

3334
class Status {

src/omnisharp/launcher.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export enum LaunchTargetKind {
1717
Solution,
1818
ProjectJson,
1919
Folder,
20-
Csx
20+
Csx,
21+
Cake
2122
}
2223

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

4748
return vscode.workspace.findFiles(
48-
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx}',
49+
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
4950
/*exclude*/ '{**/node_modules/**,**/.git/**,**/bower_components/**}',
5051
/*maxResults*/ options.maxProjectResults)
5152
.then(resources => {
@@ -74,7 +75,8 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] {
7475
hasSlnFile = false,
7576
hasProjectJson = false,
7677
hasProjectJsonAtRoot = false,
77-
hasCSX = false;
78+
hasCSX = false,
79+
hasCake = false;
7880

7981
hasCsProjFiles = resources.some(isCSharpProject);
8082

@@ -111,6 +113,11 @@ function select(resources: vscode.Uri[], rootPath: string): LaunchTarget[] {
111113
if (!hasCSX && isCsx(resource)) {
112114
hasCSX = true;
113115
}
116+
117+
// Discover if there is any Cake file
118+
if (!hasCake && isCake(resource)) {
119+
hasCake = true;
120+
}
114121
});
115122

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

147+
// if we noticed any Cake file(s), add a single Cake-specific target pointing at the root folder
148+
if (hasCake) {
149+
targets.push({
150+
label: "Cake",
151+
description: path.basename(rootPath),
152+
target: rootPath,
153+
directory: rootPath,
154+
kind: LaunchTargetKind.Cake
155+
});
156+
}
157+
140158
return targets.sort((a, b) => a.directory.localeCompare(b.directory));
141159
}
142160

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

177+
function isCake(resource: vscode.Uri): boolean {
178+
return /\.cake$/i.test(resource.fsPath);
179+
}
180+
159181
export interface LaunchResult {
160182
process: ChildProcess;
161183
command: string;

src/omnisharp/protocol.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export interface WorkspaceInformationResponse {
279279
MsBuild?: MsBuildWorkspaceInformation;
280280
DotNet?: DotNetWorkspaceInformation;
281281
ScriptCs?: ScriptCsContext;
282+
Cake?: CakeContext;
282283
}
283284

284285
export interface MsBuildWorkspaceInformation {
@@ -294,6 +295,10 @@ export interface ScriptCsContext {
294295
Path: string;
295296
}
296297

298+
export interface CakeContext {
299+
Path: string;
300+
}
301+
297302
export interface MSBuildProject {
298303
ProjectGuid: string;
299304
Path: string;

src/omnisharp/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ export class OmniSharpServer {
367367
public autoStart(preferredPath: string): Thenable<void> {
368368
return findLaunchTargets().then(launchTargets => {
369369
// If there aren't any potential launch targets, we create file watcher and try to
370-
// start the server again once a *.sln, *.csproj, project.json or CSX file is created.
370+
// start the server again once a *.sln, *.csproj, project.json, CSX or Cake file is created.
371371
if (launchTargets.length === 0) {
372372
return new Promise<void>((resolve, reject) => {
373373
// 1st watch for files
374-
let watcher = vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.csproj,**/project.json,**/*.csx}',
374+
let watcher = vscode.workspace.createFileSystemWatcher('{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
375375
/*ignoreCreateEvents*/ false,
376376
/*ignoreChangeEvents*/ true,
377377
/*ignoreDeleteEvents*/ true);

0 commit comments

Comments
 (0)