This repository has been archived by the owner on Dec 17, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sascha Brink
committed
Nov 22, 2015
1 parent
90c561a
commit 3570726
Showing
6 changed files
with
106 additions
and
18 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
out | ||
node_modules | ||
node_modules | ||
elm-stuff |
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ src/** | |
.gitignore | ||
tsconfig.json | ||
vsc-extension-quickstart.md | ||
elm-stuff |
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,3 +1,6 @@ | ||
import Html | ||
import Graphics.Element exposing (..) | ||
import Graphics.Element exposing (..) | ||
|
||
main = Html.text "Hello, World!" | ||
main : Element | ||
main = | ||
show "Hello, World!" |
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,14 @@ | ||
{ | ||
"version": "1.0.0", | ||
"summary": "helpful summary of your project, less than 80 characters", | ||
"repository": "https://github.com/user/project.git", | ||
"license": "BSD3", | ||
"source-directories": [ | ||
"." | ||
], | ||
"exposed-modules": [], | ||
"dependencies": { | ||
"elm-lang/core": "3.0.0 <= v < 4.0.0" | ||
}, | ||
"elm-version": "0.16.0 <= v < 0.17.0" | ||
} |
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,24 +1,93 @@ | ||
// The module 'vscode' contains the VS Code extensibility API | ||
// Import the module and reference it with the alias vscode in your code below | ||
import * as vscode from 'vscode'; | ||
import cp = require('child_process'); | ||
import path = require('path'); | ||
import os = require('os'); | ||
import fs = require('fs'); | ||
|
||
export interface ICheckResult { | ||
tag: string; | ||
overview: string; | ||
subregion: string; | ||
details: string; | ||
region: { | ||
start: { | ||
line: number; | ||
column: number; | ||
} | ||
end: { | ||
line: number; | ||
column: number; | ||
} | ||
} | ||
type: string; | ||
file: string; | ||
} | ||
|
||
export function checkForErrors(filename): Promise<ICheckResult[]> { | ||
return new Promise((resolve, reject) => { | ||
var cmd = 'elm-make ' + filename + ' --report=json --output /dev/null' | ||
cp.exec(cmd, {}, (err, stdout, stderr) => { | ||
try { | ||
if (err && (<any>err).code == "ENOENT") { | ||
vscode.window.showInformationMessage("The 'elm-make' compiler is not available. Install Elm from http://elm-lang.org/."); | ||
return resolve([]); | ||
} | ||
console.log('stdout', stdout.toString()); | ||
var lines:ICheckResult[] = JSON.parse(stdout.toString()); | ||
resolve(lines); | ||
} catch(e) { | ||
reject(e); | ||
} | ||
}); | ||
|
||
}); | ||
} | ||
|
||
|
||
export function createDiagnostics(document: vscode.TextDocument) { | ||
if (document.languageId != "elm") { | ||
return; | ||
} | ||
let diagnostics: vscode.Diagnostic[] = []; | ||
let compileErrors = vscode.languages.createDiagnosticCollection("compile"); | ||
let uri = document.uri; | ||
|
||
checkForErrors(uri.fsPath).then((compilerErrors) => { | ||
diagnostics = compilerErrors.map((error) => { | ||
let lineRange = new vscode.Range( | ||
error.region.start.line - 1, | ||
error.region.start.column - 1, | ||
error.region.end.line - 1, | ||
error.region.end.column - 1 | ||
); | ||
return new vscode.Diagnostic(lineRange, error.details.replace(/\[\d+m/g, ''), vscode.DiagnosticSeverity.Error); | ||
}) | ||
compileErrors.set(document.uri, diagnostics); | ||
console.log('check success', compilerErrors); | ||
}, (error) => { | ||
compileErrors.set(document.uri, []); | ||
console.log('check error', error) | ||
}) | ||
} | ||
|
||
// this method is called when your extension is activated | ||
// your extension is activated the very first time the command is executed | ||
export function activate(context: vscode.ExtensionContext) { | ||
|
||
export function activate(disposables: vscode.Disposable[]) { | ||
// Use the console to output diagnostic information (console.log) and errors (console.error) | ||
// This line of code will only be executed once when your extension is activated | ||
console.log('Congratulations, your extension "elm" is now active!'); | ||
console.log('Extension "elm" is now active!'); | ||
|
||
// The command has been defined in the package.json file | ||
// Now provide the implementation of the command with registerCommand | ||
// The commandId parameter must match the command field in package.json | ||
var disposable = vscode.commands.registerCommand('extension.sayHello', () => { | ||
// The code you place here will be executed every time your command is executed | ||
// vscode.workspace.onDidChangeTextDocument(event => { | ||
// createDiagnostics(event.document) | ||
// }, undefined, disposables); | ||
|
||
// Display a message box to the user | ||
vscode.window.showInformationMessage('Hello World!'); | ||
}); | ||
vscode.workspace.onDidOpenTextDocument(document => { | ||
createDiagnostics(document) | ||
}); | ||
|
||
context.subscriptions.push(disposable); | ||
vscode.workspace.onDidSaveTextDocument(document => { | ||
createDiagnostics(document) | ||
}) | ||
} |
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