-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the basics of #1109
- Loading branch information
Showing
8 changed files
with
106 additions
and
15 deletions.
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
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
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,41 @@ | ||
import { ChildProcessWithoutNullStreams, spawn } from "child_process"; | ||
import { Logger } from "./Logger"; | ||
import {FormatFileParameter, FormatFileResult, ICSharpierProcess2} from "./ICSharpierProcess"; | ||
import { getDotNetRoot } from "./DotNetProvider"; | ||
|
||
// TODO lots of stuff in here | ||
// https://github.com/belav/csharpier/pull/1127/files | ||
// https://github.com/belav/csharpier/pull/1203/files | ||
|
||
export class CSharpierProcessServer implements ICSharpierProcess2 { | ||
private process: ChildProcessWithoutNullStreams; | ||
private logger: Logger; | ||
private version: string; | ||
constructor(logger: Logger, csharpierPath: string, workingDirectory: string, version: string) { | ||
this.logger = logger; | ||
this.process = this.spawnProcess(csharpierPath, workingDirectory); | ||
this.version = version; | ||
|
||
this.logger.debug("Warm CSharpier with initial format"); | ||
// warm by formatting a file twice, the 3rd time is when it gets really fast | ||
this.formatFile("public class ClassName { }", "Test.cs").then(() => { | ||
this.formatFile("public class ClassName { }", "Test.cs"); | ||
}); | ||
} | ||
|
||
dispose(): any { | ||
} | ||
|
||
formatFile(content: string, filePath: string): Promise<string> { | ||
return Promise.resolve(""); | ||
} | ||
|
||
formatFile2(parameter: FormatFileParameter): FormatFileResult { | ||
return {} as any; | ||
} | ||
|
||
getVersion(): string { | ||
return this.version; | ||
} | ||
|
||
} |
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
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
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
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,29 @@ | ||
import {Disposable} from "vscode"; | ||
|
||
export interface ICSharpierProcess extends Disposable { | ||
getVersion(): string; | ||
formatFile(content: string, filePath: string): Promise<string>; | ||
} | ||
|
||
export interface ICSharpierProcess2 extends ICSharpierProcess { | ||
formatFile2(parameter: FormatFileParameter): FormatFileResult; | ||
} | ||
|
||
export interface FormatFileParameter { | ||
fileContents: string; | ||
fileName: string; | ||
} | ||
|
||
export interface FormatFileResult { | ||
formattedFile: string; | ||
status: Status; | ||
errorMessage: string; | ||
} | ||
|
||
export enum Status | ||
{ | ||
Formatted, | ||
Ignored, | ||
Failed | ||
} | ||
|
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