aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2013-12-17 15:34:58 (EST)
committerGerrit Code Review @ Eclipse.org2013-12-18 12:42:56 (EST)
commita06fed364882f1ef7addb255f4a28ed7b4cda232 (patch)
tree78179eb225530f72a3a5576d7d5ab0b1b8840e67
parent639185d5c6c5d1dc6a6072e5bdbadc2cc659dd38 (diff)
downloadorg.eclipse.orion.client-a06fed364882f1ef7addb255f4a28ed7b4cda232.zip
org.eclipse.orion.client-a06fed364882f1ef7addb255f4a28ed7b4cda232.tar.gz
org.eclipse.orion.client-a06fed364882f1ef7addb255f4a28ed7b4cda232.tar.bz2
Bug 423712 - Use estraverse in content assist - re-org, get rid of deadrefs/changes/18/19918/3
code Change-Id: Ia2c15843ef9606d8418a2916f349809c934879cd Signed-off-by: Mike Rennie <Michael_Rennie@ca.ibm.com>
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/contentAssist.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/esprimaJsContentAssist.js)293
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/esprimaVisitor.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/esprimaVisitor.js)8
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/browserIndex.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/browserIndex.js)4
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/ecma5Index.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/ecma5Index.js)4
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/nodeIndex.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/nodeIndex.js)4
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/proposalUtils.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/proposalUtils.js)0
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/serializer.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/serializer.js)6
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeEnvironment.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeEnvironment.js)8
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeInference.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeInference.js)8
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeUtils.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeUtils.js)12
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typesFromIndexFile.js (renamed from bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typesFromIndexFile.js)14
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/scriptedLogger.js104
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js8
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.html11
-rw-r--r--bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.js10
15 files changed, 82 insertions, 412 deletions
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/esprimaJsContentAssist.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/contentAssist.js
index 8c589a1..e76837f 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/esprimaJsContentAssist.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/contentAssist.js
@@ -1,6 +1,6 @@
/*******************************************************************************
* @license
- * Copyright (c) 2012 VMware, Inc. and others.
+ * Copyright (c) 2012, 2013 VMware, Inc. 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
@@ -9,20 +9,20 @@
* Contributors:
* Andy Clement (VMware) - initial API and implementation
* Andrew Eisenberg (VMware) - implemented visitor pattern
- * Manu Sridharan (IBM) - Various improvements
+ * IBM Corporation - Various improvements
******************************************************************************/
/*global define esprima doctrine inferencerPostOp*/
define([
-'javascript/esprima/esprimaVisitor',
-'javascript/esprima/typeEnvironment',
-'javascript/esprima/typeInference',
-'javascript/esprima/typeUtils',
-'javascript/esprima/proposalUtils',
-'javascript/esprima/scriptedLogger',
+'javascript/contentAssist/esprimaVisitor',
+'javascript/contentAssist/typeEnvironment',
+'javascript/contentAssist/typeInference',
+'javascript/contentAssist/typeUtils',
+'javascript/contentAssist/proposalUtils',
'orion/Deferred',
-'esprima'
-], function(mVisitor, typeEnv, typeInf, typeUtils, proposalUtils, scriptedLogger, Deferred, _) {
+'esprima',
+'estraverse'
+], function(mVisitor, typeEnv, typeInf, typeUtils, proposalUtils, Deferred, Esprima, Estraverse) {
/**
* Convert an array of parameters into a string and also compute linked editing positions
@@ -70,16 +70,12 @@ define([
return {completion: completion, positions: positions.length === 0 ? null : positions};
}
-
-
-
-
/**
* @return "top" if we are at a start of a new expression fragment (eg- at an empty line,
* or a new parameter). "member" if we are after a dot in a member expression. false otherwise
* @return {Boolean|String}
*/
- function shouldVisit(root, offset, prefix, contents) {
+ function shouldVisit(ast, offset, prefix, contents) {
/**
* A visitor that finds the parent stack at the given location
* @param node the AST node being visited
@@ -129,7 +125,7 @@ define([
};
var parents = [];
try {
- mVisitor.visit(root, parents, findParent, findParent);
+ mVisitor.visit(ast, parents, findParent, findParent);
} catch (done) {
if (done !== "done") {
// a real error
@@ -731,7 +727,7 @@ define([
* @param {{hasDependency,performIndex,retrieveSummary,retrieveGlobalSummaries}} indexer
* @param {{global:[],options:{browser:Boolean}}=} lintOptions optional set of extra lint options that can be overridden in the source (jslint or jshint)
*/
- function EsprimaJavaScriptContentAssistProvider(astManager, indexer, lintOptions) {
+ function JSContentAssist(astManager, indexer, lintOptions) {
this.astManager = astManager;
this.indexer = indexer;
this.lintOptions = lintOptions;
@@ -740,7 +736,7 @@ define([
/**
* Main entry point to provider
*/
- EsprimaJavaScriptContentAssistProvider.prototype = {
+ JSContentAssist.prototype = {
/**
* Implements the Orion content assist API v4.0
@@ -764,249 +760,42 @@ define([
return emptyArrayPromise();
}
- try {
- var root = ast;
- if (!root) {
- // assume a bad parse
- return emptyArrayPromise();
- }
-
- var offset = context.offset;
- // note that if selection has length > 0, then just ignore everything past the start
- var completionKind = shouldVisit(root, offset, context.prefix, buffer);
- if (completionKind) {
- var environmentPromise = typeEnv.createEnvironment({ buffer: buffer, uid : "local", offset : offset, indexer : this.indexer, globalObjName : findGlobalObject(root.comments, this.lintOptions), comments : root.comments });
- var self = this;
- var result = environmentPromise.then(function (environment) {
- // must defer inferring the containing function block until the end
- environment.defer = completionKind.toDefer;
- if (environment.defer) {
- // remove these comments from consideration until we are inferring the deferred
- environment.deferredComments = extractDocComments(environment.comments, environment.defer.range);
- }
- try {
- var target = typeInf.inferTypes(root, environment, self.lintOptions);
- var proposalsObj = { };
- createInferredProposals(target, environment, completionKind.kind, context.prefix, offset - context.prefix.length, proposalsObj);
- if (!context.inferredOnly) {
- // include the entire universe as potential proposals
- createNoninferredProposals(environment, context.prefix, offset - context.prefix.length, proposalsObj);
- }
- return filterAndSortProposals(proposalsObj);
- } catch (e) {
- if (typeof scriptedLogger !== "undefined") {
- scriptedLogger.error(e.message, "CONTENT_ASSIST");
- scriptedLogger.error(e.stack, "CONTENT_ASSIST");
- }
- throw (e);
- }
- });
- return result;
- } else {
- // invalid completion location
- return emptyArrayPromise();
- }
- } catch (e) {
- if (typeof scriptedLogger !== "undefined") {
- scriptedLogger.error(e.message, "CONTENT_ASSIST");
- scriptedLogger.error(e.stack, "CONTENT_ASSIST");
- }
- throw (e);
- }
- },
-
-
- _internalFindDefinition : function(buffer, offset, findName) {
- var toLookFor;
- var root = mVisitor.parse(buffer);
+ var root = ast;
if (!root) {
// assume a bad parse
- return null;
- }
- var funcList = [];
- var environment = typeEnv.createEnvironment({ buffer: buffer, uid : "local", offset : offset, indexer : this.indexer, globalObjName : findGlobalObject(root.comments, this.lintOptions), comments : root.comments });
- var findIdentifier = function(node) {
- if ((node.type === "Identifier" || node.type === "ThisExpression") && proposalUtils.inRange(offset, node.range, true)) {
- toLookFor = node;
- // cut visit short
- throw "done";
- }
- // FIXADE esprima bug...some call expressions have incorrect slocs.
- // This is fixed in trunk of esprima.
- // after next upgrade of esprima if the following has correct slocs, then
- // can remove the second part of the &&
- // mUsers.getUser().name
- if (node.range[0] > offset &&
- (node.type === "ExpressionStatement" ||
- node.type === "ReturnStatement" ||
- node.type === "ifStatement" ||
- node.type === "WhileStatement" ||
- node.type === "Program")) {
- // not at a valid hover location
- throw "no hover";
- }
-
- // the last function pushed on is the one that we need to defer
- if (node.type === "FunctionDeclaration" || node.type === "FunctionExpression") {
- funcList.push(node);
- }
- return true;
- };
+ return emptyArrayPromise();
+ }
- try {
- mVisitor.visit(root, {}, findIdentifier, function(node) {
- if (node === funcList[funcList.length-1]) {
- funcList.pop();
+ var offset = context.offset;
+ // note that if selection has length > 0, then just ignore everything past the start
+ var completionKind = shouldVisit(root, offset, context.prefix, buffer);
+ if (completionKind) {
+ var environmentPromise = typeEnv.createEnvironment({ buffer: buffer, uid : "local", offset : offset, indexer : this.indexer, globalObjName : findGlobalObject(root.comments, this.lintOptions), comments : root.comments });
+ var self = this;
+ var result = environmentPromise.then(function (environment) {
+ // must defer inferring the containing function block until the end
+ environment.defer = completionKind.toDefer;
+ if (environment.defer) {
+ // remove these comments from consideration until we are inferring the deferred
+ environment.deferredComments = extractDocComments(environment.comments, environment.defer.range);
+ }
+ var target = typeInf.inferTypes(root, environment, self.lintOptions);
+ var proposalsObj = { };
+ createInferredProposals(target, environment, completionKind.kind, context.prefix, offset - context.prefix.length, proposalsObj);
+ if (!context.inferredOnly) {
+ // include the entire universe as potential proposals
+ createNoninferredProposals(environment, context.prefix, offset - context.prefix.length, proposalsObj);
}
+ return filterAndSortProposals(proposalsObj);
});
- } catch (e) {
- if (e === "no hover") {
- // not at a valid hover location
- return null;
- } else if (e === "done") {
- // valid hover...continue
- } else {
- // a real exception
- throw e;
- }
- }
- if (!toLookFor) {
- // no hover target found
- return null;
- }
- // must defer inferring the containing function block until the end
- environment.defer = funcList.pop();
- if (environment.defer && toLookFor === environment.defer.id) {
- // don't defer if target is name of function
- delete environment.defer;
- }
-
- if (environment.defer) {
- // remove these comments from consideration until we are inferring the deferred
- environment.deferredComments = extractDocComments(environment.comments, environment.defer.range);
- }
-
- var target = typeInf.inferTypes(root, environment, this.lintOptions);
- var lookupName = toLookFor.type === "Identifier" ? toLookFor.name : 'this';
- var maybeType = environment.lookupTypeObj(lookupName, toLookFor.extras.target || target, true);
- if (maybeType) {
- // if it's a reference to a function type, suck out $$fntype
- var allTypes = environment.getAllTypes();
- if (fnTypeRef(maybeType.typeObj,allTypes)) {
- inlineFunctionTypes(allTypes[maybeType.typeObj.name].$$fntype,allTypes);
- maybeType.typeObj = allTypes[maybeType.typeObj.name].$$fntype;
- }
- var hover = typeUtils.styleAsProperty(lookupName, findName) + " : " + typeUtils.createReadableType(maybeType.typeObj, environment, true, 0, findName);
- maybeType.hoverText = hover;
- return maybeType;
+ return result;
} else {
- return null;
- }
-
- },
- /**
- * Computes the hover information for the provided offset
- */
- computeHover: function(buffer, offset) {
- return this._internalFindDefinition(buffer, offset, true);
- },
-
- findDefinition : function(buffer, offset) {
- return this._internalFindDefinition(buffer, offset, false);
- },
-
- /**
- * Computes a summary of the file that is suitable to be stored locally and used as a dependency
- * in another file
- * @param {String} buffer
- * @param {String} fileName
- */
- computeSummary: function(buffer, fileName) {
- var root = mVisitor.parse(buffer);
- if (!root) {
- // assume a bad parse
- return null;
- }
- var environment = typeEnv.createEnvironment({ buffer: buffer, uid : fileName, globalObjName : findGlobalObject(root.comments, this.lintOptions), comments : root.comments, indexer : this.indexer });
- try {
- typeInf.inferTypes(root, environment, this.lintOptions);
- } catch (e) {
- if (typeof scriptedLogger !== "undefined") {
- scriptedLogger.error("Problem inferring in: " + fileName, "CONTENT_ASSIST");
- scriptedLogger.error(e.message, "CONTENT_ASSIST");
- scriptedLogger.error(e.stack, "CONTENT_ASSIST");
- }
- throw (e);
- }
- var providedType;
- var kind;
- var modTypeObj;
- if (environment.amdModule) {
- // provide the exports of the AMD module
- // the exports is the return value of the final argument
- var args = environment.amdModule["arguments"];
- if (args && args.length > 0) {
- modTypeObj = typeUtils.extractReturnType(environment.getFnType(args[args.length-1]));
- } else {
- modTypeObj = typeUtils.OBJECT_TYPE;
- }
- kind = "AMD";
- } else if (environment.commonjsModule) {
- // a wrapped commonjs module
- // we have already checked the correctness of this function
- var exportsParam = environment.commonjsModule["arguments"][0].params[1];
- modTypeObj = exportsParam.extras.inferredTypeObj;
- providedType = environment.findType(modTypeObj);
-
- } else {
- // assume a non-module
- providedType = environment.globalScope();
-
- // if there is an exports global or a module.exports global, then assume commonjs
- var maybeExports = providedType.exports ||
- (providedType.module && environment.getAllTypes()[providedType.module.typeObj.name] &&
- environment.getAllTypes()[providedType.module.typeObj.name].exports);
-
- if (maybeExports) {
- // actually, commonjs
- kind = "commonjs";
- modTypeObj = maybeExports.typeObj;
- } else {
- kind = "global";
- modTypeObj = providedType['this'].typeObj;
- }
- }
-
- // simplify the exported type
- if (!typeUtils.isFunctionOrConstructor(modTypeObj) &&
- !environment.findType(modTypeObj).$$isBuiltin) {
-
- // this module provides a composite type
- providedType = environment.findType(modTypeObj);
- }
-
- var allTypes = environment.getAllTypes();
-
- // now filter the builtins since they are always available
- filterTypes(environment, kind, modTypeObj, providedType);
-
- // Cases when provided type is not a record type. store as a string
- // warning...not all cases handled here...eg- union types
- if (typeUtils.isFunctionOrConstructor(modTypeObj) ||
- (environment.findType(modTypeObj) && environment.findType(modTypeObj).$$isBuiltin)) {
- providedType = doctrine.type.stringify(modTypeObj, {compact: true});
- } else if (providedType.$$fntype) {
- providedType = doctrine.type.stringify(providedType.$$fntype, {compact: true});
+ // invalid completion location
+ return emptyArrayPromise();
}
-
- return {
- provided : providedType,
- types : allTypes,
- kind : kind
- };
}
};
return {
- EsprimaJavaScriptContentAssistProvider : EsprimaJavaScriptContentAssistProvider
+ JSContentAssist : JSContentAssist
};
});
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/esprimaVisitor.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/esprimaVisitor.js
index 99da693..0293b88 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/esprimaVisitor.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/esprimaVisitor.js
@@ -12,8 +12,7 @@
/*global define esprima */
define([
-'javascript/esprima/scriptedLogger'
-], function(scriptedLogger) {
+], function() {
return {
/**
@@ -36,11 +35,6 @@ define([
var parsedProgram = esprima.parse(contents, extraOptions);
return parsedProgram;
} catch (e) {
- if (typeof scriptedLogger !== "undefined") {
- scriptedLogger.warn("Problem parsing file", "CONTENT_ASSIST");
- scriptedLogger.warn(e.message, "CONTENT_ASSIST");
- scriptedLogger.warn(e.stack, "CONTENT_ASSIST");
- }
return null;
}
},
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/browserIndex.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/browserIndex.js
index 965a15b..7296f31 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/browserIndex.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/browserIndex.js
@@ -7,12 +7,12 @@
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
- * Manu Sridharan (IBM) - Initial API and implementation
+ * IBM Corporation - Initial API and implementation
******************************************************************************/
// this file was generated by a script from the model in types.js
/*global define */
-define('javascript/esprima/indexFiles/browserIndex', [
+define('javascript/contentAssist/indexFiles/browserIndex', [
], function () {
return {
"!name": "browser",
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/ecma5Index.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/ecma5Index.js
index f38c105..f110a1a 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/ecma5Index.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/ecma5Index.js
@@ -7,12 +7,12 @@
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
- * Manu Sridharan (IBM) - Initial API and implementation
+ * IBM Corporation - Initial API and implementation
******************************************************************************/
// this file was generated by a script from the model in types.js
/*global define */
-define('javascript/esprima/indexFiles/ecma5Index', [
+define('javascript/contentAssist/indexFiles/ecma5Index', [
], function () {
return {
"!name": "ecma5",
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/nodeIndex.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/nodeIndex.js
index 6c64177..7bbe585 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/indexFiles/nodeIndex.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/indexFiles/nodeIndex.js
@@ -7,10 +7,10 @@
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
- * Manu Sridharan (IBM) - Initial API and implementation
+ * IBM Corporation - Initial API and implementation
******************************************************************************/
/*global define */
-define('javascript/esprima/indexFiles/nodeIndex', [
+define('javascript/contentAssist/indexFiles/nodeIndex', [
], function () {
return {
"console": "Console",
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/proposalUtils.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/proposalUtils.js
index b1edd80..b1edd80 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/proposalUtils.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/proposalUtils.js
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/serializer.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/serializer.js
index 10bf413..b3b8643 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/serializer.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/serializer.js
@@ -7,7 +7,7 @@
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
- * Manu Sridharan (IBM) - Initial API and implementation
+ * IBM Corporation - Initial API and implementation
******************************************************************************/
/**
@@ -17,8 +17,8 @@
*/
/*global define console */
-define('javascript/esprima/serializer', [
-'javascript/esprima/typeUtils'
+define([
+'javascript/contentAssist/typeUtils'
], function (typeUtils) {
/**
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeEnvironment.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeEnvironment.js
index 323c6c7..aaaad05 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeEnvironment.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeEnvironment.js
@@ -9,13 +9,13 @@
* Contributors:
* Andy Clement (VMware) - initial API and implementation
* Andrew Eisenberg (VMware) - implemented visitor pattern
- * Manu Sridharan (IBM) - Various improvements
+ * IBM Corporation - Various improvements
******************************************************************************/
/*global define*/
-define('javascript/esprima/typeEnvironment',[
-'javascript/esprima/typeUtils',
-'javascript/esprima/typesFromIndexFile',
+define([
+'javascript/contentAssist/typeUtils',
+'javascript/contentAssist/typesFromIndexFile',
'orion/Deferred'
], function(typeUtils, mTypes, Deferred) {
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeInference.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeInference.js
index 994fce1..9112396 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeInference.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeInference.js
@@ -9,14 +9,14 @@
* Contributors:
* Andy Clement (VMware) - initial API and implementation
* Andrew Eisenberg (VMware) - implemented visitor pattern
- * Manu Sridharan (IBM) - Various improvements
+ * IBM Corporation - Various improvements
******************************************************************************/
/*global define inferencerPostOp */
define([
-'javascript/esprima/esprimaVisitor',
-'javascript/esprima/typeUtils',
-'javascript/esprima/proposalUtils'
+'javascript/contentAssist/esprimaVisitor',
+'javascript/contentAssist/typeUtils',
+'javascript/contentAssist/proposalUtils'
], function (mVisitor, typeUtils, proposalUtils) {
var RESERVED_WORDS = {
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeUtils.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeUtils.js
index bc5c7ce..2e25750 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typeUtils.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typeUtils.js
@@ -8,7 +8,7 @@
*
* Contributors:
* Andrew Eisenberg (VMware) - initial API and implementation
- * Manu Sridharan (IBM) - Various improvements
+ * IBM Corporation - Various improvements
******************************************************************************/
/*
@@ -18,10 +18,9 @@ other utility functions related to types.
/*jslint es5:true browser:true*/
/*global define doctrine console */
define([
-'javascript/esprima/proposalUtils',
-'javascript/esprima/scriptedLogger',
+'javascript/contentAssist/proposalUtils',
'doctrine/doctrine'
-], function(proposalUtils, scriptedLogger, _doctrine) {
+], function(proposalUtils, _doctrine) {
/**
* Doctrine closure compiler style type objects
*/
@@ -312,10 +311,7 @@ define([
}
}
} catch (e) {
- scriptedLogger.error(e.message, "CONTENT_ASSIST");
- scriptedLogger.error(e.stack, "CONTENT_ASSIST");
- scriptedLogger.error("Error parsing doc comment:\n" + (docComment && docComment.value),
- "CONTENT_ASSIST");
+ //TODO continue on
}
}
return result;
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typesFromIndexFile.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typesFromIndexFile.js
index 9a440f5..3ebf40d 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/typesFromIndexFile.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/contentAssist/typesFromIndexFile.js
@@ -7,7 +7,7 @@
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
- * Manu Sridharan (IBM) - Initial API and implementation
+ * IBM Coporation - Initial API and implementation
******************************************************************************/
/**
* This module contains the code for parsing index files and converting them
@@ -15,11 +15,11 @@
*/
/*global define require definitionForType doctrine*/
-define('javascript/esprima/typesFromIndexFile', [
+define([
'orion/Deferred',
-'javascript/esprima/typeUtils',
+'javascript/contentAssist/typeUtils',
'doctrine/doctrine'
-], function (Deferred, typeUtils, _doctrine) {
+], function (Deferred, typeUtils, Doctrine) {
/**
* for case where an object has its own hasOwnProperty property
@@ -411,7 +411,7 @@ define('javascript/esprima/typesFromIndexFile', [
function init() {
if (!initResult) {
var d = new Deferred();
- require(["javascript/esprima/indexFiles/ecma5Index"], function (ecma5) {
+ require(["javascript/contentAssist/indexFiles/ecma5Index"], function (ecma5) {
// add information for core libraries directly to Global.prototype
// and Types.prototype
addIndexInfo(ecma5, globalPrototype, typesPrototype);
@@ -482,9 +482,9 @@ define('javascript/esprima/typesFromIndexFile', [
globalsAndTypes = { globals: {}, types: {} };
var indexFile;
if (libName === "browser") {
- indexFile = "javascript/esprima/indexFiles/browserIndex";
+ indexFile = "javascript/contentAssist/indexFiles/browserIndex";
} else if (libName === "node") {
- indexFile = "javascript/esprima/indexFiles/nodeIndex";
+ indexFile = "javascript/contentAssist/indexFiles/nodeIndex";
} else {
throw "unknown library name " + libName;
}
diff --git a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/scriptedLogger.js b/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/scriptedLogger.js
deleted file mode 100644
index 1fb5304..0000000
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/esprima/scriptedLogger.js
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * @license
- * Copyright (c) 2013 VMware, Inc. 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:
- * Andrew Eisenberg
- * Brian Cavalier
- ******************************************************************************/
-/*jslint browser:true */
-/*global onmessage define console */
-
-define(function() {
- var handler;
- // handle situations where console is not defined,
- // eg- in a webworker
- if (typeof console === "undefined") {
- var delegate;
- if (typeof status === "function") {
- delegate = status;
- } else if (typeof onmessage === "function") {
- delegate = onmessage;
- } else {
- // logging is a no-op
- delegate = function() {};
- }
- handler = {
- info : delegate,
- debug : delegate,
- warn : delegate,
- error : delegate
- };
- } else {
- handler = console;
- }
- /**
- * Set to false to disable a category
- *
- * Logger categories. Change to false to disable
- * To use, include a parameter when calling the scriptedLogger function
- * The OTHER category is for messages that have no explicit category and
- * The ALL category disables all messages.
- * You may add new categories as necessary
- */
- var scriptedLoggerCategories = {
- ALL : true,
- OTHER : true,
- INDEXER : false,
- CONTENT_ASSIST : true,
- EXPLORER_TABLE : true,
- SETUP : true,
- PANE : true,
- STORAGE : true
- };
-
- /**
- * false means that the message kind will not be displayed
- */
- var scriptedLogger = {
- SHOW_CALLER : false,
- INFO : true,
- DEBUG : true,
- WARN : true,
- ERROR : true, // I don't know why we'd want to disable error handling, but I'll keep it here
- info : function(msg, category) {
- if (this.INFO && this.isEnabled(category)) {
- msg = this.SHOW_CALLER ? msg + " --- " + this.info.caller : msg;
- handler.info(msg);
- }
- },
- debug : function(msg, category) {
- if (this.DEBUG && this.isEnabled(category)) {
- msg = this.SHOW_CALLER ? msg + " --- " + this.debug.caller : msg;
- handler.debug(msg);
- }
- },
- warn : function(msg, category) {
- if (this.WARN && this.isEnabled(category)) {
- msg = this.SHOW_CALLER ? msg + " --- " + this.warn.caller : msg;
- handler.warn(msg);
- }
- },
- error : function(msg, category) {
- if (this.ERROR && this.isEnabled(category)) {
- msg = this.SHOW_CALLER ? msg + " --- " + this.error.caller : msg;
- handler.error(msg);
- }
- },
-
- // A message is
- isEnabled : function(catName) {
- if (!scriptedLoggerCategories.ALL) {
- return false;
- }
- return !catName || scriptedLoggerCategories[catName] === undefined ?
- scriptedLoggerCategories.OTHER :
- scriptedLoggerCategories[catName];
- }
- };
- return scriptedLogger;
-});
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
index f1d6785..fba2862 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js
@@ -13,12 +13,12 @@
define([
'javascript/astManager',
'javascript/eslint/validator',
- 'javascript/esprima/esprimaJsContentAssist',
+ 'javascript/contentAssist/contentAssist',
'javascript/occurrences',
'javascript/outliner',
'orion/i18nUtil',
'orion/plugin'
-], function(ASTManager, EslintValidator, EsprimaAssist, Occurrences, Outliner, i18nUtil, PluginProvider) {
+], function(ASTManager, EslintValidator, ContentAssist, Occurrences, Outliner, i18nUtil, PluginProvider) {
/**
* Plug-in headers
@@ -81,11 +81,11 @@ define([
/**
* Register the content assist support
*/
- provider.registerServiceProvider("orion.edit.contentassist", new EsprimaAssist.EsprimaJavaScriptContentAssistProvider(astManager),
+ provider.registerServiceProvider("orion.edit.contentassist", new ContentAssist.JSContentAssist(astManager),
{
contentType: ["application/javascript"],
name: "JavaScript content assist",
- id: "orion.edit.contentassist.esprima"
+ id: "orion.edit.contentassist.javascript"
});
/**
diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.html b/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.html
index c7686d0..d87c6e4 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.html
+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.html
@@ -9,11 +9,11 @@
require({
baseUrl: '../',
paths: {
- "scriptedLogger": 'javascript/esprima/scriptedLogger',
text: 'requirejs/text',
i18n: 'requirejs/i18n',
domReady: 'requirejs/domReady',
- esprima: 'esprima/esprima'
+ esprima: 'esprima/esprima',
+ estraverse: 'estraverse/estraverse'
}
});
window.onload = function() {
@@ -27,12 +27,7 @@
<body>
<h2>JavaScript Content Assist Tests</h2>
<p>
- This suite tests computing conntent assist proposals for the JavaScript tooling
- <br>
- Currently this support is used in:
- <ul>
- <li><b>Content Assist</b> - The Espima-based content assist used in the JavaScript editor</li>
- </ul>
+ This suite tests computing content assist proposals for the JavaScript tooling
</p>
</body>
</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.js b/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.js
index 58fe83a..5f88ecc 100644
--- a/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.js
+++ b/bundles/org.eclipse.orion.client.javascript/web/js-tests/contentAssistTests.js
@@ -13,13 +13,13 @@
/*global define esprima console setTimeout doctrine*/
define([
- 'javascript/esprima/esprimaJsContentAssist',
- 'javascript/esprima/esprimaVisitor',
+ 'javascript/contentAssist/contentAssist',
+ 'javascript/contentAssist/esprimaVisitor',
'orion/assert',
'esprima',
'doctrine/doctrine',
'orion/Deferred'
-], function(mEsprimaPlugin, mVisitor, assert, _, __, Deferred) {
+], function(ContentAssist, mVisitor, assert, _, __, Deferred) {
//////////////////////////////////////////////////////////
// helpers
@@ -52,13 +52,13 @@ define([
return new Deferred().resolve(parseFull(buffer));
}
};
- var esprimaContentAssistant = new mEsprimaPlugin.EsprimaJavaScriptContentAssistProvider(mockASTManager, null, lintOptions);
+ var assist = new ContentAssist.JSContentAssist(mockASTManager, null, lintOptions);
var mockContext = {
getText: function() {
return new Deferred().resolve(buffer);
}
};
- return esprimaContentAssistant.computeContentAssist(mockContext, {offset: offset, prefix : prefix, inferredOnly : true });
+ return assist.computeContentAssist(mockContext, {offset: offset, prefix : prefix, inferredOnly : true });
}
function testProposal(proposal, text, description) {