summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMike Rennie2013-11-04 15:04:27 (EST)
committer Gerrit Code Review @ Eclipse.org2013-11-06 14:32:23 (EST)
commite87a824ecacc42f594b3238226ae615770dd80db (patch)
tree086ebae0e88dcd6e344dded690aad45e64fe862c
parentb2a774800e5fa498d417624977f1f608fe099c16 (diff)
downloadorg.eclipse.orion.client-e87a824ecacc42f594b3238226ae615770dd80db.zip
org.eclipse.orion.client-e87a824ecacc42f594b3238226ae615770dd80db.tar.gz
org.eclipse.orion.client-e87a824ecacc42f594b3238226ae615770dd80db.tar.bz2
Bug 419984 - Provide JS tools as their own pluginv20131106-1932refs/changes/50/18050/4
Change-Id: Ibf9d4bb2e20595a1664929762d2986a60a9ca75c Signed-off-by: Mike Rennie <Michael_Rennie@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.javascript/.project28
-rw-r--r--bundles/org.eclipse.orion.client.javascript/.settings/.jsdtscope7
-rw-r--r--bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.container1
-rw-r--r--bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.name1
-rw-r--r--bundles/org.eclipse.orion.client.javascript/META-INF/MANIFEST.MF6
-rw-r--r--bundles/org.eclipse.orion.client.javascript/about.html28
-rw-r--r--bundles/org.eclipse.orion.client.javascript/build.properties2
-rw-r--r--bundles/org.eclipse.orion.client.javascript/bundle.properties3
-rw-r--r--bundles/org.eclipse.orion.client.javascript/pom.xml31
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/images/javascript.gif (renamed from bundles/org.eclipse.orion.client.ui/web/images/javascript.gif)bin191 -> 191 bytes
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/images/javascript.png (renamed from bundles/org.eclipse.orion.client.ui/web/images/javascript.png)bin1060 -> 1060 bytes
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js456
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js76
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.html51
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js102
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/defaults.pref2
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.html18
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.js45
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.html18
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.js361
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/site/selfHostingRules.js1
-rw-r--r--bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js6
-rw-r--r--features/org.eclipse.orion.client-feature/feature.xml6
-rw-r--r--releng/org.eclipse.orion.client.releng/builder/orion.mini.xml3
24 files changed, 802 insertions, 450 deletions
diff --git a/bundles/org.eclipse.orion.client.javascript/.project b/bundles/org.eclipse.orion.client.javascript/.project
new file mode 100644
index 0000000..d05260c
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.orion.client.javascript</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ </natures>
+</projectDescription>
diff --git a/bundles/org.eclipse.orion.client.javascript/.settings/.jsdtscope b/bundles/org.eclipse.orion.client.javascript/.settings/.jsdtscope
new file mode 100644
index 0000000..ad160f0
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/.settings/.jsdtscope
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path=""/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+ <classpathentry kind="output" path=""/>
+</classpath>
diff --git a/bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.container b/bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.container
new file mode 100644
index 0000000..3bd5d0a
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.name b/bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.name
new file mode 100644
index 0000000..05bd71b
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
+Window \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/META-INF/MANIFEST.MF b/bundles/org.eclipse.orion.client.javascript/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..f2cd82d
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/META-INF/MANIFEST.MF
@@ -0,0 +1,6 @@
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.orion.client.javascript
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: bundle
diff --git a/bundles/org.eclipse.orion.client.javascript/about.html b/bundles/org.eclipse.orion.client.javascript/about.html
new file mode 100644
index 0000000..bdb75d6
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>October 17, 2013</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/build.properties b/bundles/org.eclipse.orion.client.javascript/build.properties
new file mode 100644
index 0000000..b035d87
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/build.properties
@@ -0,0 +1,2 @@
+bin.includes = META-INF/,\
+ bundle.properties
diff --git a/bundles/org.eclipse.orion.client.javascript/bundle.properties b/bundles/org.eclipse.orion.client.javascript/bundle.properties
new file mode 100644
index 0000000..4a3dc37
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/bundle.properties
@@ -0,0 +1,3 @@
+#Properties file for org.eclipse.orion.client.javascript
+Bundle-Vendor = Eclipse.org
+Bundle-Name = Orion JavaScript Tools \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/pom.xml b/bundles/org.eclipse.orion.client.javascript/pom.xml
new file mode 100644
index 0000000..ac8cce9
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/pom.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2013, IBM Corporation and others.
+
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Eclipse Public License v1.0
+ (http://www.eclipse.org/legal/epl-v10.html),
+ and the Eclipse Distribution License v1.0
+ (http://www.eclipse.org/org/documents/edl-v10.html).
+
+ Contributors:
+ IBM Corporation - initial implementation
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.eclipse.orion</groupId>
+ <artifactId>org.eclipse.orion.client.javascript</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+ <parent>
+ <groupId>org.eclipse.orion</groupId>
+ <artifactId>org.eclipse.orion.client.parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+
+</project> \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/images/javascript.gif b/bundles/org.eclipse.orion.client.javascript/web/images/javascript.gif
index 2c6816a..2c6816a 100644
--- a/bundles/org.eclipse.orion.client.ui/web/images/javascript.gif
+++ b/bundles/org.eclipse.orion.client.javascript/web/images/javascript.gif
Binary files differ
diff --git a/bundles/org.eclipse.orion.client.ui/web/images/javascript.png b/bundles/org.eclipse.orion.client.javascript/web/images/javascript.png
index 3a4fa74..3a4fa74 100644
--- a/bundles/org.eclipse.orion.client.ui/web/images/javascript.png
+++ b/bundles/org.eclipse.orion.client.javascript/web/images/javascript.png
Binary files differ
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js
new file mode 100644
index 0000000..4639a3d
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/occurrences.js
@@ -0,0 +1,456 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*global define console*/
+define([
+"esprima/esprima",
+"orion/Deferred"
+], function(Esprima, Deferred) {
+
+ /**
+ * @name javascript.JavaScriptOccurrences
+ * @description creates a new instance of the outliner
+ * @constructor
+ * @public
+ */
+ function JavaScriptOccurrences() {
+ }
+
+ JavaScriptOccurrences.prototype = /** @lends javascript.JavaScriptOccurrences.prototype*/ {
+ /**
+ * @name isOccurrenceInSelScope
+ * @description Computes if the occurrence scope is covered by the other scope
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} oScope The current occurrence scope
+ * @param {Object} wScope The scope to check
+ * @returns {Boolean} <code>true</code> if the given scope encloses the occurrence scope, <code>false</code> otherwise
+ */
+ isOccurrenceInSelScope: function(oScope, wScope) {
+ if (oScope.global && wScope.global) {
+ return true;
+ }
+ if (!oScope.global && !wScope.global && (oScope.name === wScope.name) && (oScope.loc.start.line === wScope.loc.start.line) &&
+ (oScope.loc.start.column === wScope.loc.start.column)) {
+ return true;
+ }
+ return false;
+ },
+
+ /**
+ * @name filterOccurrences
+ * @description Filters the computed occurrences given the context
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} context The current context
+ * @returns {Array|null} Returns the array of matches or <code>null</code>
+ */
+ filterOccurrences: function(context) {
+ if (!context.mScope) {
+ return null;
+ }
+ var matches = [];
+ for (var i = 0; i < context.occurrences.length; i++) {
+ if (this.isOccurrenceInSelScope(context.occurrences[i].scope, context.mScope)) {
+ matches.push({
+ readAccess: context.occurrences[i].readAccess,
+ line: context.occurrences[i].node.loc.start.line,
+ start: context.occurrences[i].node.loc.start.column + 1,
+ end: context.occurrences[i].node.loc.end.column,
+ description: (context.occurrences[i].readAccess ? 'Occurrence of "' : 'Write occurrence of "') + context.word + '"' //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$
+ });
+ }
+ }
+ return matches;
+ },
+
+ /**
+ * @name updateScope
+ * @description Update the given scope when leaving the given node. This function removes scope elements
+ * when done processing <code>FunctionDeclaration</code> and <code>FunctionExpression</code> nodes.
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} node The AST node we are currently inspecting
+ * @param {Object} scope The current scope we are in
+ */
+ updateScope: function(node, scope) {
+ if (!node || !node.type || !scope) {
+ return;
+ }
+ switch (node.type) {
+ case 'FunctionDeclaration': //$NON-NLS-0$
+ scope.pop();
+ break;
+ case 'FunctionExpression': //$NON-NLS-0$
+ scope.pop();
+ break;
+ }
+ },
+
+ /**
+ * @name traverse
+ * @description Walks the given node and context to find occurrences, returns if the traversal
+ * should continue to child nodes
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} node the AST node we are currently visiting
+ * @param {Object} context the current context
+ * @param {Function} func A function to call on the node and context to process the node in the given context
+ * @returns {Boolean} <code>true</code> if we should continue traversing the given node and its children, <code>false</code> otherwise
+ */
+ traverse: function(node, context, func) {
+ if (func(node, context)) {
+ return false; // stop traversal
+ }
+ for (var key in node) {
+ if (node.hasOwnProperty(key)) {
+ var child = node[key];
+ if (child && typeof child === 'object' && child !== null) { //$NON-NLS-0$
+ if (Array.isArray(child)) {
+ for (var i=0; i<child.length; i++) {
+ if (!this.traverse(child[i], context, func)) {
+ return false;
+ }
+ }
+ } else {
+ if (!this.traverse(child, context, func)) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ this.updateScope(node, context.scope);
+ return true;
+ },
+
+ /**
+ * @name checkIdentifier
+ * @description Checks if the given identifier matches the occurrence we are looking for
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} node The AST node we are inspecting
+ * @param {Object} context the current occurrence context
+ * @returns {Boolean} <code>true</code> if we should continue traversing the given node and its children, <code>false</code> otherwise
+ */
+ checkIdentifier: function(node, context) {
+ if (node && node.type === 'Identifier') { //$NON-NLS-0$
+ if (node.name === context.word) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ /**
+ * @name findMatchingDeclaration
+ * @description Finds the first scope in the array that has a declaration
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Array} scope the array of scopes
+ * @returns {Object} Returns the scope with the declaration or <code>null</code>
+ */
+ findMatchingDeclarationScope: function(scope) {
+ for (var i = scope.length - 1; i >= 0; i--) {
+ if (scope[i].decl) {
+ return scope[i];
+ }
+ }
+ return null;
+ },
+
+ /**
+ * @name addOccurrence
+ * @description Adds an occurrence for the given node and context to the collection
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} node The AST we found the occurrence in
+ * @param {Object} context The occurrence context
+ * @param {Boolean} readAccess if there is read access to the given occurrence
+ */
+ addOccurrence: function(node, context, readAccess) {
+ if (node) {
+ if (readAccess === undefined) {
+ readAccess = true;
+ }
+
+ var mScope = this.findMatchingDeclarationScope(context.scope);
+ if (!mScope) {
+ return;
+ }
+
+ if ((node.range[0] <= context.start) && (context.end <= node.range[1])) {
+ if (mScope) {
+ context.mScope = mScope;
+ } else {
+ console.error("matching declaration scope for selected type not found " + context.word); //$NON-NLS-0$
+ }
+ }
+
+ context.occurrences.push({
+ readAccess: readAccess,
+ node: node,
+ scope: mScope
+ });
+ }
+ },
+
+ /**
+ * @name findOccurrence
+ * @description Finds the occurrence from the given context in the given AST node
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} node The current AST node to check
+ * @param {Object} context The occurrence context
+ */
+ findOccurrence: function(node, context) {
+ if (!node || !node.type) {
+ return;
+ }
+ var varScope, curScope, i;
+ switch (node.type) {
+ case 'Program': //$NON-NLS-0$
+ curScope = {
+ global: true,
+ name: null,
+ decl: false
+ };
+ context.scope.push(curScope);
+ break;
+ case 'VariableDeclarator': //$NON-NLS-0$
+ if (this.checkIdentifier(node.id, context)) {
+ varScope = context.scope.pop();
+ varScope.decl = true;
+ context.scope.push(varScope);
+ this.addOccurrence(node.id, context, false);
+ }
+ if (node.init) {
+ if (this.checkIdentifier(node.init, context)) {
+ this.addOccurrence(node.init, context);
+ break;
+ }
+ if (node.init.type === 'ObjectExpression') { //$NON-NLS-0$
+ var properties = node.init.properties;
+ for (i = 0; i < properties.length; i++) {
+ //if (checkIdentifier (properties[i].key, context)) {
+ // var varScope = scope.pop();
+ // varScope.decl = true;
+ // scope.push(varScope);
+ // addOccurrence (scope, properties[i].key, context, occurrences, false);
+ //}
+ if (this.checkIdentifier(properties[i].value, context)) {
+ this.addOccurrence(properties[i].value, context);
+ }
+ }
+ }
+ }
+ break;
+ case 'ArrayExpression': //$NON-NLS-0$
+ if (node.elements) {
+ for (i = 0; i < node.elements.length; i++) {
+ if (this.checkIdentifier(node.elements[i], context)) {
+ this.addOccurrence(node.elements[i], context);
+ }
+ }
+ }
+ break;
+ case 'AssignmentExpression': //$NON-NLS-0$
+ var leftNode = node.left;
+ if (this.checkIdentifier(leftNode, context)) {
+ this.addOccurrence(leftNode, context, false);
+ }
+ if (leftNode.type === 'MemberExpression') { //$NON-NLS-0$
+ if (this.checkIdentifier(leftNode.object, context)) {
+ this.addOccurrence(leftNode.object, context, false);
+ }
+ }
+ var rightNode = node.right;
+ if (this.checkIdentifier(rightNode, context)) {
+ this.addOccurrence(rightNode, context);
+ }
+ break;
+ case 'MemberExpression': //$NON-NLS-0$
+ if (this.checkIdentifier(node.object, context)) {
+ this.addOccurrence(node.object, context);
+ }
+ if (node.computed) { //computed = true for [], false for . notation
+ if (this.checkIdentifier(node.property, context)) {
+ this.addOccurrence(node.property, context);
+ }
+ }
+ break;
+ case 'BinaryExpression': //$NON-NLS-0$
+ if (this.checkIdentifier(node.left, context)) {
+ this.addOccurrence(node.left, context);
+ }
+ if (this.checkIdentifier(node.right, context)) {
+ this.addOccurrence(node.right, context);
+ }
+ break;
+ case 'UnaryExpression': //$NON-NLS-0$
+ if (this.checkIdentifier(node.argument, context)) {
+ this.addOccurrence(node.argument, context, node.operator === 'delete' ? false : true); //$NON-NLS-0$
+ }
+ break;
+ case 'IfStatement': //$NON-NLS-0$
+ if (this.checkIdentifier(node.test, context)) {
+ this.addOccurrence(node.test, context);
+ }
+ break;
+ case 'SwitchStatement': //$NON-NLS-0$
+ if (this.checkIdentifier(node.discriminant, context)) {
+ this.addOccurrence(node.discriminant, context, false);
+ }
+ break;
+ case 'UpdateExpression': //$NON-NLS-0$
+ if (this.checkIdentifier(node.argument, context)) {
+ this.addOccurrence(node.argument, context, false);
+ }
+ break;
+ case 'ConditionalExpression': //$NON-NLS-0$
+ if (this.checkIdentifier(node.test, context)) {
+ this.addOccurrence(node.test, context);
+ }
+ if (this.checkIdentifier(node.consequent, context)) {
+ this.addOccurrence(node.consequent, context);
+ }
+ if (this.checkIdentifier(node.alternate, context)) {
+ this.addOccurrence(node.alternate, context);
+ }
+ break;
+ case 'FunctionDeclaration': //$NON-NLS-0$
+ curScope = {
+ global: false,
+ name: node.id.name,
+ loc: node.loc,
+ decl: false
+ };
+ context.scope.push(curScope);
+ if (node.params) {
+ for (i = 0; i < node.params.length; i++) {
+ if (this.checkIdentifier(node.params[i], context)) {
+ varScope = context.scope.pop();
+ varScope.decl = true;
+ context.scope.push(varScope);
+ this.addOccurrence(node.params[i], context, false);
+ }
+ }
+ }
+ break;
+ case 'FunctionExpression': //$NON-NLS-0$
+ curScope = {
+ global: false,
+ name: null,
+ loc: node.loc,
+ decl: false
+ };
+ context.scope.push(curScope);
+ if (!node.params) {
+ break;
+ }
+ for (i = 0; i < node.params.length; i++) {
+ if (this.checkIdentifier(node.params[i], context)) {
+ varScope = context.scope.pop();
+ varScope.decl = true;
+ context.scope.push(varScope);
+ this.addOccurrence(node.params[i], context, false);
+ }
+ }
+ break;
+ case 'CallExpression': //$NON-NLS-0$
+ if (!node.arguments) {
+ break;
+ }
+ for (var j = 0; j < node.arguments.length; j++) {
+ if (this.checkIdentifier(node.arguments[j], context)) {
+ this.addOccurrence(node.arguments[j], context);
+ }
+ }
+ break;
+ case 'ReturnStatement': //$NON-NLS-0$
+ if (this.checkIdentifier(node.argument, context)) {
+ this.addOccurrence(node.argument, context);
+ }
+ }
+ },
+
+ /**
+ * @name getOccurrences
+ * @description Computes the occurrences from the given AST and context
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} ast the AST to find occurrences in
+ * @param {Object} context the current occurrence context
+ * @returns {Array|null} Returns the found array of occurrences or <code>null</code>
+ */
+ getOccurrences: function(ast, context) {
+ if (ast) {
+ this.traverse(ast, context, function(node, context) {
+ var found = false;
+ if (node.range && node.name && (node.range[0] <= context.start) && (context.end <= node.range[1])) {
+ context.word = node.name;
+ found = true;
+ }
+ return found;
+ });
+
+ if (!context || !context.word) {
+ return null;
+ }
+ context.scope = [];
+ context.occurrences = [];
+ this.traverse(ast, context, this.findOccurrence);
+ return this.filterOccurrences(context);
+ }
+ console.error("AST is null"); //$NON-NLS-0$
+ return null;
+ },
+
+ /**
+ * @name computeOccurrences
+ * @description Callback from the editor to compute the occurrences
+ * @function
+ * @public
+ * @memberof javascript.JavaScriptOccurrences.prototype
+ * @param {Object} editorContext The current editor context
+ * @param {Object} ctx The current selection context
+ */
+ computeOccurrences: function(editorContext, ctx) {
+ var d = new Deferred();
+ var that = this;
+ editorContext.getAST().then(function(ast) {
+ var context = {
+ start: ctx.selection.start,
+ end: ctx.selection.end,
+ mScope: null
+ };
+ d.resolve(that.getOccurrences(ast, context));
+ });
+ return d;
+ }
+
+ };
+
+ JavaScriptOccurrences.prototype.contructor = JavaScriptOccurrences;
+
+ return {
+ JavaScriptOccurrences: JavaScriptOccurrences
+ };
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js
new file mode 100644
index 0000000..deecf30
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*global define esprima*/
+define(["esprima/esprima"
+], function() {
+
+ /**
+ * @name javascript.JavaScriptOutliner
+ * @description creates a new instance of the outliner
+ * @constructor
+ * @public
+ */
+ function JavaScriptOutliner() {
+ }
+
+ JavaScriptOutliner.prototype = /** @lends javascript.JavaScriptOutliner.prototype*/ {
+
+ /**
+ * @name getOutline
+ * @description callback from the <code>orion.edit.outliner</code> service to create
+ * an outline
+ * @function
+ * @public
+ * @memberof javascript.JavaScriptOutliner.prototype
+ * @param {String} contents - the contents to make an outline from
+ * @param {String} title - the title
+ */
+ getOutline: function(contents, title) {
+ //TODO
+ return [];
+ },
+
+ /**
+ * @name getSourceOutline
+ * @description creates a raw heiarchical source outline
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOutliner.prototype
+ * @param {String} contents - the contents to make an outline from
+ * @param {String} title - the title
+ */
+ getSourceOultine: function(contents, title) {
+ //TODO use shared AST, do not recompute if possible
+ return [];
+ },
+
+ /**
+ * @name getJsDocOutline
+ * @description creates a heiarchical source outline based solely on JSDoc tags
+ * @function
+ * @private
+ * @memberof javascript.JavaScriptOutliner.prototype
+ * @param {String} contents - the contents to make an outline from
+ * @param {String} title - the title
+ */
+ getJsDocOutline: function(contents, title) {
+ //TODO use shared AST, do not recompute if possible
+ return [];
+ }
+ };
+
+ JavaScriptOutliner.prototype.contructor = JavaScriptOutliner;
+
+ return {
+ JavaScriptOutliner: JavaScriptOutliner
+ };
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.html b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.html
new file mode 100644
index 0000000..573cabc
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.html
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <meta name="copyright" content="Copyright (c) IBM Corporation and others 2013.">
+ <title>Orion JavaScript Support</title>
+ <script src="../../requirejs/require.js"></script>
+ <script type="text/javascript">
+ /*global require*/
+ require({
+ baseUrl: '../../',
+ paths: {
+ text: 'requirejs/text',
+ i18n: 'requirejs/i18n',
+ domReady: 'requirejs/domReady'
+ }
+ });
+ require(["javascriptPlugin.js"]);
+ </script>
+</head>
+
+<body>
+ <h3>JavaScript Tools Support</h3>
+ <p>
+ This plugin provides a variety of JavaScript tooling, including:
+ <ul>
+ <li><em>Editing</em> - an editor with syntax highlighting, navigation, code completion, etc.</li>
+ <li><em>Navigation</em> - source navigation from the editor as well as a variety of outines.</li>
+ <li><em>Content Assist</em> - smart content assist while editing.</li>
+ <li><em>Search</em> - named item searching, editor occurrences, etc.</li>
+ </ul>
+ </p>
+ <p>October 16, 2013</p>
+ <h3>License</h3>
+ <p>
+ The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+ indicated below, the Content is provided to you under the terms and conditions of the
+ <a href="http://www.eclipse.org/legal/epl-v10.html">Eclipse Public License Version 1.0</a>
+ (&quot;EPL&quot;), and the <a href="http://www.eclipse.org/org/documents/edl-v10.html">
+ Eclipse Distribution License Version 1.0</a> (&quot;EDL&quot;).
+ For purposes of the EPL and EDL, &quot;Program&quot; will mean the Content.</p>
+
+ <p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+ being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+ apply to your use of any object code in the Content. Check the Redistributor's license that was
+ provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+ indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+ and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.
+ </p>
+</body>
+</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
new file mode 100644
index 0000000..c45603d
--- /dev/null
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * @license
+ * Copyright (c) 2013 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0
+ * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
+ * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+/*global define esprima*/
+define([
+"orion/plugin",
+"javascript/outliner",
+"javascript/occurrences",
+"esprima/esprima",
+"orion/serialize",
+"orion/i18nUtil",
+"domReady!"], function(PluginProvider, Outliner, Occurrences, Serialize, i18nUtil, domReady) {
+
+ /**
+ * Plug-in headers
+ */
+ var headers = {
+ name: "Orion JavaScript Tool Support",
+ version: "1.0",
+ description: "This plugin provides JavaScript tools support for Orion, like editing, search, navigation and code completion"
+ };
+ var provider = new PluginProvider(headers);
+
+ /**
+ * Register the JavaScript content type
+ */
+ provider.registerServiceProvider("orion.core.contenttype", {}, {
+ contentTypes: [
+ { id: "application/javascript",
+ "extends": "text/plain",
+ name: "JavaScript",
+ extension: ["js"],
+ image: "../images/javascript.png"
+ }
+ ]
+ });
+
+ var outliner = new Outliner.JavaScriptOutliner();
+
+ /**
+ * Register the jsdoc-based outline
+ */
+ provider.registerServiceProvider("orion.edit.outliner", outliner,
+ { contentType: ["application/javascript"],
+ name: "JSDoc outline",
+ id: "orion.javascript.outliner.jsdoc"
+ });
+
+ /**
+ * Register the raw source-based outline
+ */
+ provider.registerServiceProvider("orion.edit.outliner", outliner,
+ { contentType: ["application/javascript"],
+ name: "Source outline",
+ id: "orion.javascript.outliner.source"
+ });
+
+ /**
+ * Register the AST provider
+ */
+ provider.registerService("orion.core.astprovider",
+ { computeAST: function(context) {
+ var ast = esprima.parse(context.text, {
+ loc: true,
+ range: true,
+ raw: true,
+ tokens: true,
+ comment: true,
+ tolerant: true
+ });
+ if (ast.errors) {
+ ast.errors = ast.errors.map(Serialize.serializeError);
+ }
+ return ast;
+ }
+ }, {
+ contentType: ["application/javascript"]
+ });
+
+ var occurrences = new Occurrences.JavaScriptOccurrences();
+
+ /**
+ * Register the mark occurrences support
+ */
+ provider.registerService("orion.edit.occurrences", occurrences,
+ {
+ name: "Mark JavaScript Occurrences", //$NON-NLS-0$
+ id: "markoccurrences.editor", //$NON-NLS-0$
+ tooltip: "Mark JavaScript Occurrences", //$NON-NLS-0$
+ key: ["M", true, true], // Ctrl+Shift+M //$NON-NLS-0$
+ contentType: ["application/javascript"] //$NON-NLS-0$
+ });
+ provider.connect();
+}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/defaults.pref b/bundles/org.eclipse.orion.client.ui/web/defaults.pref
index 0325a3c..74355c3 100644
--- a/bundles/org.eclipse.orion.client.ui/web/defaults.pref
+++ b/bundles/org.eclipse.orion.client.ui/web/defaults.pref
@@ -4,6 +4,7 @@
"plugins/fileClientPlugin.html":true,
"plugins/jslintPlugin.html":true,
"git/plugins/gitPlugin.html":true,
+ "javascript/plugins/javascriptPlugin.html":true,
"profile/userservicePlugin.html":true,
"plugins/webEditingPlugin.html":true,
"plugins/pageLinksPlugin.html":true,
@@ -11,7 +12,6 @@
"plugins/taskPlugin.html": true,
"plugins/csslintPlugin.html": true,
"plugins/site/sitePlugin.html": true,
- "plugins/esprimaAst/esprimaAstPlugin.html": true,
"plugins/esprima/esprimaJsContentAssistPlugin.html":true,
"plugins/npmPlugin.html": true,
"shell/plugins/shellPagePlugin.html":true,
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.html b/bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.html
deleted file mode 100644
index 44f5f6f..0000000
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>JavaScript AST plugin</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <script src="../../requirejs/require.js"></script>
- <script>
- /*global require*/
- require({
- baseUrl: '../../'
- });
-
- require(['esprimaAstPlugin.js']);
- </script>
-</head>
-<body>
-</body>
-</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.js b/bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.js
deleted file mode 100644
index 2a7b452..0000000
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/esprimaAst/esprimaAstPlugin.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * @license
- * Copyright (c) 2012, 2013 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0
- * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
- * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
- *
- * Contributors: IBM Corporation - initial API and implementation
- ******************************************************************************/
-/*global define esprima */
-define([
- 'orion/plugin',
- 'orion/serialize',
- 'esprima/esprima'
-], function(PluginProvider, serialize, _) {
- var provider = new PluginProvider({
- name: 'Esprima AST Provider for JavaScript',
- description: 'Provides an abstract syntax tree (AST) for JavaScript code.',
- version: '1.0'
- });
-
- provider.registerService('orion.core.astprovider',
- {
- computeAST: function(context) {
- var ast = esprima.parse(context.text, {
- loc: true,
- range: true,
- raw: true,
- tokens: true,
- comment: true,
- tolerant: true
- });
- if (ast.errors) {
- ast.errors = ast.errors.map(serialize.serializeError);
- }
- return ast;
- }
- }, {
- contentType: ['application/javascript']
- });
-
- provider.connect();
-
-}); \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.html b/bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.html
deleted file mode 100644
index 1b3a9f7..0000000
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Occurrences Plugin</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <script src="../../requirejs/require.js"></script>
- <script>
- /*global require*/
- require({
- baseUrl: '../../'
- });
- require(['jsEsprimaMarkOccurrences.js']);
- </script>
-</head>
-<body>
-<h1>Esprima based Occurrences plugin</h1>
-</body>
-</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.js b/bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.js
deleted file mode 100644
index 6bb4a2d..0000000
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/occurrences/jsEsprimaMarkOccurrences.js
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * @license
- * Copyright (c) 2011, 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License v1.0
- * (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
- * License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- ******************************************************************************/
-
-/*jslint browser:true*/
-/*global define orion console */
-define(['orion/plugin', "orion/Deferred"], function(PluginProvider, Deferred) {
-
- function isOccurrenceInSelScope(oScope, wScope) {
- if (oScope.global && wScope.global) {
- return true;
- }
- if (!oScope.global && !wScope.global && (oScope.name === wScope.name) && (oScope.loc.start.line === wScope.loc.start.line) &&
- (oScope.loc.start.column === wScope.loc.start.column)) {
- return true;
- }
- return false;
- }
-
- function filterOccurrences(context) {
- if (!context.mScope) {
- return null;
- }
- var matches = [];
- for (var i = 0; i < context.occurrences.length; i++) {
- if (isOccurrenceInSelScope(context.occurrences[i].scope, context.mScope)) {
- matches.push({
- readAccess: context.occurrences[i].readAccess,
- line: context.occurrences[i].node.loc.start.line,
- start: context.occurrences[i].node.loc.start.column + 1,
- end: context.occurrences[i].node.loc.end.column,
- description: (context.occurrences[i].readAccess ? 'Occurrence of "' : 'Write occurrence of "') + context.word + '"' //$NON-NLS-0$ //$NON-NLS-1$ //$NON-NLS-2$
- });
- }
- }
- return matches;
- }
-
- function updateScope(node, scope) {
- if (!node || !node.type || !scope) {
- return;
- }
- switch (node.type) {
- case 'FunctionDeclaration': //$NON-NLS-0$
- scope.pop();
- break;
- case 'FunctionExpression': //$NON-NLS-0$
- scope.pop();
- break;
- }
- }
-
- function traverse(node, context, func) {
- if (func(node, context)) {
- return false; // stop traversal
- }
- for (var key in node) {
- if (node.hasOwnProperty(key)) {
- var child = node[key];
- if (child && typeof child === 'object' && child !== null) { //$NON-NLS-0$
- if (Array.isArray(child)) {
- for (var i=0; i<child.length; i++) {
- if (!traverse(child[i], context, func)) {
- return false;
- }
- }
- } else {
- if (!traverse(child, context, func)) {
- return false;
- }
- }
- }
- }
- }
- updateScope(node, context.scope);
- return true;
- }
-
- function checkIdentifier(node, context) {
- if (node && node.type === 'Identifier') { //$NON-NLS-0$
- if (node.name === context.word) {
- return true;
- }
- }
- return false;
- }
-
- function findMatchingDeclarationScope(scope) {
- for (var i = scope.length - 1; i >= 0; i--) {
- if (scope[i].decl) {
- return scope[i];
- }
- }
- return null;
- }
-
- function addOccurrence(node, context, readAccess) {
- if (node) {
- if (readAccess === undefined) {
- readAccess = true;
- }
-
- var mScope = findMatchingDeclarationScope(context.scope);
- if (!mScope) {
- return;
- }
-
- if ((node.range[0] <= context.start) && (context.end <= node.range[1])) {
- if (mScope) {
- context.mScope = mScope;
- } else {
- console.error("matching declaration scope for selected type not found " + context.word); //$NON-NLS-0$
- }
- }
-
- context.occurrences.push({
- readAccess: readAccess,
- node: node,
- scope: mScope
- });
- }
- }
-
- function findOccurrence(node, context) {
- if (!node || !node.type) {
- return null;
- }
- var varScope, curScope, i;
- switch (node.type) {
- case 'Program': //$NON-NLS-0$
- curScope = {
- global: true,
- name: null,
- decl: false
- };
- context.scope.push(curScope);
- break;
- case 'VariableDeclarator': //$NON-NLS-0$
- if (checkIdentifier(node.id, context)) {
- varScope = context.scope.pop();
- varScope.decl = true;
- context.scope.push(varScope);
- addOccurrence(node.id, context, false);
- }
- if (node.init) {
- if (checkIdentifier(node.init, context)) {
- addOccurrence(node.init, context);
- break;
- }
- if (node.init.type === 'ObjectExpression') { //$NON-NLS-0$
- var properties = node.init.properties;
- for (i = 0; i < properties.length; i++) {
- //if (checkIdentifier (properties[i].key, context)) {
- // var varScope = scope.pop();
- // varScope.decl = true;
- // scope.push(varScope);
- // addOccurrence (scope, properties[i].key, context, occurrences, false);
- //}
- if (checkIdentifier(properties[i].value, context)) {
- addOccurrence(properties[i].value, context);
- }
- }
- }
- }
- break;
- case 'ArrayExpression': //$NON-NLS-0$
- if (node.elements) {
- for (i = 0; i < node.elements.length; i++) {
- if (checkIdentifier(node.elements[i], context)) {
- addOccurrence(node.elements[i], context);
- }
- }
- }
- break;
- case 'AssignmentExpression': //$NON-NLS-0$
- var leftNode = node.left;
- if (checkIdentifier(leftNode, context)) {
- addOccurrence(leftNode, context, false);
- }
- if (leftNode.type === 'MemberExpression') { //$NON-NLS-0$
- if (checkIdentifier(leftNode.object, context)) {
- addOccurrence(leftNode.object, context, false);
- }
- }
- var rightNode = node.right;
- if (checkIdentifier(rightNode, context)) {
- addOccurrence(rightNode, context);
- }
- break;
- case 'MemberExpression': //$NON-NLS-0$
- if (checkIdentifier(node.object, context)) {
- addOccurrence(node.object, context);
- }
- if (node.computed) { //computed = true for [], false for . notation
- if (checkIdentifier(node.property, context)) {
- addOccurrence(node.property, context);
- }
- }
- break;
- case 'BinaryExpression': //$NON-NLS-0$
- if (checkIdentifier(node.left, context)) {
- addOccurrence(node.left, context);
- }
- if (checkIdentifier(node.right, context)) {
- addOccurrence(node.right, context);
- }
- break;
- case 'UnaryExpression': //$NON-NLS-0$
- if (checkIdentifier(node.argument, context)) {
- addOccurrence(node.argument, context, node.operator === 'delete' ? false : true); //$NON-NLS-0$
- }
- break;
- case 'IfStatement': //$NON-NLS-0$
- if (checkIdentifier(node.test, context)) {
- addOccurrence(node.test, context);
- }
- break;
- case 'SwitchStatement': //$NON-NLS-0$
- if (checkIdentifier(node.discriminant, context)) {
- addOccurrence(node.discriminant, context, false);
- }
- break;
- case 'UpdateExpression': //$NON-NLS-0$
- if (checkIdentifier(node.argument, context)) {
- addOccurrence(node.argument, context, false);
- }
- break;
- case 'ConditionalExpression': //$NON-NLS-0$
- if (checkIdentifier(node.test, context)) {
- addOccurrence(node.test, context);
- }
- if (checkIdentifier(node.consequent, context)) {
- addOccurrence(node.consequent, context);
- }
- if (checkIdentifier(node.alternate, context)) {
- addOccurrence(node.alternate, context);
- }
- break;
- case 'FunctionDeclaration': //$NON-NLS-0$
- curScope = {
- global: false,
- name: node.id.name,
- loc: node.loc,
- decl: false
- };
- context.scope.push(curScope);
- if (node.params) {
- for (i = 0; i < node.params.length; i++) {
- if (checkIdentifier(node.params[i], context)) {
- varScope = context.scope.pop();
- varScope.decl = true;
- context.scope.push(varScope);
- addOccurrence(node.params[i], context, false);
- }
- }
- }
- break;
- case 'FunctionExpression': //$NON-NLS-0$
- curScope = {
- global: false,
- name: null,
- loc: node.loc,
- decl: false
- };
- context.scope.push(curScope);
- if (!node.params) {
- break;
- }
- for (i = 0; i < node.params.length; i++) {
- if (checkIdentifier(node.params[i], context)) {
- varScope = context.scope.pop();
- varScope.decl = true;
- context.scope.push(varScope);
- addOccurrence(node.params[i], context, false);
- }
- }
- break;
- case 'CallExpression': //$NON-NLS-0$
- if (!node.arguments) {
- break;
- }
- for (var j = 0; j < node.arguments.length; j++) {
- if (checkIdentifier(node.arguments[j], context)) {
- addOccurrence(node.arguments[j], context);
- }
- }
- break;
- case 'ReturnStatement': //$NON-NLS-0$
- if (checkIdentifier(node.argument, context)) {
- addOccurrence(node.argument, context);
- }
- }
- return null;
- }
-
- function getOccurrences(ast, context) {
- if (ast) {
- traverse(ast, context, function(node, context) {
- var found = false;
- if (node.range && node.name && (node.range[0] <= context.start) && (context.end <= node.range[1])) {
- context.word = node.name;
- found = true;
- }
- return found;
- });
-
- if (!context || !context.word) {
- return null;
- }
- context.scope = [];
- context.occurrences = [];
- traverse(ast, context, findOccurrence);
- return filterOccurrences(context);
- }
- console.error("ast is null"); //$NON-NLS-0$
- return null;
- }
-
- var headers = {
- name: "Occurrence Plugin", //$NON-NLS-0$
- version: "0.1", //$NON-NLS-0$
- description: "Esprima-based mark occurrences plugin." //$NON-NLS-0$
- };
- var provider = new PluginProvider(headers);
-
- // Create the service implementation for getting selected text
- var serviceImpl = {
- computeOccurrences: function(editorContext, ctx) {
- var d = new Deferred();
- editorContext.getAST().then(function(ast) {
- var context = {
- start: ctx.selection.start,
- end: ctx.selection.end,
- mScope: null
- };
- d.resolve(getOccurrences (ast, context));
- });
- return d;
- }
- };
-
- var serviceProperties = {
- name: 'Mark Occurrences', //$NON-NLS-0$
- id: 'markoccurrences.editor', //$NON-NLS-0$
- tooltip: 'Mark Occurrences', //$NON-NLS-0$
- key: ['M', true, true], // Ctrl+Shift+M //$NON-NLS-0$
- contentType: ['application/javascript'] //$NON-NLS-0$
- };
-
- provider.registerService("orion.edit.occurrences", serviceImpl, serviceProperties); //$NON-NLS-0$
- provider.connect();
-});
-
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/site/selfHostingRules.js b/bundles/org.eclipse.orion.client.ui/web/plugins/site/selfHostingRules.js
index dd87f1d..e54a573 100644
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/site/selfHostingRules.js
+++ b/bundles/org.eclipse.orion.client.ui/web/plugins/site/selfHostingRules.js
@@ -32,6 +32,7 @@ define([], function() {
{ type: API, source: "/useremailconfirmation", targetPattern: "${0}useremailconfirmation" },
{ type: API, source: "/site", targetPattern: "${0}site" },
{ type: FILE, source: "/", targetPattern: "${0}/bundles/org.eclipse.orion.client.git/web" },
+ { type: FILE, source: "/", targetPattern: "${0}/bundles/org.eclipse.orion.client.javascript/web" },
{ type: API, source: "/gitapi", targetPattern: "${0}gitapi" },
{ type: FILE, source: "/", targetPattern: "${0}/bundles/org.eclipse.orion.client.users/web" },
{ type: API, source: "/xfer", targetPattern: "${0}xfer" },
diff --git a/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js b/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js
index f26ba00..f8eeb84 100644
--- a/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js
+++ b/bundles/org.eclipse.orion.client.ui/web/plugins/webEditingPlugin.js
@@ -47,12 +47,6 @@ define([
extension: ["css"],
image: "../images/css.png"
},
- { id: "application/javascript",
- "extends": "text/plain",
- name: "JavaScript",
- extension: ["js"],
- image: "../images/javascript.png"
- },
{ id: "application/json",
"extends": "text/plain",
name: "JSON",
diff --git a/features/org.eclipse.orion.client-feature/feature.xml b/features/org.eclipse.orion.client-feature/feature.xml
index c4270ee..bfc57bb 100644
--- a/features/org.eclipse.orion.client-feature/feature.xml
+++ b/features/org.eclipse.orion.client-feature/feature.xml
@@ -62,4 +62,10 @@
install-size="0"
version="0.0.0"/>
+ <plugin
+ id="org.eclipse.orion.client.javascript"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
</feature>
diff --git a/releng/org.eclipse.orion.client.releng/builder/orion.mini.xml b/releng/org.eclipse.orion.client.releng/builder/orion.mini.xml
index 7fb3adc..b206f44 100644
--- a/releng/org.eclipse.orion.client.releng/builder/orion.mini.xml
+++ b/releng/org.eclipse.orion.client.releng/builder/orion.mini.xml
@@ -153,6 +153,7 @@
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.ui/web" includes="**"/>
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.editor/web" includes="**"/>
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.git/web" includes="**"/>
+ <fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.javascript/web" includes="**"/>
<fileset dir="${buildDirectory}/bundles/org.eclipse.orion.client.users/web" includes="**"/>
</copy>
@@ -172,7 +173,7 @@
<optimize pageDir="settings" name="settings" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="shell" name="shellPage" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="shell/plugins" name="shellPagePlugin" bundle="org.eclipse.orion.client.ui" />
- <optimize pageDir="plugins/esprimaAst" name="esprimaAstPlugin" bundle="org.eclipse.orion.client.ui" />
+ <optimize pageDir="javascript/plugins" name="javascriptPlugin" bundle="org.eclipse.orion.client.javascript" />
<optimize pageDir="plugins/esprima" name="esprimaJsContentAssistPlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins/site" name="sitePlugin" bundle="org.eclipse.orion.client.ui" />
<optimize pageDir="plugins" name="authenticationPlugin" bundle="org.eclipse.orion.client.ui" />