Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 1ed6c04

Browse files
author
Marcel Gerber
authored
Update Tern & Acorn (#11569)
* Update Tern -> post-0.13 Replace Acorn submodule with local copy Update Acorn -> post-2.2 * Change function call for renamed function * Load ecma6.json into Tern * Workaround non-emittable options in acorn_loose * Fix unit test Since we only get 500 hints back and there have been many new additions, Date's "getSecond" was no longer part of those 500. Thus, I decided to check for the existence of hints from Function, String and Array instead of Function, Array and Date. * Make use of the correct, renamed Tern definition * remove old acorn & tern * add acorn & tern as npm dependencies add lodash as dependency * grunt install installs dependencies for extensions from npm * fix acorn & tern paths * load libraries from node_modules, not working yet fix acorn to load it with requirejs * forgot to add glob dev dependency travis builds on node 0.10 which doesn't have promise * add eslint-env node * fix missing use strict
1 parent 63962ce commit 1ed6c04

File tree

18 files changed

+238
-39
lines changed

18 files changed

+238
-39
lines changed

.gitmodules

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@
77
[submodule "src/thirdparty/mustache"]
88
path = src/thirdparty/mustache
99
url = https://github.com/janl/mustache.js.git
10-
[submodule "src/extensions/default/JavaScriptCodeHints/thirdparty/tern"]
11-
path = src/extensions/default/JavaScriptCodeHints/thirdparty/tern
12-
url = https://github.com/ternjs/tern.git
13-
[submodule "src/extensions/default/JavaScriptCodeHints/thirdparty/acorn"]
14-
path = src/extensions/default/JavaScriptCodeHints/thirdparty/acorn
15-
url = https://github.com/marijnh/acorn.git
1610
[submodule "src/thirdparty/requirejs"]
1711
path = src/thirdparty/requirejs
1812
url = https://github.com/jrburke/requirejs.git

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ module.exports = function (grunt) {
323323
});
324324

325325
// task: install
326-
grunt.registerTask('install', ['write-config', 'less']);
326+
grunt.registerTask('install', ['write-config', 'less', 'npm-install-extensions']);
327327

328328
// task: test
329329
grunt.registerTask('test', ['eslint', 'jasmine', 'nls-check']);

npm-shrinkwrap.json

Lines changed: 10 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
},
1515
"dependencies": {
1616
"anymatch": "1.3.0",
17-
"chokidar": "1.6.0"
17+
"chokidar": "1.6.0",
18+
"lodash": "4.15.0"
1819
},
1920
"devDependencies": {
21+
"glob": "7.0.6",
2022
"grunt": "0.4.5",
2123
"jasmine-node": "1.11.0",
2224
"grunt-jasmine-node": "0.1.0",

src/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
},
3838
"dependencies": {
3939
"anymatch": "1.3.0",
40-
"chokidar": "1.6.0"
40+
"chokidar": "1.6.0",
41+
"lodash": "4.15.0"
4142
},
4243
"devDependencies": {
44+
"glob": "7.0.6",
4345
"grunt": "0.4.5",
4446
"jasmine-node": "1.11.0",
4547
"grunt-jasmine-node": "0.1.0",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/

src/extensions/default/JavaScriptCodeHints/HintUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
define(function (require, exports, module) {
2727
"use strict";
2828

29-
var Acorn = require("thirdparty/acorn/acorn");
29+
var Acorn = require("node_modules/acorn/dist/acorn");
3030

3131
var LANGUAGE_ID = "javascript",
3232
HTML_LANGUAGE_ID = "html",

src/extensions/default/JavaScriptCodeHints/ScopeManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ define(function (require, exports, module) {
5555

5656
var ternEnvironment = [],
5757
pendingTernRequests = {},
58-
builtinFiles = ["ecma5.json", "browser.json", "jquery.json"],
58+
builtinFiles = ["ecmascript.json", "browser.json", "jquery.json"],
5959
builtinLibraryNames = [],
6060
isDocumentDirty = false,
6161
_hintCount = 0,
@@ -84,7 +84,7 @@ define(function (require, exports, module) {
8484
* Read in the json files that have type information for the builtins, dom,etc
8585
*/
8686
function initTernEnv() {
87-
var path = ExtensionUtils.getModulePath(module, "thirdparty/tern/defs/"),
87+
var path = ExtensionUtils.getModulePath(module, "node_modules/tern/defs/"),
8888
files = builtinFiles,
8989
library;
9090

src/extensions/default/JavaScriptCodeHints/Session.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ define(function (require, exports, module) {
3232
HTMLUtils = brackets.getModule("language/HTMLUtils"),
3333
HintUtils = require("HintUtils"),
3434
ScopeManager = require("ScopeManager"),
35-
Acorn = require("thirdparty/acorn/acorn"),
36-
Acorn_Loose = require("thirdparty/acorn/acorn_loose");
35+
Acorn = require("node_modules/acorn/dist/acorn"),
36+
Acorn_Loose = require("node_modules/acorn/dist/acorn_loose");
3737

3838
/**
3939
* Session objects encapsulate state associated with a hinting session
@@ -669,7 +669,9 @@ define(function (require, exports, module) {
669669
var ast;
670670
try {
671671
ast = Acorn.parse(fragment);
672-
} catch (e) { ast = Acorn_Loose.parse_dammit(fragment); }
672+
} catch (e) {
673+
ast = Acorn_Loose.parse_dammit(fragment, {});
674+
}
673675

674676
// find argument as cursor location and bold it.
675677
var startOffset = this.getOffsetFromCursor(start),
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2013 - present Adobe Systems Incorporated. All rights reserved.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a
5+
* copy of this software and associated documentation files (the "Software"),
6+
* to deal in the Software without restriction, including without limitation
7+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
* and/or sell copies of the Software, and to permit persons to whom the
9+
* Software is furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
* DEALINGS IN THE SOFTWARE.
21+
*
22+
*/
23+
24+
/*eslint-env node */
25+
/*jslint node: true */
26+
27+
"use strict";
28+
29+
var fs = require("fs");
30+
var path = require("path");
31+
var fpath = path.resolve(__dirname, "node_modules", "acorn", "dist", "acorn_loose.js");
32+
var content = fs.readFileSync(fpath, "utf8");
33+
content = content.replace(/'\.\/acorn\.js'/g, "'./acorn'");
34+
fs.writeFileSync(fpath, content, "utf8");

0 commit comments

Comments
 (0)