-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commands to call CML generators via LSP
- Loading branch information
Showing
7 changed files
with
79 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ group 'org.contextmapper' | |
version '1.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
|
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 |
---|---|---|
@@ -1 +1 @@ | ||
cmlVersion=5.11.0 | ||
cmlVersion=5.11.1-SNAPSHOT |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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,36 @@ | ||
/** | ||
* CML generator commands | ||
*/ | ||
|
||
import { commands, ExtensionContext, window, workspace, Uri } from "vscode"; | ||
|
||
type CommandType = (...args: any[]) => any; | ||
|
||
export function generatePlantUML(): CommandType { | ||
return generate('cml.generate.puml', 'The PlantUML diagrams have been generated into the src-gen folder.'); | ||
} | ||
|
||
export function generateMDSL(): CommandType { | ||
return generate('cml.generate.mdsl', 'The MDSL contracts have been generated into to src-gen folder.'); | ||
} | ||
|
||
function generate(command: string, successMessage: string): CommandType { | ||
return async () => { | ||
if (editorIsNotCMLEditor()) | ||
return; | ||
|
||
if (documentInEditorHasURI()) { | ||
await commands.executeCommand(command, window.activeTextEditor.document.uri.toString()); | ||
window.showInformationMessage(successMessage); | ||
} | ||
}; | ||
} | ||
|
||
function editorIsNotCMLEditor(): boolean { | ||
let activeEditor = window.activeTextEditor; | ||
return !activeEditor || !activeEditor.document || activeEditor.document.languageId !== 'cml'; | ||
} | ||
|
||
function documentInEditorHasURI(): boolean { | ||
return window.activeTextEditor.document.uri instanceof Uri; | ||
} |
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