Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' into ack

  • Loading branch information...
commit fba38156763e52ac6ae9241c96e32a04e52f7119 2 parents bf8e36b + c576c27
Mostafa Eweda mostafaeweda authored
Showing with 11,079 additions and 763 deletions.
  1. +6 −0 Makefile
  2. +4 −0 Makefile.dryice.js
  3. +8 −4 bin/cloud9.sh
  4. +1 −1  build/packed_helper.js
  5. +3 −2 configs/default.js
  6. +3 −3 package.json
  7. +0 −126 plugins-client/ext.acebugs/acebugs.js
  8. +0 −25 plugins-client/ext.acebugs/acebugs.xml
  9. +0 −18 plugins-client/ext.acebugs/annotation_worker.js
  10. +4 −4 plugins-client/ext.beautify/beautify.js
  11. +3 −3 plugins-client/ext.clipboard/clipboard.js
  12. +105 −74 plugins-client/ext.code/code.js
  13. +1 −1  plugins-client/ext.code/code.xml
  14. +1 −0  plugins-client/ext.codecomplete/codecomplete.js
  15. +33 −2 plugins-client/ext.codecomplete/complete_util.js
  16. +88 −0 plugins-client/ext.codecomplete/mode_completer.js
  17. +9 −0 plugins-client/ext.codecomplete/modes/css.json
  18. +829 −0 plugins-client/ext.codecomplete/modes/php.json
  19. +8 −22 plugins-client/ext.codecomplete/snippet_completer.js
  20. +2 −1  plugins-client/ext.codecomplete/snippet_completer_test.js
  21. +5 −8 plugins-client/ext.codetools/codetools.js
  22. +9 −9 plugins-client/ext.colorpicker/colorpicker.js
  23. +76 −0 plugins-client/ext.csslanguage/css_handler.js
  24. +35 −0 plugins-client/ext.csslanguage/csslanguage.js
  25. +9,046 −0 plugins-client/ext.csslanguage/csslint.js
  26. +34 −0 plugins-client/ext.csslanguage/csslint_test.js
  27. +3 −3 plugins-client/{ext.acebugs → ext.csslanguage}/package.json
  28. +4 −4 plugins-client/ext.debugger/breakpoints.js
  29. +4 −4 plugins-client/ext.debugger/debugger.js
  30. +3 −3 plugins-client/ext.debugger/sources.js
  31. +8 −2 plugins-client/ext.editors/editors.js
  32. +15 −12 plugins-client/ext.filesystem/filesystem.js
  33. +2 −2 plugins-client/ext.formatjson/formatjson.js
  34. +2 −2 plugins-client/ext.gitblame/gitblame.js
  35. +2 −2 plugins-client/ext.gotofile/gotofile.js
  36. +6 −5 plugins-client/ext.guidedtour/guidedtour.js
  37. +4 −4 plugins-client/ext.guidedtour/tour.js
  38. +66 −0 plugins-client/ext.htmllanguage/html_completer.js
  39. +60 −0 plugins-client/ext.htmllanguage/html_completer_test.js
  40. +35 −0 plugins-client/ext.htmllanguage/htmllanguage.js
  41. +14 −0 plugins-client/ext.htmllanguage/package.json
  42. +20 −4 plugins-client/{ext.codecomplete/snippets/html.json → ext.htmllanguage/snippets.js}
  43. +4 −1 plugins-client/ext.jslanguage/jshint.js
  44. +1 −0  plugins-client/ext.jslanguage/jslanguage.js
  45. +30 −0 plugins-client/ext.jslanguage/jumptodef.js
  46. +5 −1 plugins-client/ext.jslanguage/outline.js
  47. +11 −4 plugins-client/ext.jslanguage/parse.js
  48. +9 −14 plugins-client/ext.jslanguage/scope_analyzer.js
  49. +4 −0 plugins-client/ext.jslanguage/scope_analyzer_test.js
  50. +2 −0  plugins-client/ext.language/base_handler.js
  51. +62 −51 plugins-client/ext.language/complete.js
  52. +3 −3 plugins-client/ext.language/jumptodef.js
  53. +32 −35 plugins-client/ext.language/language.js
  54. +8 −8 plugins-client/ext.language/liveinspect.js
  55. +2 −1  plugins-client/ext.language/marker.js
  56. +6 −6 plugins-client/ext.language/outline.js
  57. +3 −2 plugins-client/ext.language/tooltip.js
  58. +99 −113 plugins-client/ext.language/worker.js
  59. +0 −40 plugins-client/ext.main/main.xml
  60. +9 −1 plugins-client/ext.main/style/skins.xml
  61. +2 −2 plugins-client/ext.main/style/style.css
  62. +6 −5 plugins-client/ext.minimap/minimap.js
  63. +2 −2 plugins-client/ext.panels/panels.js
  64. +1 −1  plugins-client/ext.quicksearch/quicksearch.js
  65. +14 −11 plugins-client/ext.revisions/revisions.js
  66. +23 −3 plugins-client/ext.revisions/revisions_worker.js
  67. +6 −4 plugins-client/ext.save/save.js
  68. +5 −2 plugins-client/ext.searchinfiles/searchinfiles.js
  69. +25 −21 plugins-client/ext.searchreplace/searchreplace.js
  70. +2 −2 plugins-client/ext.splitview/splits.js
  71. +2 −3 plugins-client/ext.splitview/splitview.js
  72. +23 −20 plugins-client/ext.statusbar/statusbar.js
  73. +7 −2 plugins-client/ext.statusbar/statusbar.xml
  74. +1 −1  plugins-client/ext.stripws/stripws.js
  75. +8 −8 plugins-client/ext.themes/themes.js
  76. +7 −12 plugins-client/ext.tree/tree.js
  77. +1 −1  plugins-client/ext.tree/tree.xml
  78. +24 −7 plugins-client/ext.uploadfiles/uploadfiles.js
  79. +4 −4 plugins-client/ext.vim/cli.js
  80. +5 −5 plugins-client/ext.vim/vim.js
  81. +11 −9 plugins-client/ext.zen/zen.js
  82. +1 −1  plugins-server/cloud9.core/view/ide.tmpl.html
  83. +1 −1  plugins-server/cloud9.fs/fs/directory.js
  84. +5 −0 plugins-server/cloud9.fs/fs/tree.js
  85. +25 −0 plugins-server/cloud9.ide.shell/shell.js
  86. +1 −1  server.js
  87. +0 −1  test/blacklist.txt
  88. +16 −4 test/run-tests.sh
6 Makefile
View
@@ -56,6 +56,10 @@ plugins-client/lib.ace/www/worker/worker-language.js plugins-client/lib.ace/www/
$(wildcard plugins-client/ext.codecomplete/*/*) \
$(wildcard plugins-client/ext.jslanguage/*) \
$(wildcard plugins-client/ext.jslanguage/*/*) \
+ $(wildcard plugins-client/ext.csslanguage/*) \
+ $(wildcard plugins-client/ext.csslanguage/*/*) \
+ $(wildcard plugins-client/ext.htmllanguage/*) \
+ $(wildcard plugins-client/ext.htmllanguage/*/*) \
$(wildcard plugins-client/ext.jsinfer/*) \
$(wildcard plugins-client/ext.jsinfer/*/*) \
$(wildcard node_modules/treehugger/lib/*) \
@@ -69,6 +73,8 @@ plugins-client/lib.ace/www/worker/worker-language.js plugins-client/lib.ace/www/
ln -s `pwd`/plugins-client/ext.language /tmp/c9_worker_build/ext/language
ln -s `pwd`/plugins-client/ext.codecomplete /tmp/c9_worker_build/ext/codecomplete
ln -s `pwd`/plugins-client/ext.jslanguage /tmp/c9_worker_build/ext/jslanguage
+ ln -s `pwd`/plugins-client/ext.csslanguage /tmp/c9_worker_build/ext/csslanguage
+ ln -s `pwd`/plugins-client/ext.htmllanguage /tmp/c9_worker_build/ext/htmllanguage
ln -s `pwd`/plugins-client/ext.linereport /tmp/c9_worker_build/ext/linereport
ln -s `pwd`/plugins-client/ext.linereport_php /tmp/c9_worker_build/ext/linereport_php
node Makefile.dryice.js worker
4 Makefile.dryice.js
View
@@ -66,8 +66,12 @@ function worker(project) {
'ext/jslanguage/parse',
'ext/jslanguage/scope_analyzer',
'ext/jslanguage/jshint',
+ 'ext/jslanguage/jumptodef',
'ext/jslanguage/debugger',
'ext/jslanguage/outline',
+ 'ext/csslanguage/css_handler',
+ 'ext/htmllanguage/html_completer',
+ 'ext/codecomplete/mode_completer',
'ext/linereport/linereport_base',
'ext/linereport_php/linereport_php_worker',
]
12 bin/cloud9.sh
View
@@ -7,14 +7,18 @@ cd "$CMD_DIR/.."
make update
case `uname -a` in
-Linux*x86_64*) echo "Linux 64 bit"
+Linux*x86_64*) echo "Linux 64 bit"
node server.js "$@" -a x-www-browser
;;
-Linux*i686*) echo "Linux 32 bit"
+Linux*i686*) echo "Linux 32 bit"
node server.js "$@" -a x-www-browser
;;
-
+
+Linux*arm*) echo "Linux ARM"
+ node server.js "$@" -a x-www-browser
+ ;;
+
Darwin*) echo "OSX"
node server.js "$@" -a open
;;
@@ -29,7 +33,7 @@ CYGWIN*) echo "Cygwin"
MING*) echo "MingW"
node server.js "$@" -a "cmd /c start"
- ;;
+ ;;
SunOS*) echo "Solaris"
node server.js "$@"
2  build/packed_helper.js
View
@@ -39,7 +39,7 @@ clientMappings = "'" + clientMappings.join("',\n\t'") + "'";
var appTemplate = fs.readFileSync("./build/app.build.tmpl.js", "utf8");
// transform all variable paths out
-var appFile = appTemplate.replace(/%b/g, "build").replace(/%d/g, "plugins-client").replace('"%a"', '"node_modules/ace/lib/ace/worker"').replace('"%s"', clientPlugins).replace('"%m"', clientMappings).replace('"%o"', '"../plugins-client/lib.packed/www/packed.js"');
+var appFile = appTemplate.replace(/%b/g, "build").replace(/%d/g, "plugins-client").replace('"%a"', '"node_modules/ace/lib/ace/worker"').replace('"%s"', clientPlugins).replace('"%m"', clientMappings).replace('"%o"', '"../plugins-client/lib.packed/www/c9os.min.js"');
if (isClean)
appFile = appFile.replace(/\/\/\s*optimize/, 'optimize');
5 configs/default.js
View
@@ -142,7 +142,7 @@ var config = [
"ext/beautify/beautify",
"ext/offline/offline",
"ext/stripws/stripws",
- "ext/testpanel/testpanel",
+ //"ext/testpanel/testpanel",
"ext/nodeunit/nodeunit",
"ext/zen/zen",
"ext/codecomplete/codecomplete",
@@ -151,6 +151,8 @@ var config = [
"ext/guidedtour/guidedtour",
"ext/quickstart/quickstart",
"ext/jslanguage/jslanguage",
+ "ext/csslanguage/csslanguage",
+ "ext/htmllanguage/htmllanguage",
"ext/autotest/autotest",
"ext/closeconfirmation/closeconfirmation",
"ext/codetools/codetools",
@@ -163,7 +165,6 @@ var config = [
"ext/language/liveinspect"
//"ext/splitview/splitview"
//"ext/minimap/minimap"
- //"ext/acebugs/acebugs"
]
}, {
packagePath: "vfs-architect/local",
6 package.json
View
@@ -30,7 +30,7 @@
"connect-architect": "0.0.6",
"smith": "0.1.9",
- "smith.io": "0.0.32",
+ "smith.io": "0.0.36",
"vfs-architect": "0.0.2",
"jsDAV": "0.1.8",
"nak": "0.1.6"
@@ -45,8 +45,8 @@
},
"mappings": {
- "ace": ["npm", "https://github.com/ajaxorg/ace/tarball/9a08960ed064cc1a213e8dc0442a547235bcc71d"],
- "apf": ["npm", "https://github.com/ajaxorg/apf/tarball/14fdef1ba00d28b5c267cbe9136ad5f5e7ba1646"],
+ "ace": ["npm", "https://github.com/ajaxorg/ace/tarball/1bd26e19aa13bf8bc9c6647f967c46ad5fdde8c9"],
+ "apf": ["npm", "https://github.com/ajaxorg/apf/tarball/67b0929e1011dc876d4412a654b6d939335876e0"],
"asyncjs": ["npm", "https://github.com/ajaxorg/async.js/tarball/0b4ed5608a32c280a7690b5f52883d8d1fc0de08"],
"v8debug": ["npm", "https://github.com/ajaxorg/lib-v8debug/tarball/d2fac9b09724cb2e75e2807191eace9bc27d3b52"],
"packager": ["npm", "https://github.com/ajaxorg/packager/tarball/bee2a82c6d5e2875024bfdc83937e98092ccf04f"],
126 plugins-client/ext.acebugs/acebugs.js
View
@@ -1,126 +0,0 @@
-/**
- * Ace Bugs extension for Cloud9. Displays a window in the dock panel
- * showing warnings and errors retrieved from Ace
- *
- * @copyright 2011, Ajax.org B.V.
- * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
- */
-
-define(function(require, exports, module) {
-
-var ext = require("core/ext");
-var ide = require("core/ide");
-var dock = require("ext/dockpanel/dockpanel");
-var editors = require("ext/editors/editors");
-var markup = require("text!ext/acebugs/acebugs.xml");
-
-module.exports = ext.register("ext/acebugs/acebugs", {
- name: "Ace Bugs",
- dev: "Ajax.org",
- alone: true,
- type: ext.GENERAL,
- markup: markup,
-
- nodes: [],
-
- init: function(amlNode) {
- var currEditor = editors.currentEditor;
- if (currEditor) {
- this.editorSession = currEditor.amlEditor.getSession();
-
- this.editorSession.on("changeAnnotation", function(e) {
- _self.updateAnnotations();
- });
- }
- },
-
- hook: function() {
- var _self = this;
- this.annotationWorker = new Worker(ide.staticPrefix + "/ext/acebugs/annotation_worker.js");
- this.lastAnnotations = "";
- this.annotationWorker.onmessage = function(e) {
- if (e.data.outXml == _self.lastAnnotations)
- return;
-
- if (e.data.errors > 0)
- dock.increaseNotificationCount("aceAnnotations", e.data.errors);
- mdlAceAnnotations.load(apf.getXml(e.data.outXml.replace(/&/g, "&amp;")));
- };
-
- this.annotationWorker.onerror = function(e) {
-
- };
-
- ide.addEventListener("afteropenfile", function(e) {
- _self.updateAnnotations();
- });
-
- ide.addEventListener("tab.afterswitch", function(e){
- var ce = editors.currentEditor;
- if (ce) {
- _self.editorSession = ce.amlEditor.getSession();
- _self.editorSession.on("changeAnnotation", function(e) {
- _self.updateAnnotations();
- });
-
- _self.updateAnnotations();
- }
- });
-
- this.section = dock.getSection(this.name, {
- width : 260,
- height : 360
- });
-
- dock.registerPage(this.section, null, function() {
- ext.initExtension(_self);
- return aceAnnotations;
- }, {
- ident : "aceAnnotations",
- primary : {
- backgroundImage: ide.staticPrefix + "/ext/main/style/images/debugicons.png",
- defaultState: { x: -6, y: -391 },
- activeState: { x: -6, y: -391 }
- }
- });
-
- ext.initExtension(this);
- },
-
- updateAnnotations : function() {
- var ce = editors.currentEditor;
- if (!ce || typeof mdlAceAnnotations === "undefined")
- return;
-
- this.amlEditor = ce.amlEditor;
- var editorSession = this.amlEditor.getSession();
- dock.resetNotificationCount("aceAnnotations");
- this.annotationWorker.postMessage(editorSession.getAnnotations());
- },
-
- goToAnnotation : function() {
- var line_num = dgAceAnnotations.selected.getAttribute("line");
- this.amlEditor.$editor.gotoLine(line_num);
- },
-
- enable: function() {
- this.nodes.each(function(item) {
- item.enable();
- });
- },
-
- disable: function() {
- this.nodes.each(function(item) {
- item.disable();
- });
- },
-
- destroy: function() {
- this.nodes.each(function(item) {
- item.destroy(true, true);
- });
- this.nodes = [];
- }
-});
-
-});
25 plugins-client/ext.acebugs/acebugs.xml
View
@@ -1,25 +0,0 @@
-<a:application xmlns:a="http://ajax.org/2005/aml">
- <a:tab id="tabAceBugs" skin="docktab" visible="false">
- <a:model id="mdlAceAnnotations"></a:model>
- <a:page id="aceAnnotations" caption="Bugs">
- <a:datagrid id="dgAceAnnotations"
- anchors = "0 0 0 0"
- border = "0"
- options = "size|move"
- prerender = "false"
- caching = "false"
- class = "noscrollbar"
- scrollbar = "sbShared 20 2 2"
- onafterchoose = "require('ext/acebugs/acebugs').goToAnnotation()"
- model = "mdlAceAnnotations"
- loading-message = "Loading..."
- empty-message = "None found">
- <a:each match="[annotation]" sort="[@line]" data-type="number" order="ascending">
- <a:column type="icon" width="20" icon="debugger/[@type]_obj.gif" />
- <a:column caption="Line" value="[@line]" width="50" />
- <a:column caption="Description" value="[@text]" width="100%" />
- </a:each>
- </a:datagrid>
- </a:page>
- </a:tab>
-</a:application>
18 plugins-client/ext.acebugs/annotation_worker.js
View
@@ -1,18 +0,0 @@
-onmessage = function(e) {
- var annos = e.data;
- var aceerrors = 0;
- var outXml = "<annotations>";
- for (var ai in annos) {
- for (j = 0; j < annos[ai].length; j++) {
- if (annos[ai][j].type == "error")
- aceerrors++;
- var line_num = parseInt(annos[ai][j].row, 10) + 1;
- outXml += '<annotation line="' + line_num +
- '" text="' + annos[ai][j].text +
- '" type="' + annos[ai][j].type + '" />';
- }
- }
-
- outXml += "</annotations>";
- postMessage({ outXml: outXml, errors: aceerrors});
-};
8 plugins-client/ext.beautify/beautify.js
View
@@ -37,8 +37,8 @@ module.exports = ext.register("ext/beautify/beautify", {
if (!editor)
editor = editors.currentEditor;
- if (editor.ceEditor)
- editor = editor.ceEditor.$editor;
+ if (editor.amlEditor)
+ editor = editor.amlEditor.$editor;
var sel = editor.selection;
var session = editor.session;
@@ -129,8 +129,8 @@ module.exports = ext.register("ext/beautify/beautify", {
msg: "Beautifying selection.",
bindKey: {mac: "Command-Shift-B", win: "Shift-Ctrl-B"},
isAvailable : function(editor){
- if (editor && editor.ceEditor) {
- var range = editor.ceEditor.$editor.getSelectionRange();
+ if (editor && editor.path == "ext/code/code") {
+ var range = editor.amlEditor.$editor.getSelectionRange();
return range.start.row != range.end.row
|| range.start.column != range.end.column;
}
6 plugins-client/ext.clipboard/clipboard.js
View
@@ -148,11 +148,11 @@ module.exports = ext.register("ext/clipboard/clipboard", {
$getAce : function() {
var editor = editors.currentEditor;
- if (!editor || !editor.ceEditor)
+ if (!editor || !editor.amlEditor)
return;
- var ceEditor = editor.ceEditor;
- return ceEditor.$editor;
+ var amlEditor = editor.amlEditor;
+ return amlEditor.$editor;
},
enable : function(){
179 plugins-client/ext.code/code.js
View
@@ -7,7 +7,7 @@
define(function(require, exports, module) {
-/*global tabEditors ceEditor mnuSyntax*/
+/*global tabEditors mnuSyntax codeEditor_dontEverUseThisVariable */
require("apf/elements/codeeditor");
@@ -111,6 +111,7 @@ Object.keys(SupportedModes).forEach(function(name) {
module.exports = ext.register("ext/code/code", {
name : "Code Editor",
+ extName : "ext/code/code",
dev : "Ajax.org",
type : ext.EDITOR,
markup : markup,
@@ -180,17 +181,17 @@ module.exports = ext.register("ext/code/code", {
return "";
var mode = node.getAttribute("customtype");
+ var ext;
if (mode) {
- var ext = contentTypes[mode.split(";")[0]] ;
+ ext = contentTypes[mode.split(";")[0]] ;
if (ext)
mode = fileExtensions[contentTypes[mode]];
}
-
- if (!mode) {
+ else {
var fileName = node.getAttribute("name");
var dotI = fileName.lastIndexOf(".") + 1;
- var ext = dotI ? fileName.substr(dotI).toLowerCase() : "*" + fileName;
+ ext = dotI ? fileName.substr(dotI).toLowerCase() : "*" + fileName;
mode = fileExtensions[ext];
}
@@ -212,7 +213,8 @@ module.exports = ext.register("ext/code/code", {
apf.xmldb.setAttribute(file, "customtype", value);
fileExtensions[ext] = value;
- } else {
+ }
+ else {
apf.xmldb.removeAttribute(file, "customtype", "");
delete fileExtensions[ext];
@@ -221,7 +223,7 @@ module.exports = ext.register("ext/code/code", {
fileExtensions[ext] = mode;
break;
}
- }
+ }
}
var mime = this.setCustomType(dotI ? ext : file, value);
@@ -232,8 +234,8 @@ module.exports = ext.register("ext/code/code", {
mime: mime,
customType: value
});
- if (self.ceEditor)
- self.ceEditor.setAttribute("syntax", this.getSyntax(file));
+ if (this.amlEditor)
+ this.amlEditor.setAttribute("syntax", this.getSyntax(file));
},
getContentType : function(node) {
@@ -259,16 +261,16 @@ module.exports = ext.register("ext/code/code", {
setDocument : function(doc, actiontracker, isLazy){
var _self = this;
- var ceEditor = this.amlEditor;
+ var amlEditor = this.amlEditor;
if (doc.acesession) {
- ceEditor.setProperty("value", doc.acesession);
+ amlEditor.setProperty("value", doc.acesession);
}
else {
doc.isInited = doc.hasValue();
doc.acedoc = doc.acedoc || new ProxyDocument(new Document(doc.getValue() || ""));
var syntax = _self.getSyntax(doc.getNode());
- var mode = ceEditor.getMode(syntax);
+ var mode = amlEditor.getMode(syntax);
doc.acesession = new EditSession(doc.acedoc, mode);
doc.acesession.syntax = syntax;
doc.acedoc = doc.acesession.getDocument();
@@ -288,7 +290,6 @@ module.exports = ext.register("ext/code/code", {
doc.acesession.setValue(e.value || "");
-
if (doc.state)
_self.setState(doc, doc.state);
@@ -297,15 +298,15 @@ module.exports = ext.register("ext/code/code", {
if (this.$page.id != this.$page.parentNode.activepage)
return;
- ceEditor.setAttribute("syntax", syntax);
- ceEditor.setAttribute("value", doc.acesession);
+ amlEditor.setAttribute("syntax", syntax);
+ amlEditor.setAttribute("value", doc.acesession);
// force tokenize first visible rows
var rowCount = Math.min(50, doc.acesession.getLength());
doc.acesession.bgTokenizer.getTokens(0, rowCount);
});
if (!isLazy)
- ceEditor.setProperty("value", doc.acesession || "");
+ amlEditor.setProperty("value", doc.acesession || "");
doc.addEventListener("retrievevalue", function(e) {
if (this.editor != _self || !doc)
@@ -452,8 +453,8 @@ module.exports = ext.register("ext/code/code", {
};
command.findEditor = function(editor) {
- if (editor && editor.ceEditor)
- return editor.ceEditor.$editor;
+ if (editor && editor.amlEditor)
+ return editor.amlEditor.$editor;
return editor;
};
};
@@ -604,7 +605,7 @@ module.exports = ext.register("ext/code/code", {
menus.addItemByPath("View/Syntax/", new apf.menu({
"onprop.visible" : function(e){
if (e.value) {
- if (!editors.currentEditor || !editors.currentEditor.ceEditor)
+ if (!editors.currentEditor || !editors.currentEditor.amlEditor)
this.disable();
else {
this.enable();
@@ -660,30 +661,19 @@ module.exports = ext.register("ext/code/code", {
menus.addItemByPath("View/Wrap Lines", new apf.item({
type : "check",
- checked : "[{tabEditors.activepage && tabEditors.getPage(tabEditors.activepage).$model}::@wrapmode]",
- isAvailable : function(editor){
- return editor && editor.ceEditor;
- }
+ checked : "[{tabEditors.activepage && tabEditors.getPage(tabEditors.activepage).$model}::@wrapmode]"
}), 500000),
menus.addItemByPath("View/Wrap To Viewport", new apf.item({
id : "mnuWrapView",
type : "check",
- checked : "[{require('core/settings').model}::editors/code/@wrapmodeViewport]",
- isAvailable : function(editor){
- if (!editor || !editor.ceEditor)
- return false;
-
- var page = tabEditors.getPage();
- if (page.$model)
- return apf.isTrue(page.$model.queryValue("@wrapmode"));
-
- return false;
- }
+ checked : "[{require('core/settings').model}::editors/code/@wrapmodeViewport]"
}), 600000)
);
c = 0;
+
+ var otherGrpSyntax;
this.menus.push(
grpSyntax = new apf.group(),
@@ -710,8 +700,19 @@ module.exports = ext.register("ext/code/code", {
menus.addItemByPath("View/Syntax/~", new apf.divider(), c += 100)
);
+ function onModeClick(e) {
+ if (!_self.prevSelection)
+ _self.prevSelection = this;
+ else {
+ _self.prevSelection.uncheck();
+ if (_self.prevSelection.group.selectedItem.caption == "Other") {
+ _self.prevSelection.group.selectedItem.$ext.setAttribute("class", "menu_item submenu");
+ }
+ _self.prevSelection = this;
+ }
+ }
+
for (var mode in ModesCaption) {
- var path;
if (hiddenMode[mode])
continue;
@@ -720,17 +721,7 @@ module.exports = ext.register("ext/code/code", {
type: "radio",
value: ModesCaption[mode],
group : otherMode[mode] ? otherGrpSyntax : grpSyntax,
- onclick : function (e) {
- if (_self.prevSelection == null)
- _self.prevSelection = this;
- else {
- _self.prevSelection.uncheck();
- if (_self.prevSelection.group.selectedItem.caption == "Other") {
- _self.prevSelection.group.selectedItem.$ext.setAttribute("class", "menu_item submenu")
- }
- _self.prevSelection = this;
- }
- }
+ onclick : onModeClick
}), c += 100)
);
}
@@ -754,22 +745,56 @@ module.exports = ext.register("ext/code/code", {
addEditorMenu("Goto/Scroll to Selection", "centerselection")
);
+
+ ide.addEventListener("tab.afterswitch", function(e) {
+ var method = e.nextPage.$editor.path != "ext/code/code" ? "disable" : "enable";
+
+ menus.menus["Edit"][method]();
+ menus.menus["Selection"][method]();
+ menus.menus["Find"][method]();
+ menus.menus["View/Syntax"][method]();
+ menus.menus["View/Font Size"][method]();
+ menus.menus["View/Syntax/Other"][method]();
+ menus.menus["View/Syntax"][method]();
+ menus.menus["View/Newline Mode"][method]();
+ // WY U NO WORK??
+ menus.menus["Goto"][method]();
+ });
},
init: function(amlPage) {
var _self = this;
- this.ceEditor = this.amlEditor = ceEditor;
- this.amlEditor.show();
+ if (window.__defineGetter__ && !window.cloud9config.packed) {
+ function getCeEditor() {
+ var d = document.createElement("div");
+ d.style.position = "absolute";
+ d.style.zIndex = 100001;
+ d.style.left = ((apf.getWindowWidth() / 2) - 200) + "px";
+ d.style.top = ((apf.getWindowHeight() / 2) - 200) + "px";
+ d.addEventListener("click", function () {
+ document.body.removeChild(d);
+ });
+ var i = document.createElement("img");
+ i.src = "http://100procentjan.nl/c9/3rlzgl.jpeg";
+ d.appendChild(i);
+ document.body.appendChild(d);
+ }
+ window.__defineGetter__("ceEditor", getCeEditor);
+ this.__defineGetter__("ceEditor", getCeEditor);
+ }
- this.amlEditor.$editor.$nativeCommands = ceEditor.$editor.commands;
- this.amlEditor.$editor.commands = commands;
+ _self.amlEditor = codeEditor_dontEverUseThisVariable;
+ _self.amlEditor.show();
+
+ _self.amlEditor.$editor.$nativeCommands = _self.amlEditor.$editor.commands;
+ _self.amlEditor.$editor.commands = commands;
// preload common language modes
var noop = function() {};
- ceEditor.getMode("javascript", noop);
- ceEditor.getMode("html", noop);
- ceEditor.getMode("css", noop);
+ _self.amlEditor.getMode("javascript", noop);
+ _self.amlEditor.getMode("html", noop);
+ _self.amlEditor.getMode("css", noop);
ide.addEventListener("reload", function(e) {
var doc = e.doc;
@@ -803,7 +828,7 @@ module.exports = ext.register("ext/code/code", {
var syntax = _self.getSyntax(doc.getNode());
// This event is triggered also when closing files, so session may be gone already.
if(doc.acesession) {
- doc.acesession.setMode(ceEditor.getMode(syntax));
+ doc.acesession.setMode(_self.amlEditor.getMode(syntax));
doc.acesession.syntax = syntax;
}
});
@@ -818,57 +843,63 @@ module.exports = ext.register("ext/code/code", {
});
ide.addEventListener("animate", function(e){
- if (!ceEditor.$ext.offsetHeight)
+ if (!_self.amlEditor.$ext.offsetHeight)
return;
+ var renderer, delta;
if (e.type == "editor") {
- var renderer = ceEditor.$editor.renderer;
- renderer.onResize(true, null, null, ceEditor.getHeight() + e.delta);
+ renderer = _self.amlEditor.$editor.renderer;
+ renderer.onResize(true, null, null, _self.amlEditor.getHeight() + e.delta);
}
else if (e.type == "splitbox") {
- if (e.options.height != undefined && apf.isChildOf(e.other, ceEditor, true)) {
- var delta = e.which.getHeight() - parseInt(e.options.height);
+ if (e.options.height !== undefined && apf.isChildOf(e.other, _self.amlEditor, true)) {
+ delta = e.which.getHeight() - Number(e.options.height);
if (delta < 0) return;
- var renderer = ceEditor.$editor.renderer;
- renderer.onResize(true, null, null, ceEditor.getHeight() + delta);
+ renderer = _self.amlEditor.$editor.renderer;
+ renderer.onResize(true, null, null, _self.amlEditor.getHeight() + delta);
}
- else if (e.options.width != undefined && apf.isChildOf(e.other, ceEditor, true)) {
- var delta = e.which.getWidth() - parseInt(e.options.width);
+ else if (e.options.width !== undefined && apf.isChildOf(e.other, _self.amlEditor, true)) {
+ delta = e.which.getWidth() - Number(e.options.width);
if (delta < 0) return;
- var renderer = ceEditor.$editor.renderer;
- renderer.onResize(true, null, ceEditor.getWidth() + delta);
+ renderer = _self.amlEditor.$editor.renderer;
+ renderer.onResize(true, null, _self.amlEditor.getWidth() + delta);
}
}
});
-
+
// display feedback while loading files
- var isOpen, bgMessage;
+ var isOpen, bgMessage, animationEndTimeout;
var checkLoading = function(e) {
- if (!ceEditor.xmlRoot)
+ if (!_self.amlEditor.xmlRoot)
return;
- var loading = ceEditor.xmlRoot.hasAttribute("loading");
- var container = ceEditor.$editor.container;
+ var loading = _self.amlEditor.xmlRoot.hasAttribute("loading");
+ var container = _self.amlEditor.$editor.container;
if (loading) {
if (!bgMessage || !bgMessage.parentNode) {
- bgMessage = bgMessage|| document.createElement("div");
+ bgMessage = bgMessage|| document.createElement("div");
container.parentNode.appendChild(bgMessage);
}
- var isDark = container.className.indexOf("ace_dark")!=-1;
+ var isDark = container.className.indexOf("ace_dark") != -1;
bgMessage.className = "ace_smooth_loading" + (isDark ? " ace_dark" : "");
-
- bgMessage.textContent = "Loading " + ceEditor.xmlRoot.getAttribute("name");
+
+ bgMessage.textContent = "Loading " + _self.amlEditor.xmlRoot.getAttribute("name");
container.style.transitionProperty = "opacity";
container.style.transitionDuration = "300ms";
container.style.pointerEvents = "none";
container.style.opacity = 0;
isOpen = true;
+ clearTimeout(animationEndTimeout);
} else if (isOpen) {
isOpen = false;
container.style.opacity = 1;
container.style.pointerEvents = "";
+ animationEndTimeout = setTimeout(function() {
+ if (bgMessage.parentNode)
+ bgMessage.parentNode.removeChild(bgMessage);
+ }, 350);
}
};
2  plugins-client/ext.code/code.xml
View
@@ -1,5 +1,5 @@
<a:application xmlns:a="http://ajax.org/2005/aml">
- <a:codeeditor id="ceEditor"
+ <a:codeeditor id="codeEditor_dontEverUseThisVariable"
flex = "1"
anchors = "6 0 0 0"
theme = "[{require('core/settings').model}::editors/code/@theme]"
1  plugins-client/ext.codecomplete/codecomplete.js
View
@@ -22,6 +22,7 @@ module.exports = ext.register("ext/codecomplete/codecomplete", {
init : function() {
language.registerLanguageHandler('ext/codecomplete/local_completer');
language.registerLanguageHandler('ext/codecomplete/snippet_completer');
+ language.registerLanguageHandler("ext/codecomplete/mode_completer");
language.registerLanguageHandler('ext/codecomplete/open_files_local_completer');
},
35 plugins-client/ext.codecomplete/complete_util.js
View
@@ -2,10 +2,11 @@ define(function(require, exports, module) {
var ID_REGEX = /[a-zA-Z_0-9\$]/;
-function retrievePreceedingIdentifier(text, pos) {
+function retrievePreceedingIdentifier(text, pos, regex) {
+ regex = regex || ID_REGEX;
var buf = [];
for (var i = pos-1; i >= 0; i--) {
- if(ID_REGEX.test(text[i]))
+ if (regex.test(text[i]))
buf.push(text[i]);
else
break;
@@ -13,6 +14,18 @@ function retrievePreceedingIdentifier(text, pos) {
return buf.reverse().join("");
}
+function retrieveFollowingIdentifier(text, pos, regex) {
+ regex = regex || ID_REGEX;
+ var buf = [];
+ for (var i = pos; i < text.length; i++) {
+ if (regex.test(text[i]))
+ buf.push(text[i]);
+ else
+ break;
+ }
+ return buf;
+}
+
function prefixBinarySearch(items, prefix) {
var startIndex = 0;
var stopIndex = items.length - 1;
@@ -43,7 +56,25 @@ function findCompletions(prefix, allIdentifiers) {
return matches;
}
+function fetchText(staticPrefix, path) {
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', staticPrefix + "/" + path, false);
+ try {
+ xhr.send();
+ }
+ // Likely we got a cross-script error (equivalent with a 404 in our cloud setup)
+ catch(e) {
+ return false;
+ }
+ if (xhr.status === 200)
+ return xhr.responseText;
+ else
+ return false;
+}
+
exports.retrievePreceedingIdentifier = retrievePreceedingIdentifier;
+exports.retrieveFollowingIdentifier = retrieveFollowingIdentifier;
exports.findCompletions = findCompletions;
+exports.fetchText = fetchText;
});
88 plugins-client/ext.codecomplete/mode_completer.js
View
@@ -0,0 +1,88 @@
+/**
+ * Cloud9 Language Foundation
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
+define(function(require, exports, module) {
+
+var completeUtil = require("ext/codecomplete/complete_util");
+var baseLanguageHandler = require('ext/language/base_handler');
+
+var completer = module.exports = Object.create(baseLanguageHandler);
+
+var modeCache = {}; // extension -> static data
+var iconLanglist = ["php"];
+
+completer.handlesLanguage = function(language) {
+ return ["css", "php"].indexOf(language) !== -1;
+};
+
+var ID_REGEXES = {
+ "css": /[a-zA-Z_0-9-]/
+};
+
+completer.complete = function(doc, fullAst, pos, currentNode, callback) {
+ var language = this.language;
+ var line = doc.getLine(pos.row);
+ var idRegex = ID_REGEXES[language];
+ var identifier = completeUtil.retrievePreceedingIdentifier(line, pos.column, idRegex);
+ if(!identifier.length) // No completion after "."
+ return callback([]);
+
+ var mode = modeCache[language];
+
+ if (mode === undefined) {
+ var text;
+ if (language)
+ text = completeUtil.fetchText(this.staticPrefix, 'ext/codecomplete/modes/' + this.language + '.json');
+ mode = text ? JSON.parse(text) : {};
+ // Cache
+ modeCache[language] = mode;
+ }
+
+ function getIcon(type) {
+ if (iconLanglist.indexOf(language) === -1)
+ return null;
+ var iconMap = {
+ "variable": "property",
+ "constant": "property",
+ "function": "method"
+ };
+ var subs = Object.keys(iconMap);
+ for (var i = 0; i < subs.length; i++)
+ if (type.indexOf(subs[i]) !== -1)
+ return iconMap[subs[i]];
+ return null;
+ }
+
+ // keywords, functions, constants, ..etc
+ var types = Object.keys(mode);
+ var matches = [];
+ types.forEach(function (type) {
+ var icon = getIcon(type);
+ var nameAppend = "", replaceAppend = "";
+ if (type.indexOf("function") !== -1) {
+ nameAppend = "()";
+ replaceAppend = "(^^)";
+ }
+ var deprecated = type.indexOf("deprecated") === -1 ? 0 : 1;
+ var compls = completeUtil.findCompletions(identifier, mode[type]);
+ matches.push.apply(matches, compls.map(function(m) {
+ return {
+ name : m + nameAppend,
+ replaceText : m + replaceAppend,
+ doc : deprecated ? ("Deprecated: <del>" + m + nameAppend + "</del>") : null,
+ icon : icon,
+ meta : type,
+ idRegex : idRegex,
+ priority : 2 - deprecated
+ };
+ }));
+ });
+
+ callback(matches);
+};
+
+
+});
9 plugins-client/ext.codecomplete/modes/css.json
View
@@ -0,0 +1,9 @@
+{
+ "type": ["animation-fill-mode", "alignment-adjust", "alignment-baseline", "animation-delay", "animation-direction", "animation-duration", "animation-iteration-count", "animation-name", "animation-play-state", "animation-timing-function", "animation", "appearance", "azimuth", "backface-visibility", "background-attachment", "background-break", "background-clip", "background-color", "background-image", "background-origin", "background-position", "background-repeat", "background-size", "background", "baseline-shift", "binding", "bleed", "bookmark-label", "bookmark-level", "bookmark-state", "bookmark-target", "border-bottom", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-collapse", "border-color", "border-image", "border-image-outset", "border-image-repeat", "border-image-slice", "border-image-source", "border-image-width", "border-left", "border-left-color", "border-left-style", "border-left-width", "border-radius", "border-right", "border-right-color", "border-right-style", "border-right-width", "border-spacing", "border-style", "border-top", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "border-width", "border", "bottom", "box-align", "box-decoration-break", "box-direction", "box-flex-group", "box-flex", "box-lines", "box-ordinal-group", "box-orient", "box-pack", "box-shadow", "box-sizing", "break-after", "break-before", "break-inside", "caption-side", "clear", "clip", "color-profile", "color", "column-count", "column-fill", "column-gap", "column-rule", "column-rule-color", "column-rule-style", "column-rule-width", "column-span", "column-width", "columns", "content", "counter-increment", "counter-reset", "crop", "cue-after", "cue-before", "cue", "cursor", "direction", "display", "dominant-baseline", "drop-initial-after-adjust", "drop-initial-after-align", "drop-initial-before-adjust", "drop-initial-before-align", "drop-initial-size", "drop-initial-value", "elevation", "empty-cells", "fit", "fit-position", "float-offset", "float", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "font", "grid-columns", "grid-rows", "hanging-punctuation", "height", "hyphenate-after", "hyphenate-before", "hyphenate-character", "hyphenate-lines", "hyphenate-resource", "hyphens", "icon", "image-orientation", "image-rendering", "image-resolution", "inline-box-align", "left", "letter-spacing", "line-height", "line-stacking-ruby", "line-stacking-shift", "line-stacking-strategy", "line-stacking", "list-style-image", "list-style-position", "list-style-type", "list-style", "margin-bottom", "margin-left", "margin-right", "margin-top", "margin", "mark-after", "mark-before", "mark", "marks", "marquee-direction", "marquee-play-count", "marquee-speed", "marquee-style", "max-height", "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index", "nav-left", "nav-right", "nav-up", "opacity", "orphans", "outline-color", "outline-offset", "outline-style", "outline-width", "outline", "overflow-style", "overflow-x", "overflow-y", "overflow", "padding-bottom", "padding-left", "padding-right", "padding-top", "padding", "page-break-after", "page-break-before", "page-break-inside", "page-policy", "page", "pause-after", "pause-before", "pause", "perspective-origin", "perspective", "phonemes", "pitch-range", "pitch", "play-during", "position", "presentation-level", "punctuation-trim", "quotes", "rendering-intent", "resize", "rest-after", "rest-before", "rest", "richness", "right", "rotation-point", "rotation", "ruby-align", "ruby-overhang", "ruby-position", "ruby-span", "size", "speak-header", "speak-numeral", "speak-punctuation", "speak", "speech-rate", "stress", "string-set", "table-layout", "target-name", "target-new", "target-position", "target", "text-align-last", "text-align", "text-decoration", "text-emphasis", "text-height", "text-indent", "text-justify", "text-outline", "text-shadow", "text-transform", "text-wrap", "top", "transform-origin", "transform-style", "transform", "transition-delay", "transition-duration", "transition-property", "transition-timing-function", "transition", "unicode-bidi", "vertical-align", "visibility", "voice-balance", "voice-duration", "voice-family", "voice-pitch-range", "voice-pitch", "voice-rate", "voice-stress", "voice-volume", "volume", "white-space-collapse", "white-space", "widows", "width", "word-break", "word-spacing", "word-wrap", "z-index"],
+ "function": ["rgb", "rgba", "url", "attr", "counter", "counters"],
+ "constant": ["absolute", "after-edge", "after", "all-scroll", "all", "alphabetic", "always", "antialiased", "armenian", "auto", "avoid-column", "avoid-page", "avoid", "balance", "baseline", "before-edge", "before", "below", "bidi-override", "block-line-height", "block", "bold", "bolder", "border-box", "both", "bottom", "box", "break-all", "break-word", "capitalize", "caps-height", "caption", "center", "central", "char", "circle", "cjk-ideographic", "clone", "close-quote", "col-resize", "collapse", "column", "consider-shifts", "contain", "content-box", "cover", "crosshair", "cubic-bezier", "dashed", "decimal-leading-zero", "decimal", "default", "disabled", "disc", "disregard-shifts", "distribute-all-lines", "distribute-letter", "distribute-space", "distribute", "dotted", "double", "e-resize", "ease-in", "ease-in-out", "ease-out", "ease", "ellipsis", "end", "exclude-ruby", "fill", "fixed", "georgian", "glyphs", "grid-height", "groove", "hand", "hanging", "hebrew", "help", "hidden", "hiragana-iroha", "hiragana", "horizontal", "icon", "ideograph-alpha", "ideograph-numeric", "ideograph-parenthesis", "ideograph-space", "ideographic", "inactive", "include-ruby", "inherit", "initial", "inline-block", "inline-box", "inline-line-height", "inline-table", "inline", "inset", "inside", "inter-ideograph", "inter-word", "invert", "italic", "justify", "katakana-iroha", "katakana", "keep-all", "last", "left", "lighter", "line-edge", "line-through", "line", "linear", "list-item", "local", "loose", "lower-alpha", "lower-greek", "lower-latin", "lower-roman", "lowercase", "lr-tb", "ltr", "mathematical", "max-height", "max-size", "medium", "menu", "message-box", "middle", "move", "n-resize", "ne-resize", "newspaper", "no-change", "no-close-quote", "no-drop", "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap", "nw-resize", "oblique", "open-quote", "outset", "outside", "overline", "padding-box", "page", "pointer", "pre-line", "pre-wrap", "pre", "preserve-3d", "progress", "relative", "repeat-x", "repeat-y", "repeat", "replaced", "reset-size", "ridge", "right", "round", "row-resize", "rtl", "s-resize", "scroll", "se-resize", "separate", "slice", "small-caps", "small-caption", "solid", "space", "square", "start", "static", "status-bar", "step-end", "step-start", "steps", "stretch", "strict", "sub", "super", "sw-resize", "table-caption", "table-cell", "table-column-group", "table-column", "table-footer-group", "table-header-group", "table-row-group", "table-row", "table", "tb-rl", "text-after-edge", "text-before-edge", "text-bottom", "text-size", "text-top", "text", "thick", "thin", "transparent", "underline", "upper-alpha", "upper-latin", "upper-roman", "uppercase", "use-script", "vertical-ideographic", "vertical-text", "visible", "w-resize", "wait", "whitespace", "z-index", "zero"],
+ "color": ["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"],
+ "font": ["arial", "century", "comic", "courier", "garamond", "georgia", "helvetica", "impact", "lucida", "symbol", "system", "tahoma", "times", "trebuchet", "utopia", "verdana", "webdings", "sans-serif", "serif", "monospace"],
+ "pseudo.element": ["after", "before", "first-letter", "first-line", "moz-selection", "selection"],
+ "pseudo.class": ["active", "checked", "disabled", "empty", "enabled", "first-child", "first-of-type", "focus", "hover", "indeterminate", "invalid", "last-child", "last-of-type", "link", "not", "nth-child", "nth-last-child", "nth-last-of-type", "nth-of-type", "only-child", "only-of-type", "required", "root", "target", "valid", "visited"]
+}
829 plugins-client/ext.codecomplete/modes/php.json
View
829 additions, 0 deletions not shown
30 plugins-client/ext.codecomplete/snippet_completer.js
View
@@ -1,5 +1,9 @@
-var globalRequire = require;
-
+/**
+ * Cloud9 Language Foundation
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
define(function(require, exports, module) {
var completeUtil = require("ext/codecomplete/complete_util");
@@ -10,24 +14,7 @@ var completer = module.exports = Object.create(baseLanguageHandler);
var snippetCache = {}; // extension -> snippets
completer.handlesLanguage = function(language) {
- return true;
-};
-
-completer.fetchText = function(staticPrefix, path) {
- var xhr = new XMLHttpRequest();
- xhr.open('GET', staticPrefix + "/" + path, false);
- try {
- xhr.send();
- }
- // Likely we got a cross-script error (equivalent with a 404 in our cloud setup)
- catch(e) {
- return false;
- }
-
- if(xhr.status === 200)
- return xhr.responseText;
- else
- return false;
+ return language === "javascript";
};
completer.complete = function(doc, fullAst, pos, currentNode, callback) {
@@ -41,7 +28,7 @@ completer.complete = function(doc, fullAst, pos, currentNode, callback) {
if (snippets === undefined) {
var text;
if (this.language)
- text = this.fetchText(this.staticPrefix, 'ext/codecomplete/snippets/' + this.language + '.json');
+ text = completeUtil.fetchText(this.staticPrefix, 'ext/codecomplete/snippets/' + this.language + '.json');
snippets = text ? JSON.parse(text) : {};
// Cache
snippetCache[this.language] = snippets;
@@ -62,5 +49,4 @@ completer.complete = function(doc, fullAst, pos, currentNode, callback) {
}));
};
-
});
3  plugins-client/ext.codecomplete/snippet_completer_test.js
View
@@ -8,6 +8,7 @@ define(function(require, exports, module) {
var Document = require("ace/document").Document;
var assert = require("ace/test/assertions");
var completer = require("ext/codecomplete/snippet_completer");
+var completeUtil = require("ext/codecomplete/complete_util");
function matchSorter(matches) {
matches.sort(function(a, b) {
@@ -20,7 +21,7 @@ function matchSorter(matches) {
});
}
-completer.fetchText = function(staticPrefix, path) {
+completeUtil.fetchText = function(staticPrefix, path) {
return require('fs').readFileSync(__dirname + "/../" + path.replace("ext/", "ext."), 'ascii');
};
13 plugins-client/ext.codetools/codetools.js
View
@@ -22,14 +22,11 @@ module.exports = ext.register("ext/codetools/codetools", {
register: function(plugin) {
var _self = this;
- if (typeof ceEditor !== "undefined")
- return attachCE();
-
- ide.addEventListener("init.ext/code/code", attachCE);
- function attachCE() {
- if (!ceEditor.$codeToolsAttached)
- _self.attachEditorEvents(ceEditor);
- }
+ ide.addEventListener("init.ext/code/code", function attachCE() {
+ var code = require("ext/code/code");
+ if (!code.amlEditor.$codeToolsAttached)
+ _self.attachEditorEvents(code.amlEditor);
+ });
},
attachEditorEvents: function(amlEditor) {
18 plugins-client/ext.colorpicker/colorpicker.js
View
@@ -166,8 +166,8 @@ module.exports = ext.register("ext/colorpicker/colorpicker", {
if (a) {
apf.removeEventListener("keydown", a.listeners.onKeyDown);
a.editor.removeEventListener("mousewheel", a.listeners.onScroll);
+ a.editor.removeEventListener("mousedown", a.listeners.onScroll);
ide.removeEventListener("codetools.cursorchange", a.listeners.onCursorChange);
- ide.removeEventListener("codetools.selectionchange", a.listeners.onSelectionChange);
delete _self.$activeColor;
_self.hideColorTooltips(a.editor);
_self.colorpicker.$input.blur();
@@ -223,8 +223,8 @@ module.exports = ext.register("ext/colorpicker/colorpicker", {
var editor = e.editor;
var line = doc.getLine(1);
- if (!(e.amlEditor.syntax == "css" || e.amlEditor.syntax == "svg"
- || e.amlEditor.syntax == "html" || (line && line.indexOf("<a:skin") > -1)))
+ if (!(e.amlEditor.syntax == "css" || e.amlEditor.syntax == "svg" ||
+ (line && line.indexOf("<a:skin") > -1)))
return;
line = doc.getLine(pos.row);
@@ -432,7 +432,7 @@ module.exports = ext.register("ext/colorpicker/colorpicker", {
// set appropriate event listeners, that will be removed when the colorpicker
// hides.
- var onKeyDown, onScroll, onCursorChange, onSelectionChange;
+ var onKeyDown, onScroll, onCursorChange;
var _self = this;
apf.addEventListener("keydown", onKeyDown = function(e) {
var a = _self.$activeColor;
@@ -458,8 +458,7 @@ module.exports = ext.register("ext/colorpicker/colorpicker", {
var pos = e.pos.start;
var range = a.marker[0];
- if (pos.row < range.start.row || pos.row > range.end.row
- || pos.column < range.start.column || pos.column > range.end.column)
+ if (!range.contains(pos))
menu.hide();
});
@@ -471,6 +470,8 @@ module.exports = ext.register("ext/colorpicker/colorpicker", {
menu.hide();
});
+
+ editor.addEventListener("mousedown", onScroll);
var id = "colorpicker" + parsed.hex + pos.row;
delete this.$activeColor;
@@ -492,8 +493,7 @@ module.exports = ext.register("ext/colorpicker/colorpicker", {
listeners: {
onKeyDown: onKeyDown,
onScroll: onScroll,
- onCursorChange: onCursorChange,
- onSelectionChange: onSelectionChange
+ onCursorChange: onCursorChange
}
};
if (parsed.type == "rgb") {
@@ -610,7 +610,7 @@ module.exports = ext.register("ext/colorpicker/colorpicker", {
if (!range)
return;
a.marker[0] = range;
- doc.replace(range, newColor);
+ range.end = doc.replace(range, newColor);
a.current = newColor;
}, 200);
},
76 plugins-client/ext.csslanguage/css_handler.js
View
@@ -0,0 +1,76 @@
+/**
+ * Cloud9 Language Foundation
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
+define(function(require, exports, module) {
+
+var baseLanguageHandler = require("ext/language/base_handler");
+var CSSLint = require("ext/csslanguage/csslint");
+var handler = module.exports = Object.create(baseLanguageHandler);
+
+handler.handlesLanguage = function(language) {
+ return language === "css";
+};
+
+handler.analyze = function(doc, ast, callback) {
+ callback(handler.analyzeSync(doc, ast));
+};
+
+var CSSLint_RULESET = {
+ "adjoining-classes" : 1,
+ "box-model" : 1,
+ "box-sizing" : 1,
+ "compatible-vendor-prefixes" : 1,
+ "display-property-grouping" : 1,
+ "duplicate-background-images" : 1,
+ "duplicate-properties" : 1,
+ "empty-rules" : 1,
+ "errors" : 1,
+ "fallback-colors" : 1,
+ "floats" : 1,
+ "font-faces" : 1,
+ "font-sizes" : 1,
+ "gradients" : 1,
+ // "ids" : 1,
+ "import" : 1,
+ "important" : 1,
+ "known-properties" : 1,
+ "outline-none" : 1,
+ "overqualified-elements" : 1,
+ "qualified-headings" : 1,
+ "regex-selectors" : 1,
+ "rules-count" : 1,
+ "shorthand" : 1,
+ "star-property-hack" : 1,
+ "text-indent" : 1,
+ "underscore-property-hack" : 1,
+ "unique-headings" : 1,
+ "universal-selector" : 1,
+ "unqualified-attributes" : 1,
+ "vendor-prefix" : 1,
+ "zero-units" : 1
+};
+
+handler.analyzeSync = function(doc, ast) {
+ var value = doc.getValue();
+ value = value.replace(/^(#!.*\n)/, "//$1");
+
+ var results = CSSLint.verify(value, CSSLint_RULESET);
+ var warnings = results.messages;
+
+ return warnings.map(function(warning) {
+ return {
+ pos: {
+ sl: warning.line-1,
+ sc: warning.col-1
+ },
+ type: warning.type,
+ level: warning.type,
+ message: warning.message
+ };
+ });
+};
+
+});
35 plugins-client/ext.csslanguage/csslanguage.js
View
@@ -0,0 +1,35 @@
+/**
+ * Cloud9 Language Foundation
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
+define(function(require, exports, module) {
+
+var ext = require("core/ext");
+var editors = require("ext/editors/editors");
+var language = require("ext/language/language");
+
+module.exports = ext.register("ext/csslanguage/csslanguage", {
+ name : "CSS Language Support",
+ dev : "Ajax.org",
+ type : ext.GENERAL,
+ deps : [editors, language],
+ nodes : [],
+ alone : true,
+
+ init : function() {
+ language.registerLanguageHandler("ext/csslanguage/css_handler");
+ },
+
+ enable : function() {
+ },
+
+ disable : function() {
+ },
+
+ destroy : function() {
+ }
+});
+
+});
9,046 plugins-client/ext.csslanguage/csslint.js
View
9,046 additions, 0 deletions not shown
34 plugins-client/ext.csslanguage/csslint_test.js
View
@@ -0,0 +1,34 @@
+if (typeof process !== "undefined") {
+ require("amd-loader");
+ require("../../test/setup_paths");
+}
+
+define(function(require, exports, module) {
+
+var assert = require("ace/test/assertions");
+//var handler = require('ext/jslanguage/jshint');
+var LanguageWorker = require('ext/language/worker').LanguageWorker;
+var EventEmitter = require("ace/lib/event_emitter").EventEmitter;
+
+module.exports = {
+
+ "test integration base case" : function(next) {
+ var emitter = Object.create(EventEmitter);
+ emitter.emit = emitter._dispatchEvent;
+ emitter.on("markers", function(markers) {
+ // false color & empty selector
+ assert.equal(markers.length, 2);
+ next();
+ });
+ var worker = new LanguageWorker(emitter);
+ worker.register("ext/csslanguage/css_handler");
+ assert.equal(worker.handlers.length, 1);
+ worker.switchFile("test.css", "css", "#hello { color: 1px; } #nonused{}");
+ }
+};
+
+});
+
+if (typeof module !== "undefined" && module === require.main) {
+ require("asyncjs").test.testcase(module.exports).exec()
+}
6 plugins-client/ext.acebugs/package.json → plugins-client/ext.csslanguage/package.json
View
@@ -1,11 +1,11 @@
{
- "name": "ext.acebugs",
+ "name": "ext.csslanguage",
"version": "0.0.1",
- "main": "acebugs-ext.js",
+ "main": "csslanguage-ext.js",
"private": true,
"plugin": {
"provides": [
- "ext.acebugs"
+ "ext.csslanguage"
],
"consumes": [
"client-plugins"
8 plugins-client/ext.debugger/breakpoints.js
View
@@ -97,9 +97,9 @@ module.exports = {
ide.addEventListener("tab.afterswitch", function(e) {
var page = e.nextPage;
- if (!page || !page.$editor || !page.$editor.ceEditor)
+ if (!page || !page.$editor || page.$editor.path != "ext/code/code")
return;
- var ace = page.$editor.ceEditor.$editor;
+ var ace = page.$editor.amlEditor.$editor;
if (!ace.$breakpointListener)
_self.initEditor(ace);
@@ -308,8 +308,8 @@ module.exports = {
$syncOpenFiles: function() {
// var tabFiles = ide.getAllPageModels();
var page = tabEditors.$activepage;
- if (page && page.$editor && page.$editor.ceEditor) {
- var session = page.$editor.ceEditor.$editor.session;
+ if (page && page.$editor && page.$editor.path == "ext/code/code") {
+ var session = page.$editor.amlEditor.$editor.session;
this.updateSession(session);
}
}
8 plugins-client/ext.debugger/debugger.js
View
@@ -21,7 +21,7 @@ var apfhook = require("./apfhook");
require("ext/debugger/inspector");
-/*global dbInteractive txtCode dbg ceEditor
+/*global dbInteractive txtCode dbg
dbgVariable pgDebugNav tabDebug dgVars*/
module.exports = ext.register("ext/debugger/debugger", {
@@ -99,13 +99,13 @@ module.exports = ext.register("ext/debugger/debugger", {
if (dbg.state != "stopped")
return false;
if (event instanceof KeyboardEvent &&
- (!apf.activeElement || apf.activeElement != ceEditor))
+ (!apf.activeElement || !apf.activeElement.$editor || apf.activeElement.$editor.path != "ext/code/code"))
return false;
return true;
},
findEditor: function(editor) {
- if (editor && editor.ceEditor)
- return editor.ceEditor.$editor;
+ if (editor && editor.amlEditor)
+ return editor.amlEditor.$editor;
return editor;
}
});
6 plugins-client/ext.debugger/sources.js
View
@@ -93,8 +93,8 @@ module.exports = {
}
function updateMarker(frame) {
- var ceEditor = editors.currentEditor && editors.currentEditor.ceEditor;
- var session = ceEditor && ceEditor.$editor.session;
+ var amlEditor = editors.currentEditor && editors.currentEditor.amlEditor;
+ var session = amlEditor && amlEditor.$editor.session;
if (!session)
return;
@@ -102,7 +102,7 @@ module.exports = {
session.$stepMarker && removeMarker(session, "step");
if (frame) {
- var path = ceEditor.xmlRoot.getAttribute("path");
+ var path = amlEditor.xmlRoot.getAttribute("path");
var framePath = frame.getAttribute("scriptPath");
var row = parseInt(frame.getAttribute("line"), 10);
if (frame.hasAttribute("istop")) {
10 plugins-client/ext.editors/editors.js
View
@@ -56,10 +56,12 @@ module.exports = ext.register("ext/editors/editors", {
}), 40000);
oExtension.fileExtensions.each(function(mime){
+ // force lower-case, to account for other LowerCase checks below
+ mime = mime.toLowerCase();
(_self.fileExtensions[mime] || (_self.fileExtensions[mime] = [])).push(oExtension);
});
- if (!this.fileExtensions["default"] || (oExtension.name && oExtension.name == "Code Editor"))
+ if (!this.fileExtensions["default"] || (oExtension.name && oExtension.path == "ext/code/code"))
this.fileExtensions["default"] = oExtension;
},
@@ -287,7 +289,7 @@ module.exports = ext.register("ext/editors/editors", {
anims.animateMultiple([
{ duration : duration, node: ext, top : (this.showTabs || preview ? 0 : -16) + "px"},
- //{ duration : duration, node: ext, height : ((this.showTabs || preview ? 0 : 16) + ph.offsetHeight - d[1]) + "px"},
+ // { duration : duration, node: ext, height : ((this.showTabs || preview ? 0 : 16) + ph.offsetHeight - d[1]) + "px"},
{ duration : duration, node: tabEditors.$buttons, height: (this.showTabs || preview ? 22 : 7) + "px"},
{ duration : duration, node: this.buttons.add, opacity : dir ? 1 : 0},
{ duration : duration, node: this.buttons.add, height : (dir ? 17 : 10) + "px"},
@@ -461,6 +463,8 @@ module.exports = ext.register("ext/editors/editors", {
doc: doc
});
+ apf.setStyleClass(tabEditors.$ext, "", ["empty"])
+
if (active === false) // init && !
return {editor: editor, page: fake};
@@ -574,6 +578,8 @@ module.exports = ext.register("ext/editors/editors", {
editor.clear && editor.clear();
require("ext/editors/editors").currentEditor = null;
+
+ apf.setStyleClass(tabEditors.$ext, "empty")
}
//Destroy the app page if it has no application instance
27 plugins-client/ext.filesystem/filesystem.js
View
@@ -22,7 +22,7 @@ module.exports = ext.register("ext/filesystem/filesystem", {
alone : true,
deps : [],
autodisable : ext.ONLINE | ext.LOCAL,
-
+
createFileNodeFromPath : function (path, attributes) {
var name = path.split("/").pop();
var node = apf.n("<file />")
@@ -320,21 +320,21 @@ module.exports = ext.register("ext/filesystem/filesystem", {
});
},
- beforeStopRename : function(name) {
- // Returning false from this function will cancel the rename. We do this
- // when the name to which the file is to be renamed contains invalid
- // characters
- var match = name.match(/^(?:\w|[.])(?:\w|[.-])*$/);
-
- return match !== null && match[0] == name;
- },
-
beforeRename : function(node, name, newPath, isCopyAction, isReplaceAction) {
var path = node.getAttribute("path");
var page = tabEditors.getPage(path);
-
- if (name)
+
+ if (name) {
+ // Returning false from this function will cancel the rename. We do this
+ // when the name to which the file is to be renamed contains invalid
+ // characters
+ var match = name.match(/^(?:\w|[.])(?:\w|[.-])*$/);
+ if (!(match !== null && match[0] == name)) {
+ return false;
+ }
+
newPath = path.replace(/^(.*\/)[^\/]+$/, "$1" + name);
+ }
else
name = newPath.match(/[^\/]+$/);
@@ -367,6 +367,9 @@ module.exports = ext.register("ext/filesystem/filesystem", {
replace: isReplaceAction,
isFolder: node.getAttribute("type") === "folder"
});
+
+ // let us continue!
+ return true;
},
beforeMove: function(parent, node) {
4 plugins-client/ext.formatjson/formatjson.js
View
@@ -55,8 +55,8 @@ module.exports = ext.register("ext/formatjson/formatjson", {
bindKey : {mac: "Shift-Command-J", win: "Ctrl-Shift-J"},
hint: "reformat the current JSON document",
isAvailable : function(editor){
- if (editor && editor.ceEditor) {
- var range = editor.ceEditor.$editor.getSelectionRange();
+ if (editor && editor.amlEditor && editor.amlEditor.$editor.path == "ext/code/code") {
+ var range = editor.amlEditor.$editor.getSelectionRange();
return range.start.row == range.end.row
&& range.start.column == range.end.column
}
4 plugins-client/ext.gitblame/gitblame.js
View
@@ -33,7 +33,7 @@ module.exports = ext.register("ext/gitblame/gitblame", {
_self.startBlame();
},
isAvailable : function(editor){
- return editor && editor.ceEditor;
+ return editor && editor.path === "ext/code/code";
}
}), 500);
@@ -42,7 +42,7 @@ module.exports = ext.register("ext/gitblame/gitblame", {
_self.startBlame();
},
isAvailable : function(editor){
- return editor && editor.ceEditor;
+ return editor && editor.path === "ext/code/code";
}
}), 909);
},
4 plugins-client/ext.gotofile/gotofile.js
View
@@ -531,8 +531,8 @@ module.exports = ext.register("ext/gotofile/gotofile", {
winGoToFile.hide();
setTimeout(function() {
- if (editors.currentEditor && editors.currentEditor.ceEditor)
- editors.currentEditor.ceEditor.focus();
+ if (editors.currentEditor && editors.currentEditor.amlEditor)
+ editors.currentEditor.amlEditor.focus();
}, 0);
callback && callback();
11 plugins-client/ext.guidedtour/guidedtour.js
View
@@ -251,6 +251,7 @@ module.exports = ext.register("ext/guidedtour/guidedtour", {
// forwards and back, so we DRY
commonStepOps: function(step){
function getCurrentEl(){
+ var amlEditor = require("ext/code/code").amlEditor;
if (step.el !== undefined) {
if(typeof step.el == "string")
step.el = self[step.el];
@@ -259,8 +260,8 @@ module.exports = ext.register("ext/guidedtour/guidedtour", {
_self.currentEl = step.el;
}
// All of these fix issues with elements not being available when this plugin loads
- else if (step.div == "ceEditor"){
- _self.currentEl = ceEditor;
+ else if (step.div == "editor"){
+ _self.currentEl = amlEditor;
}
else if (step.div == "barIdeStatus") {
_self.currentEl = barIdeStatus;
@@ -272,14 +273,14 @@ module.exports = ext.register("ext/guidedtour/guidedtour", {
else if (step.div == "expandedDbg") {
_self.currentEl = expandedDbg;
}
- else if (step.div == "ceEditorGutter") {
- _self.currentEl = (apf.XPath || apf.runXpath() || apf.XPath).selectNodes('DIV[2]/DIV[1]/DIV[2]', ceEditor.$ext);
+ else if (step.div == "editorGutter") {
+ _self.currentEl = (apf.XPath || apf.runXpath() || apf.XPath).selectNodes('DIV[2]/DIV[1]/DIV[2]', amlEditor.$ext);
}
else if (step.node !== undefined) {
_self.currentEl = (apf.XPath || apf.runXpath() || apf.XPath).selectNodes(step.div, apf.document.selectSingleNode(step.node).$ext);
}
else {
- _self.currentEl = (apf.XPath || apf.runXpath() || apf.XPath).selectNodes(step.div, ceEditor.$ext);
+ _self.currentEl = (apf.XPath || apf.runXpath() || apf.XPath).selectNodes(step.div, amlEditor.$ext);
}
}
else {
8 plugins-client/ext.guidedtour/tour.js
View
@@ -86,7 +86,7 @@ this.tour = {
require("ext/tree/tree").refresh();
},
el: undefined,
- div: "ceEditor",
+ div: "editor",
desc: "Here's a quick Node.js example, saved as \"helloWorld-guidedTour.js.\"",
extra: -40,
pos: "left",
@@ -99,7 +99,7 @@ this.tour = {
}
},
el: undefined,
- div: "ceEditorGutter",
+ div: "editorGutter",
desc: "The gutter does more than show line numbers. It also detects and displays warnings and errors in your code. If you're debugging a Node.js application, you can also set breakpoints here.",
extraTop: -40,
pos: "right",
@@ -171,11 +171,11 @@ this.tour = {
before: function() {
//winRunCfgNew.hide();
//ideConsole.disable();
- var doc = require("ext/editors/editors").currentEditor.ceEditor.getSession();
+ var doc = require("ext/code/code").amlEditor.getSession();
doc.setBreakpoints([1]);
},
el: undefined,
- div: "ceEditorGutter",
+ div: "editorGutter",
extraTop: -40,
desc: "We're ready to test our code, so we've inserted a breakpoint on this line by clicking in the gutter. Before debugging, though, we'll need to set up a debugging scenario.",
pos: "right",
66 plugins-client/ext.htmllanguage/html_completer.js
View
@@ -0,0 +1,66 @@
+/**
+ * Cloud9 Language Foundation
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
+define(function(require, exports, module) {
+
+var completeUtil = require("ext/codecomplete/complete_util");
+var baseLanguageHandler = require('ext/language/base_handler');
+var htmlSnippets = require("ext/htmllanguage/snippets");
+
+var completer = module.exports = Object.create(baseLanguageHandler);
+
+completer.handlesLanguage = function(language) {
+ return language === "html";
+};
+
+var JADE_REGEX = /.*?([a-zA-Z]*)([.#])([\w]+)/;
+var JADE_ID_REGEX = /[a-zA-Z_0-9\$\_.#]/;
+
+completer.complete = function(doc, fullAst, pos, currentNode, callback) {
+ var line = doc.getLine(pos.row);
+ var match = JADE_REGEX.exec(line.substring(0, pos.column));
+ if(match) {
+ var replaceText;
+ var snippet = htmlSnippets[match[1]];
+ if (snippet) {
+ replaceText = snippet.replace("<" + match[1] + ">",
+ ["<", match[1], match[2] === "." ? " class=\"" : " id=\"",
+ match[3], "\">"].join(""));
+ }
+ else {
+ replaceText = ["<", match[1] || "div",
+ match[2] === "." ? " class=\"" : " id=\"", match[3],
+ "\">^^", "</", match[1] || "div", ">"].join("");
+ }
+ callback([{
+ name : match[1]+match[2]+match[3],
+ replaceText : replaceText,
+ doc : "<pre>" + replaceText.replace("\^\^", "&#9251;") + "</pre>",
+ icon : null,
+ meta : "Jade-Haml",
+ idRegex : JADE_ID_REGEX,
+ priority : 100
+ }]);
+ }
+ else {
+ var identifier = completeUtil.retrievePreceedingIdentifier(line, pos.column);
+ var allIdentifiers = Object.keys(htmlSnippets);
+ var matches = completeUtil.findCompletions(identifier, allIdentifiers);
+ callback(matches.map(function(m) {
+ return {
+ name : m,
+ replaceText : htmlSnippets[m],
+ doc : "<pre>" + htmlSnippets[m].replace("\^\^", "&#9251;") + "</pre>",
+ icon : null,
+ meta : "snippet",
+ priority : 2
+ };
+ }));
+ }
+};
+
+
+});
60 plugins-client/ext.htmllanguage/html_completer_test.js
View
@@ -0,0 +1,60 @@
+if (typeof process !== "undefined") {
+ require("amd-loader");
+ require("../../test/setup_paths");
+}
+
+define(function(require, exports, module) {
+
+var assert = require("ace/test/assertions");
+var Document = require("ace/document").Document;
+var completer = require("ext/htmllanguage/html_completer");
+
+module.exports = {
+
+ "test basic snippet completion 1" : function(next) {
+ var doc = new Document("<bo");
+ var matches = completer.complete(doc, null, {row: 0, column: 3}, null, function(matches) {
+ console.log("Matches:", matches);
+ assert.equal(matches.length, 1);
+ assert.equal(matches[0].name, "body");
+ next();
+ });
+ },
+
+ "test basic snippet completion 2" : function(next) {
+ var doc = new Document("link");
+ var matches = completer.complete(doc, null, {row: 0, column: 3}, null, function(matches) {
+ console.log("Matches:", matches);
+ assert.equal(matches.length, 1);
+ assert.ok(matches[0].replaceText.match(/^<link .*stylesheet.*css.*\/>$/));
+ next();
+ });
+ },
+
+ "test Jade/Haml completion 1" : function(next) {
+ var doc = new Document("\n.breaty");
+ var matches = completer.complete(doc, null, {row: 1, column: 7}, null, function(matches) {
+ console.log("Matches:", matches);
+ assert.equal(matches.length, 1);
+ assert.equal(matches[0].replaceText, '<div class="breaty">^^</div>');
+ next();
+ });
+ },
+
+ "test Jade/Haml completion 2" : function(next) {
+ var doc = new Document("<span>anything</span>table.cool<p>stuff</p>");
+ var matches = completer.complete(doc, null, {row: 0, column: 31}, null, function(matches) {
+ console.log("Matches:", matches);
+ assert.equal(matches.length, 1);
+ assert.ok(matches[0].replaceText.match(/^<table/));
+ assert.ok(matches[0].replaceText.match(/<\/table>$/));
+ next();
+ });
+ }
+};
+
+});
+
+if (typeof module !== "undefined" && module === require.main) {
+ require("asyncjs").test.testcase(module.exports).exec();
+}
35 plugins-client/ext.htmllanguage/htmllanguage.js
View
@@ -0,0 +1,35 @@
+/**
+ * Cloud9 Language Foundation
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
+define(function(require, exports, module) {
+
+var ext = require("core/ext");
+var editors = require("ext/editors/editors");
+var language = require("ext/language/language");
+
+module.exports = ext.register("ext/htmllanguage/htmllanguage", {
+ name : "HTML Language Support",
+ dev : "Ajax.org",
+ type : ext.GENERAL,
+ deps : [editors, language],
+ nodes : [],
+ alone : true,
+
+ init : function() {
+ language.registerLanguageHandler("ext/htmllanguage/html_completer");
+ },
+
+ enable : function() {
+ },
+
+ disable : function() {
+ },
+
+ destroy : function() {
+ }
+});
+
+});
14 plugins-client/ext.htmllanguage/package.json
View
@@ -0,0 +1,14 @@
+{
+ "name": "ext.htmllanguage",
+ "version": "0.0.1",
+ "main": "htmllanguage-ext.js",
+ "private": true,
+ "plugin": {
+ "provides": [
+ "ext.htmllanguage"
+ ],
+ "consumes": [
+ "client-plugins"
+ ]
+ }
+}
24 plugins-client/ext.codecomplete/snippets/html.json → plugins-client/ext.htmllanguage/snippets.js
View
@@ -1,13 +1,29 @@
-{
- "script": "<script type=\"text/javascript\" charset=\"utf-8\">\n^^\n</script>",
+define(function(require, exports, module) {
+
+module.exports = {
+ "script": "<script type=\"text/javascript\" src=\"^^\"></script>",
"csslink": "<link rel=\"stylesheet\" href=\"^^\" type=\"text/css\" />",
+ "link": "<link rel=\"stylesheet\" href=\"^^\" type=\"text/css\" />",
+ "style": "<style type=\"text/css\">\n ^^\n</style>",
"amailto": "<a href=\"mailto:^^\"></a>",
- "table": "<table>\n ^^\n</table>",
+ "html": "<!DOCTYPE html>\n<html>\n ^^\n</html>",
+ "body": "<body>\n ^^\n</body>",
+ "head": "<head>\n ^^\n</head>",
+ "table": "<table>\n <tr>\n <td>^^</td>\n </tr>\n</table>",
+ "th": "<th>\n ^^\n</th>",
"tr": "<tr>\n ^^\n</tr>",
"td": "<td>^^</td>",
"divc": "<div class=\"^^\"></div>",
"div": "<div>^^</div>",
"spanc": "<span class=\"^^\"></span>",
"span": "<span>^^</span>",
+ "form": "<form>\n <input type=\"text\" name=\"^^\"/>\n <input type=\"submit\" value=\"Submit\"/>\n</form>",
+ "input": "<input type=\"text\" name=\"^^\"/>",
+ "password": "<input type=\"password\" name=\"^^\"/>",
+ "textarea": "<input type=\"textarea\" name=\"^^\"/>",
+ "img": "<img src=\"^^\"></img>",
+ "label" : "<label for=\"\">^^</label>",
"lorem": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit,\nsed diam nonummy nibh euismod tincidunt ut laoreet dolore\nmagna aliquam erat volutpat. Ut wisi enim ad minim veniam,\nquis nostrud exerci tation ullamcorper suscipit lobortis nisl\nut aliquip ex ea commodo consequat. Duis autem vel eum iriure\ndolor in hendrerit in vulputate velit esse molestie consequat,\nvel illum dolore eu feugiat nulla facilisis at vero eros et\naccumsan et iusto odio dignissim qui blandit praesent luptatum\nzzril delenit augue duis dolore te feugait nulla facilisi.\nNam liber tempor cum soluta nobis eleifend option congue\nnihil imperdiet doming id quod mazim placerat facer possim\nassum. Typi non habent claritatem insitam; est usus legentis\nin iis qui facit eorum claritatem. Investigationes\ndemonstraverunt lectores legere me lius quod ii legunt saepius.\nClaritas est etiam processus dynamicus, qui sequitur mutationem\nconsuetudium lectorum. Mirum est notare quam littera gothica,\nquam nunc putamus parum claram, anteposuerit litterarum formas\nhumanitatis per seacula quarta decima et quinta decima. Eodem\nmodo typi, qui nunc nobis videntur parum clari, fiant sollemnes\nin futurum.^^"
-}
+};
+
+});
5 plugins-client/ext.jslanguage/jshint.js
View
@@ -45,7 +45,8 @@ handler.analyzeSync = function(doc, ast) {
laxcomma: true,
loopfunc: true,
lastsemic: true,
- multistr: true
+ multistr: true,
+ onecase: true
});
lint.errors.forEach(function(warning) {
@@ -88,6 +89,8 @@ handler.analyzeSync = function(doc, ast) {
* like / * global foo: true * /
*/
handler.getGlobals = function() {
+ if (!lint.errors || !this.isFeatureEnabled("jshint"))
+ return {};
var array = lint.data().globals;
if (!array) // no data (yet?)
return {};
1  plugins-client/ext.jslanguage/jslanguage.js
View
@@ -24,6 +24,7 @@ module.exports = ext.register("ext/jslanguage/jslanguage", {
// indirectly invoked by scope_analyzer: 'ext/jslanguage/jshint'
language.registerLanguageHandler('ext/jslanguage/debugger');
language.registerLanguageHandler('ext/jslanguage/outline');
+ language.registerLanguageHandler('ext/jslanguage/jumptodef');
},
enable : function() {
30 plugins-client/ext.jslanguage/jumptodef.js
View
@@ -0,0 +1,30 @@
+/**
+ * JavaScript jump to definition.
+ *
+ * @copyright 2011, Ajax.org B.V.
+ * @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
+ */
+define(function(require, exports, module) {
+
+var baseLanguageHandler = require('ext/language/base_handler');
+var handler = module.exports = Object.create(baseLanguageHandler);
+var scopes = require("ext/jslanguage/scope_analyzer");
+
+handler.handlesLanguage = function(language) {
+ return language === 'javascript';
+};
+
+handler.jumpToDefinition = function(doc, fullAst, pos, currentNode, callback) {
+ if (!fullAst)
+ return callback();
+ scopes.getVariablePositions(doc, fullAst, pos, currentNode, function (data) {
+ if (!data || !data.declarations || data.declarations.length === 0) {
+ return callback(null);
+ }
+
+ // invoke the callback with the position of the last declared variable
+ callback(data.declarations[data.declarations.length - 1]);
+ });
+};
+
+});
6 plugins-client/ext.jslanguage/outline.js
View
@@ -14,7 +14,9 @@ var NOT_EVENT_HANDLERS = {
traverseUp : true,
traverse : true,
topdown : true,
- traverseTopDown : true
+ traverseTopDown : true,
+ rewrite : true,
+ traverseAll : true
};
outlineHandler.handlesLanguage = function(language) {
@@ -22,6 +24,8 @@ outlineHandler.handlesLanguage = function(language) {
};
outlineHandler.outline = function(doc, ast, callback) {
+ if (!ast)
+ return callback();
callback({ body : extractOutline(doc, ast) });
};
15 plugins-client/ext.jslanguage/parse.js
View
@@ -17,10 +17,17 @@ handler.handlesLanguage = function(language) {
};
handler.parse = function(code, callback) {
- code = code.replace(/^(#!.*\n)/, "//$1");
- var ast = parser.parse(code);
- traverse.addParentPointers(ast);
- callback(ast);
+ var result;
+ try {
+ code = code.replace(/^(#!.*\n)/, "//$1");
+ result = parser.parse(code);
+ traverse.addParentPointers(result);
+ } catch (e) {
+ // Ignore any *fatal* parse errors; JSHint will report them
+ result = null;
+ }
+
+ callback(result);
};
handler.isParsingSupported = function() {
23 plugins-client/ext.jslanguage/scope_analyzer.js
View
@@ -621,9 +621,13 @@ handler.analyze = function(doc, ast, callback) {
jshintGlobals = jshint.getGlobals();
}
- var rootScope = new Scope();
- scopeAnalyzer(rootScope, ast);
- callback(markers.concat(jshintMarkers));
+ if (ast) {
+ var rootScope = new Scope();
+ scopeAnalyzer(rootScope, ast);
+ callback(markers.concat(jshintMarkers));
+ } else {
+ callback(jshintMarkers);
+ }
};
var isCallbackCall = function(node) {
@@ -722,6 +726,8 @@ handler.onCursorMovedNode = function(doc, fullAst, cursorPos, currentNode, callb
};
handler.getVariablePositions = function(doc, fullAst, cursorPos, currentNode, callback) {
+ if (!fullAst)
+ return callback();
var v;
var mainNode;
currentNode.rewrite(
@@ -787,15 +793,4 @@ handler.getVariablePositions = function(doc, fullAst, cursorPos, currentNode, ca
});
};
-handler.jumpToDefinition = function(doc, fullAst, pos, currentNode, callback) {
- handler.getVariablePositions(doc, fullAst, pos, currentNode, function (data) {
- if (!data || !data.declarations || data.declarations.length === 0) {
- return callback(null);
- }
-
- // invoke the callback with the position of the last declared variable
- callback(data.declarations[data.declarations.length - 1]);
- });
-};
-