-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start implementation validation for mixed types. See
- Loading branch information
1 parent
b9f6382
commit 63485b5
Showing
2 changed files
with
157 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<!doctype html> | ||
|
||
<title>CodeMirror: Tern Demo</title> | ||
<meta charset="utf-8"/> | ||
<link rel=stylesheet href="codemirror/doc/docs.css"> | ||
|
||
<!-- CodeMirror --> | ||
<link rel="stylesheet" href="codemirror/lib/codemirror.css"> | ||
<script src="codemirror/lib/codemirror.js"></script> | ||
<link rel="stylesheet" href="codemirror/theme/eclipse.css"> | ||
<script src="codemirror/addon/edit/closetag.js"></script> | ||
<script src="codemirror/addon/edit/closebrackets.js"></script> | ||
<script src="codemirror/addon/edit/matchbrackets.js"></script> | ||
<script src="codemirror/addon/selection/active-line.js"></script> | ||
<script src="codemirror/addon/runmode/runmode.js"></script> | ||
<script src="codemirror/mode/javascript/javascript.js"></script> | ||
|
||
<script src="codemirror/addon/lint/lint.js"></script> | ||
<link rel="stylesheet" href="codemirror/addon/lint/lint.css"> | ||
|
||
|
||
<script> | ||
var defs = []; | ||
CodeMirror.tern = {}; | ||
CodeMirror.tern.addDef = function(def) { | ||
defs.push(def); | ||
} | ||
</script> | ||
<script src="codemirror-javascript/addon/hint/tern/defs/ecma5.json.js"></script> | ||
<script src="codemirror-javascript/addon/hint/tern/defs/browser.json.js"></script> | ||
|
||
<!-- Tern JS --> | ||
<script src="ternjs/acorn/dist/acorn.js"></script> | ||
<script src=" ternjs/acorn/dist/acorn_loose.js"></script> | ||
<script src="ternjs/acorn/dist/walk.js"></script> | ||
<script src="ternjs/tern/lib/signal.js"></script> | ||
<script src="ternjs/tern/lib/tern.js"></script> | ||
<script src="ternjs/tern/lib/def.js"></script> | ||
<script src="ternjs/tern/lib/comment.js"></script> | ||
<script src="ternjs/tern/lib/infer.js"></script> | ||
|
||
<script src="ternjs/tern/plugin/doc_comment.js"></script> | ||
|
||
|
||
<!-- Official CodeMirror Tern addon --> | ||
<script src="codemirror/addon/tern/tern.js"></script> | ||
|
||
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css"> | ||
<link rel="stylesheet" href="codemirror/addon/hint/show-hint.css"> | ||
<link rel="stylesheet" href="codemirror/addon/tern/tern.css"> | ||
<script src="codemirror/addon/dialog/dialog.js"></script> | ||
<script src="codemirror/addon/hint/show-hint.js"></script> | ||
<script src="codemirror/addon/tern/tern.js"></script> | ||
|
||
<!-- Tern Lint --> | ||
<script src="../codemirror/addon/lint/tern-lint.js"></script> | ||
<script src="../lint.js"></script> | ||
|
||
<style> | ||
.CodeMirror {border: 1px solid #ddd;} | ||
</style> | ||
<div id=nav> | ||
<a href="http://codemirror.net"><img id=logo src="codemirror/doc/logo.png"></a> | ||
|
||
<ul> | ||
<li><a href="../index.html">Home</a> | ||
<li><a href="../doc/manual.html">Manual</a> | ||
<li><a href="https://github.com/marijnh/codemirror">Code</a> | ||
</ul> | ||
<ul> | ||
<li><a class=active href="#">Tern</a> | ||
</ul> | ||
</div> | ||
|
||
<article> | ||
<h2>Tern Lint Demo</h2> | ||
<form><textarea id="code" name="code">function test(state) { | ||
if (state) { | ||
return true | ||
} else { | ||
return 'false' | ||
} | ||
} //Raise warning | ||
</textarea></p> | ||
|
||
<p>Demonstrates integration of <a href="http://ternjs.net/">Tern</a> | ||
and CodeMirror. The following keys are bound:</p> | ||
|
||
<dl> | ||
<dt>Ctrl-Space</dt><dd>Autocomplete</dd> | ||
<dt>Ctrl-I</dt><dd>Find type at cursor</dd> | ||
<dt>Alt-.</dt><dd>Jump to definition (Alt-, to jump back)</dd> | ||
<dt>Ctrl-Q</dt><dd>Rename variable</dd> | ||
</dl> | ||
|
||
<p>Documentation is sparse for now. See the top of | ||
the <a href="codemirror/addon/tern/tern.js">script</a> for a rough API | ||
overview.</p> | ||
|
||
<script> | ||
|
||
function getURL(url, c) { | ||
var xhr = new XMLHttpRequest(); | ||
xhr.open("get", url, true); | ||
xhr.send(); | ||
xhr.onreadystatechange = function() { | ||
if (xhr.readyState != 4) return; | ||
if (xhr.status < 400) return c(null, xhr.responseText); | ||
var e = new Error(xhr.responseText || "No response"); | ||
e.status = xhr.status; | ||
c(e); | ||
}; | ||
} | ||
|
||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), { | ||
lineNumbers: true, | ||
mode: "javascript" | ||
}); | ||
|
||
//var server; | ||
//getURL("http://ternjs.net/defs/ecma5.json", function(err, code) { | ||
// if (err) throw new Error("Request for ecma5.json: " + err); | ||
var server = new CodeMirror.TernServer({defs: defs, plugins:{"lint":{}, "doc_comment": {}}}); | ||
editor.setOption("extraKeys", { | ||
"Ctrl-Space": function(cm) { server.complete(cm); }, | ||
"Ctrl-I": function(cm) { server.showType(cm); }, | ||
"Alt-.": function(cm) { server.jumpToDef(cm); }, | ||
"Alt-,": function(cm) { server.jumpBack(cm); }, | ||
"Ctrl-Q": function(cm) { server.rename(cm); }, | ||
}) | ||
editor.setOption("gutters",["CodeMirror-lint-markers"]); | ||
editor.setOption("lint", {getAnnotations: CodeMirror.ternLint, async : true, server: server}) | ||
editor.on("cursorActivity", function(cm) { server.updateArgHints(cm); }); | ||
//}); | ||
|
||
</script> | ||
|
||
</article> |
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